aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/include
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 17:29:19 +1000
committerDavid Walter Seikel2013-01-13 17:29:19 +1000
commit07274513e984f0b5544586c74508ccd16e7dcafa (patch)
treeb32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/eina/src/include
parentAdded Irrlicht 1.8, but without all the Windows binaries. (diff)
downloadSledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/eina/src/include')
-rw-r--r--libraries/eina/src/include/Eina.h233
-rw-r--r--libraries/eina/src/include/Makefile.am94
-rw-r--r--libraries/eina/src/include/Makefile.in570
-rw-r--r--libraries/eina/src/include/eina_accessor.h340
-rw-r--r--libraries/eina/src/include/eina_array.h450
-rw-r--r--libraries/eina/src/include/eina_benchmark.h453
-rw-r--r--libraries/eina/src/include/eina_binbuf.h235
-rw-r--r--libraries/eina/src/include/eina_binshare.h193
-rw-r--r--libraries/eina/src/include/eina_clist.h378
-rw-r--r--libraries/eina/src/include/eina_config.h86
-rw-r--r--libraries/eina/src/include/eina_config.h.in86
-rw-r--r--libraries/eina/src/include/eina_convert.h374
-rw-r--r--libraries/eina/src/include/eina_counter.h213
-rw-r--r--libraries/eina/src/include/eina_cpu.h39
-rw-r--r--libraries/eina/src/include/eina_error.h198
-rw-r--r--libraries/eina/src/include/eina_file.h483
-rw-r--r--libraries/eina/src/include/eina_fp.h111
-rw-r--r--libraries/eina/src/include/eina_hamster.h58
-rw-r--r--libraries/eina/src/include/eina_hash.h1040
-rw-r--r--libraries/eina/src/include/eina_inarray.h710
-rw-r--r--libraries/eina/src/include/eina_inline_array.x184
-rw-r--r--libraries/eina/src/include/eina_inline_clist.x135
-rw-r--r--libraries/eina/src/include/eina_inline_f16p16.x83
-rw-r--r--libraries/eina/src/include/eina_inline_f32p32.x110
-rw-r--r--libraries/eina/src/include/eina_inline_f8p24.x82
-rw-r--r--libraries/eina/src/include/eina_inline_fp.x153
-rw-r--r--libraries/eina/src/include/eina_inline_hash.x151
-rw-r--r--libraries/eina/src/include/eina_inline_list.x67
-rw-r--r--libraries/eina/src/include/eina_inline_lock_posix.x556
-rw-r--r--libraries/eina/src/include/eina_inline_lock_void.x273
-rw-r--r--libraries/eina/src/include/eina_inline_lock_win32.x550
-rw-r--r--libraries/eina/src/include/eina_inline_lock_wince.x212
-rw-r--r--libraries/eina/src/include/eina_inline_log.x197
-rw-r--r--libraries/eina/src/include/eina_inline_mempool.x148
-rw-r--r--libraries/eina/src/include/eina_inline_rbtree.x50
-rw-r--r--libraries/eina/src/include/eina_inline_rectangle.x254
-rw-r--r--libraries/eina/src/include/eina_inline_str.x76
-rw-r--r--libraries/eina/src/include/eina_inline_stringshare.x91
-rw-r--r--libraries/eina/src/include/eina_inline_tiler.x151
-rw-r--r--libraries/eina/src/include/eina_inline_trash.x90
-rw-r--r--libraries/eina/src/include/eina_inline_ustringshare.x93
-rw-r--r--libraries/eina/src/include/eina_inline_value.x1790
-rw-r--r--libraries/eina/src/include/eina_inlist.h814
-rw-r--r--libraries/eina/src/include/eina_iterator.h337
-rw-r--r--libraries/eina/src/include/eina_lalloc.h60
-rw-r--r--libraries/eina/src/include/eina_list.h1631
-rw-r--r--libraries/eina/src/include/eina_lock.h129
-rw-r--r--libraries/eina/src/include/eina_log.h903
-rw-r--r--libraries/eina/src/include/eina_magic.h330
-rw-r--r--libraries/eina/src/include/eina_main.h165
-rw-r--r--libraries/eina/src/include/eina_matrixsparse.h399
-rw-r--r--libraries/eina/src/include/eina_mempool.h123
-rw-r--r--libraries/eina/src/include/eina_mmap.h59
-rw-r--r--libraries/eina/src/include/eina_model.h3105
-rw-r--r--libraries/eina/src/include/eina_module.h350
-rw-r--r--libraries/eina/src/include/eina_prefix.h228
-rw-r--r--libraries/eina/src/include/eina_quadtree.h53
-rw-r--r--libraries/eina/src/include/eina_rbtree.h271
-rw-r--r--libraries/eina/src/include/eina_rectangle.h239
-rw-r--r--libraries/eina/src/include/eina_refcount.h76
-rw-r--r--libraries/eina/src/include/eina_safety_checks.h254
-rw-r--r--libraries/eina/src/include/eina_sched.h39
-rw-r--r--libraries/eina/src/include/eina_simple_xml_parser.h390
-rw-r--r--libraries/eina/src/include/eina_str.h325
-rw-r--r--libraries/eina/src/include/eina_strbuf.h623
-rw-r--r--libraries/eina/src/include/eina_stringshare.h345
-rw-r--r--libraries/eina/src/include/eina_tiler.h310
-rw-r--r--libraries/eina/src/include/eina_trash.h100
-rw-r--r--libraries/eina/src/include/eina_types.h300
-rw-r--r--libraries/eina/src/include/eina_unicode.h186
-rw-r--r--libraries/eina/src/include/eina_ustrbuf.h464
-rw-r--r--libraries/eina/src/include/eina_ustringshare.h200
-rw-r--r--libraries/eina/src/include/eina_value.h3533
-rw-r--r--libraries/eina/src/include/eina_xattr.h215
74 files changed, 0 insertions, 28396 deletions
diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h
deleted file mode 100644
index d99b129..0000000
--- a/libraries/eina/src/include/Eina.h
+++ /dev/null
@@ -1,233 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008-2012 Enlightenment Developers:
3 * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
4 * Alexandre "diaxen" Becoulet <diaxen@free.fr>
5 * Andre Dieb <andre.dieb@gmail.com>
6 * Arnaud de Turckheim "quarium" <quarium@gmail.com>
7 * Carsten Haitzler <raster@rasterman.com>
8 * Cedric Bail <cedric.bail@free.fr>
9 * Corey "atmos" Donohoe <atmos@atmos.org>
10 * Fabiano FidĂȘncio <fidencio@profusion.mobi>
11 * Gustavo Chaves <glima@profusion.mobi>
12 * Gustavo Sverzut Barbieri <barbieri@gmail.com>
13 * Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com>
14 * Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de>
15 * Raphael Kubo da Costa <kubo@profusion.mobi>
16 * Tilman Sauerbeck <tilman@code-monkey.de>
17 * Vincent "caro" Torri <vtorri at univ-evry dot fr>
18 * Tom Hacohen <tom@stosb.com>
19 * Jonas M. Gastal <jgastal@profusion.mobi>
20 *
21 * This library is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public
23 * License as published by the Free Software Foundation; either
24 * version 2.1 of the License, or (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library;
33 * if not, see <http://www.gnu.org/licenses/>.
34 */
35
36#ifndef EINA_H_
37#define EINA_H_
38
39/**
40 * @file
41 * @brief Eina Utility library
42 *
43 * These routines are used for Eina.
44 */
45
46/**
47 * @mainpage Eina
48 *
49 * @version 1.1
50 * @date 2008-2012
51 *
52 * @section eina_intro_sec Introduction
53 *
54 * The Eina library is a library that implements an API for data types
55 * in an efficient way. It also provides some useful tools like
56 * opening shared libraries, errors management, type conversion,
57 * time accounting and memory pool.
58 *
59 * This library is cross-platform and can be compiled and used on
60 * Linux, BSD, Opensolaris and Windows (XP and CE).
61 *
62 * The data types that are available are (see @ref Eina_Data_Types_Group):
63 * @li @ref Eina_Inline_Array_Group standard array of inlined members.
64 * @li @ref Eina_Array_Group standard array of @c void* data.
65 * @li @ref Eina_Hash_Group standard hash of @c void* data.
66 * @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
67 * @li @ref Eina_CList_Group Compact List.
68 * @li @ref Eina_List_Group standard list of @c void* data.
69 * @li @ref Eina_Iterator_Group Iterator functions.
70 * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
71 * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user type.
72 * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or append strings to a buffer.
73 * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
74 * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions.
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.
78 *
79 * The tools that are available are (see @ref Eina_Tools_Group):
80 * @li @ref Eina_Benchmark_Group helper to write benchmarks.
81 * @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc.
82 * @li @ref Eina_Counter_Group measures number of calls and their time.
83 * @li @ref Eina_Error_Group error identifiers.
84 * @li @ref Eina_File_Group simple file list and path split.
85 * @li @ref Eina_Lalloc_Group simple lazy allocator.
86 * @li @ref Eina_Log_Group full-featured logging system.
87 * @li @ref Eina_Magic_Group provides runtime type checking.
88 * @li @ref Eina_Memory_Pool_Group abstraction for various memory allocators.
89 * @li @ref Eina_Module_Group lists, loads and share modules using Eina_Module standard.
90 * @li @ref Eina_Rectangle_Group rectangle structure and standard manipulation methods.
91 * @li @ref Eina_Safety_Checks_Group extra checks that will report unexpected conditions and can be disabled at compile time.
92 * @li @ref Eina_String_Group a set of functions that manages C strings.
93 *
94 * Please see the @ref authors page for contact details.
95 *
96 * @defgroup Eina_Data_Types_Group Data Types
97 *
98 * Eina provide easy to use and optimized data types and structures.
99 *
100 *
101 * @defgroup Eina_Containers_Group Containers
102 *
103 * Containers are data types that hold data and allow iteration over
104 * their elements with an @ref Eina_Iterator_Group, or eventually an
105 * @ref Eina_Accessor_Group.
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.
132 *
133 * @defgroup Eina_Tools_Group Tools
134 *
135 * Eina tools aims to help application development, providing ways to
136 * make it safer, log errors, manage memory more efficiently and more.
137 *
138 */
139
140/**
141 *
142 * @page authors Authors
143 *
144 * @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
145 * @author Alexandre "diaxen" Becoulet <diaxen@@free.fr>
146 * @author Andre Dieb <andre.dieb@@gmail.com>
147 * @author Arnaud de Turckheim "quarium" <quarium@@gmail.com>
148 * @author Carsten Haitzler <raster@@rasterman.com>
149 * @author Cedric Bail <cedric.bail@@free.fr>
150 * @author Corey "atmos" Donohoe <atmos@@atmos.org>
151 * @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
152 * @author Fabiano FidĂȘncio <fidencio@@profusion.mobi>
153 * @author Gustavo Chaves <glima@@profusion.mobi>
154 * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
155 * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
156 * @author Tilman Sauerbeck <tilman@@code-monkey.de>
157 * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
158 * @author Raphael Kubo da Costa <kubo@@profusion.mobi>
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>
167 *
168 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in
169 * contact with the developers and maintainers.
170 *
171 */
172
173#ifdef _WIN32
174# include <Evil.h>
175#endif
176
177#ifdef __cplusplus
178extern "C" {
179#endif
180
181#include "eina_config.h"
182#include "eina_types.h"
183#include "eina_main.h"
184#include "eina_fp.h"
185#include "eina_rectangle.h"
186#include "eina_clist.h"
187#include "eina_inlist.h"
188#include "eina_file.h"
189#include "eina_list.h"
190#include "eina_hash.h"
191#include "eina_trash.h"
192#include "eina_lalloc.h"
193#include "eina_module.h"
194#include "eina_mempool.h"
195#include "eina_error.h"
196#include "eina_log.h"
197#include "eina_inarray.h"
198#include "eina_array.h"
199#include "eina_binshare.h"
200#include "eina_stringshare.h"
201#include "eina_ustringshare.h"
202#include "eina_magic.h"
203#include "eina_counter.h"
204#include "eina_rbtree.h"
205#include "eina_accessor.h"
206#include "eina_iterator.h"
207#include "eina_benchmark.h"
208#include "eina_convert.h"
209#include "eina_cpu.h"
210#include "eina_sched.h"
211#include "eina_tiler.h"
212#include "eina_hamster.h"
213#include "eina_matrixsparse.h"
214#include "eina_str.h"
215#include "eina_strbuf.h"
216#include "eina_binbuf.h"
217#include "eina_ustrbuf.h"
218#include "eina_unicode.h"
219#include "eina_quadtree.h"
220#include "eina_simple_xml_parser.h"
221#include "eina_lock.h"
222#include "eina_prefix.h"
223#include "eina_refcount.h"
224#include "eina_mmap.h"
225#include "eina_xattr.h"
226#include "eina_value.h"
227#include "eina_model.h"
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif /* EINA_H */
diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am
deleted file mode 100644
index 31ef71e..0000000
--- a/libraries/eina/src/include/Makefile.am
+++ /dev/null
@@ -1,94 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3EINAHEADERS = \
4eina_safety_checks.h \
5eina_error.h \
6eina_log.h \
7eina_inline_log.x \
8eina_fp.h \
9eina_inline_f32p32.x \
10eina_inline_f16p16.x \
11eina_inline_f8p24.x \
12eina_inline_fp.x \
13eina_hash.h \
14eina_inline_hash.x \
15eina_lalloc.h \
16eina_clist.h \
17eina_inline_clist.x \
18eina_inarray.h \
19eina_inlist.h \
20eina_list.h \
21eina_file.h \
22eina_mempool.h \
23eina_module.h \
24eina_rectangle.h \
25eina_types.h \
26eina_array.h \
27eina_counter.h \
28eina_inline_array.x \
29eina_magic.h \
30eina_stringshare.h \
31eina_binshare.h \
32eina_binbuf.h \
33eina_ustringshare.h \
34eina_inline_stringshare.x \
35eina_inline_ustringshare.x \
36eina_inline_list.x \
37eina_accessor.h \
38eina_convert.h \
39eina_rbtree.h \
40eina_benchmark.h \
41eina_inline_rbtree.x \
42eina_inline_mempool.x \
43eina_inline_rectangle.x \
44eina_inline_trash.x \
45eina_trash.h \
46eina_iterator.h \
47eina_main.h \
48eina_cpu.h \
49eina_sched.h \
50eina_tiler.h \
51eina_hamster.h \
52eina_matrixsparse.h \
53eina_inline_tiler.x \
54eina_str.h \
55eina_inline_str.x \
56eina_strbuf.h \
57eina_ustrbuf.h \
58eina_unicode.h \
59eina_quadtree.h \
60eina_simple_xml_parser.h \
61eina_lock.h \
62eina_prefix.h \
63eina_refcount.h \
64eina_mmap.h \
65eina_xattr.h \
66eina_value.h \
67eina_inline_value.x \
68eina_model.h
69
70# Will be back for developper after 1.1.
71# eina_object.h
72
73if EINA_HAVE_THREADS
74if EINA_HAVE_WINCE
75EINAHEADERS += eina_inline_lock_wince.x
76else
77if EINA_HAVE_WIN32
78EINAHEADERS += eina_inline_lock_win32.x
79else
80EINAHEADERS += eina_inline_lock_posix.x
81endif
82endif
83else
84EINAHEADERS += eina_inline_lock_void.x
85endif
86
87installed_mainheaderdir = $(includedir)/eina-@VMAJ@
88dist_installed_mainheader_DATA = Eina.h eina_config.h
89
90installed_headersdir = $(includedir)/eina-@VMAJ@/eina
91dist_installed_headers_DATA = $(EINAHEADERS)
92
93EXTRA_DIST = \
94eina_config.h.in
diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in
deleted file mode 100644
index 7e819b8..0000000
--- a/libraries/eina/src/include/Makefile.in
+++ /dev/null
@@ -1,570 +0,0 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18VPATH = @srcdir@
19pkgdatadir = $(datadir)/@PACKAGE@
20pkgincludedir = $(includedir)/@PACKAGE@
21pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644
25install_sh_PROGRAM = $(install_sh) -c
26install_sh_SCRIPT = $(install_sh) -c
27INSTALL_HEADER = $(INSTALL_DATA)
28transform = $(program_transform_name)
29NORMAL_INSTALL = :
30PRE_INSTALL = :
31POST_INSTALL = :
32NORMAL_UNINSTALL = :
33PRE_UNINSTALL = :
34POST_UNINSTALL = :
35build_triplet = @build@
36host_triplet = @host@
37
38# Will be back for developper after 1.1.
39# eina_object.h
40@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WINCE_TRUE@am__append_1 = eina_inline_lock_wince.x
41@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_TRUE@@EINA_HAVE_WINCE_FALSE@am__append_2 = eina_inline_lock_win32.x
42@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_FALSE@@EINA_HAVE_WINCE_FALSE@am__append_3 = eina_inline_lock_posix.x
43@EINA_HAVE_THREADS_FALSE@am__append_4 = eina_inline_lock_void.x
44subdir = src/include
45DIST_COMMON = $(am__dist_installed_headers_DATA_DIST) \
46 $(dist_installed_mainheader_DATA) $(srcdir)/Makefile.am \
47 $(srcdir)/Makefile.in $(srcdir)/eina_config.h.in
48ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
49am__aclocal_m4_deps = $(top_srcdir)/m4/eina/eina_bench.m4 \
50 $(top_srcdir)/m4/eina/eina_check.m4 \
51 $(top_srcdir)/m4/common/efl_attribute.m4 \
52 $(top_srcdir)/m4/common/efl_benchmark.m4 \
53 $(top_srcdir)/m4/common/efl_compiler_flag.m4 \
54 $(top_srcdir)/m4/common/efl_coverage.m4 \
55 $(top_srcdir)/m4/common/efl_cpu.m4 \
56 $(top_srcdir)/m4/common/efl_doxygen.m4 \
57 $(top_srcdir)/m4/common/efl_examples.m4 \
58 $(top_srcdir)/m4/common/efl_fnmatch.m4 \
59 $(top_srcdir)/m4/common/efl_path_max.m4 \
60 $(top_srcdir)/m4/common/efl_tests.m4 \
61 $(top_srcdir)/m4/common/efl_threads.m4 \
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
67am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
68 $(ACLOCAL_M4)
69mkinstalldirs = $(install_sh) -d
70CONFIG_HEADER = $(top_builddir)/config.h
71CONFIG_CLEAN_FILES = eina_config.h
72CONFIG_CLEAN_VPATH_FILES =
73AM_V_GEN = $(am__v_GEN_$(V))
74am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
75am__v_GEN_0 = @echo " GEN " $@;
76AM_V_at = $(am__v_at_$(V))
77am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
78am__v_at_0 = @
79SOURCES =
80DIST_SOURCES =
81am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \
82 eina_error.h eina_log.h eina_inline_log.x eina_fp.h \
83 eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \
84 eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \
85 eina_clist.h eina_inline_clist.x eina_inarray.h eina_inlist.h \
86 eina_list.h eina_file.h eina_mempool.h eina_module.h \
87 eina_rectangle.h eina_types.h eina_array.h eina_counter.h \
88 eina_inline_array.x eina_magic.h eina_stringshare.h \
89 eina_binshare.h eina_binbuf.h eina_ustringshare.h \
90 eina_inline_stringshare.x eina_inline_ustringshare.x \
91 eina_inline_list.x eina_accessor.h eina_convert.h \
92 eina_rbtree.h eina_benchmark.h eina_inline_rbtree.x \
93 eina_inline_mempool.x eina_inline_rectangle.x \
94 eina_inline_trash.x eina_trash.h eina_iterator.h eina_main.h \
95 eina_cpu.h eina_sched.h eina_tiler.h eina_hamster.h \
96 eina_matrixsparse.h eina_inline_tiler.x eina_str.h \
97 eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \
98 eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \
99 eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \
100 eina_value.h eina_inline_value.x eina_model.h \
101 eina_inline_lock_wince.x eina_inline_lock_win32.x \
102 eina_inline_lock_posix.x eina_inline_lock_void.x
103am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
104am__vpath_adj = case $$p in \
105 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
106 *) f=$$p;; \
107 esac;
108am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
109am__install_max = 40
110am__nobase_strip_setup = \
111 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
112am__nobase_strip = \
113 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
114am__nobase_list = $(am__nobase_strip_setup); \
115 for p in $$list; do echo "$$p $$p"; done | \
116 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
117 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
118 if (++n[$$2] == $(am__install_max)) \
119 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
120 END { for (dir in files) print dir, files[dir] }'
121am__base_list = \
122 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
123 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
124am__installdirs = "$(DESTDIR)$(installed_headersdir)" \
125 "$(DESTDIR)$(installed_mainheaderdir)"
126DATA = $(dist_installed_headers_DATA) \
127 $(dist_installed_mainheader_DATA)
128DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
129ACLOCAL = @ACLOCAL@
130ALLOCA = @ALLOCA@
131AMTAR = @AMTAR@
132AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
133AR = @AR@
134AS = @AS@
135AUTOCONF = @AUTOCONF@
136AUTOHEADER = @AUTOHEADER@
137AUTOMAKE = @AUTOMAKE@
138AWK = @AWK@
139CC = @CC@
140CCDEPMODE = @CCDEPMODE@
141CFLAGS = @CFLAGS@
142CHECK_CFLAGS = @CHECK_CFLAGS@
143CHECK_LIBS = @CHECK_LIBS@
144CPP = @CPP@
145CPPFLAGS = @CPPFLAGS@
146CXX = @CXX@
147CXXCPP = @CXXCPP@
148CXXDEPMODE = @CXXDEPMODE@
149CXXFLAGS = @CXXFLAGS@
150CYGPATH_W = @CYGPATH_W@
151DEFS = @DEFS@
152DEPDIR = @DEPDIR@
153DLLTOOL = @DLLTOOL@
154DSYMUTIL = @DSYMUTIL@
155DUMPBIN = @DUMPBIN@
156ECHO_C = @ECHO_C@
157ECHO_N = @ECHO_N@
158ECHO_T = @ECHO_T@
159ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@
160ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@
161EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
162EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
163EFL_EINA_BUILD = @EFL_EINA_BUILD@
164EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
165EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@
166EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@
167EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
168EGREP = @EGREP@
169EINA_CFLAGS = @EINA_CFLAGS@
170EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
171EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
172EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
173EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
174EINA_CONFIGURE_HAVE_EXOTIC = @EINA_CONFIGURE_HAVE_EXOTIC@
175EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
176EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
177EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
178EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@
179EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@
180EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@
181EINA_LIBS = @EINA_LIBS@
182EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@
183EMEMOA_CFLAGS = @EMEMOA_CFLAGS@
184EMEMOA_LIBS = @EMEMOA_LIBS@
185ESCAPE_CFLAGS = @ESCAPE_CFLAGS@
186ESCAPE_LIBS = @ESCAPE_LIBS@
187EVIL_CFLAGS = @EVIL_CFLAGS@
188EVIL_LIBS = @EVIL_LIBS@
189EXEEXT = @EXEEXT@
190EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
191EXOTIC_LIBS = @EXOTIC_LIBS@
192FGREP = @FGREP@
193GLIB_CFLAGS = @GLIB_CFLAGS@
194GLIB_LIBS = @GLIB_LIBS@
195GREP = @GREP@
196INSTALL = @INSTALL@
197INSTALL_DATA = @INSTALL_DATA@
198INSTALL_PROGRAM = @INSTALL_PROGRAM@
199INSTALL_SCRIPT = @INSTALL_SCRIPT@
200INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
201LD = @LD@
202LDFLAGS = @LDFLAGS@
203LIBOBJS = @LIBOBJS@
204LIBS = @LIBS@
205LIBTOOL = @LIBTOOL@
206LIPO = @LIPO@
207LN_S = @LN_S@
208LTLIBOBJS = @LTLIBOBJS@
209MAKEINFO = @MAKEINFO@
210MKDIR_P = @MKDIR_P@
211MODULE_ARCH = @MODULE_ARCH@
212NM = @NM@
213NMEDIT = @NMEDIT@
214OBJDUMP = @OBJDUMP@
215OBJEXT = @OBJEXT@
216OTOOL = @OTOOL@
217OTOOL64 = @OTOOL64@
218PACKAGE = @PACKAGE@
219PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
220PACKAGE_NAME = @PACKAGE_NAME@
221PACKAGE_STRING = @PACKAGE_STRING@
222PACKAGE_TARNAME = @PACKAGE_TARNAME@
223PACKAGE_URL = @PACKAGE_URL@
224PACKAGE_VERSION = @PACKAGE_VERSION@
225PATH_SEPARATOR = @PATH_SEPARATOR@
226PKG_CONFIG = @PKG_CONFIG@
227PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
228PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
229RANLIB = @RANLIB@
230SED = @SED@
231SET_MAKE = @SET_MAKE@
232SHELL = @SHELL@
233STRIP = @STRIP@
234VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
235VALGRIND_LIBS = @VALGRIND_LIBS@
236VERSION = @VERSION@
237VMAJ = @VMAJ@
238abs_builddir = @abs_builddir@
239abs_srcdir = @abs_srcdir@
240abs_top_builddir = @abs_top_builddir@
241abs_top_srcdir = @abs_top_srcdir@
242ac_ct_CC = @ac_ct_CC@
243ac_ct_CXX = @ac_ct_CXX@
244ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
245am__include = @am__include@
246am__leading_dot = @am__leading_dot@
247am__quote = @am__quote@
248am__tar = @am__tar@
249am__untar = @am__untar@
250bindir = @bindir@
251build = @build@
252build_alias = @build_alias@
253build_cpu = @build_cpu@
254build_os = @build_os@
255build_vendor = @build_vendor@
256builddir = @builddir@
257datadir = @datadir@
258datarootdir = @datarootdir@
259dlopen_libs = @dlopen_libs@
260docdir = @docdir@
261dvidir = @dvidir@
262efl_doxygen = @efl_doxygen@
263efl_have_doxygen = @efl_have_doxygen@
264exec_prefix = @exec_prefix@
265have_lcov = @have_lcov@
266host = @host@
267host_alias = @host_alias@
268host_cpu = @host_cpu@
269host_os = @host_os@
270host_vendor = @host_vendor@
271htmldir = @htmldir@
272iconv_libs = @iconv_libs@
273includedir = @includedir@
274infodir = @infodir@
275install_sh = @install_sh@
276libdir = @libdir@
277libexecdir = @libexecdir@
278localedir = @localedir@
279localstatedir = @localstatedir@
280lt_ECHO = @lt_ECHO@
281lt_enable_auto_import = @lt_enable_auto_import@
282mandir = @mandir@
283mkdir_p = @mkdir_p@
284oldincludedir = @oldincludedir@
285pdfdir = @pdfdir@
286pkgconfig_requires_private = @pkgconfig_requires_private@
287prefix = @prefix@
288program_transform_name = @program_transform_name@
289psdir = @psdir@
290release_info = @release_info@
291requirement_eina = @requirement_eina@
292rt_libs = @rt_libs@
293sbindir = @sbindir@
294sharedstatedir = @sharedstatedir@
295srcdir = @srcdir@
296sysconfdir = @sysconfdir@
297target_alias = @target_alias@
298top_build_prefix = @top_build_prefix@
299top_builddir = @top_builddir@
300top_srcdir = @top_srcdir@
301version_info = @version_info@
302MAINTAINERCLEANFILES = Makefile.in
303EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \
304 eina_inline_log.x eina_fp.h eina_inline_f32p32.x \
305 eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \
306 eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \
307 eina_inline_clist.x eina_inarray.h eina_inlist.h eina_list.h \
308 eina_file.h eina_mempool.h eina_module.h eina_rectangle.h \
309 eina_types.h eina_array.h eina_counter.h eina_inline_array.x \
310 eina_magic.h eina_stringshare.h eina_binshare.h eina_binbuf.h \
311 eina_ustringshare.h eina_inline_stringshare.x \
312 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \
313 eina_convert.h eina_rbtree.h eina_benchmark.h \
314 eina_inline_rbtree.x eina_inline_mempool.x \
315 eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \
316 eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \
317 eina_tiler.h eina_hamster.h eina_matrixsparse.h \
318 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \
319 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \
320 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \
321 eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \
322 eina_inline_value.x eina_model.h $(am__append_1) \
323 $(am__append_2) $(am__append_3) $(am__append_4)
324installed_mainheaderdir = $(includedir)/eina-@VMAJ@
325dist_installed_mainheader_DATA = Eina.h eina_config.h
326installed_headersdir = $(includedir)/eina-@VMAJ@/eina
327dist_installed_headers_DATA = $(EINAHEADERS)
328EXTRA_DIST = \
329eina_config.h.in
330
331all: all-am
332
333.SUFFIXES:
334$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
335 @for dep in $?; do \
336 case '$(am__configure_deps)' in \
337 *$$dep*) \
338 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
339 && { if test -f $@; then exit 0; else break; fi; }; \
340 exit 1;; \
341 esac; \
342 done; \
343 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/include/Makefile'; \
344 $(am__cd) $(top_srcdir) && \
345 $(AUTOMAKE) --gnu src/include/Makefile
346.PRECIOUS: Makefile
347Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
348 @case '$?' in \
349 *config.status*) \
350 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
351 *) \
352 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
353 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
354 esac;
355
356$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
357 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
358
359$(top_srcdir)/configure: $(am__configure_deps)
360 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
361$(ACLOCAL_M4): $(am__aclocal_m4_deps)
362 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
363$(am__aclocal_m4_deps):
364eina_config.h: $(top_builddir)/config.status $(srcdir)/eina_config.h.in
365 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
366
367mostlyclean-libtool:
368 -rm -f *.lo
369
370clean-libtool:
371 -rm -rf .libs _libs
372install-dist_installed_headersDATA: $(dist_installed_headers_DATA)
373 @$(NORMAL_INSTALL)
374 test -z "$(installed_headersdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_headersdir)"
375 @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \
376 for p in $$list; do \
377 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
378 echo "$$d$$p"; \
379 done | $(am__base_list) | \
380 while read files; do \
381 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_headersdir)'"; \
382 $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_headersdir)" || exit $$?; \
383 done
384
385uninstall-dist_installed_headersDATA:
386 @$(NORMAL_UNINSTALL)
387 @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \
388 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
389 test -n "$$files" || exit 0; \
390 echo " ( cd '$(DESTDIR)$(installed_headersdir)' && rm -f" $$files ")"; \
391 cd "$(DESTDIR)$(installed_headersdir)" && rm -f $$files
392install-dist_installed_mainheaderDATA: $(dist_installed_mainheader_DATA)
393 @$(NORMAL_INSTALL)
394 test -z "$(installed_mainheaderdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_mainheaderdir)"
395 @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \
396 for p in $$list; do \
397 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
398 echo "$$d$$p"; \
399 done | $(am__base_list) | \
400 while read files; do \
401 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_mainheaderdir)'"; \
402 $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_mainheaderdir)" || exit $$?; \
403 done
404
405uninstall-dist_installed_mainheaderDATA:
406 @$(NORMAL_UNINSTALL)
407 @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \
408 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
409 test -n "$$files" || exit 0; \
410 echo " ( cd '$(DESTDIR)$(installed_mainheaderdir)' && rm -f" $$files ")"; \
411 cd "$(DESTDIR)$(installed_mainheaderdir)" && rm -f $$files
412tags: TAGS
413TAGS:
414
415ctags: CTAGS
416CTAGS:
417
418
419distdir: $(DISTFILES)
420 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
421 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
422 list='$(DISTFILES)'; \
423 dist_files=`for file in $$list; do echo $$file; done | \
424 sed -e "s|^$$srcdirstrip/||;t" \
425 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
426 case $$dist_files in \
427 */*) $(MKDIR_P) `echo "$$dist_files" | \
428 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
429 sort -u` ;; \
430 esac; \
431 for file in $$dist_files; do \
432 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
433 if test -d $$d/$$file; then \
434 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
435 if test -d "$(distdir)/$$file"; then \
436 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
437 fi; \
438 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
439 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
440 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
441 fi; \
442 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
443 else \
444 test -f "$(distdir)/$$file" \
445 || cp -p $$d/$$file "$(distdir)/$$file" \
446 || exit 1; \
447 fi; \
448 done
449check-am: all-am
450check: check-am
451all-am: Makefile $(DATA)
452installdirs:
453 for dir in "$(DESTDIR)$(installed_headersdir)" "$(DESTDIR)$(installed_mainheaderdir)"; do \
454 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
455 done
456install: install-am
457install-exec: install-exec-am
458install-data: install-data-am
459uninstall: uninstall-am
460
461install-am: all-am
462 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
463
464installcheck: installcheck-am
465install-strip:
466 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
467 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
468 `test -z '$(STRIP)' || \
469 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
470mostlyclean-generic:
471
472clean-generic:
473
474distclean-generic:
475 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
476 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
477
478maintainer-clean-generic:
479 @echo "This command is intended for maintainers to use"
480 @echo "it deletes files that may require special tools to rebuild."
481 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
482clean: clean-am
483
484clean-am: clean-generic clean-libtool mostlyclean-am
485
486distclean: distclean-am
487 -rm -f Makefile
488distclean-am: clean-am distclean-generic
489
490dvi: dvi-am
491
492dvi-am:
493
494html: html-am
495
496html-am:
497
498info: info-am
499
500info-am:
501
502install-data-am: install-dist_installed_headersDATA \
503 install-dist_installed_mainheaderDATA
504
505install-dvi: install-dvi-am
506
507install-dvi-am:
508
509install-exec-am:
510
511install-html: install-html-am
512
513install-html-am:
514
515install-info: install-info-am
516
517install-info-am:
518
519install-man:
520
521install-pdf: install-pdf-am
522
523install-pdf-am:
524
525install-ps: install-ps-am
526
527install-ps-am:
528
529installcheck-am:
530
531maintainer-clean: maintainer-clean-am
532 -rm -f Makefile
533maintainer-clean-am: distclean-am maintainer-clean-generic
534
535mostlyclean: mostlyclean-am
536
537mostlyclean-am: mostlyclean-generic mostlyclean-libtool
538
539pdf: pdf-am
540
541pdf-am:
542
543ps: ps-am
544
545ps-am:
546
547uninstall-am: uninstall-dist_installed_headersDATA \
548 uninstall-dist_installed_mainheaderDATA
549
550.MAKE: install-am install-strip
551
552.PHONY: all all-am check check-am clean clean-generic clean-libtool \
553 distclean distclean-generic distclean-libtool distdir dvi \
554 dvi-am html html-am info info-am install install-am \
555 install-data install-data-am \
556 install-dist_installed_headersDATA \
557 install-dist_installed_mainheaderDATA install-dvi \
558 install-dvi-am install-exec install-exec-am install-html \
559 install-html-am install-info install-info-am install-man \
560 install-pdf install-pdf-am install-ps install-ps-am \
561 install-strip installcheck installcheck-am installdirs \
562 maintainer-clean maintainer-clean-generic mostlyclean \
563 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
564 uninstall uninstall-am uninstall-dist_installed_headersDATA \
565 uninstall-dist_installed_mainheaderDATA
566
567
568# Tell versions [3.59,3.63) of GNU make to not export all variables.
569# Otherwise a system limit (for SysV at least) may be exceeded.
570.NOEXPORT:
diff --git a/libraries/eina/src/include/eina_accessor.h b/libraries/eina/src/include/eina_accessor.h
deleted file mode 100644
index cae7a5c..0000000
--- a/libraries/eina/src/include/eina_accessor.h
+++ /dev/null
@@ -1,340 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ACCESSOR_H__
20#define EINA_ACCESSOR_H__
21
22#include "eina_config.h"
23
24#include "eina_types.h"
25#include "eina_magic.h"
26
27/**
28 * @page eina_accessor_example_01_page Eina_Accessor usage
29 * @dontinclude eina_accessor_01.c
30 *
31 * We start by including necessary headers, declaring variables and
32 * initializing eina:
33 * @skip #include
34 * @until eina_init
35 *
36 * Next we populate our array and list:
37 * @until }
38 *
39 * Now that we have two containers populated we can actually start the example
40 * and create an accessor:
41 * @until accessor_new
42 *
43 * Once having the accessor we can use it to access certain elements in the
44 * container:
45 * @until }
46 * @note Unlike iterators accessors allow us non-linear access, which allows us
47 * to print only the odd elements in the container.
48 *
49 * As with every other resource we allocate we need to free the accessor(and the
50 * array):
51 * @until array_free
52 *
53 * Now we create another accessor, this time for the list:
54 * @until accessor_new
55 *
56 * And now the interesting bit, we use the same code we used above to print
57 * parts of the array to print parts of the list:
58 * @until }
59 *
60 * And to free the list we use a gimmick, instead of freeing @a list, we ask the
61 * accessor for it's container and free that:
62 * @until list_free
63 *
64 * Finally we shut eina down and leave:
65 * @until }
66 *
67 * The full source code can be found on the examples folder
68 * on the @ref eina_accessor_01_c "eina_accessor_01.c" file.
69 */
70
71/**
72 * @page eina_accessor_01_c Eina_Accessor usage example
73 *
74 * @include eina_accessor_01.c
75 * @example eina_accessor_01.c
76 */
77
78/**
79 * @addtogroup Eina_Accessor_Group Accessor Functions
80 *
81 * @brief These functions manage accessor on containers.
82 *
83 * These functions allow to access elements of a container in a
84 * generic way, without knowing which container is used (a bit like
85 * iterators in the C++ STL). Accessors allows random access (that is, any
86 * element in the container). For sequential access, see
87 * @ref Eina_Iterator_Group.
88 *
89 * An accessor is created from container data types, so no creation
90 * function is available here. An accessor is deleted with
91 * eina_accessor_free(). To get the data of an element at a given
92 * position, use eina_accessor_data_get(). To call a function on
93 * chosen elements of a container, use eina_accessor_over().
94 *
95 * See an example @ref eina_accessor_example_01_page "here".
96 */
97
98/**
99 * @addtogroup Eina_Content_Access_Group Content Access
100 *
101 * @{
102 */
103
104/**
105 * @defgroup Eina_Accessor_Group Accessor Functions
106 *
107 * @{
108 */
109
110/**
111 * @typedef Eina_Accessor
112 * Abstract type for accessors.
113 */
114typedef struct _Eina_Accessor Eina_Accessor;
115
116/**
117 * @typedef Eina_Accessor_Get_At_Callback
118 * Type for a callback that returns the data of a container as the given index.
119 */
120typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it,
121 unsigned int idx,
122 void **data);
123
124/**
125 * @typedef Eina_Accessor_Get_Container_Callback
126 * Type for a callback that returns the container.
127 */
128typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it);
129
130/**
131 * @typedef Eina_Accessor_Free_Callback
132 * Type for a callback that frees the container.
133 */
134typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
135
136/**
137 * @typedef Eina_Accessor_Lock_Callback
138 * Type for a callback that lock the container.
139 */
140typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
141
142/**
143 * @struct _Eina_Accessor
144 * Type to provide random access to data structures.
145 */
146struct _Eina_Accessor
147{
148#define EINA_ACCESSOR_VERSION 1
149 int version; /**< Version of the Accessor API. */
150
151 Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT; /**< Callback called when a data element is requested. */
152 Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */
153 Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */
154
155 Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */
156 Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */
157
158#define EINA_MAGIC_ACCESSOR 0x98761232
159 EINA_MAGIC
160};
161
162/**
163 * @def FUNC_ACCESSOR_GET_AT(Function)
164 * Helper macro to cast @p Function to a Eina_Accessor_Get_At_Callback.
165 */
166#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
167
168/**
169 * @def FUNC_ACCESSOR_GET_CONTAINER(Function)
170 * Helper macro to cast @p Function to a Eina_Accessor_Get_Container_Callback.
171 */
172#define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function)
173
174/**
175 * @def FUNC_ACCESSOR_FREE(Function)
176 * Helper macro to cast @p Function to a Eina_Accessor_Free_Callback.
177 */
178#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function)
179
180/**
181 * @def FUNC_ACCESSOR_LOCK(Function)
182 * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
183 */
184#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function)
185
186
187/**
188 * @brief Free an accessor.
189 *
190 * @param accessor The accessor to free.
191 *
192 * This function frees @p accessor if it is not @c NULL;
193 */
194EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
195
196/**
197 * @brief Retrieve the data of an accessor at a given position.
198 *
199 * @param accessor The accessor.
200 * @param position The position of the element.
201 * @param data The pointer that stores the data to retrieve.
202 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
203 *
204 * This function retrieves the data of the element pointed by
205 * @p accessor at the porition @p position, and stores it in
206 * @p data. If @p accessor is @c NULL or if an error occurred,
207 * #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
208 */
209EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
210 unsigned int position,
211 void **data) EINA_ARG_NONNULL(1);
212
213/**
214 * @brief Return the container of an accessor.
215 *
216 * @param accessor The accessor.
217 * @return The container which created the accessor.
218 *
219 * This function returns the container which created @p accessor. If
220 * @p accessor is @c NULL, this function returns @c NULL.
221 */
222EAPI void *eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
223
224/**
225 * @brief Iterate over the container and execute a callback on chosen elements.
226 *
227 * @param accessor The accessor.
228 * @param cb The callback called on the chosen elements.
229 * @param start The position of the first element.
230 * @param end The position of the last element.
231 * @param fdata The data passed to the callback.
232 *
233 * This function iterates over the elements pointed by @p accessor,
234 * starting from the element at position @p start and ending to the
235 * element at position @p end. For Each element, the callback
236 * @p cb is called with the data @p fdata. If @p accessor is @c NULL
237 * or if @p start is greter or equal than @p end, the function returns
238 * immediately.
239 */
240EAPI void eina_accessor_over(Eina_Accessor *accessor,
241 Eina_Each_Cb cb,
242 unsigned int start,
243 unsigned int end,
244 const void *fdata) EINA_ARG_NONNULL(1, 2);
245
246/**
247 * @brief Lock the container of the accessor.
248 *
249 * @param accessor The accessor.
250 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
251 *
252 * If the container of the @p accessor permits it, it will be locked. When a
253 * container is locked calling eina_accessor_over() on it will return
254 * immediately. If @p accessor is @c NULL or if a problem occurred, #EINA_FALSE
255 * is returned, otherwise #EINA_TRUE is returned. If the container isn't
256 * lockable, it will return EINA_TRUE.
257 *
258 * @warning None of the existing eina data structures are lockable.
259 */
260EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
261
262/**
263 * @brief Unlock the container of the accessor.
264 *
265 * @param accessor The accessor.
266 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
267 *
268 * If the container of the @p accessor permits it and was previously
269 * locked, it will be unlocked. If @p accessor is @c NULL or if a
270 * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
271 * is returned. If the container is not lockable, it will return
272 * EINA_TRUE.
273 *
274 * @warning None of the existing eina data structures are lockable.
275 */
276EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
277
278/**
279 * @def EINA_ACCESSOR_FOREACH
280 * @brief Macro to iterate over all elements easily.
281 *
282 * @param accessor The accessor to use.
283 * @param counter A counter used by eina_accessor_data_get() when
284 * iterating over the container.
285 * @param data Where to store * data, must be a pointer support getting
286 * its address since * eina_accessor_data_get() requires a pointer to
287 * pointer!
288 *
289 * This macro allows a convenient way to loop over all elements in an
290 * accessor, very similar to EINA_LIST_FOREACH().
291 *
292 * This macro can be used for freeing the data of a list, like in the
293 * following example. It has the same goal as the one documented in
294 * EINA_LIST_FOREACH(), but using accessors:
295 *
296 * @code
297 * Eina_List *list;
298 * Eina_Accessor *accessor;
299 * unsigned int i;
300 * char *data;
301 *
302 * // list is already filled,
303 * // its elements are just duplicated strings
304 *
305 * accessor = eina_list_accessor_new(list);
306 * EINA_ACCESSOR_FOREACH(accessor, i, data)
307 * free(data);
308 * eina_accessor_free(accessor);
309 * eina_list_free(list);
310 * @endcode
311 *
312 * @note if the datatype provides both iterators and accessors prefer
313 * to use iterators to iterate over, as they're likely to be more
314 * optimized for such task.
315 *
316 * @note this example is not optimal algorithm to release a list since
317 * it will walk the list twice, but it serves as an example. For
318 * optimized version use EINA_LIST_FREE()
319 *
320 * @warning unless explicitly stated in functions returning accessors,
321 * do not modify the accessed object while you walk it, in this
322 * example using lists, do not remove list nodes or you might
323 * crash! This is not a limitiation of accessors themselves,
324 * rather in the accessors implementations to keep them as simple
325 * and fast as possible.
326 */
327#define EINA_ACCESSOR_FOREACH(accessor, counter, data) \
328 for ((counter) = 0; \
329 eina_accessor_data_get((accessor), (counter), (void **)(void *)&(data)); \
330 (counter)++)
331
332/**
333 * @}
334 */
335
336/**
337 * @}
338 */
339
340#endif
diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h
deleted file mode 100644
index 4ab3b50..0000000
--- a/libraries/eina/src/include/eina_array.h
+++ /dev/null
@@ -1,450 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ARRAY_H_
20#define EINA_ARRAY_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_error.h"
28#include "eina_iterator.h"
29#include "eina_accessor.h"
30#include "eina_magic.h"
31
32
33/**
34 * @page eina_array_01_example_page Basic array usage
35 * @dontinclude eina_array_01.c
36 *
37 * For this example we add stdlib.h, stdio.h and string.h for some
38 * convenience functions. The first thing to do to be able to use an
39 * @ref Eina_Array is to include Eina.h:
40 * @skip #include
41 * @until Eina.h
42 *
43 * Here we have a callback that prints the element given to it:
44 * @until }
45 *
46 * Now we create our entry point and declare some variables, nothing especial:
47 * @until unsigned
48 *
49 * Before we can start using any array function we need to initialize eina:
50 * @until eina_init
51 *
52 * So now to actually creating our array. The only interesting thing here is the
53 * argument given to the eina_array_new() function, this argument sets how fast
54 * the array grows.
55 * @until array_new
56 *
57 * If you know before hand how big the array will need to be you should set the
58 * step to that. In our case we can set it to the number of string we have and
59 * since we didn't do that in the eina_array_new() we can do it now:
60 * @until array_step_set
61 *
62 * Now let us populate our array with some strings:
63 * @until push
64 * @note Notice we use strdup, so we will have to free that memory later on.
65 *
66 * Now lets check the size of the array:
67 * @until printf
68 *
69 * And now we call a function on every member of our array to print it:
70 * @until foreach
71 *
72 * One of the strenghts of @ref Eina_Array over @ref Eina_List is that it has
73 * very fast random access to elements, so this is very efficient:
74 * @until printf
75 *
76 * And now we free up the memory allocated with the strdup()s:
77 * @until free
78 *
79 * And the array memory itself:
80 * @until array_free
81 *
82 * And finally shutdown eina and exit:
83 * @until }
84 *
85 * The full source code can be found on the examples folder
86 * on the @ref eina_array_01_c "eina_array_01.c" file.
87 */
88
89/**
90 * @page eina_array_01_c Basic array usage example
91 *
92 * @include eina_array_01.c
93 * @example eina_array_01.c
94 */
95
96/**
97 * @page eina_array_02_example_page Removing array elements
98 * @dontinclude eina_array_02.c
99 *
100 * Just the usual includes:
101 * @skip #include
102 * @until Eina.h
103 *
104 * This the callback we are going to use to decide which strings stay on the
105 * array and which will be removed, we use something simple, but this can be as
106 * complex as you like:
107 * @until }
108 *
109 * This is the same code we used before to populate the list with the slight
110 * difference of not using strdup:
111 * @until array_push
112 *
113 * So we have added all our elements to the array, but it turns out that is not
114 * the elements we wanted, so let's empty the array and add the correct strings:
115 * @until array_push
116 *
117 * It seems we made a little mistake in one of our strings so we need to replace
118 * it, here is how:
119 * @until data_set
120 *
121 * Now that there is a populated array we can remove elements from it easily:
122 * @until array_remove
123 *
124 * And check that the elements were actually removed:
125 * @until printf
126 *
127 * Since this time we didn't use strdup we don't need to free each string:
128 * @until }
129 *
130 * The full source code can be found on the examples folder
131 * on the @ref eina_array_02_c "eina_array_02.c" file.
132 */
133
134/**
135 * @page eina_array_02_c Basic array usage example
136 *
137 * @include eina_array_02.c
138 * @example eina_array_02.c
139 */
140
141/**
142 * @addtogroup Eina_Array_Group Array
143 *
144 * @brief These functions provide array management.
145 *
146 * The Array data type in Eina is designed to have very fast access to
147 * its data (compared to the Eina @ref Eina_List_Group). On the other hand,
148 * data can be added or removed only at the end of the array. To insert
149 * data at any place, the Eina @ref Eina_List_Group is the correct container
150 * to use.
151 *
152 * To use the array data type, eina_init() must be called before any
153 * other array functions. When no more eina array functions are used,
154 * eina_shutdown() must be called to free all the resources.
155 *
156 * An array must be created with eina_array_new(). It allocates all
157 * the necessary data for an array. When not needed anymore, an array
158 * is freed with eina_array_free(). This function does not free any
159 * allocated memory used to store the data of each element. For that,
160 * just iterate over the array to free them. A convenient way to do
161 * that is by using #EINA_ARRAY_ITER_NEXT. An example of code is given
162 * in the description of this macro.
163 *
164 * @warning Functions do not check if the used array is valid or not. It's up to
165 * the user to be sure of that. It is designed like that for performance
166 * reasons.
167 *
168 * The usual features of an array are classic ones: to append an
169 * element, use eina_array_push() and to remove the last element, use
170 * eina_array_pop(). To retrieve the element at a given position, use
171 * eina_array_data_get(). The number of elements can be retrieved with
172 * eina_array_count().
173 *
174 * Eina_Array is different from a conventional C array in a number of ways, most
175 * importantly they grow and shrink dynamically, this means that if you add an
176 * element to a full array it grows and that when you remove an element from an
177 * array it @b may shrink.
178 *
179 * When the array needs to grow it allocates memory not just for the element
180 * currently being added since that would mean allocating memory(which is
181 * computationally expensive) often, instead it grows to be able to hold @p step
182 * more elements. Similarly if you remove elements in such a way that that the
183 * array is left holding its capacity - @p step elements it will shrink.
184 *
185 * The following image illustrates how an Eina_Array grows:
186 *
187 * @image html eina_array-growth.png
188 * @image latex eina_array-growth.eps width=\textwidth
189 *
190 * Eina_Array only stores pointers but it can store data of any type in the form
191 * of void pointers.
192 *
193 * See here some examples:
194 * @li @ref eina_array_01_example_page
195 * @li @ref eina_array_02_example_page
196 */
197
198/**
199 * @addtogroup Eina_Data_Types_Group Data Types
200 *
201 * @{
202 */
203
204/**
205 * @addtogroup Eina_Containers_Group Containers
206 *
207 * @{
208 */
209
210/**
211 * @defgroup Eina_Array_Group Array
212 *
213 * @{
214 */
215
216/**
217 * @typedef Eina_Array
218 * Type for a generic vector.
219 */
220typedef struct _Eina_Array Eina_Array;
221
222/**
223 * @typedef Eina_Array_Iterator
224 * Type for an iterator on arrays, used with #EINA_ARRAY_ITER_NEXT.
225 */
226typedef void **Eina_Array_Iterator;
227
228/**
229 * @struct _Eina_Array
230 * Type for an array of data.
231 */
232struct _Eina_Array
233{
234#define EINA_ARRAY_VERSION 1
235 int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
236
237 void **data; /**< Pointer to a vector of pointer to payload */
238 unsigned int total; /**< Total number of slots in the vector */
239 unsigned int count; /**< Number of active slots in the vector */
240 unsigned int step; /**< How much must we grow the vector when it is full */
241 EINA_MAGIC
242};
243
244
245/**
246 * @brief Create a new array.
247 *
248 * @param step The count of pointers to add when increasing the array size.
249 * @return @c NULL on failure, non @c NULL otherwise.
250 *
251 * This function creates a new array. When adding an element, the array
252 * allocates @p step elements. When that buffer is full, then adding
253 * another element will increase the buffer by @p step elements again.
254 *
255 * This function return a valid array on success, or @c NULL if memory
256 * allocation fails. In that case, the error is set to
257 * #EINA_ERROR_OUT_OF_MEMORY.
258 */
259EAPI Eina_Array *eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
260
261/**
262 * @brief Free an array.
263 *
264 * @param array The array to free.
265 *
266 * This function frees @p array. It calls first eina_array_flush() then
267 * free the memory of the pointer. It does not free the memory
268 * allocated for the elements of @p array. To free them, use
269 * #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check
270 * of @p array.
271 */
272EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
273
274/**
275 * @brief Set the step of an array.
276 *
277 * @param array The array.
278 * @param sizeof_eina_array Should be the value returned by sizeof(Eina_Array).
279 * @param step The count of pointers to add when increasing the array size.
280 *
281 * This function sets the step of @p array to @p step. For performance
282 * reasons, there is no check of @p array. If it is @c NULL or
283 * invalid, the program may crash.
284 *
285 * @warning This function can @b only be called on uninitialized arrays.
286 */
287EAPI void eina_array_step_set(Eina_Array *array,
288 unsigned int sizeof_eina_array,
289 unsigned int step) EINA_ARG_NONNULL(1);
290/**
291 * @brief Clean an array.
292 *
293 * @param array The array to clean.
294 *
295 * This function sets the count member of @p array to 0, however it doesn't free
296 * any space. This is particularly useful if you need to empty the array and
297 * add lots of elements quickly. For performance reasons, there is no check of
298 * @p array. If it is @c NULL or invalid, the program may crash.
299 */
300static inline void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
301
302/**
303 * @brief Flush an array.
304 *
305 * @param array The array to flush.
306 *
307 * This function sets the count and total members of @p array to 0,
308 * frees and set to NULL its data member. For performance reasons,
309 * there is no check of @p array. If it is @c NULL or invalid, the
310 * program may crash.
311 */
312EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
313
314/**
315 * @brief Rebuild an array by specifying the data to keep.
316 *
317 * @param array The array.
318 * @param keep The functions which selects the data to keep.
319 * @param gdata The data to pass to the function keep.
320 * @return #EINA_TRUE on success, #EINA_FALSE oterwise.
321 *
322 * This function rebuilds @p array be specifying the elements to keep with the
323 * function @p keep. No empty/invalid fields are left in the array. @p gdata is
324 * an additional data to pass to @p keep. For performance reasons, there is no
325 * check of @p array. If it is @c NULL or invalid, the program may crash.
326 *
327 * If it wasn't able to remove items due to an allocation failure, it will
328 * return #EINA_FALSE and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
329 */
330EAPI Eina_Bool eina_array_remove(Eina_Array * array,
331 Eina_Bool (*keep)(void *data, void *gdata),
332 void *gdata) EINA_ARG_NONNULL(1, 2);
333static inline Eina_Bool eina_array_push(Eina_Array *array,
334 const void *data) EINA_ARG_NONNULL(1, 2);
335static inline void *eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1);
336static inline void *eina_array_data_get(const Eina_Array *array,
337 unsigned int idx) EINA_ARG_NONNULL(1);
338/**
339 * @brief Set the data at a given position in an array.
340 *
341 * @param array The array.
342 * @param idx The potition of the data to set.
343 * @param data The data to set.
344 *
345 * This function sets the data at the position @p idx in @p
346 * array to @p data, this effectively replaces the previously held data, you
347 * must therefore get a pointer to it first if you need to free it. For
348 * performance reasons, there is no check of @p array or @p idx. If it is @c
349 * NULL or invalid, the program may crash.
350*/
351static inline void eina_array_data_set(const Eina_Array *array,
352 unsigned int idx,
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;
355static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
356
357/**
358 * @brief Returned a new iterator associated to an array.
359 *
360 * @param array The array.
361 * @return A new iterator.
362 *
363 * This function returns a newly allocated iterator associated to
364 * @p array. If @p array is @c NULL or the count member of @p array is
365 * less or equal than 0, this function returns NULL. If the memory can
366 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
367 * set. Otherwise, a valid iterator is returned.
368 */
369EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
370
371/**
372 * @brief Returned a new accessor associated to an array.
373 *
374 * @param array The array.
375 * @return A new accessor.
376 *
377 * This function returns a newly allocated accessor associated to
378 * @p array. If @p array is @c NULL or the count member of @p array is
379 * less or equal than 0, this function returns NULL. If the memory can
380 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
381 * set. Otherwise, a valid accessor is returned.
382 */
383EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
384/**
385 * @brief Provide a safe way to iterate over an array
386 *
387 * @param array The array to iterate over.
388 * @param cb The callback to call for each item.
389 * @param fdata The user data to pass to the callback.
390 * @return EINA_TRUE if it successfully iterate all items of the array.
391 *
392 * This function provide a safe way to iterate over an array. @p cb should
393 * return EINA_TRUE as long as you want the function to continue iterating,
394 * by returning EINA_FALSE it will stop and return EINA_FALSE as a result.
395 */
396static inline Eina_Bool eina_array_foreach(Eina_Array *array,
397 Eina_Each_Cb cb,
398 void *fdata);
399/**
400 * @def EINA_ARRAY_ITER_NEXT
401 * @brief Macro to iterate over an array easily.
402 *
403 * @param array The array to iterate over.
404 * @param index The integer number that is increased while itareting.
405 * @param item The data
406 * @param iterator The iterator
407 *
408 * This macro allows the iteration over @p array in an easy way. It
409 * iterates from the first element to the last one. @p index is an
410 * integer that increases from 0 to the number of elements. @p item is
411 * the data of each element of @p array, so it is a pointer to a type
412 * chosen by the user. @p iterator is of type #Eina_Array_Iterator.
413 *
414 * This macro can be used for freeing the data of an array, like in
415 * the following example:
416 *
417 * @code
418 * Eina_Array *array;
419 * char *item;
420 * Eina_Array_Iterator iterator;
421 * unsigned int i;
422 *
423 * // array is already filled,
424 * // its elements are just duplicated strings,
425 * // EINA_ARRAY_ITER_NEXT will be used to free those strings
426 *
427 * EINA_ARRAY_ITER_NEXT(array, i, item, iterator)
428 * free(item);
429 * @endcode
430 */
431#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
432 for (index = 0, iterator = (array)->data; \
433 (index < eina_array_count(array)) && ((item = *((iterator)++))); \
434 ++(index))
435
436#include "eina_inline_array.x"
437
438/**
439 * @}
440 */
441
442/**
443 * @}
444 */
445
446/**
447 * @}
448 */
449
450#endif
diff --git a/libraries/eina/src/include/eina_benchmark.h b/libraries/eina/src/include/eina_benchmark.h
deleted file mode 100644
index 9e96d64..0000000
--- a/libraries/eina/src/include/eina_benchmark.h
+++ /dev/null
@@ -1,453 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_BENCHMARK_H_
20#define EINA_BENCHMARK_H_
21
22#include "eina_array.h"
23
24
25
26/**
27 * @page tutorial_benchmark_page Benchmark Tutorial
28 *
29 * The Benchmark module allows you to write easily benchmarks
30 * framework in a project for timing critical part and detect slow
31 * parts of code. In addition it automatically creates data files of
32 * these benchmark, as well as a gnuplot file which can display the
33 * comparison curves of the benchmarks.
34 *
35 * @section tutorial_benchmark_basic_usage Basic Usage
36 *
37 * To create a basic benchmark, you have to follow these steps:
38 *
39 * @li Create a new bechmark
40 * @li Write the functions that wraps the the functions you want to
41 * bechmark.
42 * @li Register these wrappers functions.
43 * @li Run the benchmark.
44 * @li Free the memory.
45 *
46 * Here is a basic example of bechmark which creates two functions
47 * that will be run. These functions just print a message.
48 *
49 * @code
50 * #include <stdlib.h>
51 * #include <stdio.h>
52 *
53 * #include <Eina.h>
54 *
55 * static
56 * void work1(int request)
57 * {
58 * printf ("work1 in progress... Request: %d\n", request);
59 * }
60 *
61 * static
62 * void work2(int request)
63 * {
64 * printf ("work2 in progress... Request: %d\n", request);
65 * }
66 *
67 * int main()
68 * {
69 * Eina_Benchmark *test;
70 * Eina_Array *ea;
71 *
72 * if (!eina_init())
73 * return EXIT_FAILURE;
74 *
75 * test = eina_benchmark_new("test", "run");
76 * if (!test)
77 * goto shutdown_eina;
78 *
79 * eina_benchmark_register(test, "work-1", EINA_BENCHMARK(work1), 200, 300, 10);
80 * eina_benchmark_register(test, "work-2", EINA_BENCHMARK(work2), 100, 150, 5);
81 *
82 * ea = eina_benchmark_run(test);
83 *
84 * eina_benchmark_free(test);
85 * eina_shutdown();
86 *
87 * return EXIT_SUCCESS;
88 *
89 * shutdown_eina:
90 * eina_shutdown();
91 *
92 * return EXIT_FAILURE;
93 * }
94 * @endcode
95 *
96 * As "test", "run" are passed to eina_benchmark_new() and as the tests
97 * "work-1" and "work-2" are registered, the data files
98 * bench_test_run.work-1.data and bench_test_run.work-2.data will be
99 * created after the eina_benchmark_run() call. They contain four
100 * columns. The file bench_test_run.work-1.data contains for example:
101 *
102 * @code
103 * # specimen experiment time starting time ending time
104 * 200 23632 2852446 2876078
105 * 210 6924 2883046 2889970
106 * 220 6467 2895962 2902429
107 * 230 6508 2908271 2914779
108 * 240 6278 2920610 2926888
109 * 250 6342 2932830 2939172
110 * 260 6252 2944954 2951206
111 * 270 6463 2956978 2963441
112 * 280 6347 2969548 2975895
113 * 290 6457 2981702 2988159
114 * @endcode
115 *
116 * The first column (specimen) is the integer passed to the work1()
117 * function when the test is run. The second column (experiment time)
118 * is the time, in nanosecond, that work1() takes. The third and
119 * fourth columnd are self-explicit.
120 *
121 * You can see that the integer passed work1() starts from 200 and
122 * finishes at 290, with a step of 10. These values are computed withe
123 * last 3 values passed to eina_benchmark_register(). See the document
124 * of that function for the detailed behavior.
125 *
126 * The gnuplot file will be named bench_test_run.gnuplot. Just run:
127 *
128 * @code
129 * gnuplot bench_test_run.gnuplot
130 * @endcode
131 *
132 * to create the graphic of the comparison curves. The image file is
133 * named output_test_run.png.
134 *
135 * @section tutorial_benchmark_advanced_usage More Advanced Usage
136 *
137 * In this section, several test will be created and run. The idea is
138 * exactly the same than in the previous section, but with some basic
139 * automatic way to run all the benchmarks. The following code
140 * benchmarks some Eina converts functions, and some Eina containers
141 * types:
142 *
143 * @code
144 * #include <stdlib.h>
145 * #include <stdio.h>
146 * #include <time.h>
147 *
148 * #include <Eina.h>
149 *
150 * static void bench_convert(Eina_Benchmark *bench);
151 * static void bench_container(Eina_Benchmark *bench);
152 *
153 * typedef struct _Benchmark_Case Benchmark_Case;
154 *
155 * struct _Benchmark_Case
156 * {
157 * const char *bench_case;
158 * void (*build)(Eina_Benchmark *bench);
159 * };
160 *
161 * static const Benchmark_Case benchmarks[] = {
162 * { "Bench 1", bench_convert },
163 * { "Bench 2", bench_container },
164 * { NULL, NULL }
165 * };
166 *
167 * static
168 * void convert1(int request)
169 * {
170 * char tmp[128];
171 * int i;
172 *
173 * srand(time(NULL));
174 *
175 * for (i = 0; i < request; ++i)
176 * eina_convert_itoa(rand(), tmp);
177 * }
178 *
179 * static
180 * void convert2(int request)
181 * {
182 * char tmp[128];
183 * int i;
184 *
185 * srand(time(NULL));
186 *
187 * for (i = 0; i < request; ++i)
188 * eina_convert_xtoa(rand(), tmp);
189 * }
190 *
191 * static void
192 * bench_convert(Eina_Benchmark *bench)
193 * {
194 * eina_benchmark_register(bench, "convert-1", EINA_BENCHMARK(convert1), 200, 400, 10);
195 * eina_benchmark_register(bench, "convert-2", EINA_BENCHMARK(convert2), 200, 400, 10);
196 * }
197 *
198 * static
199 * void array(int request)
200 * {
201 * Eina_Array *array;
202 * Eina_Array_Iterator it;
203 * int *data;
204 * int i;
205 *
206 * srand(time(NULL));
207 *
208 * array = eina_array_new(64);
209 *
210 * for (i = 0; i < request; ++i)
211 * {
212 * data = (int *)malloc(sizeof(int));
213 * if (!data) continue;
214 * *data = rand();
215 * eina_array_push(array, data);
216 * }
217 *
218 * EINA_ARRAY_ITER_NEXT(array, i, data, it)
219 * free(data);
220 *
221 * eina_array_free(array);
222 * }
223 *
224 * static
225 * void list(int request)
226 * {
227 * Eina_List *l = NULL;
228 * int *data;
229 * int i;
230 *
231 * srand(time(NULL));
232 *
233 * for (i = 0; i < request; ++i)
234 * {
235 * data = (int *)malloc(sizeof(int));
236 * if (!data) continue;
237 * *data = rand();
238 * l = eina_list_prepend(l, data);
239 * }
240 *
241 * while (l)
242 * {
243 * free(eina_list_data_get(l));
244 * l = eina_list_remove_list(l, l);
245 * }
246 * }
247 *
248 * static void
249 * bench_container(Eina_Benchmark *bench)
250 * {
251 * eina_benchmark_register(bench, "array", EINA_BENCHMARK(array), 200, 300, 10);
252 * eina_benchmark_register(bench, "list", EINA_BENCHMARK(list), 200, 300, 10);
253 * }
254 *
255 * int main()
256 * {
257 * Eina_Benchmark *test;
258 * Eina_Array *ea;
259 * unsigned int i;
260 *
261 * if (!eina_init())
262 * return EXIT_FAILURE;
263 *
264 * for (i = 0; benchmarks[i].bench_case != NULL; ++i)
265 * {
266 * test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark example");
267 * if (!test)
268 * continue;
269 *
270 * benchmarks[i].build(test);
271 *
272 * ea = eina_benchmark_run(test);
273 *
274 * eina_benchmark_free(test);
275 * }
276 *
277 * eina_shutdown();
278 *
279 * return EXIT_SUCCESS;
280 * }
281 * @endcode
282 *
283 * gnuplot can be used to see how are performed the convert functions
284 * together, as well as how are performed the containers. So it is now
285 * easy to see that the hexadecimal convert function is faster than
286 * the decimal one, and that arrays are faster than lists.
287 *
288 * You can improve all that by executing automatically gnuplot in your
289 * program, or integrate the Eina benchmark framework in an autotooled
290 * project. See that
291 * <a href="http://trac.enlightenment.org/e/wiki/AutotoolsIntegration#Benchmark">page</a>
292 * for more informations.
293 *
294 */
295
296
297/**
298 * @addtogroup Eina_Benchmark_Group Benchmark
299 *
300 * These functions allow you to add benchmark framework in a project
301 * for timing critical part and detect slow parts of code. It is used
302 * in Eina to compare the time used by eina, glib, evas and ecore data
303 * types.
304 *
305 * To use the benchmark module, Eina must be initialized with
306 * eina_init() and later shut down with eina_shutdown(). A benchmark
307 * is created with eina_benchmark_new() and freed with
308 * eina_benchmark_free().
309 *
310 * eina_benchmark_register() adds a test to a benchmark. That test can
311 * be run a certain amount of times. Adding more than one test to be
312 * executed allows the comparison between several parts of a program,
313 * or different implementations.
314 *
315 * eina_benchmark_run() runs all the tests registered with
316 * eina_benchmark_register(). The amount of time of each test is
317 * written in a gnuplot file.
318 *
319 * For more information, you can look at the @ref tutorial_benchmark_page.
320 */
321
322/**
323 * @addtogroup Eina_Tools_Group Tools
324 *
325 * @{
326 */
327
328/**
329 * @defgroup Eina_Benchmark_Group Benchmark
330 *
331 * @{
332 */
333
334/**
335 * @typedef Eina_Benchmark
336 * Type for a benchmark.
337 */
338typedef struct _Eina_Benchmark Eina_Benchmark;
339
340/**
341 * @typedef Eina_Benchmark_Specimens
342 * Type for a test function to be called when running a benchmark.
343 */
344typedef void (*Eina_Benchmark_Specimens)(int request);
345
346/**
347 * @def EINA_BENCHMARK
348 * @brief cast to an #Eina_Benchmark_Specimens.
349 *
350 * @param function The function to cast.
351 *
352 * This macro casts @p function to Eina_Benchmark_Specimens.
353 */
354#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
355
356
357/**
358 * @brief Create a new array.
359 *
360 * @param name The name of the benchmark.
361 * @param run The name of the run.
362 * @return @c NULL on failure, non @c NULL otherwise.
363 *
364 * This function creates a new benchmark. @p name and @p run are used
365 * to name the gnuplot file that eina_benchmark_run() will create.
366 *
367 * This function return a valid benchmark on success, or @c NULL if
368 * memory allocation fails. In that case, the error is set to
369 * #EINA_ERROR_OUT_OF_MEMORY.
370 *
371 * When the new module is not needed anymore, use
372 * eina_benchmark_free() to free the allocated memory.
373 */
374EAPI Eina_Benchmark *eina_benchmark_new(const char *name,
375 const char *run);
376
377/**
378 * @brief Free a benchmark object.
379 *
380 * @param bench The benchmark to free.
381 *
382 * This function removes all the benchmark tests that have been
383 * registered and frees @p bench. If @p bench is @c NULL, this
384 * function returns immediately.
385 */
386EAPI void eina_benchmark_free(Eina_Benchmark *bench);
387
388/**
389 * @brief Add a test to a benchmark.
390 *
391 * @param bench The benchmark.
392 * @param name The name of the test.
393 * @param bench_cb The test function to be called.
394 * @param count_start The start data to be passed to @p bench_cb.
395 * @param count_end The end data to be passed to @p bench_cb.
396 * @param count_step The step data to be passed to @p bench_cb.
397 * @return #EINA_FALSE on failure, #EINA_TRUE otherwise.
398 *
399 * This function adds the test named @p name to @p benchmark. @p
400 * bench_cb is the function called when the test is executed. That
401 * test can be executed a certain amount of time. @p count_start, @p count_end and
402 * @p count_step define a loop with a step increment. The integer that is
403 * increasing by @p count_step from @p count_start to @p count_end is passed to @p
404 * bench_cb when eina_benchmark_run() is called.
405 *
406 * If @p bench is @c NULL, this function returns imediatly. If the
407 * allocation of the memory of the test to add fails, the error is set
408 * to #EINA_ERROR_OUT_OF_MEMORY. This function returns #EINA_FALSE
409 * on failure, #EINA_TRUE otherwise.
410 */
411EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench,
412 const char *name,
413 Eina_Benchmark_Specimens bench_cb,
414 int count_start,
415 int count_end,
416 int count_step);
417
418/**
419 * @brief Run the benchmark tests that have been registered.
420 *
421 * @param bench The benchmark.
422 * @return The list of names of the test files.
423 *
424 * This function runs all the tests that as been registered with
425 * eina_benchmark_register() and save the result in a gnuplot
426 * file. The name of the file has the following format:
427 *
428 * @code
429 * bench_[name]_[run]%s.gnuplot
430 * @endcode
431 *
432 * where [name] and [run] are the values passed to
433 * eina_benchmark_new().
434 *
435 * Each registered test is executed and timed. The time is written to
436 * the gnuplot file. The number of times each test is executed is
437 * controlled by the parameters passed to eina_benchmark_register().
438 *
439 * If @p bench is @c NULL, this functions returns @c NULL
440 * immediately. Otherwise, it returns the list of the names of each
441 * test.
442 */
443EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
444
445/**
446 * @}
447 */
448
449/**
450 * @}
451 */
452
453#endif /* EINA_BENCHMARK_H_ */
diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h
deleted file mode 100644
index 7c3524b..0000000
--- a/libraries/eina/src/include/eina_binbuf.h
+++ /dev/null
@@ -1,235 +0,0 @@
1#ifndef EINA_BINBUF_H
2#define EINA_BINBUF_H
3
4#include <stddef.h>
5#include <stdarg.h>
6
7#include "eina_types.h"
8
9/**
10 * @addtogroup Eina_Binary_Buffer_Group Binary Buffer
11 *
12 * @brief These functions provide string buffers management.
13 *
14 * The Binary Buffer data type is designed to be a mutable string,
15 * allowing to append, prepend or insert a string to a buffer.
16 */
17
18/**
19 * @addtogroup Eina_Data_Types_Group Data Types
20 *
21 * @{
22 */
23
24/**
25 * @defgroup Eina_Binary_Buffer_Group Binary Buffer
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_Binbuf
32 * Type for a string buffer.
33 */
34typedef struct _Eina_Strbuf Eina_Binbuf;
35
36/**
37 * @brief Create a new string buffer.
38 *
39 * @return Newly allocated string buffer instance.
40 *
41 * This function creates a new string buffer. On error, @c NULL is
42 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
43 * free the resources, use eina_binbuf_free().
44 *
45 * @see eina_binbuf_free()
46 * @see eina_binbuf_append()
47 * @see eina_binbuf_string_get()
48 */
49EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
50
51/**
52 * @brief Create a new string buffer using the passed string. The passed
53 * string is used directly as the buffer, it's somehow the opposite function of
54 * @ref eina_binbuf_string_steal . The passed string must be malloced.
55 *
56 * @param str the string to manage
57 * @param length the length of the string.
58 * @return Newly allocated string buffer instance.
59 *
60 * This function creates a new string buffer. On error, @c NULL is
61 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
62 * free the resources, use eina_binbuf_free().
63 *
64 * @see eina_binbuf_manage_new()
65 * @since 1.2.0
66 */
67EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
68
69/**
70 * @brief Free a string buffer.
71 *
72 * @param buf The string buffer to free.
73 *
74 * This function frees the memory of @p buf. @p buf must have been
75 * created by eina_binbuf_new().
76 */
77EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
78
79/**
80 * @brief Reset a string buffer.
81 *
82 * @param buf The string buffer to reset.
83 *
84 * This function reset @p buf: the buffer len is set to 0, and the
85 * string is set to '\\0'. No memory is free'd.
86 */
87EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
88
89/**
90 * @brief Append a string of exact length to a buffer, reallocating as necessary.
91 *
92 * @param buf The string buffer to append to.
93 * @param str The string to append.
94 * @param length The exact length to use.
95 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
96 *
97 * This function appends @p str to @p buf. @p str must be of size at
98 * most @p length. It is slightly faster than eina_binbuf_append() as
99 * it does not compute the size of @p str. It is useful when dealing
100 * with strings of known size, such as eina_strngshare. If @p buf
101 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
102 * returned.
103 *
104 * @see eina_stringshare_length()
105 * @see eina_binbuf_append()
106 * @see eina_binbuf_append_n()
107 */
108EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char *str, size_t length) EINA_ARG_NONNULL(1, 2);
109
110/**
111 * @brief Append a character to a string buffer, reallocating as
112 * necessary.
113 *
114 * @param buf The string buffer to append to.
115 * @param c The char to append.
116 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
117 *
118 * This function inserts @p c to @p buf. If it can not insert it,
119 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
120 */
121EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_ARG_NONNULL(1);
122
123/**
124 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
125 *
126 * @param buf The string buffer to insert to.
127 * @param str The string to insert.
128 * @param length The exact length to use.
129 * @param pos The position to insert the string.
130 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
131 *
132 * This function inserts @p str to @p buf. @p str must be of size at
133 * most @p length. It is slightly faster than eina_binbuf_insert() as
134 * it does not compute the size of @p str. It is useful when dealing
135 * with strings of known size, such as eina_strngshare. If @p buf
136 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
137 * returned.
138 *
139 * @see eina_stringshare_length()
140 * @see eina_binbuf_insert()
141 * @see eina_binbuf_insert_n()
142 */
143EAPI Eina_Bool eina_binbuf_insert_length(Eina_Binbuf *buf, const unsigned char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
144
145/**
146 * @brief Insert a character to a string buffer, reallocating as
147 * necessary.
148 *
149 * @param buf The string buffer to insert to.
150 * @param c The char to insert.
151 * @param pos The position to insert the char.
152 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
153 *
154 * This function inserts @p c to @p buf at position @p pos. If @p buf
155 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
156 * returned.
157 */
158EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t pos) EINA_ARG_NONNULL(1);
159
160/**
161 * @brief Remove a slice of the given string buffer.
162 *
163 * @param buf The string buffer to remove a slice.
164 * @param start The initial (inclusive) slice position to start
165 * removing, in bytes.
166 * @param end The final (non-inclusive) slice position to finish
167 * removing, in bytes.
168 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
169 *
170 * This function removes a slice of @p buf, starting at @p start
171 * (inclusive) and ending at @p end (non-inclusive). Both values are
172 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
173 */
174
175EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
176
177/**
178 * @brief Retrieve a pointer to the contents of a string buffer
179 *
180 * @param buf The string buffer.
181 * @return The current string in the string buffer.
182 *
183 * This function returns the string contained in @p buf. The returned
184 * value must not be modified and will no longer be valid if @p buf is
185 * modified. In other words, any eina_binbuf_append() or similar will
186 * make that pointer invalid.
187 *
188 * @see eina_binbuf_string_steal()
189 */
190EAPI const unsigned char *eina_binbuf_string_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
191
192/**
193 * @brief Steal the contents of a string buffer.
194 *
195 * @param buf The string buffer to steal.
196 * @return The current string in the string buffer.
197 *
198 * This function returns the string contained in @p buf. @p buf is
199 * then initialized and does not own the returned string anymore. The
200 * caller must release the memory of the returned string by calling
201 * free().
202 *
203 * @see eina_binbuf_string_get()
204 */
205EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
206
207/**
208 * @brief Free the contents of a string buffer but not the buffer.
209 *
210 * @param buf The string buffer to free the string of.
211 *
212 * This function frees the string contained in @p buf without freeing
213 * @p buf.
214 */
215EAPI void eina_binbuf_string_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
216
217/**
218 * @brief Retrieve the length of the string buffer content.
219 *
220 * @param buf The string buffer.
221 * @return The current length of the string, in bytes.
222 *
223 * This function returns the length of @p buf.
224 */
225EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
226
227/**
228 * @}
229 */
230
231/**
232 * @}
233 */
234
235#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_binshare.h b/libraries/eina/src/include/eina_binshare.h
deleted file mode 100644
index 55b17a6..0000000
--- a/libraries/eina/src/include/eina_binshare.h
+++ /dev/null
@@ -1,193 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_BINSHARE_H_
52#define EINA_BINSHARE_H_
53
54#include "eina_types.h"
55
56/**
57 * @page tutorial_binshare_page Binary Share Tutorial
58 *
59 * Should call eina_binshare_init() before usage and eina_binshare_shutdown() after.
60 * to be written...
61 *
62 */
63
64/**
65 * @addtogroup Eina_Binshare_Group Binary Share
66 *
67 * These functions allow you to store one copy of an object, and use it
68 * throughout your program.
69 *
70 * This is a method to reduce the number of duplicated objects kept in
71 * memory.
72 *
73 * For more information, you can look at the @ref tutorial_binshare_page.
74 */
75
76/**
77 * @addtogroup Eina_Data_Types_Group Data Types
78 *
79 * @{
80 */
81
82/**
83 * @defgroup Eina_Binshare_Group Binary Share
84 *
85 * @{
86 */
87
88
89/**
90 * @brief Retrieve an instance of an object for use in a program.
91 *
92 * @param obj The binary object to retrieve an instance of.
93 * @param olen The byte size
94 * @return A pointer to an instance of the object on success.
95 * @c NULL on failure.
96 *
97 * This function retrieves an instance of @p obj. If @p obj is
98 * @c NULL, then @c NULL is returned. If @p obj is already stored, it
99 * is just returned and its reference counter is increased. Otherwise
100 * it is added to the objects to be searched and a duplicated object
101 * of @p obj is returned.
102 *
103 * This function does not check object size, but uses the
104 * exact given size. This can be used to share part of a larger
105 * object or subobject.
106 *
107 * @see eina_binshare_add()
108 */
109EAPI const void *eina_binshare_add_length(const void *obj,
110 unsigned int olen) EINA_PURE EINA_WARN_UNUSED_RESULT;
111
112/**
113 * Increment references of the given shared object.
114 *
115 * @param obj The shared object.
116 * @return A pointer to an instance of the object on success.
117 * @c NULL on failure.
118 *
119 * This is similar to eina_share_common_add(), but it's faster since it will
120 * avoid lookups if possible, but on the down side it requires the parameter
121 * to be shared before, in other words, it must be the return of a previous
122 * eina_binshare_add().
123 *
124 * There is no unref since this is the work of eina_binshare_del().
125 */
126EAPI const void *eina_binshare_ref(const void *obj);
127
128/**
129 * @brief Note that the given object has lost an instance.
130 *
131 * @param obj object The given object.
132 *
133 * This function decreases the reference counter associated to @p obj
134 * if it exists. If that counter reaches 0, the memory associated to
135 * @p obj is freed. If @p obj is NULL, the function returns
136 * immediately.
137 *
138 * Note that if the given pointer is not shared or NULL, bad things
139 * will happen, likely a segmentation fault.
140 */
141EAPI void eina_binshare_del(const void *obj);
142
143/**
144 * @brief Note that the given object @b must be shared.
145 *
146 * @param obj the shared object to know the length. It is safe to
147 * give NULL, in that case -1 is returned.
148 * @return The length of the shared object.
149 *
150 * This function is a cheap way to known the length of a shared
151 * object. Note that if the given pointer is not shared, bad
152 * things will happen, likely a segmentation fault. If in doubt, try
153 * strlen().
154 */
155EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT;
156
157/**
158 * @brief Dump the contents of the share_common.
159 *
160 * This function dumps all objects in the share_common to stdout with a
161 * DDD: prefix per line and a memory usage summary.
162 */
163EAPI void eina_binshare_dump(void);
164
165/**
166 * @brief Retrieve an instance of a blob for use in a program.
167 *
168 * @param ptr The binary blob to retrieve an instance of.
169 * @return A pointer to an instance of the string on success.
170 * @c NULL on failure.
171 *
172 * This macro retrieves an instance of @p obj. If @p obj is
173 * @c NULL, then @c NULL is returned. If @p obj is already stored, it
174 * is just returned and its reference counter is increased. Otherwise
175 * it is added to the blobs to be searched and a duplicated blob
176 * of @p obj is returned.
177 *
178 * This macro essentially calls eina_binshare_add_length with ptr and sizeof(*ptr)
179 * as the parameters. It's useful for pointers to structures.
180 *
181 * @see eina_stringshare_add_length()
182 */
183#define eina_binshare_add(ptr) eina_binshare_add_length(ptr, sizeof(*ptr))
184
185/**
186 * @}
187 */
188
189/**
190 * @}
191 */
192
193#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_clist.h b/libraries/eina/src/include/eina_clist.h
deleted file mode 100644
index 096a4b7..0000000
--- a/libraries/eina/src/include/eina_clist.h
+++ /dev/null
@@ -1,378 +0,0 @@
1/*
2 * Linked lists support
3 *
4 * Copyright (C) 2002 Alexandre Julliard
5 * Copyright (C) 2011 Mike McCormack (adapted for Eina)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifndef __EINA_CLIST_H__
23#define __EINA_CLIST_H__
24
25/**
26 * @addtogroup Eina_Data_Types_Group Data Types
27 *
28 * @{
29 */
30
31/**
32 * @addtogroup Eina_Containers_Group Containers
33 *
34 * @{
35 */
36
37/**
38 * @defgroup Eina_CList_Group Compact List
39 *
40 * @{
41 *
42 * @brief Eina_Clist is a compact (inline) list implementation
43 *
44 * Elements of this list are members of the structs stored in the list
45 *
46 * Advantages over @ref Eina_List and @ref Eina_Inlist:
47 * - uses less memory (two machine words per item)
48 * - allows removing items without knowing which list they're in using O(1) time
49 * - no need to keep updating the head pointer as the list is changed
50 *
51 * Disadvantages:
52 * - O(N) time to calculate list length
53 * - requires one list entry in a struct per list (i.e. it's an inlist)
54 * - requires a head/tail pointer
55 * - need to know the list head when moving to next or previous pointer
56 *
57 * @note There's no NULL at the end of the list, the last item points to the head.
58 *
59 * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init
60 *
61 * Define a list like so:
62 *
63 * @code
64 * struct gadget
65 * {
66 * struct Eina_Clist entry; <-- doesn't have to be the first item in the struct
67 * int a, b;
68 * };
69 *
70 * static Eina_Clist global_gadgets = EINA_CLIST_INIT( global_gadgets );
71 * @endcode
72 *
73 * or
74 *
75 * @code
76 * struct some_global_thing
77 * {
78 * Eina_Clist gadgets;
79 * };
80 *
81 * eina_clist_init( &some_global_thing->gadgets );
82 * @endcode
83 *
84 * Manipulate it like this:
85 *
86 * @code
87 * eina_clist_add_head( &global_gadgets, &new_gadget->entry );
88 * eina_clist_remove( &new_gadget->entry );
89 * eina_clist_add_after( &some_random_gadget->entry, &new_gadget->entry );
90 * @endcode
91 *
92 * And to iterate over it:
93 *
94 * @code
95 * struct gadget *gadget;
96 * EINA_CLIST_FOR_EACH_ENTRY( gadget, &global_gadgets, struct gadget, entry )
97 * {
98 * ...
99 * }
100 * @endcode
101 *
102 */
103
104/**
105 * @typedef Eina_Clist
106 * This is the list head and the list entry.
107 * @since 1.1.0
108 */
109typedef struct _Eina_Clist Eina_Clist;
110
111/**
112 * @struct _Eina_Clist
113 * Compact list type
114 * @note This structure is used as both the list head and the list entry.
115 * @since 1.1.0
116 */
117struct _Eina_Clist
118{
119 Eina_Clist *next;
120 Eina_Clist *prev;
121};
122
123/**
124 * Add an element after the specified one.
125 *
126 * @param elem An element in the list
127 * @param to_add The element to add to the list
128 * @pre The list head must be initialized once before adding anything.
129 * @pre The element is not in any list.
130 *
131 * @note There's no need to initialize an element before adding it to the list.
132 * @since 1.1.0
133 */
134static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add);
135
136/**
137 * Add an element before the specified one.
138 *
139 * @param elem An element in the list
140 * @param to_add The element to add to the list
141 * @pre The list head must be initialized once before adding anything.
142 * @pre The element is not in any list.
143 *
144 * @note There's no need to initialize an element before adding it to the list.
145 * @since 1.1.0
146 */
147static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add);
148
149/**
150 * Add element at the head of the list.
151 *
152 * @param list The list
153 * @param elem An element
154 * @pre The list head must be initialized once before adding anything.
155 * @pre The element is not in any list.
156 *
157 * @note There's no need to initialize an element before adding it to the list.
158 * @since 1.1.0
159 */
160static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem);
161
162/**
163 * Add element at the tail of the list.
164 *
165 * @param list The list
166 * @param elem An element
167 * @pre The list head must be initialized once before adding anything.
168 * @pre The element is not in any list.
169 *
170 * @note There's no need to initialize an element before adding it to the list.
171 * @since 1.1.0
172 */
173static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem);
174
175/**
176 * Init an (unlinked) element.
177 *
178 * Call this function on elements that have not been added to the list
179 * if you want eina_clist_element_init() to work correctly
180 *
181 * @param elem An element
182 * @pre The element is not in any list.
183 * @post The element is marked as not being in any list
184 *
185 * @note It is not necessary to call this before adding an element to this list.
186 * @since 1.1.0
187 */
188static inline void eina_clist_element_init(Eina_Clist *elem);
189
190/**
191 * Check if an element is in a list or not.
192 *
193 * @param elem An element
194 *
195 * @pre Either eina_clist_element_init() has been called on @a elem,
196 * it has been added to a list or remove from a list.
197 * @since 1.1.0
198 */
199static inline int eina_clist_element_is_linked(Eina_Clist *elem);
200
201/**
202 * Remove an element from its list.
203 *
204 * @param elem An element
205 * @pre The element is in a list already
206 * @post The element is marked as not being in any list
207 * @since 1.1.0
208 */
209static inline void eina_clist_remove(Eina_Clist *elem);
210
211/**
212 * Get the next element.
213 *
214 * @param list The list
215 * @param elem An element
216 * @pre @a elem is in @a list
217 * @return The element after @a elem in @a list or @c NULL if @a elem is last in @a list
218 * @since 1.1.0
219 */
220static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem);
221
222/**
223 * Get the previous element.
224 *
225 * @param list The list
226 * @param elem An element
227 *
228 * @return The element before @a elem or NULL if @a elem is the first in the list
229 * @since 1.1.0
230 */
231static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem);
232
233/**
234 * Get the first element.
235 *
236 * @param list The list
237 * @returns The first element in @a list or NULL if @a list is empty
238 * @since 1.1.0
239 */
240static inline Eina_Clist *eina_clist_head(const Eina_Clist *list);
241
242/**
243 * Get the last element.
244 *
245 * @param list The list
246 * @returns The last element in @a list or NULL if @a list is empty
247 * @since 1.1.0
248 */
249static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list);
250
251/**
252 * Check if a list is empty.
253 *
254 * @param list The list
255 * @returns non-zero if @a list is empty, zero if it is not
256 * @since 1.1.0
257 */
258static inline int eina_clist_empty(const Eina_Clist *list);
259
260/**
261 * Initialize a list
262 *
263 * @param list The list
264 * @pre The list is uninitialized
265 * @post The list contains no items
266 *
267 * @note Don't call this function on a list with items
268 * @note This function must be called. Don't try do
269 * initialize the list by zero'ing out the list head.
270 * @since 1.1.0
271 */
272static inline void eina_clist_init(Eina_Clist *list);
273
274/**
275 * Count the elements of a list
276 *
277 * @param list The list
278 * @returns The number of items in the list
279 * @since 1.1.0
280 */
281static inline unsigned int eina_clist_count(const Eina_Clist *list);
282
283/**
284 * Move all elements from src to the tail of dst
285 *
286 * @param dst List to be appended to
287 * @param src List to append
288 *
289 * @post @a src is initialized but empty after this operation
290 * @since 1.1.0
291 */
292static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src);
293
294/**
295 * move all elements from src to the head of dst
296 *
297 * @param dst List to be prepended to
298 * @param src List to prepend
299 *
300 * @post @a src is initialized but empty after this operation
301 * @since 1.1.0
302 */
303static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src);
304
305/**
306 * iterate through the list
307 */
308#define EINA_CLIST_FOR_EACH(cursor,list) \
309 for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
310
311/* iterate through the list, with safety against removal */
312#define EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) \
313 for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
314 (cursor) != (list); \
315 (cursor) = (cursor2), (cursor2) = (cursor)->next)
316
317/* iterate through the list using a list entry */
318#define EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) \
319 for ((elem) = EINA_CLIST_ENTRY((list)->next, type, field); \
320 &(elem)->field != (list); \
321 (elem) = EINA_CLIST_ENTRY((elem)->field.next, type, field))
322
323/* iterate through the list using a list entry, with safety against removal */
324#define EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field) \
325 for ((cursor) = EINA_CLIST_ENTRY((list)->next, type, field), \
326 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field); \
327 &(cursor)->field != (list); \
328 (cursor) = (cursor2), \
329 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field))
330
331/* iterate through the list in reverse order */
332#define EINA_CLIST_FOR_EACH_REV(cursor,list) \
333 for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev)
334
335/* iterate through the list in reverse order, with safety against removal */
336#define EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \
337 for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \
338 (cursor) != (list); \
339 (cursor) = (cursor2), (cursor2) = (cursor)->prev)
340
341/* iterate through the list in reverse order using a list entry */
342#define EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \
343 for ((elem) = EINA_CLIST_ENTRY((list)->prev, type, field); \
344 &(elem)->field != (list); \
345 (elem) = EINA_CLIST_ENTRY((elem)->field.prev, type, field))
346
347/* iterate through the list in reverse order using a list entry, with safety against removal */
348#define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field) \
349 for ((cursor) = EINA_CLIST_ENTRY((list)->prev, type, field), \
350 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field); \
351 &(cursor)->field != (list); \
352 (cursor) = (cursor2), \
353 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field))
354
355/* macros for statically initialized lists */
356#undef EINA_CLIST_INIT
357#define EINA_CLIST_INIT(list) { &(list), &(list) }
358
359/* get pointer to object containing list element */
360#undef EINA_CLIST_ENTRY
361#define EINA_CLIST_ENTRY(elem, type, field) \
362 ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
363
364#include "eina_inline_clist.x"
365
366/**
367 * @}
368 */
369
370/**
371 * @}
372 */
373
374/**
375 * @}
376 */
377
378#endif /* __EINA_CLIST_H__ */
diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h
deleted file mode 100644
index b1108b6..0000000
--- a/libraries/eina/src/include/eina_config.h
+++ /dev/null
@@ -1,86 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_
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
31#ifdef EINA_MAGIC_DEBUG
32# undef EINA_MAGIC_DEBUG
33#endif
34#define EINA_MAGIC_DEBUG
35
36#ifdef EINA_DEFAULT_MEMPOOL
37# undef EINA_DEFAULT_MEMPOOL
38#endif
39
40
41#ifdef EINA_SAFETY_CHECKS
42# undef EINA_SAFETY_CHECKS
43#endif
44#define EINA_SAFETY_CHECKS
45
46#ifdef EINA_HAVE_INTTYPES_H
47# undef EINA_HAVE_INTTYPES_H
48#endif
49#define EINA_HAVE_INTTYPES_H
50
51#ifdef EINA_HAVE_STDINT_H
52# undef EINA_HAVE_STDINT_H
53#endif
54#define EINA_HAVE_STDINT_H
55
56#ifdef EINA_HAVE_THREADS
57# undef EINA_HAVE_THREADS
58#endif
59#define EINA_HAVE_THREADS
60
61#ifdef EINA_HAVE_DEBUG_THREADS
62# undef EINA_HAVE_DEBUG_THREADS
63#endif
64
65
66#ifdef EINA_SIZEOF_WCHAR_T
67# undef EINA_SIZEOF_WCHAR_T
68#endif
69#define EINA_SIZEOF_WCHAR_T 4
70
71#ifdef EINA_HAVE_ON_OFF_THREADS
72# undef EINA_HAVE_ON_OFF_THREADS
73#endif
74
75
76#ifdef EINA_CONFIGURE_HAVE_DIRENT_H
77# undef EINA_CONFIGURE_HAVE_DIRENT_H
78#endif
79#define EINA_HAVE_DIRENT_H
80
81#ifdef EINA_CONFIGURE_ENABLE_LOG
82# undef EINA_CONFIGURE_ENABLE_LOG
83#endif
84#define EINA_ENABLE_LOG
85
86#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in
deleted file mode 100644
index 937d208..0000000
--- a/libraries/eina/src/include/eina_config.h.in
+++ /dev/null
@@ -1,86 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_
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
31#ifdef EINA_MAGIC_DEBUG
32# undef EINA_MAGIC_DEBUG
33#endif
34@EINA_CONFIGURE_MAGIC_DEBUG@
35
36#ifdef EINA_DEFAULT_MEMPOOL
37# undef EINA_DEFAULT_MEMPOOL
38#endif
39@EINA_CONFIGURE_DEFAULT_MEMPOOL@
40
41#ifdef EINA_SAFETY_CHECKS
42# undef EINA_SAFETY_CHECKS
43#endif
44@EINA_CONFIGURE_SAFETY_CHECKS@
45
46#ifdef EINA_HAVE_INTTYPES_H
47# undef EINA_HAVE_INTTYPES_H
48#endif
49@EINA_CONFIGURE_HAVE_INTTYPES_H@
50
51#ifdef EINA_HAVE_STDINT_H
52# undef EINA_HAVE_STDINT_H
53#endif
54@EINA_CONFIGURE_HAVE_STDINT_H@
55
56#ifdef EINA_HAVE_THREADS
57# undef EINA_HAVE_THREADS
58#endif
59@EINA_CONFIGURE_HAVE_THREADS@
60
61#ifdef EINA_HAVE_DEBUG_THREADS
62# undef EINA_HAVE_DEBUG_THREADS
63#endif
64@EINA_CONFIGURE_HAVE_DEBUG_THREADS@
65
66#ifdef EINA_SIZEOF_WCHAR_T
67# undef EINA_SIZEOF_WCHAR_T
68#endif
69#define EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@
70
71#ifdef EINA_HAVE_ON_OFF_THREADS
72# undef EINA_HAVE_ON_OFF_THREADS
73#endif
74@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
75
76#ifdef EINA_CONFIGURE_HAVE_DIRENT_H
77# undef EINA_CONFIGURE_HAVE_DIRENT_H
78#endif
79@EINA_CONFIGURE_HAVE_DIRENT_H@
80
81#ifdef EINA_CONFIGURE_ENABLE_LOG
82# undef EINA_CONFIGURE_ENABLE_LOG
83#endif
84@EINA_CONFIGURE_ENABLE_LOG@
85
86#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_convert.h b/libraries/eina/src/include/eina_convert.h
deleted file mode 100644
index af839e2..0000000
--- a/libraries/eina/src/include/eina_convert.h
+++ /dev/null
@@ -1,374 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric BAIL, Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONVERT_H_
20#define EINA_CONVERT_H_
21
22#include "eina_types.h"
23#include "eina_error.h"
24
25#include "eina_fp.h"
26
27
28/**
29 * @addtogroup Eina_Convert_Group Convert
30 *
31 * These functions allow you to convert integer or real numbers to
32 * string or conversely.
33 *
34 * To use these functions, you have to call eina_init()
35 * first, and eina_shutdown() when eina is not used anymore.
36 *
37 * @section Eina_Convert_From_Integer_To_Sring Conversion from integer to string
38 *
39 * To convert an integer to a string in the decimal base,
40 * eina_convert_itoa() should be used. If the hexadecimal base is
41 * wanted, eina_convert_xtoa() should be used. They all need a bufffer
42 * sufficiently large to store all the cyphers.
43 *
44 * Here is an example of use:
45 *
46 * @code
47 * #include <stdlib.h>
48 * #include <stdio.h>
49 *
50 * #include <Eina.h>
51 *
52 * int main(void)
53 * {
54 * char tmp[128];
55 *
56 * if (!eina_init())
57 * {
58 * printf ("Error during the initialization of eina.\n");
59 * return EXIT_FAILURE;
60 * }
61 *
62 * eina_convert_itoa(45, tmp);
63 * printf("value: %s\n", tmp);
64 * eina_convert_xtoa(0xA1, tmp);
65 * printf("value: %s\n", tmp);
66 *
67 * eina_shutdown();
68 *
69 * return EXIT_SUCCESS;
70 * }
71 * @endcode
72 *
73 * Compile this code with the following command:
74 *
75 * @code
76 * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina`
77 * @endcode
78 *
79 * @note
80 * The alphabetical cyphers are in lower case.
81 *
82 * @section Eina_Convert_Double Conversion double / string
83 *
84 * To convert a double to a string, eina_convert_dtoa() should be
85 * used. Like with the integer functions, a buffer must be used. The
86 * resulting string ghas the following format (which is the result
87 * obtained with snprintf() and the @%a modifier):
88 *
89 * @code
90 * [-]0xh.hhhhhp[+-]e
91 * @endcode
92 *
93 * To convert a string to a double, eina_convert_atod() should be
94 * used. The format of the string must be as above. Then, the double
95 * has the following mantiss and exponent:
96 *
97 * @code
98 * mantiss : [-]hhhhhh
99 * exponent : 2^([+-]e - 4 * n)
100 * @endcode
101 *
102 * with n being number of cypers after the point in the string
103 * format. To obtain the double number from the mantiss and exponent,
104 * use ldexp().
105 *
106 * Here is an example of use:
107 *
108 * @code
109 * #include <stdlib.h>
110 * #include <stdio.h>
111 * #include <math.h>
112 *
113 * #include <Eina.h>
114 *
115 * int main(void)
116 * {
117 * char tmp[128];
118 * long long int m = 0;
119 * long int e = 0;
120 * double r;
121 *
122 * if (!eina_init())
123 * {
124 * printf ("Error during the initialization of eina.\n");
125 * return EXIT_FAILURE;
126 * }
127 *
128 * printf("initial value : 40.56\n");
129 * eina_convert_dtoa(40.56, tmp);
130 * printf("result dtoa : %s\n", tmp);
131
132 * eina_convert_atod(tmp, 128, &m, &e);
133 * r = ldexp((double)m, e);
134 * printf("result atod : %f\n", r);
135 *
136 * eina_shutdown();
137 *
138 * return EXIT_SUCCESS;
139 * }
140 * @endcode
141 *
142 * Compile this code with the following command:
143 *
144 * @code
145 * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina` -lm
146 * @endcode
147 */
148
149/**
150 * @addtogroup Eina_Tools_Group Tools
151 *
152 * @{
153 */
154
155/**
156 * @defgroup Eina_Convert_Group Convert
157 *
158 * @{
159 */
160
161/**
162 * @var EINA_ERROR_CONVERT_P_NOT_FOUND
163 * Error identifier corresponding to string not containing 'p'.
164 */
165
166EAPI extern Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND;
167
168/**
169 * @var EINA_ERROR_CONVERT_0X_NOT_FOUND
170 * Error identifier corresponding to string not containing '0x'.
171 */
172EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
173
174/**
175 * @var EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH
176 * Error identifier corresponding to length of the string being too small.
177 */
178EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
179
180/**
181 * @brief Convert an integer number to a string in decimal base.
182 *
183 * @param n The integer to convert.
184 * @param s The buffer to store the converted integer.
185 * @return The length of the string, including the nul terminated
186 * character.
187 *
188 * This function converts @p n to a nul terminated string. The
189 * converted string is in decimal base. As no check is done, @p s must
190 * be a buffer that is sufficiently large to store the integer.
191 *
192 * The returned value is the length of the string, including the nul
193 * terminated character.
194 */
195EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
196
197/**
198 * @brief Convert an integer number to a string in hexadecimal base.
199 *
200 * @param n The integer to convert.
201 * @param s The buffer to store the converted integer.
202 * @return The length of the string, including the nul terminated
203 * character.
204 *
205 * This function converts @p n to a nul terminated string. The
206 * converted string is in hexadecimal base and the alphabetical
207 * cyphers are in lower case. As no check is done, @p s must be a
208 * buffer that is sufficiently large to store the integer.
209 *
210 * The returned value is the length of the string, including the nul
211 * terminated character.
212 */
213EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
214
215
216/**
217 * @brief Convert a double to a string.
218 *
219 * @param d The double to convert.
220 * @param des The destination buffer to store the converted double.
221 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
222 *
223 * This function converts the double @p d to a string. The string is
224 * stored in the buffer pointed by @p des and must be sufficiently
225 * large to contain the converted double. The returned string is nul
226 * terminated and has the following format:
227 *
228 * @code
229 * [-]0xh.hhhhhp[+-]e
230 * @endcode
231 *
232 * where the h are the hexadecimal cyphers of the mantiss and e the
233 * exponent (a decimal number).
234 *
235 * The returned value is the length of the string, including the nul
236 * character.
237 */
238EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
239
240/**
241 * @brief Convert a string to a double.
242 *
243 * @param src The string to convert.
244 * @param length The length of the string.
245 * @param m The mantisse.
246 * @param e The exponent.
247 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
248 *
249 * This function converts the string @p s of length @p length that
250 * represent a double in hexadecimal base to a double. It is used to
251 * replace the use of snprintf() with the \%a modifier, which is
252 * missing on some platform (like Windows (tm) or OpenBSD).
253 *
254 * The string must have the following format:
255 *
256 * @code
257 * [-]0xh.hhhhhp[+-]e
258 * @endcode
259 *
260 * where the h are the hexadecimal cyphers of the mantiss and e the
261 * exponent (a decimal number). If n is the number of cypers after the
262 * point, the returned mantiss and exponents are:
263 *
264 * @code
265 * mantiss : [-]hhhhhh
266 * exponent : 2^([+-]e - 4 * n)
267 * @endcode
268 *
269 * The mantiss and exponent are stored in the buffers pointed
270 * respectively by @p m and @p e.
271 *
272 * If the string is invalid, the error is set to:
273 *
274 * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
275 * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
276 * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
277 * correct.
278 *
279 * In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is
280 * returned.
281 */
282EAPI Eina_Bool eina_convert_atod(const char *src,
283 int length,
284 long long *m,
285 long *e) EINA_ARG_NONNULL(1, 3, 4);
286
287
288/**
289 * @brief Convert a 32.32 fixed point number to a string.
290 *
291 * @param fp The fixed point number to convert.
292 * @param des The destination buffer to store the converted fixed point number.
293 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
294 *
295 * This function converts the 32.32 fixed point number @p fp to a
296 * string. The string is stored in the buffer pointed by @p des and
297 * must be sufficiently large to contain the converted fixed point
298 * number. The returned string is terminated and has the following
299 * format:
300 *
301 * @code
302 * [-]0xh.hhhhhp[+-]e
303 * @endcode
304 *
305 * where the h are the hexadecimal cyphers of the mantiss and e the
306 * exponent (a decimal number).
307 *
308 * The returned value is the length of the string, including the nul
309 * character.
310 *
311 * @note The code is the same than eina_convert_dtoa() except that it
312 * implements the frexp() function for fixed point numbers and does
313 * some optimisations.
314 */
315EAPI int eina_convert_fptoa(Eina_F32p32 fp,
316 char *des) EINA_ARG_NONNULL(2);
317
318/**
319 * @brief Convert a string to a 32.32 fixed point number.
320 *
321 * @param src The string to convert.
322 * @param length The length of the string.
323 * @param fp The fixed point number.
324 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
325 *
326 * This function converts the string @p src of length @p length that
327 * represent a double in hexadecimal base to a 32.32 fixed point
328 * number stored in @p fp. The function always tries to convert the
329 * string with eina_convert_atod().
330 *
331 * The string must have the following format:
332 *
333 * @code
334 * [-]0xh.hhhhhp[+-]e
335 * @endcode
336 *
337 * where the h are the hexadecimal cyphers of the mantiss and e the
338 * exponent (a decimal number). If n is the number of cypers after the
339 * point, the returned mantiss and exponents are:
340 *
341 * @code
342 * mantiss : [-]hhhhhh
343 * exponent : 2^([+-]e - 4 * n)
344 * @endcode
345 *
346 * The mantiss and exponent are stored in the buffers pointed
347 * respectively by @p m and @p e.
348 *
349 * If the string is invalid, the error is set to:
350 *
351 * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
352 * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
353 * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
354 * correct.
355 *
356 * In those cases, or if @p fp is @c NULL, #EINA_FALSE is returned,
357 * otherwise @p fp is computed and #EINA_TRUE is returned.
358 *
359 * @note The code uses eina_convert_atod() and do the correct bit
360 * shift to compute the fixed point number.
361 */
362EAPI Eina_Bool eina_convert_atofp(const char *src,
363 int length,
364 Eina_F32p32 *fp) EINA_ARG_NONNULL(1, 3);
365
366/**
367 * @}
368 */
369
370/**
371 * @}
372 */
373
374#endif /* EINA_CONVERT_H_ */
diff --git a/libraries/eina/src/include/eina_counter.h b/libraries/eina/src/include/eina_counter.h
deleted file mode 100644
index 26bee06..0000000
--- a/libraries/eina/src/include/eina_counter.h
+++ /dev/null
@@ -1,213 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_COUNTER_H_
20#define EINA_COUNTER_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Counter_Group Counter
26 *
27 * @brief These functions allow you to get the time spent in a part of a code.
28 *
29 * Before using the counter system, Eina must be initialized with
30 * eina_init() and later shut down with eina_shutdown(). The create a
31 * counter, use eina_counter_new(). To free it, use
32 * eina_counter_free().
33 *
34 * To time a part of a code, call eina_counter_start() just before it,
35 * and eina_counter_stop() just after it. Each time you start to time
36 * a code, a clock is added to a list. You can give a number of that
37 * clock with the second argument of eina_counter_stop(). To send all
38 * the registered clocks to a stream (like stdout, ofr a file), use
39 * eina_counter_dump().
40 *
41 * Here is a straightforward example:
42 *
43 * @code
44 * #include <stdlib.h>
45 * #include <stdio.h>
46 *
47 * #include <eina_counter.h>
48 *
49 * void test_malloc(void)
50 * {
51 * int i;
52 *
53 * for (i = 0; i < 100000; ++i)
54 * {
55 * void *buf;
56 *
57 * buf = malloc(100);
58 * free(buf);
59 * }
60 * }
61 *
62 * int main(void)
63 * {
64 * Eina_Counter *counter;
65 *
66 * if (!eina_init())
67 * {
68 * printf("Error during the initialization of eina\n");
69 * return EXIT_FAILURE;
70 * }
71 *
72 * counter = eina_counter_new("malloc");
73 *
74 * eina_counter_start(counter);
75 * test_malloc();
76 * eina_counter_stop(counter, 1);
77 *
78 * char* result = eina_counter_dump(counter);
79 * printf("%s", result);
80 * free(result);
81 *
82 * eina_counter_free(counter);
83 * eina_shutdown();
84 *
85 * return EXIT_SUCCESS;
86 * }
87 * @endcode
88 *
89 * Compile this code with the following commant:
90 *
91 * @verbatim
92 * gcc -Wall -o test_eina_counter test_eina.c `pkg-config --cflags --libs eina`
93 * @endverbatim
94 *
95 * The result should be something like that:
96 *
97 * @verbatim
98 * \# specimen experiment time starting time ending time
99 * 1 9794125 783816 10577941
100 * @endverbatim
101 *
102 * Note that the displayed time is in nanosecond.
103 */
104
105/**
106 * @addtogroup Eina_Tools_Group Tools
107 *
108 * @{
109 */
110
111/**
112 * @defgroup Eina_Counter_Group Counter
113 *
114 * @{
115 */
116
117/**
118 * @typedef Eina_Counter
119 * Counter type.
120 */
121typedef struct _Eina_Counter Eina_Counter;
122
123
124/**
125 * @brief Return a counter.
126 *
127 * @param name The name of the counter.
128 * @return A newly allocated counter.
129 *
130 * This function returns a new counter. It is characterized by @p
131 * name. If @p name is @c NULL, the function returns @c NULL
132 * immediately. If memory allocation fails, @c NULL is returned and the
133 * error is set to #EINA_ERROR_OUT_OF_MEMORY.
134 *
135 * Whe the new counter is not needed anymore, use eina_counter_free() to
136 * free the allocated memory.
137 */
138EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
139
140/**
141 * @brief Delete a counter.
142 *
143 * @param counter The counter to delete.
144 *
145 * This function remove the clock of @p counter from the used clocks
146 * (see eina_counter_start()) and frees the memory allocated for
147 * @p counter. If @p counter is @c NULL, the function returns
148 * immediately.
149 */
150EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
151
152/**
153 * @brief Start the time count.
154 *
155 * @param counter The counter.
156 *
157 * This function specifies that the part of the code beginning just
158 * after its call is being to be timed, using @p counter. If
159 * @p counter is @c NULL, this function returns immediately.
160 *
161 * This function adds the clock associated to @p counter in a list. If
162 * the memory needed by that clock can not be allocated, the function
163 * returns and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
164 *
165 * To stop the timing, eina_counter_stop() must be called with the
166 * same counter.
167 */
168EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
169
170/**
171 * @brief Stop the time count.
172 *
173 * @param counter The counter.
174 * @param specimen The number of the test.
175 *
176 * This function stop the timing that has been started with
177 * eina_counter_start(). @p counter must be the same than the one used
178 * with eina_counter_start(). @p specimen is the number of the
179 * test. If @p counter or its associated clock are @c NULL, or if the
180 * time can't be retrieved the function exits.
181 */
182EAPI void eina_counter_stop(Eina_Counter *counter,
183 int specimen) EINA_ARG_NONNULL(1);
184
185/**
186 * @brief Dump the result of all clocks of a counter to a stream.
187 *
188 * @return A string with a summary of the test.
189 * @param counter The counter.
190 *
191 * This function returns an malloc'd string containing the dump of
192 * all the valid clocks of @p counter.
193 * If @p counter @c NULL, the functions exits
194 * immediately. Otherwise, the output is formattted like that:
195 *
196 * @verbatim
197 * \# specimen experiment time starting time ending time
198 * 1 208 120000 120208
199 * @endverbatim
200 *
201 * The unit of time is the nanosecond.
202 */
203EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
204
205/**
206 * @}
207 */
208
209/**
210 * @}
211 */
212
213#endif /* EINA_COUNTER_H_ */
diff --git a/libraries/eina/src/include/eina_cpu.h b/libraries/eina/src/include/eina_cpu.h
deleted file mode 100644
index ac32e1d..0000000
--- a/libraries/eina/src/include/eina_cpu.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CPU_H_
20#define EINA_CPU_H_
21
22#include "eina_types.h"
23
24typedef enum _Eina_Cpu_Features
25{
26 EINA_CPU_MMX = 0x00000001,
27 EINA_CPU_SSE = 0x00000002,
28 EINA_CPU_SSE2 = 0x00000004,
29 EINA_CPU_SSE3 = 0x00000008,
30 /* TODO 3DNow! */
31 EINA_CPU_ALTIVEC = 0x00000010,
32 EINA_CPU_VIS = 0x00000020,
33 EINA_CPU_NEON = 0x00000040,
34} Eina_Cpu_Features;
35
36EAPI Eina_Cpu_Features eina_cpu_features_get(void);
37EAPI int eina_cpu_count(void);
38
39#endif /* EINA_CPU_H_ */
diff --git a/libraries/eina/src/include/eina_error.h b/libraries/eina/src/include/eina_error.h
deleted file mode 100644
index dd87edf..0000000
--- a/libraries/eina/src/include/eina_error.h
+++ /dev/null
@@ -1,198 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ERROR_H_
20#define EINA_ERROR_H_
21
22#include <stdarg.h>
23
24#include "eina_types.h"
25
26
27/**
28 * @page tutorial_error_page Error Tutorial
29 *
30 * @section tutorial_error_registering_msg Registering messages
31 *
32 * The error module can provide a system that mimics the errno system
33 * of the C standard library. It consists in 2 parts:
34 *
35 * @li a way of registering new messages with
36 * eina_error_msg_register() and eina_error_msg_get(),
37 * @li a way of setting / getting last error message with
38 * eina_error_set() / eina_error_get().
39 *
40 * So one has to fisrt register all the error messages that a program
41 * or a lib should manage. Then, when an error can occur, use
42 * eina_error_set(), and when errors are managed, use
43 * eina_error_get(). If eina_error_set() is used to set an error, do
44 * not forget to call before eina_error_set(), to remove previous set
45 * errors.
46 *
47 * Here is an example of use:
48 *
49 * @include eina_error_01.c
50 *
51 * Of course, instead of printf(), eina_log_print() can be used to
52 * have beautiful error messages.
53 */
54
55/**
56 * @addtogroup Eina_Error_Group Error
57 *
58 * @brief These functions provide error management for projects.
59 *
60 * The Eina error module provides a way to manage errors in a simple but
61 * powerful way in libraries and modules. It is also used in Eina itself.
62 * Similar to libC's @c errno and strerror() facilities, this is extensible and
63 * recommended for other libraries and applications.
64 *
65 * A simple example of how to use this can be seen @ref tutorial_error_page
66 * "here".
67 */
68
69/**
70 * @addtogroup Eina_Tools_Group Tools
71 *
72 * @{
73 */
74
75/**
76 * @defgroup Eina_Error_Group Error
77 *
78 * @{
79 */
80
81/**
82 * @typedef Eina_Error
83 * Error type.
84 */
85typedef int Eina_Error;
86
87/**
88 * @var EINA_ERROR_OUT_OF_MEMORY
89 * Error identifier corresponding to a lack of memory.
90 */
91
92EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
93
94/**
95 * @brief Register a new error type.
96 *
97 * @param msg The description of the error. It will be duplicated using
98 * eina_stringshare_add().
99 * @return The unique number identifier for this error.
100 *
101 * This function stores in a list the error message described by
102 * @p msg. The returned value is a unique identifier greater or equal
103 * than 1. The description can be retrieve later by passing to
104 * eina_error_msg_get() the returned value.
105 *
106 * @see eina_error_msg_static_register()
107 */
108EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
109
110/**
111 * @brief Register a new error type, statically allocated message.
112 *
113 * @param msg The description of the error. This string will not be
114 * duplicated and thus the given pointer should live during
115 * usage of eina_error.
116 * @return The unique number identifier for this error.
117 *
118 * This function stores in a list the error message described by
119 * @p msg. The returned value is a unique identifier greater or equal
120 * than 1. The description can be retrieve later by passing to
121 * eina_error_msg_get() the returned value.
122 *
123 * @see eina_error_msg_register()
124 */
125EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
126
127/**
128 * @brief Change the message of an already registered message
129 *
130 * @param error The Eina_Error to change the message of
131 * @param msg The description of the error. This string will be
132 * duplicated only if the error was registered with @ref eina_error_msg_register
133 * otherwise it must remain intact for the duration.
134 * @return EINA_TRUE if successful, EINA_FALSE on error
135 *
136 * This function modifies the message associated with @p error and changes
137 * it to @p msg. If the error was previously registered by @ref eina_error_msg_static_register
138 * then the string will not be duplicated, otherwise the previous message
139 * will be unrefed and @p msg copied.
140 *
141 * @see eina_error_msg_register()
142 */
143EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
144 const char *msg) EINA_ARG_NONNULL(2);
145
146/**
147 * @brief Return the last set error.
148 *
149 * @return The last error.
150 *
151 * This function returns the last error set by eina_error_set(). The
152 * description of the message is returned by eina_error_msg_get().
153 */
154EAPI Eina_Error eina_error_get(void);
155
156/**
157 * @brief Set the last error.
158 *
159 * @param err The error identifier.
160 *
161 * This function sets the last error identifier. The last error can be
162 * retrieved with eina_error_get().
163 *
164 * @note This is also used to clear previous errors, in that case @p err should
165 * be @c 0.
166 */
167EAPI void eina_error_set(Eina_Error err);
168
169/**
170 * @brief Return the description of the given an error number.
171 *
172 * @param error The error number.
173 * @return The description of the error.
174 *
175 * This function returns the description of an error that has been
176 * registered with eina_error_msg_register(). If an incorrect error is
177 * given, then @c NULL is returned.
178 */
179EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
180
181/**
182 * @brief Find the #Eina_Error corresponding to a message string
183 * @param msg The error message string to match (NOT @c NULL)
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.
186 * If no such value is found, 0 is returned.
187 */
188EAPI Eina_Error eina_error_find(const char *msg) EINA_ARG_NONNULL(1) EINA_PURE;
189
190/**
191 * @}
192 */
193
194/**
195 * @}
196 */
197
198#endif /* EINA_ERROR_H_ */
diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h
deleted file mode 100644
index 1af22af..0000000
--- a/libraries/eina/src/include/eina_file.h
+++ /dev/null
@@ -1,483 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * 2011 Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_FILE_H_
21#define EINA_FILE_H_
22
23#include <limits.h>
24#include <time.h>
25#include <sys/stat.h>
26
27#include "eina_types.h"
28#include "eina_array.h"
29#include "eina_iterator.h"
30
31
32/**
33 * @page eina_file_example_01_page
34 * @dontinclude eina_file_01.c
35 *
36 * For brevity includes, variable declarations and initialization was omitted
37 * from this page, however the full source code can be seen @ref
38 * eina_file_example_01 "here".
39 *
40 * Here we have a simple callback to print the name of a file and the path that
41 * contains it:
42 * @skip static
43 * @until }
44 *
45 * We can use this callback in the following call:
46 * @skipline eina_file_dir_list
47 *
48 * The above was a way to print the files in a directory, but it is not the only
49 * one:
50 * @until iterator_free
51 *
52 * And now two ways to get more information than just file names:
53 * @until iterator_free
54 * @until iterator_free
55 *
56 * The above ways of getting files on a list may produce the same output, but
57 * they have an important difference, eina_file_direct_ls() will @b not call
58 * stat, this means that on some systems it might not have file type
59 * information. On the other hand it might be faster than eina_file_stat_ls().
60 */
61/**
62 * @page eina_file_example_01
63 * @include eina_file_01.c
64 * @example eina_file_01.c
65 */
66/**
67 * @addtogroup Eina_Tools_Group Tools
68 *
69 * @{
70 */
71/**
72 * @addtogroup Eina_File_Group File
73 *
74 * @brief Functions to handle files and directories.
75 *
76 * This functions make it easier to do a number o file and directory operations
77 * such as getting the list of files in a directory, spliting paths and finding
78 * out file size and type.
79 *
80 * @warning All functions in this group are @b blocking which means they make
81 * take a long time to return, use them carefully.
82 *
83 * See an example @ref eina_file_example_01_page "here".
84 *
85 * @{
86 */
87
88/**
89 * @typedef Eina_File_Direct_Info
90 * A typedef to #_Eina_File_Direct_Info.
91 */
92typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
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/**
102 * @typedef Eina_File_Dir_List_Cb
103 * Type for a callback to be called when iterating over the files of a
104 * directory.
105 * @param The file name EXCLUDING the path
106 * @param path The path passed to eina_file_dir_list()
107 * @param data The data passed to eina_file_dir_list()
108 */
109typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
110
111/**
112 * @typedef Eina_File_Type
113 * file type in Eina_File_Direct_Info.
114 */
115typedef enum {
116 EINA_FILE_UNKNOWN, /**< Unknown file type. */
117 EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */
118 EINA_FILE_CHR, /**< Character device type (unused on Windows). */
119 EINA_FILE_DIR, /**< Directory type. */
120 EINA_FILE_BLK, /**< Block device type (unused on Windows). */
121 EINA_FILE_REG, /**< Regular file type. */
122 EINA_FILE_LNK, /**< Symbolic link type. */
123 EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */
124 EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */
125} Eina_File_Type;
126
127typedef struct _Eina_File Eina_File;
128
129typedef enum {
130 EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memory. */
131 EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped memory. */
132 EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */
133 EINA_FILE_POPULATE /**< Request all the mapped memory. */
134} Eina_File_Populate;
135
136/* Why do this? Well PATH_MAX may vary from when eina itself is compiled
137 * to when the app using eina is compiled. exposing the path buffer below
138 * can't safely and portably vary based on how/when you compile. it should
139 * always be the same for both eina inside AND for apps outside that use eina
140 * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (with
141 * windows i think being 260), so 8192 should cover almost all cases. there
142 * is a possibility that PATH_MAX could be more than 8192. if anyone spots
143 * a path_max that is bigger - let us know, but, for now we will assume
144 * it never happens */
145#define EINA_PATH_MAX 8192
146/**
147 * @struct _Eina_File_Direct_Info
148 * A structure to store informations of a path.
149 */
150struct _Eina_File_Direct_Info
151{
152 size_t path_length; /**< size of the whole path */
153 size_t name_length; /**< size of the filename/basename component */
154 size_t name_start; /**< where the filename/basename component starts */
155 Eina_File_Type type; /**< file type */
156 char path[EINA_PATH_MAX]; /**< the path */
157};
158
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/**
185 * @def EINA_FILE_DIR_LIST_CB
186 * @brief cast to an #Eina_File_Dir_List_Cb.
187 *
188 * @param function The function to cast.
189 *
190 * This macro casts @p function to Eina_File_Dir_List_Cb.
191 */
192#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
193
194
195/**
196 * @brief List all files on the directory calling the function for every file found.
197 *
198 * @param dir The directory name.
199 * @param recursive Iterate recursively in the directory.
200 * @param cb The callback to be called.
201 * @param data The data to pass to the callback.
202 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
203 *
204 * This function calls @p cb for each file that is in @p dir. To have @p cb
205 * called on files that are in subdirectories of @p dir @p recursive should be
206 * EINA_TRUE. In other words if @p recursive is EINA_FALSE, only direct children
207 * of @p dir will be operated on, if @p recursive is EINA_TRUE the entire tree
208 * of files that is below @p dir will be operated on.
209 *
210 * If @p cb or @p dir are @c NULL, or if @p dir is a string of size 0,
211 * or if @p dir can not be opened, this function returns #EINA_FALSE
212 * immediately. otherwise, it returns #EINA_TRUE.
213 */
214EAPI Eina_Bool eina_file_dir_list(const char *dir,
215 Eina_Bool recursive,
216 Eina_File_Dir_List_Cb cb,
217 void *data) EINA_ARG_NONNULL(1, 3);
218
219/**
220 * @brief Split a path according to the delimiter of the filesystem.
221 *
222 * @param path The path to split.
223 * @return An array of the parts of the path to split.
224 *
225 * This function splits @p path according to the delimiter of the used
226 * filesystem. If @p path is @c NULL or if the array can not be
227 * created, @c NULL is returned, otherwise, an array with each part of @p path
228 * is returned.
229 */
230EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
231
232/**
233 * @brief Get an iterator to list the content of a directory.
234 *
235 * @param dir The name of the directory to list
236 * @return Return an Eina_Iterator that will walk over the files and directories
237 * in @p dir. On failure it will return NULL.
238 *
239 * Returns an iterator for shared strings, the name of each file in @p dir will
240 * only be fetched when advancing the iterator, which means there is very little
241 * cost associated with creating the list and stopping halfway through it.
242 *
243 * @warning The iterator will hand the user a stringshared value with the full
244 * path. The user must free the string using eina_stringshare_del() on it.
245 *
246 * @note The container for the iterator is of type DIR*.
247 * @note The iterator will walk over '.' and '..' without returning them.
248 *
249 * @see eina_file_direct_ls()
250 */
251EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
252
253/**
254 * @brief Get an iterator to list the content of a directory, with direct
255 * information.
256 *
257 * @param dir The name of the directory to list
258 *
259 * @return Return an Eina_Iterator that will walk over the files and
260 * directory in the pointed directory. On failure it will
261 * return NULL.
262 *
263 * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p
264 * dir will only be fetched when advancing the iterator, which means there is
265 * cost associated with creating the list and stopping halfway through it.
266 *
267 * @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b>
268 * be modified in any way.
269 * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info
270 * returned is no longer valid.
271 *
272 * @note The container for the iterator is of type DIR*.
273 * @note The iterator will walk over '.' and '..' without returning them.
274 * @note The difference between this function ahd eina_file_direct_ls() is that
275 * it guarantees the file type information will be correct incurring a
276 * possible performance penalty.
277 *
278 * @see eina_file_direct_ls()
279 */
280EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
281
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/**
301 * @brief Get an iterator to list the content of a directory, with direct
302 * information.
303 *
304 * @param dir The name of the directory to list
305 *
306 * @return Return an Eina_Iterator that will walk over the files and
307 * directory in the pointed directory. On failure it will
308 * return NULL.
309 *
310 * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p
311 * dir will only be fetched when advancing the iterator, which means there is
312 * cost associated with creating the list and stopping halfway through it.
313 *
314 * @warning If readdir_r doesn't contain file type information file type will
315 * be DT_UNKNOW.
316 * @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b>
317 * be modified in any way.
318 * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info
319 * returned is no longer valid.
320 *
321 * @note The container for the iterator is of type DIR*.
322 * @note The iterator will walk over '.' and '..' without returning them.
323 * @note The difference between this function ahd eina_file_stat_ls() is that
324 * it may not get the file type information however it is likely to be
325 * faster.
326 *
327 * @see eina_file_ls()
328 */
329EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
330
331/**
332 * @brief Sanitize file path.
333 *
334 * @param path The path to sanitize
335 *
336 * @return an allocated string with the sanitized path.
337 *
338 * This function take care of adding the current working directory if it's a
339 * relative path and also remove all '..' and '//' reference in the original
340 * path.
341 *
342 * @since 1.1
343 */
344EAPI char *eina_file_path_sanitize(const char *path);
345
346/**
347 * @brief Get a read-only handler to a file.
348 *
349 * @param name Filename to open
350 * @param shared Requested a shm
351 *
352 * Opens a file in read-only mode. @p name should be an absolute path. An
353 * Eina_File handle can be shared among multiple instances if @p shared is
354 * EINA_TRUE.
355 *
356 * @since 1.1
357 */
358EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
359
360/**
361 * @brief Unref file handler.
362 *
363 * @param file File handler to unref.
364 *
365 * Decremente file's refcount and if it reaches zero close it.
366 *
367 * @since 1.1
368 */
369EAPI void eina_file_close(Eina_File *file);
370
371/**
372 * @brief Get file size at open time.
373 *
374 * @param file The file handler to request the size from.
375 * @return The length of the file.
376 *
377 * @since 1.1
378 */
379EAPI size_t eina_file_size_get(Eina_File *file);
380
381/**
382 * @brief Get the last modification time of an open file.
383 *
384 * @param file The file handler to request the modification time from.
385 * @return The last modification time.
386 *
387 * @since 1.1
388 */
389EAPI time_t eina_file_mtime_get(Eina_File *file);
390
391/**
392 * @brief Get the filename of an open file.
393 *
394 * @param file The file handler to request the name from.
395 * @return Stringshared filename of the file.
396 *
397 * @since 1.1
398 */
399EAPI const char *eina_file_filename_get(Eina_File *file);
400
401/**
402 * @brief Get the eXtended attribute of an open file.
403 *
404 * @param file The file handler to request the eXtended attribute from.
405 * @return an iterator.
406 *
407 * The iterator will list all eXtended attribute name without allocating
408 * them, so you need to copy them yourself if needed.
409 *
410 * @since 1.2
411 */
412EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file);
413
414/**
415 * @brief Get the eXtended attribute of an open file.
416 *
417 * @param file The file handler to request the eXtended attribute from.
418 * @return an iterator.
419 *
420 * The iterator will list all eXtended attribute without allocating
421 * them, so you need to copy them yourself if needed. It is returning
422 * Eina_Xattr structure.
423 *
424 * @since 1.2
425 */
426EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file);
427
428/**
429 * @brief Map all the file to a buffer.
430 *
431 * @param file The file handler to map in memory
432 * @param rule The rule to apply to the mapped memory
433 * @return A pointer to a buffer that map all the file content. @c NULL if it fail.
434 *
435 * @since 1.1
436 */
437EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule);
438
439/**
440 * @brief Map a part of the file.
441 *
442 * @param file The file handler to map in memory
443 * @param rule The rule to apply to the mapped memory
444 * @param offset The offset inside the file
445 * @param length The length of the memory to map
446 * @return A valid pointer to the system memory with @p length valid byte in it. And @c NULL if not inside the file or anything else goes wrong.
447 *
448 * This does handle refcounting so it will share map that target the same memory area.
449 *
450 * @since 1.1
451 */
452EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
453 unsigned long int offset, unsigned long int length);
454
455/**
456 * @brief Unref and unmap memory if possible.
457 *
458 * @param file The file handler to unmap memory from.
459 * @param map Memory map to unref and unmap.
460 *
461 * @since 1.1
462 */
463EAPI void eina_file_map_free(Eina_File *file, void *map);
464
465/**
466 * @brief Tell if their was an IO error during the life of a mmaped file
467 *
468 * @param file The file handler to the mmaped file.
469 * @param map Memory map to check if an error occured on it.
470 *
471 * @since 1.2
472 */
473EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map);
474
475/**
476 * @}
477 */
478
479/**
480 * @}
481 */
482
483#endif /* EINA_FILE_H_ */
diff --git a/libraries/eina/src/include/eina_fp.h b/libraries/eina/src/include/eina_fp.h
deleted file mode 100644
index c73dc16..0000000
--- a/libraries/eina/src/include/eina_fp.h
+++ /dev/null
@@ -1,111 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_FP_H_
21# define EINA_FP_H_
22
23#include "eina_types.h"
24
25#ifdef _MSC_VER
26typedef unsigned __int64 uint64_t;
27typedef signed __int64 int64_t;
28typedef signed int int32_t;
29#else
30# include <stdint.h>
31#endif
32
33#define EINA_F32P32_PI 0x00000003243f6a89
34
35typedef int64_t Eina_F32p32;
36typedef int32_t Eina_F16p16;
37typedef int32_t Eina_F8p24;
38
39static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
40static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
41static inline Eina_F32p32 eina_f32p32_double_from(double v);
42static inline double eina_f32p32_double_to(Eina_F32p32 v);
43
44static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a,
45 Eina_F32p32 b);
46static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a,
47 Eina_F32p32 b);
48static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a,
49 Eina_F32p32 b);
50static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a,
51 int b);
52static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a,
53 Eina_F32p32 b);
54static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
55static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
56
57// dont use llabs - issues if not on 64bit
58#define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a))
59
60EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
61EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
62
63static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
64static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
65static inline Eina_F16p16 eina_f16p16_float_from(float v);
66static inline float eina_f16p16_float_to(Eina_F16p16 v);
67
68static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a,
69 Eina_F16p16 b);
70static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a,
71 Eina_F16p16 b);
72static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a,
73 Eina_F16p16 b);
74static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a,
75 int b);
76static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a,
77 Eina_F16p16 b);
78static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
79static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v);
80
81static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
82static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
83static inline Eina_F8p24 eina_f8p24_float_from(float v);
84static inline float eina_f8p24_float_to(Eina_F8p24 v);
85
86static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a,
87 Eina_F8p24 b);
88static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a,
89 Eina_F8p24 b);
90static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a,
91 Eina_F8p24 b);
92static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a,
93 int b);
94static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a,
95 Eina_F8p24 b);
96static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
97static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v);
98
99static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
100static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
101static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
102static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
103static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
104static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
105
106#include "eina_inline_f32p32.x"
107#include "eina_inline_f16p16.x"
108#include "eina_inline_f8p24.x"
109#include "eina_inline_fp.x"
110
111#endif
diff --git a/libraries/eina/src/include/eina_hamster.h b/libraries/eina/src/include/eina_hamster.h
deleted file mode 100644
index bea759d..0000000
--- a/libraries/eina/src/include/eina_hamster.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_HAMSTER_H_
20#define EINA_HAMSTER_H_
21
22/**
23 * @addtogroup Eina_Hamster_Group Hamster
24 *
25 * @brief These functions provide hamster calls.
26 *
27 * @{
28 */
29
30/**
31 * @addtogroup Eina_Core_Group Core
32 *
33 * @{
34 */
35
36/**
37 * @defgroup Eina_Hamster_Group Hamster
38 */
39
40
41/**
42 * @brief Get the hamster count.
43 *
44 * @return The number of available hamsters.
45 *
46 * This function returns how many hamsters you have.
47 */
48EAPI int eina_hamster_count(void);
49
50/**
51 * @}
52 */
53
54/**
55 * @}
56 */
57
58#endif /* EINA_HAMSTER_H_ */
diff --git a/libraries/eina/src/include/eina_hash.h b/libraries/eina/src/include/eina_hash.h
deleted file mode 100644
index 57316b2..0000000
--- a/libraries/eina/src/include/eina_hash.h
+++ /dev/null
@@ -1,1040 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Gustavo Sverzut Barbieri,
3 * Vincent Torri, Jorge Luis Zapata Muga, Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_HASH_H_
21#define EINA_HASH_H_
22
23#include "eina_types.h"
24#include "eina_iterator.h"
25
26/**
27 * @page hash_01_example_page Eina_Hash in action
28 * @dontinclude eina_hash_01.c
29 *
30 * We are going to store some tuples into our table, that will map each @a name
31 * to a @a number. The cost to access a given number from the name should be
32 * very small, even with many entries in our table. This is the initial data:
33 * @skip _Phone_Entry
34 * @until // _start_entries
35 *
36 * Before starting to play with the hash, let's write a callback that will be
37 * used to free the elements from it. Since we are just storing strduped
38 * strings, we just need to free them:
39 *
40 * @skip static
41 * @until }
42 *
43 * We also need a callback to iterate over the elements of the list later, so
44 * we are defining it now:
45 *
46 * @skip Eina_Bool
47 * @until }
48 *
49 * Now let's create our @ref Eina_Hash using @ref
50 * eina_hash_string_superfast_new :
51 *
52 * @skip eina_init
53 * @until phone_book
54 *
55 * Now we add the keys and data to the hash using @ref eina_hash_add . This
56 * means that the key is copied inside the table, together with the pointer to
57 * the data (phone numbers).
58 *
59 * @skip for
60 * @until }
61 *
62 * Some basic manipulations with the hash, like finding a value given a key,
63 * deleting an entry, modifying an entry are exemplified in the following lines.
64 * Notice that the @ref eina_hash_modify function returns the old value stored
65 * in that entry, and it needs to be freed, while the @ref eina_hash_del
66 * function already calls our free callback:
67 *
68 * @skip Look for
69 * @until free(
70 *
71 * The @ref eina_hash_set function can be used to set a key-value entry to the
72 * table if it doesn't exist, or to modify an existent entry. It returns the old
73 * entry if it was already set, and NULL otherwise. But since it will
74 * return NULL on error too, we need to check if an error has occurred:
75 *
76 * @skip Modify
77 * @until printf("\n");
78 *
79 * There are different ways of iterate over the entries of a hash. Here we show
80 * two of them: using @ref eina_hash_foreach and @ref Eina_Iterator .
81 *
82 * @skip List of phones
83 * @until eina_iterator_free(it);
84 *
85 * It's also possible to change the key for a specific entry, without having to
86 * remove the entry from the table and adding it again:
87 *
88 * @skipline eina_hash_move
89 *
90 * We can remove all the elements from the table without free the table itself:
91 *
92 * @skip Empty the phone book
93 * @until eina_hash_population
94 *
95 * Or free the the entire table with its content:
96 *
97 * @skipline eina_hash_free
98 *
99 *
100 * The full code for this example can be seen here: @ref eina_hash_01_c
101 */
102
103/**
104 * @page eina_hash_01_c Hash table in action
105 *
106 * @include eina_hash_01.c
107 * @example eina_hash_01.c
108 */
109
110/**
111 * @page hash_02_example_page Different types of tables
112 *
113 * This example shows two more types of hash tables that can be created using
114 * @ref Eina_Hash . For more types, consult the reference documentation of @ref
115 * eina_hash_new.
116 * @include eina_hash_02.c
117 * @example eina_hash_02.c
118 */
119
120/**
121 * @example eina_hash_03.c
122 * Same example as @ref hash_01_example_page but using a "string small" hash
123 * table instead of "string superfast".
124 */
125
126/**
127 * @example eina_hash_04.c
128 * Same example as @ref hash_01_example_page but using a "string djb2" hash
129 * table instead of "string superfast".
130 */
131
132/**
133 * @example eina_hash_05.c
134 * Same example as @ref hash_01_example_page but using a "int32" hash
135 * table instead of "string superfast".
136 */
137
138/**
139 * @example eina_hash_06.c
140 * Same example as @ref hash_01_example_page but using a "int64" hash
141 * table instead of "string superfast".
142 */
143
144/**
145 * @example eina_hash_07.c
146 * Same example as @ref hash_01_example_page but using a "pointer" hash
147 * table instead of "string superfast".
148 */
149
150/**
151 * @example eina_hash_08.c
152 * This example shows the the usage of eina_hash_add(), eina_hash_add_by_hash(),
153 * eina_hash_direct_add_by_hash(), eina_hash_del(), eina_hash_del_by_key_hash(),
154 * eina_hash_del_by_key(), eina_hash_del_by_data(), eina_hash_find_by_hash() and
155 * eina_hash_modify_by_hash().
156 */
157
158/**
159 * @addtogroup Eina_Hash_Group Hash Table
160 *
161 * @brief Hash table management. Useful for mapping keys to values.
162 *
163 * The hash table is useful for when one wants to implement a table that maps
164 * keys (usually strings) to data, and have relatively fast access time. The
165 * performance is proportional to the load factor of the table (number of
166 * elements / number of buckets). See @ref hashtable_algo for implementation
167 * details.
168 *
169 * Different implementations exists depending on what kind of key will be used
170 * to access the data: strings, integers, pointers, stringshared or your own.
171 *
172 * Eina hash tables can copy the keys when using eina_hash_add() or not when
173 * using eina_hash_direct_add().
174 *
175 * @section hashtable_algo Algorithm
176 *
177 * The Eina_Hash is implemented using an array of N "buckets", where each
178 * bucket is a pointer to a structure that is the head of a <a
179 * href="http://en.wikipedia.org/wiki/Red-black_tree">red-black tree</a>. The
180 * array can then be indexed by the [hash_of_element mod N]. The
181 * hash_of_element is calculated using the hashing function, passed as
182 * parameter to the @ref eina_hash_new function. N is the number of buckets
183 * (array positions), and is calculated based on the buckets_power_size
184 * (argument of @ref eina_hash_new too). The following picture ilustrates the
185 * basic idea:
186 *
187 * @htmlonly
188 * <img src="01_hash-table.png" width="500" />
189 * @endhtmlonly
190 * @image latex 01_hash-table.eps
191 *
192 * Adding an element to the hash table is made of:
193 * @li calculating the hash for that key (using the specified hash function);
194 * @li calculate the array position [hash mod N];
195 * @li add the element to the rbtree on that position.
196 *
197 * The two first steps have constant time, proportional to the hash function
198 * being used. Adding the key to the rbtree will be proportional on the number
199 * of keys on that bucket.
200 *
201 * The average cost of lookup depends on the number of keys per
202 * bucket (load factor) of the table, if the distribution of keys is
203 * sufficiently uniform.
204 *
205 * @section hashtable_perf Performance
206 *
207 * As said before, the performance depends on the load factor. So trying to keep
208 * the load factor as small as possible will improve the hash table performance. But
209 * increasing the buckets_power_size will also increase the memory consumption.
210 * The default hash table creation functions already have a good number of
211 * buckets, enough for most cases. Particularly for strings, if just a few keys
212 * (less than 30) will be added to the hash table, @ref
213 * eina_hash_string_small_new should be used, since it will reduce the memory
214 * consumption for the buckets, and you still won't have many collisions.
215 * However, @ref eina_hash_string_small_new still uses the same hash calculation
216 * function that @ref eina_hash_string_superfast_new, which is more complex than
217 * @ref eina_hash_string_djb2_new. The latter has a faster hash computation
218 * function, but that will imply on a not so good distribution. But if just a
219 * few keys are being added, this is not a problem, it will still have not many
220 * collisions and be faster to calculate the hash than in a hash created with
221 * @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new.
222 *
223 * A simple comparison between them would be:
224 *
225 * @li @c djb2 - faster hash function - 256 buckets (higher memory consumption)
226 * @li @c string_small - slower hash function but less collisions - 32 buckets
227 * (lower memory consumption)
228 * @li @c string_superfast - slower hash function but less collisions - 256 buckets
229 * (higher memory consumption)
230 *
231 * Basically for a very small number of keys (10 or less), @c djb2 should be
232 * used, or @c string_small if you have a restriction on memory usage. And for a
233 * higher number of keys, @c string_superfast should be always preferred.
234 *
235 * If just stringshared keys are being added, use @ref
236 * eina_hash_stringshared_new. If a lot of keys will be added to the hash table
237 * (e.g. more than 1000), then it's better to increase the buckets_power_size.
238 * See @ref eina_hash_new for more details.
239 *
240 * When adding a new key to a hash table, use @ref eina_hash_add or @ref
241 * eina_hash_direct_add (the latter if this key is already stored elsewhere). If
242 * the key may be already inside the hash table, instead of checking with
243 * @ref eina_hash_find and then doing @ref eina_hash_add, one can use just @ref
244 * eina_hash_set (this will change the data pointed by this key if it was
245 * already present in the table).
246 *
247 * @section hashtable_tutorial Tutorial
248 *
249 * These examples show many Eina_Hash functions in action:
250 * <ul>
251 * <li> @ref hash_01_example_page
252 * <li> @ref hash_02_example_page
253 * <li> Different types of hash in use:
254 * <ul>
255 * <li> @ref eina_hash_03.c "string small"
256 * <li> @ref eina_hash_04.c "string djb2"
257 * <li> @ref eina_hash_05.c "int32"
258 * <li> @ref eina_hash_06.c "int64"
259 * <li> @ref eina_hash_07.c "pointer"
260 * </ul>
261 * <li> @ref eina_hash_08.c "Different add and delete functions"
262 * </ul>
263 */
264
265/**
266 * @addtogroup Eina_Data_Types_Group Data Types
267 *
268 * @{
269 */
270
271/**
272 * @addtogroup Eina_Containers_Group Containers
273 *
274 * @{
275 */
276
277/**
278 * @defgroup Eina_Hash_Group Hash Table
279 *
280 * @{
281 */
282
283/**
284 * @typedef Eina_Hash
285 * Type for a generic hash table.
286 */
287typedef struct _Eina_Hash Eina_Hash;
288
289typedef struct _Eina_Hash_Tuple Eina_Hash_Tuple;
290
291struct _Eina_Hash_Tuple
292{
293 const void *key; /**< The key */
294 void *data; /**< The data associated to the key */
295 unsigned int key_length; /**< The length of the key */
296};
297
298typedef unsigned int (*Eina_Key_Length)(const void *key);
299#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
300typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, const void *key2, int key2_length);
301#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
302typedef int (*Eina_Key_Hash)(const void *key, int key_length);
303#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
304typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
305
306
307/**
308 * @brief Create a new hash table.
309 *
310 * @param key_length_cb The function called when getting the size of the key.
311 * @param key_cmp_cb The function called when comparing the keys.
312 * @param key_hash_cb The function called when getting the values.
313 * @param data_free_cb The function called on each value when the hash table is
314 * freed, or when an item is deleted from it. @c NULL can be passed as
315 * callback.
316 * @param buckets_power_size The size of the buckets.
317 * @return The new hash table.
318 *
319 * This function creates a new hash table using user-defined callbacks
320 * to manage the hash table. On failure, @c NULL is returned and
321 * #EINA_ERROR_OUT_OF_MEMORY is set. If @p key_cmp_cb or @p key_hash_cb
322 * are @c NULL, @c NULL is returned. If @p buckets_power_size is
323 * smaller or equal than 2, or if it is greater or equal than 17,
324 * @c NULL is returned.
325 *
326 * The number of buckets created will be 2 ^ @p buckets_power_size. This means
327 * that if @p buckets_power_size is 5, there will be created 32 buckets. for a
328 * @p buckets_power_size of 8, there will be 256 buckets.
329 *
330 * Pre-defined functions are available to create a hash table. See
331 * eina_hash_string_djb2_new(), eina_hash_string_superfast_new(),
332 * eina_hash_string_small_new(), eina_hash_int32_new(),
333 * eina_hash_int64_new(), eina_hash_pointer_new() and
334 * eina_hash_stringshared_new().
335 */
336EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb,
337 Eina_Key_Cmp key_cmp_cb,
338 Eina_Key_Hash key_hash_cb,
339 Eina_Free_Cb data_free_cb,
340 int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
341
342/**
343 * @brief Redefine the callback that clean the data of a hash
344 *
345 * @param hash The given hash table
346 * @param data_free_cb The function called on each value when the hash
347 * table is freed, or when an item is deleted from it. @c NULL can be passed as
348 * callback.
349 * @since 1.1
350 * See @ref eina_hash_new.
351 */
352EAPI void eina_hash_free_cb_set(Eina_Hash *hash, Eina_Free_Cb data_free_cb) EINA_ARG_NONNULL(1);
353
354/**
355 * @brief Create a new hash table using the djb2 algorithm.
356 *
357 * @param data_free_cb The function called on each value when the hash table
358 * is freed, or when an item is deleted from it. @c NULL can be passed as
359 * callback.
360 * @return The new hash table.
361 *
362 * This function creates a new hash table using the djb2 algorithm for
363 * table management and strcmp() to compare the keys. Values can then
364 * be looked up with pointers other than the original key pointer that
365 * was used to add values. On failure, this function returns @c NULL.
366 */
367EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
368
369/**
370 * @brief Create a new hash table for use with strings.
371 *
372 * @param data_free_cb The function called on each value when the hash table
373 * is freed, or when an item is deleted from it. @c NULL can be passed as
374 * callback.
375 * @return The new hash table.
376 *
377 * This function creates a new hash table using the superfast algorithm
378 * for table management and strcmp() to compare the keys. Values can
379 * then be looked up with pointers other than the original key pointer
380 * that was used to add values. On failure, this function returns
381 * @c NULL.
382 */
383EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
384
385/**
386 * @brief Create a new hash table for use with strings with small bucket size.
387 *
388 * @param data_free_cb The function called on each value when the hash table
389 * is freed, or when an item is deleted from it. @c NULL can be passed as
390 * callback.
391 * @return The new hash table.
392 *
393 * This function creates a new hash table using the superfast algorithm
394 * for table management and strcmp() to compare the keys, but with a
395 * smaller bucket size (compared to eina_hash_string_superfast_new())
396 * which will minimize the memory used by the returned hash
397 * table. Values can then be looked up with pointers other than the
398 * original key pointer that was used to add values. On failure, this
399 * function returns @c NULL.
400 */
401EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
402
403/**
404 * @brief Create a new hash table for use with 32bit integers.
405 *
406 * @param data_free_cb The function called on each value when the hash table
407 * is freed, or when an item is deleted from it. @c NULL can be passed as
408 * callback.
409 * @return The new hash table.
410 *
411 * This function creates a new hash table where keys are 32bit integers.
412 * When adding or looking up in the hash table, pointers to 32bit integers
413 * must be passed. They can be addresses on the stack if you let the
414 * eina_hash copy the key. Values can then
415 * be looked up with pointers other than the original key pointer that was
416 * used to add values. This method is not suitable to match string keys as
417 * it would only match the first character.
418 * On failure, this function returns @c NULL.
419 */
420EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb);
421
422/**
423 * @brief Create a new hash table for use with 64bit integers.
424 *
425 * @param data_free_cb The function called on each value when the hash table
426 * is freed, or when an item is deleted from it. @c NULL can be passed as
427 * callback.
428 * @return The new hash table.
429 *
430 * This function creates a new hash table where keys are 64bit integers.
431 * When adding or looking up in the hash table, pointers to 64bit integers
432 * must be passed. They can be addresses on the stack. Values can then
433 * be looked up with pointers other than the original key pointer that was
434 * used to add values. This method is not suitable to match string keys as
435 * it would only match the first character.
436 * On failure, this function returns @c NULL.
437 */
438EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb);
439
440/**
441 * @brief Create a new hash table for use with pointers.
442 *
443 * @param data_free_cb The function called on each value when the hash table
444 * is freed, or when an item is deleted from it. @c NULL can be passed as
445 * callback.
446 * @return The new hash table.
447 *
448 * This function creates a new hash table using the int64/int32 algorithm for
449 * table management and dereferenced pointers to compare the
450 * keys. Values can then be looked up with pointers other than the
451 * original key pointer that was used to add values. This method may
452 * appear to be able to match string keys, actually it only matches
453 * the first character. On failure, this function returns @c NULL.
454 */
455EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
456
457/**
458 * @brief Create a new hash table optimized for stringshared values.
459 *
460 * @param data_free_cb The function called on each value when the hash table
461 * is freed, or when an item is deleted from it. @c NULL can be passed as
462 * callback.
463 * @return The new hash table.
464 *
465 * This function creates a new hash table optimized for stringshared
466 * values. Values CAN NOT be looked up with pointers not
467 * equal to the original key pointer that was used to add a value. On failure,
468 * this function returns @c NULL.
469 *
470 * Excerpt of code that will NOT work with this type of hash:
471 *
472 * @code
473 * extern Eina_Hash *hash;
474 * extern const char *value;
475 * const char *a = eina_stringshare_add("key");
476 *
477 * eina_hash_add(hash, a, value);
478 * eina_hash_find(hash, "key")
479 * @endcode
480 */
481EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
482
483/**
484 * @brief Add an entry to the given hash table.
485 *
486 * @param hash The given hash table. Cannot be @c NULL.
487 * @param key A unique key. Cannot be @c NULL.
488 * @param data Data to associate with the string given by @p key. Cannot be @c
489 * NULL.
490 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
491 *
492 * This function adds @p key to @p hash. @p key is
493 * expected to be unique within the hash table. Key uniqueness varies
494 * depending on the type of @p hash: a stringshared @ref Eina_Hash
495 * need to have unique pointers (which implies unique strings).
496 * All other string hash types require the strings
497 * themselves to be unique. Pointer, int32 and int64 hashes need to have these
498 * values as unique. Failure to use sufficient uniqueness will
499 * result in unexpected results when inserting data pointers accessed
500 * with eina_hash_find(), and removed with eina_hash_del(). Key
501 * strings are case sensitive. If an error occurs, eina_error_get()
502 * should be used to determine if an allocation error occurred during
503 * this function. This function returns #EINA_FALSE if an error
504 * occurred, #EINA_TRUE otherwise.
505 */
506EAPI Eina_Bool eina_hash_add(Eina_Hash *hash,
507 const void *key,
508 const void *data) EINA_ARG_NONNULL(1, 2, 3);
509
510/**
511 * @brief Add an entry to the given hash table without duplicating the string
512 * key.
513 *
514 * @param hash The given hash table. Cannot be @c NULL.
515 * @param key A unique key. Cannot be @c NULL.
516 * @param data Data to associate with the string given by @p key. Cannot be @c
517 * NULL
518 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
519 *
520 * This function adds @p key to @p hash. @p key is
521 * expected to be unique within the hash table. Key uniqueness varies
522 * depending on the type of @p hash: a stringshared @ref Eina_Hash
523 * need have unique pointers (which implies unique strings).
524 * All other string hash types require the strings
525 * themselves to be unique. Pointer, int32 and int64 hashes need to have these
526 * values as unique. Failure to use sufficient uniqueness will
527 * result in unexpected results when inserting data pointers accessed
528 * with eina_hash_find(), and removed with eina_hash_del(). This
529 * function does not make a copy of @p key, so it must be a string
530 * constant or stored elsewhere ( in the object being added). Key
531 * strings are case sensitive. If an error occurs, eina_error_get()
532 * should be used to determine if an allocation error occurred during
533 * this function. This function returns #EINA_FALSE if an error
534 * occurred, #EINA_TRUE otherwise.
535 */
536EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash,
537 const void *key,
538 const void *data) EINA_ARG_NONNULL(1, 2, 3);
539
540/**
541 * @brief Remove the entry identified by a key or a data from the given
542 * hash table.
543 *
544 * @param hash The given hash table.
545 * @param key The key.
546 * @param data The data pointer to remove if the key is @c NULL.
547 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
548 *
549 * This function removes the entry identified by @p key or @p data
550 * from @p hash. If a free function was given to the
551 * callback on creation, it will be called for the data being
552 * deleted. If @p hash is @c NULL, the functions returns immediately
553 * #EINA_FALSE. If @p key is @c NULL, then @p data is used to find the a
554 * match to remove, otherwise @p key is used and @p data is not
555 * required and can be @c NULL. This function returns #EINA_FALSE if
556 * an error occurred, #EINA_TRUE otherwise.
557 *
558 * @note if you know you already have the key, use
559 * eina_hash_del_by_key() or eina_hash_del_by_key_hash(). If you
560 * know you don't have the key, use eina_hash_del_by_data()
561 * directly.
562 */
563EAPI Eina_Bool eina_hash_del(Eina_Hash *hash,
564 const void *key,
565 const void *data) EINA_ARG_NONNULL(1);
566
567/**
568 * @brief Retrieve a specific entry in the given hash table.
569 *
570 * @param hash The given hash table.
571 * @param key The key of the entry to find.
572 * @return The data pointer for the stored entry on success, @c NULL
573 * otherwise.
574 *
575 * This function retrieves the entry associated to @p key in
576 * @p hash. If @p hash is @c NULL, this function returns immediately
577 * @c NULL. This function returns the data pointer on success, @c NULL
578 * otherwise.
579 */
580EAPI void *eina_hash_find(const Eina_Hash *hash,
581 const void *key) EINA_ARG_NONNULL(2);
582
583/**
584 * @brief Modify the entry pointer at the specified key and return the old
585 * entry.
586 * @param hash The given hash table.
587 * @param key The key of the entry to modify.
588 * @param data The data to replace the old entry.
589 * @return The data pointer for the old stored entry on success, or
590 * @c NULL otherwise.
591 *
592 * This function modifies the data of @p key with @p data in @p
593 * hash. If no entry is found, nothing is added to @p hash. On success
594 * this function returns the old entry, otherwise it returns @c NULL.
595 */
596EAPI void *eina_hash_modify(Eina_Hash *hash,
597 const void *key,
598 const void *data) EINA_ARG_NONNULL(1, 2, 3);
599
600/**
601 * @brief Modify the entry pointer at the specified key and return the
602 * old entry or add the entry if not found.
603 *
604 * @param hash The given hash table.
605 * @param key The key of the entry to modify.
606 * @param data The data to replace the old entry
607 * @return The data pointer for the old stored entry, or @c NULL
608 * otherwise.
609 *
610 * This function modifies the data of @p key with @p data in @p
611 * hash. If no entry is found, @p data is added to @p hash with the
612 * key @p key. On success this function returns the old entry,
613 * otherwise it returns @c NULL. To check for errors, use
614 * eina_error_get().
615 */
616EAPI void *eina_hash_set(Eina_Hash *hash,
617 const void *key,
618 const void *data) EINA_ARG_NONNULL(1, 2);
619
620/**
621 * @brief Change the key associated with a data without triggering the
622 * free callback.
623 *
624 * @param hash The given hash table.
625 * @param old_key The current key associated with the data
626 * @param new_key The new key to associate data with
627 * @return EINA_FALSE in any case but success, EINA_TRUE on success.
628 *
629 * This function allows for the move of data from one key to another,
630 * but does not call the Eina_Free_Cb associated with the hash table
631 * when destroying the old key.
632 */
633EAPI Eina_Bool eina_hash_move(Eina_Hash *hash,
634 const void *old_key,
635 const void *new_key) EINA_ARG_NONNULL(1, 2, 3);
636
637/**
638 * Free the given hash table resources.
639 *
640 * @param hash The hash table to be freed.
641 *
642 * This function frees up all the memory allocated to storing @p hash,
643 * and call the free callback if it has been passed to the hash table
644 * at creation time. If no free callback has been passed, any entries
645 * in the table that the program has no more pointers for elsewhere
646 * may now be lost, so this should only be called if the program has
647 * already freed any allocated data in the hash table or has the
648 * pointers for data in the table stored elsewhere as well. If @p hash
649 * is @c NULL, the function returns immediately.
650 *
651 * Example:
652 * @code
653 * extern Eina_Hash *hash;
654 *
655 * eina_hash_free(hash);
656 * hash = NULL;
657 * @endcode
658 */
659EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
660
661/**
662 * Free the given hash table buckets resources.
663 *
664 * @param hash The hash table whose buckets have to be freed.
665 *
666 * This function frees up all the memory allocated to storing the
667 * buckets of @p hash, and calls the free callback on all hash table
668 * buckets if it has been passed to the hash table at creation time,
669 * then frees the buckets. If no free callback has been passed, no
670 * buckets value will be freed. If @p hash is @c NULL, the function
671 * returns immediately.
672 */
673EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
674
675/**
676 * @brief Returns the number of entries in the given hash table.
677 *
678 * @param hash The given hash table.
679 * @return The number of entries in the hash table.
680 *
681 * This function returns the number of entries in @p hash, or 0 on
682 * error. If @p hash is @c NULL, 0 is returned.
683 */
684EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
685
686/**
687 * @brief Add an entry to the given hash table.
688 *
689 * @param hash The given hash table. Cannot be @c NULL.
690 * @param key A unique key. Cannot be @c NULL.
691 * @param key_length The length of the key.
692 * @param key_hash The hash that will always match key.
693 * @param data The data to associate with the string given by the key. Cannot be
694 * @c NULL.
695 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
696 *
697 * This function adds @p key to @p hash. @p hash, @p key and @p data
698 * cannot be @c NULL, in that case #EINA_FALSE is returned. @p key is
699 * expected to be a unique within the hash table. Otherwise,
700 * one cannot be sure which inserted data pointer will be accessed
701 * with @ref eina_hash_find, and removed with @ref eina_hash_del. Do
702 * not forget to count '\\0' for string when setting the value of
703 * @p key_length. @p key_hash is expected to always match
704 * @p key. Otherwise, one cannot be sure to find it again with @ref
705 * eina_hash_find_by_hash. Key strings are case sensitive. If an error
706 * occurs, eina_error_get() should be used to determine if an
707 * allocation error occurred during this function. This function
708 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
709 *
710 * @see eina_hash_add()
711 */
712EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
713 const void *key,
714 int key_length,
715 int key_hash,
716 const void *data) EINA_ARG_NONNULL(1, 2, 5);
717
718/**
719 * @brief Add an entry to the given hash table and do not duplicate the string
720 * key.
721 *
722 * @param hash The given hash table. Cannot be @c NULL.
723 * @param key A unique key. Cannot be @c NULL.
724 * @param key_length Should be the length of @p key (don't forget to count
725 * '\\0' for string).
726 * @param key_hash The hash that will always match key.
727 * @param data Data to associate with the string given by @p key. Cannot be @c
728 * NULL.
729 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
730 *
731 * This function adds @p key to @p hash. @p hash, @p key and @p data
732 * can be @c NULL, in that case #EINA_FALSE is returned. @p key is
733 * expected to be unique within the hash table. Otherwise,
734 * one cannot be sure which inserted data pointer will be accessed
735 * with @ref eina_hash_find, and removed with @ref eina_hash_del. This
736 * function does not make a copy of @p key so it must be a string
737 * constant or stored elsewhere (in the object being added). Do
738 * not forget to count '\\0' for string when setting the value of
739 * @p key_length. @p key_hash is expected to always match
740 * @p key. Otherwise, one cannot be sure to find it again with @ref
741 * eina_hash_find_by_hash. Key strings are case sensitive. If an error
742 * occurs, eina_error_get() should be used to determine if an
743 * allocation error occurred during this function. This function
744 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
745 *
746 * @see eina_hash_direct_add()
747 */
748EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
749 const void *key,
750 int key_length,
751 int key_hash,
752 const void *data) EINA_ARG_NONNULL(1, 2, 5);
753
754/**
755 * @brief Remove the entry identified by a key and a key hash from the given
756 * hash table.
757 *
758 * @param hash The given hash table. Cannot be @c NULL.
759 * @param key The key. Cannot be @c NULL.
760 * @param key_length The length of the key.
761 * @param key_hash The hash that always match the key.
762 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
763 *
764 * This function removes the entry identified by @p key and
765 * @p key_hash from @p hash. If a free function was given to the
766 * callback on creation, it will be called for the data being
767 * deleted. Do not forget to count '\\0' for string when setting the
768 * value of @p key_length. If @p hash or @p key are @c NULL, the
769 * functions returns immediately #EINA_FALSE. This function returns
770 * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
771 *
772 * @note if you don't have the key_hash, use eina_hash_del_by_key() instead.
773 * @note if you don't have the key, use eina_hash_del_by_data() instead.
774 */
775EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash,
776 const void *key,
777 int key_length,
778 int key_hash) EINA_ARG_NONNULL(1, 2);
779
780/**
781 * @brief Remove the entry identified by a key from the given hash table.
782 *
783 * This version will calculate key length and hash by using functions
784 * provided to hash creation function.
785 *
786 * @param hash The given hash table. Cannot be @c NULL.
787 * @param key The key. Cannot be @c NULL.
788 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
789 *
790 * This function removes the entry identified by @p key from @p
791 * hash. The key length and hash will be calculated automatically by
792 * using functiond provided to has creation function. If a free
793 * function was given to the callback on creation, it will be called
794 * for the data being deleted. If @p hash or @p key are @c NULL, the
795 * functions returns immediately #EINA_FALSE. This function returns
796 * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
797 *
798 * @note if you already have the key_hash, use eina_hash_del_by_key_hash()
799 * instead.
800 * @note if you don't have the key, use eina_hash_del_by_data() instead.
801 */
802EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash,
803 const void *key) EINA_ARG_NONNULL(1, 2);
804
805/**
806 * @brief Remove the entry identified by a data from the given hash table.
807 *
808 * This version is slow since there is no quick access to nodes based on data.
809 *
810 * @param hash The given hash table. Cannot be @c NULL.
811 * @param data The data value to search and remove. Cannot be @c NULL.
812 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
813 * thing goes fine.
814 *
815 * This function removes the entry identified by @p data from @p
816 * hash. If a free function was given to the callback on creation, it
817 * will be called for the data being deleted. If @p hash or @p data
818 * are @c NULL, the functions returns immediately #EINA_FALSE. This
819 * function returns #EINA_FALSE if an error occurred, #EINA_TRUE
820 * otherwise.
821 *
822 * @note if you already have the key, use eina_hash_del_by_key() or
823 * eina_hash_del_by_key_hash() instead.
824 */
825EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash,
826 const void *data) EINA_ARG_NONNULL(1, 2);
827
828/**
829 * @brief Remove the entry identified by a key and a key hash or a
830 * data from the given hash table.
831 *
832 * If @p key is @c NULL, then @p data is used to find a match to
833 * remove.
834 *
835 * @param hash The given hash table. Cannot be @c NULL.
836 * @param key The key.
837 * @param key_length The length of the key.
838 * @param key_hash The hash that always match the key.
839 * @param data The data pointer to remove if the key is @c NULL.
840 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
841 *
842 * This function removes the entry identified by @p key and
843 * @p key_hash, or @p data, from @p hash. If a free function was given to
844 * the callback on creation, it will be called for the data being
845 * deleted. If @p hash is @c NULL, the functions returns immediately
846 * #EINA_FALSE. If @p key is @c NULL, then @p key_length and @p key_hash
847 * are ignored and @p data is used to find a match to remove,
848 * otherwise @p key and @p key_hash are used and @p data is not
849 * required and can be @c NULL. Do not forget to count '\\0' for
850 * string when setting the value of @p key_length. This function
851 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
852 *
853 * @note if you know you already have the key, use eina_hash_del_by_key_hash(),
854 * if you know you don't have the key, use eina_hash_del_by_data()
855 * directly.
856 */
857EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
858 const void *key,
859 int key_length,
860 int key_hash,
861 const void *data) EINA_ARG_NONNULL(1);
862
863/**
864 * @brief Retrieve a specific entry in the given hash table.
865 *
866 * @param hash The given hash table. Cannot be @c NULL.
867 * @param key The key of the entry to find.
868 * @param key_length The length of the key.
869 * @param key_hash The hash that always match the key
870 * @return The data pointer for the stored entry on success, @c NULL
871 * otherwise.
872 *
873 * This function retrieves the entry associated to @p key of length
874 * @p key_length in @p hash. @p key_hash is the hash that always match
875 * @p key. It is ignored if @p key is @c NULL. Do not forget to count
876 * '\\0' for string when setting the value of @p key_length. If
877 * @p hash is @c NULL, this function returns immediately @c NULL. This
878 * function returns the data pointer on success, @c NULL otherwise.
879 */
880EAPI void *eina_hash_find_by_hash(const Eina_Hash *hash,
881 const void *key,
882 int key_length,
883 int key_hash) EINA_ARG_NONNULL(1, 2);
884
885/**
886 * @brief Modify the entry pointer at the specified key and returns
887 * the old entry.
888 *
889 * @param hash The given hash table.
890 * @param key The key of the entry to modify.
891 * @param key_length Should be the length of @p key (don't forget to count
892 * '\\0' for string).
893 * @param key_hash The hash that always match the key. Ignored if @p key is
894 * @c NULL.
895 * @param data The data to replace the old entry, if it exists.
896 * @return The data pointer for the old stored entry, or @c NULL if not
897 * found. If an existing entry is not found, nothing is added to the
898 * hash.
899 */
900EAPI void *eina_hash_modify_by_hash(Eina_Hash *hash,
901 const void *key,
902 int key_length,
903 int key_hash,
904 const void *data) EINA_ARG_NONNULL(1, 2, 5);
905
906/**
907 * @brief Returned a new iterator associated to hash keys.
908 *
909 * @param hash The hash.
910 * @return A new iterator.
911 *
912 * This function returns a newly allocated iterator associated to @p
913 * hash. If @p hash is not populated, this function still returns a
914 * valid iterator that will always return false on
915 * eina_iterator_next(), thus keeping API sane.
916 *
917 * If the memory can not be allocated, NULL is returned and
918 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
919 * returned.
920 *
921 * @warning if the hash structure changes then the iterator becomes
922 * invalid! That is, if you add or remove items this iterator
923 * behavior is undefined and your program may crash!
924 */
925EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
926
927/**
928 * @brief Returned a new iterator associated to hash data.
929 *
930 * @param hash The hash.
931 * @return A new iterator.
932 *
933 * This function returns a newly allocated iterator associated to
934 * @p hash. If @p hash is not populated, this function still returns a
935 * valid iterator that will always return false on
936 * eina_iterator_next(), thus keeping API sane.
937 *
938 * If the memory can not be allocated, @c NULL is returned and
939 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
940 * returned.
941 *
942 * @warning if the hash structure changes then the iterator becomes
943 * invalid. That is, if you add or remove items this iterator behavior
944 * is undefined and your program may crash.
945 */
946EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
947
948/**
949 * @brief Returned a new iterator associated to hash keys and data.
950 *
951 * @param hash The hash.
952 * @return A new iterator.
953 *
954 * This function returns a newly allocated iterator associated to @p
955 * hash. If @p hash is not populated, this function still returns a
956 * valid iterator that will always return false on
957 * eina_iterator_next(), thus keeping API sane.
958 *
959 * If the memory can not be allocated, NULL is returned and
960 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
961 * returned.
962 *
963 * @note iterator data will provide values as Eina_Hash_Tuple that should not
964 * be modified!
965 *
966 * @warning if the hash structure changes then the iterator becomes
967 * invalid! That is, if you add or remove items this iterator
968 * behavior is undefined and your program may crash!
969 */
970EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
971
972/**
973 * @brief Call a function on every member stored in the hash table
974 *
975 * @param hash The hash table whose members will be walked
976 * @param func The function to call on each parameter
977 * @param fdata The data pointer to pass to the function being called
978 *
979 * This function goes through every entry in the hash table @p hash and calls
980 * the function @p func on each member. The function should @b not modify the
981 * hash table contents if it returns 1. @b If the hash table contents are
982 * modified by this function or the function wishes to stop processing it must
983 * return 0, otherwise return 1 to keep processing.
984 *
985 * Example:
986 * @code
987 * extern Eina_Hash *hash;
988 *
989 * Eina_Bool hash_fn(const Eina_Hash *hash, const void *key,
990 * void *data, void *fdata)
991 * {
992 * printf("Func data: %s, Hash entry: %s / %p\n",
993 * fdata, (const char *)key, data);
994 * return 1;
995 * }
996 *
997 * int main(int argc, char **argv)
998 * {
999 * char *hash_fn_data;
1000 *
1001 * hash_fn_data = strdup("Hello World");
1002 * eina_hash_foreach(hash, hash_fn, hash_fn_data);
1003 * free(hash_fn_data);
1004 * }
1005 * @endcode
1006 */
1007EAPI void eina_hash_foreach(const Eina_Hash *hash,
1008 Eina_Hash_Foreach func,
1009 const void *fdata) EINA_ARG_NONNULL(1, 2);
1010/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
1011EAPI int eina_hash_superfast(const char *key,
1012 int len) EINA_ARG_NONNULL(1);
1013/* Hash function first reported by dan bernstein many years ago in comp.lang.c */
1014static inline int eina_hash_djb2(const char *key,
1015 int len) EINA_ARG_NONNULL(1);
1016static inline int eina_hash_djb2_len(const char *key,
1017 int *plen) EINA_ARG_NONNULL(1, 2);
1018/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
1019static inline int eina_hash_int32(const unsigned int *pkey,
1020 int len) EINA_ARG_NONNULL(1);
1021static inline int eina_hash_int64(const unsigned long int *pkey,
1022 int len) EINA_ARG_NONNULL(1);
1023/* http://sites.google.com/site/murmurhash/ */
1024static inline int eina_hash_murmur3(const char *key,
1025 int len) EINA_ARG_NONNULL(1);
1026#include "eina_inline_hash.x"
1027
1028/**
1029 * @}
1030 */
1031
1032/**
1033 * @}
1034 */
1035
1036/**
1037 * @}
1038 */
1039
1040#endif /*EINA_HASH_H_*/
diff --git a/libraries/eina/src/include/eina_inarray.h b/libraries/eina/src/include/eina_inarray.h
deleted file mode 100644
index 079f1e3..0000000
--- a/libraries/eina/src/include/eina_inarray.h
+++ /dev/null
@@ -1,710 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INARRAY_H_
20#define EINA_INARRAY_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_accessor.h"
25
26/**
27 * @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/**
152 * @addtogroup Eina_Data_Types_Group Data Types
153 *
154 * @since 1.2
155 *
156 * @{
157 */
158
159/**
160 * @addtogroup Eina_Containers_Group Containers
161 *
162 * @{
163 */
164
165/**
166 * @defgroup Eina_Inline_Array_Group Inline Array
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 *
181 * @{
182 */
183
184
185/**
186 * @typedef Eina_Inarray
187 * Inlined array type.
188 *
189 * @since 1.2
190 */
191typedef struct _Eina_Inarray Eina_Inarray;
192
193/**
194 * Inline array structure, use #Eina_Inarray typedef instead.
195 *
196 * Do not modify these fields directly, use eina_inarray_setup() or
197 * eina_inarray_new() instead.
198 *
199 * @since 1.2
200 */
201struct _Eina_Inarray
202{
203 unsigned int member_size; /**< byte size of each entry in members */
204 unsigned int len; /**< number of elements used in members */
205 unsigned int max; /**< number of elements allocated in members */
206 unsigned int step; /**< amount to grow number of members allocated */
207 void *members; /**< actual array of elements */
208 EINA_MAGIC
209};
210
211/**
212 * @brief Create new inline array.
213 *
214 * @param member_size size of each member in the array.
215 * @param step when resizing the array, do this using the following
216 * extra amount.
217 * @return The new inline array table or @c NULL on failure.
218 *
219 * Create a new array where members are inlined in a sequence. Each
220 * member has @a member_size bytes.
221 *
222 * If the @a step is 0, then a safe default is chosen.
223 *
224 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
225 * set. If @a member_size is zero, then @c NULL is returned.
226 *
227 * @see eina_inarray_free()
228 *
229 * @since 1.2
230 */
231EAPI Eina_Inarray *eina_inarray_new(unsigned int member_size,
232 unsigned int step) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
233
234/**
235 * @brief Free array and its members.
236 * @param array array object
237 *
238 * @see eina_inarray_flush()
239 *
240 * @since 1.2
241 */
242EAPI void eina_inarray_free(Eina_Inarray *array) EINA_ARG_NONNULL(1);
243
244/**
245 * @brief Initialize inline array.
246 * @param array array object to initialize.
247 * @param member_size size of each member in the array.
248 * @param step when resizing the array, do this using the following
249 * extra amount.
250 *
251 * Initialize array. If the @a step is 0, then a safe default is
252 * chosen.
253 *
254 * This is useful for arrays inlined into other structures or
255 * allocated at stack.
256 *
257 * @see eina_inarray_flush()
258 *
259 * @since 1.2
260 */
261EAPI void eina_inarray_setup(Eina_Inarray *array,
262 unsigned int member_size,
263 unsigned int step) EINA_ARG_NONNULL(1);
264
265/**
266 * @brief Remove every member from array.
267 * @param array array object
268 *
269 * @since 1.2
270 */
271EAPI void eina_inarray_flush(Eina_Inarray *array) EINA_ARG_NONNULL(1);
272
273/**
274 * @brief Copy the data as the last member of the array.
275 * @param array array object
276 * @param data data to be copied at the end
277 * @return the index of the new member or -1 on errors.
278 *
279 * Copies the given pointer contents at the end of the array. The
280 * pointer is not referenced, instead it's contents is copied to the
281 * members array using the previously defined @c member_size.
282 *
283 * @see eina_inarray_insert_at().
284 *
285 * @since 1.2
286 */
287EAPI int eina_inarray_append(Eina_Inarray *array,
288 const void *data) EINA_ARG_NONNULL(1, 2);
289
290/**
291 * @brief Copy the data to array at position found by comparison function
292 * @param array array object
293 * @param data data to be copied
294 * @param compare compare function
295 * @return the index of the new member or -1 on errors.
296 *
297 * Copies the given pointer contents at the array position defined by
298 * given @a compare function. The pointer is not referenced, instead
299 * it's contents is copied to the members array using the previously
300 * defined @c member_size.
301 *
302 * The data given to @a compare function are the pointer to member
303 * memory itself, do no change it.
304 *
305 * @see eina_inarray_insert_sorted()
306 * @see eina_inarray_insert_at()
307 * @see eina_inarray_append()
308 *
309 * @since 1.2
310 */
311EAPI int eina_inarray_insert(Eina_Inarray *array,
312 const void *data,
313 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
314
315/**
316 * @brief Copy the data to array at position found by comparison function
317 * @param array array object
318 * @param data data to be copied
319 * @param compare compare function
320 * @return the index of the new member or -1 on errors.
321 *
322 * Copies the given pointer contents at the array position defined by
323 * given @a compare function. The pointer is not referenced, instead
324 * it's contents is copied to the members array using the previously
325 * defined @c member_size.
326 *
327 * The data given to @a compare function are the pointer to member
328 * memory itself, do no change it.
329 *
330 * This variation will optimize insertion position assuming the array
331 * is already sorted by doing binary search.
332 *
333 * @see eina_inarray_sort()
334 *
335 * @since 1.2
336 */
337EAPI int eina_inarray_insert_sorted(Eina_Inarray *array,
338 const void *data,
339 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
340
341/**
342 * @brief Find data and remove matching member
343 * @param array array object
344 * @param data data to be found and removed
345 * @return the index of the removed member or -1 on errors.
346 *
347 * Find data in the array and remove it. Data may be an existing
348 * member of array (then optimized) or the contents will be matched
349 * using memcmp().
350 *
351 * @see eina_inarray_pop()
352 * @see eina_inarray_remove_at()
353 *
354 * @since 1.2
355 */
356EAPI int eina_inarray_remove(Eina_Inarray *array,
357 const void *data) EINA_ARG_NONNULL(1, 2);
358
359/**
360 * @brief Removes the last member of the array
361 * @param array array object
362 * @return the index of the removed member or -1 on errors.
363 *
364 * @since 1.2
365 */
366EAPI int eina_inarray_pop(Eina_Inarray *array) EINA_ARG_NONNULL(1);
367
368/**
369 * @brief Get the member at given position
370 * @param array array object
371 * @param position member position
372 * @return pointer to current member memory.
373 *
374 * Gets the member given its position in the array. It is a pointer to
375 * its current memory, then it can be invalidated with functions that
376 * changes the array such as eina_inarray_append(),
377 * eina_inarray_insert_at() or eina_inarray_remove_at() or variants.
378 *
379 * See also eina_inarray_lookup() and eina_inarray_lookup_sorted().
380 *
381 * @since 1.2
382 */
383EAPI void *eina_inarray_nth(const Eina_Inarray *array,
384 unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
385
386/**
387 * @brief Copy the data at given position in the array
388 * @param array array object
389 * @param position where to insert the member
390 * @param data data to be copied at position
391 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
392 *
393 * Copies the given pointer contents at the given @a position in the
394 * array. The pointer is not referenced, instead it's contents is
395 * copied to the members array using the previously defined
396 * @c member_size.
397 *
398 * All the members from @a position to the end of the array are
399 * shifted to the end.
400 *
401 * If @a position is equal to the end of the array (equals to
402 * eina_inarray_count()), then the member is appended.
403 *
404 * If @a position is bigger than the array length, it will fail.
405 *
406 * @since 1.2
407 */
408EAPI Eina_Bool eina_inarray_insert_at(Eina_Inarray *array,
409 unsigned int position,
410 const void *data) EINA_ARG_NONNULL(1, 3);
411
412/**
413 * @brief Opens a space at given position, returning its pointer.
414 * @param array array object
415 * @param position where to insert first member (open/allocate space)
416 * @param member_count how many times member_size bytes will be allocated.
417 * @return pointer to first member memory allocated or @c NULL on errors.
418 *
419 * This is similar to eina_inarray_insert_at(), but useful if the
420 * members contents are still unknown or unallocated. It will make
421 * room for the required number of items and return the pointer to the
422 * first item, similar to malloc(member_count * member_size), with the
423 * guarantee all memory is within members array.
424 *
425 * The new member memory is undefined, it's not automatically zeroed.
426 *
427 * All the members from @a position to the end of the array are
428 * shifted to the end.
429 *
430 * If @a position is equal to the end of the array (equals to
431 * eina_inarray_count()), then the member is appended.
432 *
433 * If @a position is bigger than the array length, it will fail.
434 *
435 * @since 1.2
436 */
437EAPI void *eina_inarray_alloc_at(Eina_Inarray *array,
438 unsigned int position,
439 unsigned int member_count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
440
441/**
442 * @brief Copy the data over the given position.
443 * @param array array object
444 * @param position where to replace the member
445 * @param data data to be copied at position
446 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
447 *
448 * Copies the given pointer contents at the given @a position in the
449 * array. The pointer is not referenced, instead it's contents is
450 * copied to the members array using the previously defined
451 * @c member_size.
452 *
453 * If @a position does not exist, it will fail.
454 *
455 * @since 1.2
456 */
457EAPI Eina_Bool eina_inarray_replace_at(Eina_Inarray *array,
458 unsigned int position,
459 const void *data) EINA_ARG_NONNULL(1, 3);
460
461/**
462 * @brief Remove member at given position
463 * @param array array object
464 * @param position position to be removed
465 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
466 *
467 * The member is removed from array and any members after it are moved
468 * towards the array head.
469 *
470 * See also eina_inarray_pop() and eina_inarray_remove().
471 *
472 * @since 1.2
473 */
474EAPI Eina_Bool eina_inarray_remove_at(Eina_Inarray *array,
475 unsigned int position) EINA_ARG_NONNULL(1);
476
477/**
478 * @brief Reverse members in the array.
479 * @param array array object
480 *
481 * If you do not want to change the array, just walk its elements
482 * backwards, then use EINA_INARRAY_REVERSE_FOREACH() macro.
483 *
484 * @see EINA_INARRAY_REVERSE_FOREACH()
485 *
486 * @since 1.2
487 */
488EAPI void eina_inarray_reverse(Eina_Inarray *array) EINA_ARG_NONNULL(1);
489
490/**
491 * @brief Applies quick sort to array
492 * @param array array object
493 * @param compare compare function
494 *
495 * Applies quick sort to the @a array.
496 *
497 * The data given to @a compare function are the pointer to member
498 * memory itself, do no change it.
499 *
500 * @see eina_inarray_insert_sorted()
501 *
502 * @since 1.2
503 */
504EAPI void eina_inarray_sort(Eina_Inarray *array,
505 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2);
506
507/**
508 * @brief Search member (linear walk)
509 * @param array array object
510 * @param data member to search using @a compare function.
511 * @param compare compare function
512 * @return the member index or -1 if not found.
513 *
514 * Walks array linearly looking for given data as compared by
515 * @a compare function.
516 *
517 * The data given to @a compare function are the pointer to member
518 * memory itself, do no change it.
519 *
520 * See also eina_inarray_lookup_sorted().
521 *
522 * @since 1.2
523 */
524EAPI int eina_inarray_search(const Eina_Inarray *array,
525 const void *data,
526 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
527
528/**
529 * @brief Search member (binary search walk)
530 * @param array array object
531 * @param data member to search using @a compare function.
532 * @param compare compare function
533 * @return the member index or -1 if not found.
534 *
535 * Uses binary search for given data as compared by @a compare function.
536 *
537 * The data given to @a compare function are the pointer to member
538 * memory itself, do no change it.
539 *
540 * @since 1.2
541 */
542EAPI int eina_inarray_search_sorted(const Eina_Inarray *array,
543 const void *data,
544 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
545
546/**
547 * @brief Call function for each array member
548 * @param array array object
549 * @param function callback function
550 * @param user_data user data given to callback @a function
551 * @return #EINA_TRUE if it successfully iterate all items of the array.
552 *
553 * Call @a function for every given data in @a array.
554 *
555 * Safe way to iterate over an array. @p function should return
556 * #EINA_TRUE as long as you want the function to continue iterating,
557 * by returning #EINA_FALSE it will stop and return #EINA_FALSE as a
558 * result.
559 *
560 * The data given to @a function are the pointer to member memory
561 * itself.
562 *
563 * @see EINA_INARRAY_FOREACH()
564 *
565 * @since 1.2
566 */
567EAPI Eina_Bool eina_inarray_foreach(const Eina_Inarray *array,
568 Eina_Each_Cb function,
569 const void *user_data) EINA_ARG_NONNULL(1, 2);
570
571/**
572 * @brief Remove all members that matched.
573 * @param array array object
574 * @param match match function
575 * @param user_data user data given to callback @a match.
576 * @return number of removed entries or -1 on error.
577 *
578 * Remove all entries in the @a array where @a match function
579 * returns #EINA_TRUE.
580 *
581 * @since 1.2
582 */
583EAPI int eina_inarray_foreach_remove(Eina_Inarray *array,
584 Eina_Each_Cb match,
585 const void *user_data) EINA_ARG_NONNULL(1, 2);
586
587/**
588 * @brief number of members in array.
589 * @param array array object
590 * @return number of members in array.
591 *
592 * @since 1.2
593 */
594EAPI unsigned int eina_inarray_count(const Eina_Inarray *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
595
596/**
597 * @brief Returned a new iterator associated to an array.
598 * @param array array object
599 * @return A new iterator.
600 *
601 * This function returns a newly allocated iterator associated to
602 * @p array.
603 *
604 * If the memory can not be allocated, NULL is returned and
605 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
606 * returned.
607 *
608 * @warning if the array structure changes then the iterator becomes
609 * invalid! That is, if you add or remove members this
610 * iterator behavior is undefined and your program may crash!
611 *
612 * @since 1.2
613 */
614EAPI Eina_Iterator *eina_inarray_iterator_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
615
616/**
617 * @brief Returned a new reversed iterator associated to an array.
618 * @param array array object
619 * @return A new iterator.
620 *
621 * This function returns a newly allocated iterator associated to
622 * @p array.
623 *
624 * Unlike eina_inarray_iterator_new(), this will walk the array backwards.
625 *
626 * If the memory can not be allocated, NULL is returned and
627 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
628 * returned.
629 *
630 * @warning if the array structure changes then the iterator becomes
631 * invalid! That is, if you add or remove nodes this iterator
632 * behavior is undefined and your program may crash!
633 *
634 * @since 1.2
635 */
636EAPI Eina_Iterator *eina_inarray_iterator_reversed_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
637
638/**
639 * @brief Returned a new accessor associated to an array.
640 * @param array array object
641 * @return A new accessor.
642 *
643 * This function returns a newly allocated accessor associated to
644 * @p array.
645 *
646 * If the memory can not be allocated, NULL is returned and
647 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid accessor is
648 * returned.
649 *
650 * @since 1.2
651 */
652EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
653
654/**
655 * @def EINA_INARRAY_FOREACH
656 * @brief walks array linearly from head to tail
657 * @param array array object
658 * @param itr the iterator pointer
659 *
660 * @a itr must be a pointer with sizeof(itr*) == array->member_size.
661 *
662 * @warning This is fast as it does direct pointer access, but it will
663 * not check for @c NULL pointers or invalid array object!
664 * See eina_inarray_foreach() to do that.
665 *
666 * @warning Do not modify array as you walk it! If that is desired,
667 * then use eina_inarray_foreach_remove()
668 *
669 * @since 1.2
670 */
671#define EINA_INARRAY_FOREACH(array, itr) \
672 for ((itr) = (array)->members; \
673 (itr) < (((typeof(*itr)*)(array)->members) + (array)->len); \
674 (itr)++)
675
676/**
677 * @def EINA_INARRAY_REVERSE_FOREACH
678 * @brief walks array linearly from tail to head
679 * @param array array object
680 * @param itr the iterator pointer
681 *
682 * @a itr must be a pointer with sizeof(itr*) == array->member_size.
683 *
684 * @warning This is fast as it does direct pointer access, but it will
685 * not check for @c NULL pointers or invalid array object!
686 *
687 * @warning Do not modify array as you walk it! If that is desired,
688 * then use eina_inarray_foreach_remove()
689 *
690 * @since 1.2
691 */
692#define EINA_INARRAY_REVERSE_FOREACH(array, itr) \
693 for ((itr) = ((((typeof(*(itr))*)(array)->members) + (array)->len) - 1); \
694 (((itr) >= (typeof(*(itr))*)(array)->members) \
695 && ((array)->members != NULL)); \
696 (itr)--)
697
698/**
699 * @}
700 */
701
702/**
703 * @}
704 */
705
706/**
707 * @}
708 */
709
710#endif /*EINA_INARRAY_H_*/
diff --git a/libraries/eina/src/include/eina_inline_array.x b/libraries/eina/src/include/eina_inline_array.x
deleted file mode 100644
index a635ee2..0000000
--- a/libraries/eina/src/include/eina_inline_array.x
+++ /dev/null
@@ -1,184 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_ARRAY_X_
20#define EINA_INLINE_ARRAY_X_
21
22#include <stddef.h>
23
24#include <stdio.h>
25
26/**
27 * @cond LOCAL
28 */
29
30EAPI Eina_Bool eina_array_grow(Eina_Array *array);
31
32/**
33 * @endcond
34 */
35
36/**
37 * @addtogroup Eina_Array_Group Array
38 *
39 * @brief These functions provide array management.
40 *
41 * @{
42 */
43
44/**
45 * @brief Append a data to an array.
46 *
47 * @param array The array.
48 * @param data The data to add.
49 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
50 *
51 * This function appends @p data to @p array. For performance
52 * reasons, there is no check of @p array. If it is @c NULL or
53 * invalid, the program may crash. If @p data is @c NULL, or if an
54 * allocation is necessary and fails, #EINA_FALSE is returned and
55 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, #EINA_TRUE is
56 * returned.
57 */
58
59static inline Eina_Bool
60eina_array_push(Eina_Array *array, const void *data)
61{
62 if (!data) return EINA_FALSE;
63
64 if (EINA_UNLIKELY((array->count + 1) > array->total))
65 if (!eina_array_grow(array))
66 return EINA_FALSE;
67
68 array->data[array->count++] = (void*) data;
69
70 return EINA_TRUE;
71}
72
73/**
74 * @brief Remove the last data of an array.
75 *
76 * @param array The array.
77 * @return The retrieved data.
78 *
79 * This function removes the last data of @p array, decreases the count
80 * of @p array and returns the data. For performance reasons, there
81 * is no check of @p array. If it is @c NULL or invalid, the program
82 * may crash. If the count member is less or equal than 0, @c NULL is
83 * returned.
84 */
85static inline void *
86eina_array_pop(Eina_Array *array)
87{
88 void *ret = NULL;
89
90 if (array->count <= 0)
91 goto on_empty;
92
93 ret = array->data[--array->count];
94
95 on_empty:
96 return ret;
97}
98
99/**
100 * @brief Return the data at a given position in an array.
101 *
102 * @param array The array.
103 * @param idx The potition of the data to retrieve.
104 * @return The retrieved data.
105 *
106 * This function returns the data at the position @p idx in @p
107 * array. For performance reasons, there is no check of @p array or @p
108 * idx. If it is @c NULL or invalid, the program may crash.
109 */
110static inline void *
111eina_array_data_get(const Eina_Array *array, unsigned int idx)
112{
113 return array->data[idx];
114}
115
116static inline void
117eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data)
118{
119 array->data[idx] = (void*) data;
120}
121
122/**
123 * @brief Return the number of elements in an array.
124 *
125 * @param array The array.
126 * @return The number of elements.
127 *
128 * This function returns the number of elements in @p array. For
129 * performance reasons, there is no check of @p array. If it is
130 * @c NULL or invalid, the program may crash.
131 *
132 * @deprecated use eina_array_count()
133 */
134static inline unsigned int
135eina_array_count_get(const Eina_Array *array)
136{
137 return array->count;
138}
139
140/**
141 * @brief Return the number of elements in an array.
142 *
143 * @param array The array.
144 * @return The number of elements.
145 *
146 * This function returns the number of elements in @p array. For
147 * performance reasons, there is no check of @p array. If it is
148 * @c NULL or invalid, the program may crash.
149 */
150static inline unsigned int
151eina_array_count(const Eina_Array *array)
152{
153 return array->count;
154}
155
156static inline Eina_Bool
157eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
158{
159 void *data;
160 Eina_Array_Iterator iterator;
161 unsigned int i;
162 Eina_Bool ret = EINA_TRUE;
163
164 EINA_ARRAY_ITER_NEXT(array, i, data, iterator)
165 if (cb(array, data, fdata) != EINA_TRUE)
166 {
167 ret = EINA_FALSE;
168 break;
169 }
170
171 return ret;
172}
173
174static inline void
175eina_array_clean(Eina_Array *array)
176{
177 array->count = 0;
178}
179
180/**
181 * @}
182 */
183
184#endif
diff --git a/libraries/eina/src/include/eina_inline_clist.x b/libraries/eina/src/include/eina_inline_clist.x
deleted file mode 100644
index 66223fe..0000000
--- a/libraries/eina/src/include/eina_inline_clist.x
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * Linked lists support
3 *
4 * Copyright (C) 2002 Alexandre Julliard
5 * Copyright (C) 2011 Mike McCormack (adapted for Eina)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifndef __EINA_CLIST_INLINE_H__
23#define __EINA_CLIST_INLINE_H__
24
25#include <stddef.h>
26
27static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
28{
29 to_add->next = elem->next;
30 to_add->prev = elem;
31 elem->next->prev = to_add;
32 elem->next = to_add;
33}
34
35static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
36{
37 to_add->next = elem;
38 to_add->prev = elem->prev;
39 elem->prev->next = to_add;
40 elem->prev = to_add;
41}
42
43static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
44{
45 eina_clist_add_after(list, elem);
46}
47
48static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
49{
50 eina_clist_add_before(list, elem);
51}
52
53static inline void eina_clist_element_init(Eina_Clist *elem)
54{
55 elem->next = NULL;
56 elem->prev = NULL;
57}
58
59static inline int eina_clist_element_is_linked(Eina_Clist *elem)
60{
61 return (elem->next != NULL && elem->prev != NULL);
62}
63
64static inline void eina_clist_remove(Eina_Clist *elem)
65{
66 elem->next->prev = elem->prev;
67 elem->prev->next = elem->next;
68 eina_clist_element_init(elem);
69}
70
71static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem)
72{
73 Eina_Clist *ret = elem->next;
74 if (elem->next == list) ret = NULL;
75 return ret;
76}
77
78static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem)
79{
80 Eina_Clist *ret = elem->prev;
81 if (elem->prev == list) ret = NULL;
82 return ret;
83}
84
85static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
86{
87 return eina_clist_next(list, list);
88}
89
90static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
91{
92 return eina_clist_prev(list, list);
93}
94
95static inline int eina_clist_empty(const Eina_Clist *list)
96{
97 return list->next == list;
98}
99
100static inline void eina_clist_init(Eina_Clist *list)
101{
102 list->next = list->prev = list;
103}
104
105static inline unsigned int eina_clist_count(const Eina_Clist *list)
106{
107 unsigned count = 0;
108 const Eina_Clist *ptr;
109 for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
110 return count;
111}
112
113static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
114{
115 if (eina_clist_empty(src)) return;
116
117 dst->prev->next = src->next;
118 src->next->prev = dst->prev;
119 dst->prev = src->prev;
120 src->prev->next = dst;
121 eina_clist_init(src);
122}
123
124static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
125{
126 if (eina_clist_empty(src)) return;
127
128 dst->next->prev = src->prev;
129 src->prev->next = dst->next;
130 dst->next = src->next;
131 src->next->prev = dst;
132 eina_clist_init(src);
133}
134
135#endif
diff --git a/libraries/eina/src/include/eina_inline_f16p16.x b/libraries/eina/src/include/eina_inline_f16p16.x
deleted file mode 100644
index e16d188..0000000
--- a/libraries/eina/src/include/eina_inline_f16p16.x
+++ /dev/null
@@ -1,83 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_F16P16_X_
21#define EINA_INLINE_F16P16_X_
22
23static inline Eina_F16p16
24eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b)
25{
26 return a + b;
27}
28
29static inline Eina_F16p16
30eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b)
31{
32 return a - b;
33}
34
35static inline Eina_F16p16
36eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b)
37{
38 return (Eina_F16p16)(((int64_t)a * (int64_t)b) >> 16);
39}
40
41static inline Eina_F16p16
42eina_f16p16_scale(Eina_F16p16 a, int b)
43{
44 return a * b;
45}
46
47static inline Eina_F16p16
48eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b)
49{
50 return (Eina_F16p16) ((((int64_t) a) << 16) / (int64_t) b);
51}
52
53static inline Eina_F16p16
54eina_f16p16_sqrt(Eina_F16p16 a)
55{
56 unsigned int root, remHi, remLo, testDiv, count;
57
58 root = 0; /* Clear root */
59 remHi = 0; /* Clear high part of partial remainder */
60 remLo = a; /* Get argument into low part of partial remainder */
61 count = (15 + (16 >> 1)); /* Load loop counter */
62 do {
63 remHi = (remHi << 2) | (remLo >> 30);
64 remLo <<= 2; /* get 2 bits of arg */
65 root <<= 1; /* Get ready for the next bit in the root */
66 testDiv = (root << 1) + 1; /* Test radical */
67 if (remHi >= testDiv)
68 {
69 remHi -= testDiv;
70 root++;
71 }
72 } while (count-- != 0);
73
74 return root;
75}
76
77static inline unsigned int
78eina_f16p16_fracc_get(Eina_F16p16 v)
79{
80 return (v & 0xffff);
81}
82
83#endif
diff --git a/libraries/eina/src/include/eina_inline_f32p32.x b/libraries/eina/src/include/eina_inline_f32p32.x
deleted file mode 100644
index 73480de..0000000
--- a/libraries/eina/src/include/eina_inline_f32p32.x
+++ /dev/null
@@ -1,110 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2009 Jorge Luis Zapata Muga, Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_F32P32_X_
20# define EINA_INLINE_F32P32_X_
21
22#include <stdlib.h>
23
24static inline Eina_F32p32
25eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b)
26{
27 return a + b;
28}
29
30static inline Eina_F32p32
31eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b)
32{
33 return a - b;
34}
35
36static inline Eina_F32p32
37eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b)
38{
39 /* Prevent overflow and do '(a * b) >> 32' */
40 /* Basically do: Eina_F16p16 * Eina_F16p16 = Eina_F32p32 */
41 Eina_F32p32 up;
42 Eina_F32p32 down;
43 Eina_F32p32 result;
44 uint64_t as, bs;
45 Eina_F32p32 sign;
46
47 sign = a ^ b;
48 as = eina_fp32p32_llabs(a);
49 bs = eina_fp32p32_llabs(b);
50
51 up = (as >> 16) * (bs >> 16);
52 down = (as & 0xFFFF) * (bs & 0xFFFF);
53
54 result = up + (down >> 32);
55
56 return sign < 0 ? - result : result;
57}
58
59static inline Eina_F32p32
60eina_f32p32_scale(Eina_F32p32 a, int b)
61{
62 return a * b;
63}
64
65static inline Eina_F32p32
66eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b)
67{
68 Eina_F32p32 sign;
69 Eina_F32p32 result;
70
71 sign = a ^ b;
72
73 if (b == 0)
74 return sign < 0 ? (Eina_F32p32) 0x8000000000000000ull : (Eina_F32p32) 0x7FFFFFFFFFFFFFFFull;
75
76 result = (eina_f32p32_mul(eina_fp32p32_llabs(a), (((uint64_t) 1 << 62) / ((uint64_t)(eina_fp32p32_llabs(b)) >> 2))));
77
78 return sign < 0 ? - result : result;
79}
80
81static inline Eina_F32p32
82eina_f32p32_sqrt(Eina_F32p32 a)
83{
84 uint64_t root, remHi, remLo, testDiv, count;
85
86 root = 0; /* Clear root */
87 remHi = 0; /* Clear high part of partial remainder */
88 remLo = a; /* Get argument into low part of partial remainder */
89 count = (31 + (32 >> 1)); /* Load loop counter */
90 do {
91 remHi = (remHi << 2) | (remLo >> 30);
92 remLo <<= 2; /* get 2 bits of arg */
93 root <<= 1; /* Get ready for the next bit in the root */
94 testDiv = (root << 1) + 1; /* Test radical */
95 if (remHi >= testDiv) {
96 remHi -= testDiv;
97 root++;
98 }
99 } while (count-- != 0);
100
101 return root;
102}
103
104static inline unsigned int
105eina_f32p32_fracc_get(Eina_F32p32 v)
106{
107 return (unsigned int)v;
108}
109
110#endif
diff --git a/libraries/eina/src/include/eina_inline_f8p24.x b/libraries/eina/src/include/eina_inline_f8p24.x
deleted file mode 100644
index f80bf61..0000000
--- a/libraries/eina/src/include/eina_inline_f8p24.x
+++ /dev/null
@@ -1,82 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_F8P24_X_
21#define EINA_INLINE_F8P24_X_
22
23static inline Eina_F8p24
24eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b)
25{
26 return a + b;
27}
28
29static inline Eina_F8p24
30eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b)
31{
32 return a - b;
33}
34
35static inline Eina_F8p24
36eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b)
37{
38 return (Eina_F8p24)(((int64_t) a * (int64_t) b) >> 24);
39}
40
41static inline Eina_F8p24
42eina_f8p24_scale(Eina_F8p24 a, int b)
43{
44 return a * b;
45}
46
47static inline Eina_F8p24
48eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b)
49{
50 return (Eina_F8p24) ((((int64_t) a) << 24) / (int64_t) b);
51}
52
53static inline Eina_F8p24
54eina_f8p24_sqrt(Eina_F8p24 a)
55{
56 unsigned int root, remHi, remLo, testDiv, count;
57
58 root = 0; /* Clear root */
59 remHi = 0; /* Clear high part of partial remainder */
60 remLo = a; /* Get argument into low part of partial remainder */
61 count = (23 + (24 >> 1)); /* Load loop counter */
62 do {
63 remHi = (remHi << 2) | (remLo >> 30);
64 remLo <<= 2; /* get 2 bits of arg */
65 root <<= 1; /* Get ready for the next bit in the root */
66 testDiv = (root << 1) + 1; /* Test radical */
67 if (remHi >= testDiv)
68 {
69 remHi -= testDiv;
70 root++;
71 }
72 } while (count-- != 0);
73 return (root);
74}
75
76static inline unsigned int
77eina_f8p24_fracc_get(Eina_F8p24 v)
78{
79 return (v & 0xffffff);
80}
81
82#endif
diff --git a/libraries/eina/src/include/eina_inline_fp.x b/libraries/eina/src/include/eina_inline_fp.x
deleted file mode 100644
index de44123..0000000
--- a/libraries/eina/src/include/eina_inline_fp.x
+++ /dev/null
@@ -1,153 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_FP_X_
21# define EINA_INLINE_FP_X_
22
23static inline Eina_F32p32
24eina_f32p32_int_from(int32_t v)
25{
26 return (Eina_F32p32)(v) << 32;
27}
28
29static inline int32_t
30eina_f32p32_int_to(Eina_F32p32 v)
31{
32 return (int32_t)(v >> 32);
33}
34
35static inline Eina_F32p32
36eina_f32p32_double_from(double v)
37{
38 Eina_F32p32 r;
39 r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5));
40 return r;
41}
42
43static inline double
44eina_f32p32_double_to(Eina_F32p32 v)
45{
46 double r;
47 r = v / 4294967296.0;
48 return r;
49}
50
51
52
53static inline Eina_F16p16
54eina_f16p16_int_from(int32_t v)
55{
56 return v << 16;
57}
58
59static inline int32_t
60eina_f16p16_int_to(Eina_F16p16 v)
61{
62 return v >> 16;
63}
64
65static inline Eina_F16p16
66eina_f16p16_float_from(float v)
67{
68 Eina_F16p16 r;
69
70 r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f));
71 return r;
72}
73
74static inline float
75eina_f16p16_float_to(Eina_F16p16 v)
76{
77 float r;
78
79 r = v / 65536.0f;
80 return r;
81}
82
83
84
85static inline Eina_F8p24
86eina_f8p24_int_from(int32_t v)
87{
88 return v << 24;
89}
90
91static inline int32_t
92eina_f8p24_int_to(Eina_F8p24 v)
93{
94 return v >> 24;
95}
96
97static inline Eina_F8p24
98eina_f8p24_float_from(float v)
99{
100 Eina_F8p24 r;
101
102 r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f));
103 return r;
104}
105
106static inline float
107eina_f8p24_float_to(Eina_F8p24 v)
108{
109 float r;
110
111 r = v / 16777216.0f;
112 return r;
113}
114
115
116
117static inline Eina_F32p32
118eina_f16p16_to_f32p32(Eina_F16p16 a)
119{
120 return ((Eina_F32p32) a) << 16;
121}
122
123static inline Eina_F32p32
124eina_f8p24_to_f32p32(Eina_F8p24 a)
125{
126 return ((Eina_F32p32) a) << 8;
127}
128
129static inline Eina_F16p16
130eina_f32p32_to_f16p16(Eina_F32p32 a)
131{
132 return (Eina_F16p16) (a >> 16);
133}
134
135static inline Eina_F16p16
136eina_f8p24_to_f16p16(Eina_F8p24 a)
137{
138 return (Eina_F16p16) (a >> 8);
139}
140
141static inline Eina_F8p24
142eina_f32p32_to_f8p24(Eina_F32p32 a)
143{
144 return (Eina_F8p24) (a >> 8);
145}
146
147static inline Eina_F8p24
148eina_f16p16_to_f8p24(Eina_F16p16 a)
149{
150 return (Eina_F8p24) (a << 8);
151}
152
153#endif
diff --git a/libraries/eina/src/include/eina_inline_hash.x b/libraries/eina/src/include/eina_inline_hash.x
deleted file mode 100644
index be20e8f..0000000
--- a/libraries/eina/src/include/eina_inline_hash.x
+++ /dev/null
@@ -1,151 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_HASH_X_
20#define EINA_INLINE_HASH_X_
21
22/*
23 djb2 hash algorithm was first reported by dan bernstein, and was the old
24 default hash function for evas.
25 */
26static inline int
27eina_hash_djb2(const char *key, int len)
28{
29 unsigned int hash_num = 5381;
30 const unsigned char *ptr;
31
32 if (!key) return 0;
33 for (ptr = (unsigned char *)key; len; ptr++, len--)
34 hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */
35
36 return (int)hash_num;
37}
38
39static inline int
40eina_hash_djb2_len(const char *key, int *plen)
41{
42 unsigned int hash_num = 5381;
43 int len = 0;
44 const unsigned char *ptr;
45
46 if (!key) return 0;
47
48 for (ptr = (unsigned char *)key; *ptr; ptr++, len++)
49 hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */
50
51 *plen = len + 1;
52
53 return (int)hash_num;
54}
55
56static inline int
57eina_hash_int32(const unsigned int *pkey, int len)
58{
59 unsigned int key = *pkey;
60
61 (void) len;
62
63 key = ~key + (key << 15);
64 key ^= key >> 12;
65 key += key << 2;
66 key ^= key >> 4;
67 key *= 2057;
68 key ^= key >> 16;
69 return key;
70}
71
72static inline int
73eina_hash_int64(const unsigned long int *pkey, int len)
74{
75 unsigned long int key = *pkey;
76
77 (void) len;
78
79 key = ~key + (key << 18);
80 key ^= key >> 31;
81 key *= 21;
82 key ^= key >> 11;
83 key += key << 6;
84 key ^= key >> 22;
85 return (int) key;
86}
87
88static inline unsigned int _rotl32(unsigned int x, char r)
89{
90 return (x << r) | (x >> (32 - r));
91}
92
93static inline unsigned int _fmix32(unsigned int h)
94{
95 h ^= h >> 16;
96 h *= 0x85ebca6b;
97 h ^= h >> 13;
98 h *= 0xc2b2ae35;
99 h ^= h >> 16;
100
101 return h;
102}
103
104static inline int
105eina_hash_murmur3(const char *key, int len)
106{
107 const unsigned char * data = (const unsigned char*)key;
108 const int nblocks = len / 4;
109 unsigned int h1 = 0, k1;
110 unsigned int c1 = 0xcc9e2d51;
111 unsigned int c2 = 0x1b873593;
112 const unsigned int * blocks = (const unsigned int *)(data + nblocks*4);
113 int i;
114 const unsigned char *tail;
115
116 for(i = -nblocks; i; i++)
117 {
118 k1 = blocks[i];
119
120 k1 *= c1;
121 k1 = _rotl32(k1, 15);
122 k1 *= c2;
123
124 h1 ^= k1;
125 h1 = _rotl32(h1, 13);
126 h1 = h1*5+0xe6546b64;
127 }
128
129 tail = (const unsigned char*)(data + nblocks*4);
130
131 k1 = 0;
132
133 switch(len & 3)
134 {
135 case 3:
136 k1 ^= tail[2] << 16;
137 case 2:
138 k1 ^= tail[1] << 8;
139 case 1:
140 k1 ^= tail[0];
141 k1 *= c1;
142 k1 = _rotl32(k1, 16);
143 k1 *= c2;
144 h1 ^= k1;
145 }
146
147 h1 ^= len;
148
149 return _fmix32(h1);
150}
151#endif
diff --git a/libraries/eina/src/include/eina_inline_list.x b/libraries/eina/src/include/eina_inline_list.x
deleted file mode 100644
index 3397a1b..0000000
--- a/libraries/eina/src/include/eina_inline_list.x
+++ /dev/null
@@ -1,67 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LIST_INLINE_H_
20#define EINA_LIST_INLINE_H_
21
22static inline Eina_List *
23eina_list_last(const Eina_List *list)
24{
25 if (!list) return NULL;
26 return list->accounting->last;
27}
28
29static inline Eina_List *
30eina_list_next(const Eina_List *list)
31{
32 if (!list) return NULL;
33 return list->next;
34}
35
36static inline Eina_List *
37eina_list_prev(const Eina_List *list)
38{
39 if (!list) return NULL;
40 return list->prev;
41}
42
43static inline void *
44eina_list_data_get(const Eina_List *list)
45{
46 if (!list) return NULL;
47 return list->data;
48}
49
50static inline void *
51eina_list_data_set(Eina_List *list, const void *data)
52{
53 void *tmp;
54 if (!list) return NULL;
55 tmp = list->data;
56 list->data = (void*) data;
57 return tmp;
58}
59
60static inline unsigned int
61eina_list_count(const Eina_List *list)
62{
63 if (!list) return 0;
64 return list->accounting->count;
65}
66
67#endif /* EINA_LIST_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x
deleted file mode 100644
index 64e049a..0000000
--- a/libraries/eina/src/include/eina_inline_lock_posix.x
+++ /dev/null
@@ -1,556 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_POSIX_X_
20#define EINA_INLINE_LOCK_POSIX_X_
21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
31#include <errno.h>
32#ifndef __USE_UNIX98
33# define __USE_UNIX98
34# include <pthread.h>
35# undef __USE_UNIX98
36#else
37# include <pthread.h>
38#endif
39
40#include <semaphore.h>
41
42#include <sys/time.h>
43#include <stdio.h>
44
45#ifdef EINA_HAVE_DEBUG_THREADS
46#include <stdlib.h>
47#include <string.h>
48#include <assert.h>
49#include <execinfo.h>
50#define EINA_LOCK_DEBUG_BT_NUM 64
51typedef void (*Eina_Lock_Bt_Func) ();
52
53#include "eina_inlist.h"
54#endif
55
56typedef struct _Eina_Lock Eina_Lock;
57typedef struct _Eina_RWLock Eina_RWLock;
58typedef struct _Eina_Condition Eina_Condition;
59typedef pthread_key_t Eina_TLS;
60typedef sem_t Eina_Semaphore;
61
62struct _Eina_Lock
63{
64#ifdef EINA_HAVE_DEBUG_THREADS
65 EINA_INLIST;
66#endif
67 pthread_mutex_t mutex;
68#ifdef EINA_HAVE_DEBUG_THREADS
69 pthread_t lock_thread_id;
70 Eina_Lock_Bt_Func lock_bt[EINA_LOCK_DEBUG_BT_NUM];
71 int lock_bt_num;
72 Eina_Bool locked : 1;
73#endif
74};
75
76struct _Eina_Condition
77{
78 Eina_Lock *lock;
79 pthread_cond_t condition;
80};
81
82struct _Eina_RWLock
83{
84 pthread_rwlock_t mutex;
85#ifdef EINA_HAVE_DEBUG_THREADS
86 pthread_t lock_thread_wid;
87#endif
88};
89
90EAPI extern Eina_Bool _eina_threads_activated;
91
92#ifdef EINA_HAVE_DEBUG_THREADS
93EAPI extern int _eina_threads_debug;
94EAPI extern pthread_t _eina_main_loop;
95EAPI extern pthread_mutex_t _eina_tracking_lock;
96EAPI extern Eina_Inlist *_eina_tracking;
97#endif
98
99static inline void
100eina_lock_debug(const Eina_Lock *mutex)
101{
102#ifdef EINA_HAVE_DEBUG_THREADS
103 printf("lock %p, locked: %i, by %i\n",
104 mutex, (int)mutex->locked, (int)mutex->lock_thread_id);
105 backtrace_symbols_fd((void **)mutex->lock_bt, mutex->lock_bt_num, 1);
106#else
107 (void) mutex;
108#endif
109}
110
111static inline Eina_Bool
112eina_lock_new(Eina_Lock *mutex)
113{
114 pthread_mutexattr_t attr;
115
116#ifdef EINA_HAVE_DEBUG_THREADS
117 if (!_eina_threads_activated)
118 assert(pthread_equal(_eina_main_loop, pthread_self()));
119#endif
120
121 if (pthread_mutexattr_init(&attr) != 0)
122 return EINA_FALSE;
123 /* NOTE: PTHREAD_MUTEX_RECURSIVE is not allowed at all, you will break on/off
124 feature for sure with that change. */
125#ifdef EINA_HAVE_DEBUG_THREADS
126 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0)
127 return EINA_FALSE;
128 memset(mutex, 0, sizeof(Eina_Lock));
129#endif
130 if (pthread_mutex_init(&(mutex->mutex), &attr) != 0)
131 return EINA_FALSE;
132
133 pthread_mutexattr_destroy(&attr);
134
135 return EINA_TRUE;
136}
137
138static inline void
139eina_lock_free(Eina_Lock *mutex)
140{
141#ifdef EINA_HAVE_DEBUG_THREADS
142 if (!_eina_threads_activated)
143 assert(pthread_equal(_eina_main_loop, pthread_self()));
144#endif
145
146 pthread_mutex_destroy(&(mutex->mutex));
147#ifdef EINA_HAVE_DEBUG_THREADS
148 memset(mutex, 0, sizeof(Eina_Lock));
149#endif
150}
151
152static inline Eina_Lock_Result
153eina_lock_take(Eina_Lock *mutex)
154{
155 Eina_Lock_Result ret = EINA_LOCK_FAIL;
156 int ok;
157
158#ifdef EINA_HAVE_ON_OFF_THREADS
159 if (!_eina_threads_activated)
160 {
161#ifdef EINA_HAVE_DEBUG_THREADS
162 assert(pthread_equal(_eina_main_loop, pthread_self()));
163#endif
164 return EINA_LOCK_SUCCEED;
165 }
166#endif
167
168#ifdef EINA_HAVE_DEBUG_THREADS
169 if (_eina_threads_debug)
170 {
171 struct timeval t0, t1;
172 int dt;
173
174 gettimeofday(&t0, NULL);
175 ok = pthread_mutex_lock(&(mutex->mutex));
176 gettimeofday(&t1, NULL);
177
178 dt = (t1.tv_sec - t0.tv_sec) * 1000000;
179 if (t1.tv_usec > t0.tv_usec)
180 dt += (t1.tv_usec - t0.tv_usec);
181 else
182 dt -= t0.tv_usec - t1.tv_usec;
183 dt /= 1000;
184
185 if (dt > _eina_threads_debug) abort();
186 }
187 else
188 {
189#endif
190 ok = pthread_mutex_lock(&(mutex->mutex));
191#ifdef EINA_HAVE_DEBUG_THREADS
192 }
193#endif
194
195 if (ok == 0) ret = EINA_LOCK_SUCCEED;
196 else if (ok == EDEADLK)
197 {
198 printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex);
199 eina_lock_debug(mutex);
200 ret = EINA_LOCK_DEADLOCK; // magic
201#ifdef EINA_HAVE_DEBUG_THREADS
202 if (_eina_threads_debug) abort();
203#endif
204 }
205
206#ifdef EINA_HAVE_DEBUG_THREADS
207 mutex->locked = 1;
208 mutex->lock_thread_id = pthread_self();
209 mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM);
210
211 pthread_mutex_lock(&_eina_tracking_lock);
212 _eina_tracking = eina_inlist_append(_eina_tracking,
213 EINA_INLIST_GET(mutex));
214 pthread_mutex_unlock(&_eina_tracking_lock);
215#endif
216
217 return ret;
218}
219
220static inline Eina_Lock_Result
221eina_lock_take_try(Eina_Lock *mutex)
222{
223 Eina_Lock_Result ret = EINA_LOCK_FAIL;
224 int ok;
225
226#ifdef EINA_HAVE_ON_OFF_THREADS
227 if (!_eina_threads_activated)
228 {
229#ifdef EINA_HAVE_DEBUG_THREADS
230 assert(pthread_equal(_eina_main_loop, pthread_self()));
231#endif
232 return EINA_LOCK_SUCCEED;
233 }
234#endif
235
236#ifdef EINA_HAVE_DEBUG_THREADS
237 if (!_eina_threads_activated)
238 assert(pthread_equal(_eina_main_loop, pthread_self()));
239#endif
240
241 ok = pthread_mutex_trylock(&(mutex->mutex));
242 if (ok == 0) ret = EINA_LOCK_SUCCEED;
243 else if (ok == EDEADLK)
244 {
245 printf("ERROR ERROR: DEADLOCK on trylock %p\n", mutex);
246 ret = EINA_LOCK_DEADLOCK; // magic
247 }
248#ifdef EINA_HAVE_DEBUG_THREADS
249 if (ret == EINA_LOCK_SUCCEED)
250 {
251 mutex->locked = 1;
252 mutex->lock_thread_id = pthread_self();
253 mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM);
254
255 pthread_mutex_lock(&_eina_tracking_lock);
256 _eina_tracking = eina_inlist_append(_eina_tracking,
257 EINA_INLIST_GET(mutex));
258 pthread_mutex_unlock(&_eina_tracking_lock);
259 }
260#endif
261 return ret;
262}
263
264static inline Eina_Lock_Result
265eina_lock_release(Eina_Lock *mutex)
266{
267 Eina_Lock_Result ret;
268
269#ifdef EINA_HAVE_ON_OFF_THREADS
270 if (!_eina_threads_activated)
271 {
272#ifdef EINA_HAVE_DEBUG_THREADS
273 assert(pthread_equal(_eina_main_loop, pthread_self()));
274#endif
275 return EINA_LOCK_SUCCEED;
276 }
277#endif
278
279#ifdef EINA_HAVE_DEBUG_THREADS
280 pthread_mutex_lock(&_eina_tracking_lock);
281 _eina_tracking = eina_inlist_remove(_eina_tracking,
282 EINA_INLIST_GET(mutex));
283 pthread_mutex_unlock(&_eina_tracking_lock);
284
285 mutex->locked = 0;
286 mutex->lock_thread_id = 0;
287 memset(mutex->lock_bt, 0, EINA_LOCK_DEBUG_BT_NUM * sizeof(Eina_Lock_Bt_Func));
288 mutex->lock_bt_num = 0;
289#endif
290 ret = (pthread_mutex_unlock(&(mutex->mutex)) == 0) ?
291 EINA_LOCK_SUCCEED : EINA_LOCK_FAIL;
292 return ret;
293}
294
295static inline Eina_Bool
296eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
297{
298#ifdef EINA_HAVE_DEBUG_THREADS
299 assert(mutex != NULL);
300 if (!_eina_threads_activated)
301 assert(pthread_equal(_eina_main_loop, pthread_self()));
302 memset(cond, 0, sizeof (Eina_Condition));
303#endif
304
305 cond->lock = mutex;
306 if (pthread_cond_init(&cond->condition, NULL) != 0)
307 {
308#ifdef EINA_HAVE_DEBUG_THREADS
309 if (errno == EBUSY)
310 printf("eina_condition_new on already initialized Eina_Condition\n");
311#endif
312 return EINA_FALSE;
313 }
314
315 return EINA_TRUE;
316}
317
318static inline void
319eina_condition_free(Eina_Condition *cond)
320{
321#ifdef EINA_HAVE_DEBUG_THREADS
322 if (!_eina_threads_activated)
323 assert(pthread_equal(_eina_main_loop, pthread_self()));
324#endif
325
326 pthread_cond_destroy(&(cond->condition));
327#ifdef EINA_HAVE_DEBUG_THREADS
328 memset(cond, 0, sizeof (Eina_Condition));
329#endif
330}
331
332static inline Eina_Bool
333eina_condition_wait(Eina_Condition *cond)
334{
335 Eina_Bool r;
336
337#ifdef EINA_HAVE_DEBUG_THREADS
338 assert(_eina_threads_activated);
339 assert(cond->lock != NULL);
340
341 pthread_mutex_lock(&_eina_tracking_lock);
342 _eina_tracking = eina_inlist_remove(_eina_tracking,
343 EINA_INLIST_GET(cond->lock));
344 pthread_mutex_unlock(&_eina_tracking_lock);
345#endif
346
347 r = pthread_cond_wait(&(cond->condition),
348 &(cond->lock->mutex)) == 0 ? EINA_TRUE : EINA_FALSE;
349
350#ifdef EINA_HAVE_DEBUG_THREADS
351 pthread_mutex_lock(&_eina_tracking_lock);
352 _eina_tracking = eina_inlist_append(_eina_tracking,
353 EINA_INLIST_GET(cond->lock));
354 pthread_mutex_unlock(&_eina_tracking_lock);
355#endif
356
357 return r;
358}
359
360static inline Eina_Bool
361eina_condition_timedwait(Eina_Condition *cond, double t)
362{
363 struct timespec tv;
364 Eina_Bool r;
365
366#ifdef EINA_HAVE_DEBUG_THREADS
367 assert(_eina_threads_activated);
368 assert(cond->lock != NULL);
369
370 pthread_mutex_lock(&_eina_tracking_lock);
371 _eina_tracking = eina_inlist_remove(_eina_tracking,
372 EINA_INLIST_GET(cond->lock));
373 pthread_mutex_unlock(&_eina_tracking_lock);
374#endif
375
376 tv.tv_sec = t;
377 tv.tv_nsec = (t - (double) tv.tv_sec) * 1000000000;
378
379 r = pthread_cond_timedwait(&(cond->condition),
380 &(cond->lock->mutex),
381 &tv) == 0 ?
382 EINA_TRUE : EINA_FALSE;
383
384#ifdef EINA_HAVE_DEBUG_THREADS
385 pthread_mutex_lock(&_eina_tracking_lock);
386 _eina_tracking = eina_inlist_append(_eina_tracking,
387 EINA_INLIST_GET(cond->lock));
388 pthread_mutex_unlock(&_eina_tracking_lock);
389#endif
390
391 return r;
392}
393
394static inline Eina_Bool
395eina_condition_broadcast(Eina_Condition *cond)
396{
397#ifdef EINA_HAVE_DEBUG_THREADS
398 assert(cond->lock != NULL);
399#endif
400
401 return pthread_cond_broadcast(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE;
402}
403
404static inline Eina_Bool
405eina_condition_signal(Eina_Condition *cond)
406{
407#ifdef EINA_HAVE_DEBUG_THREADS
408 assert(cond->lock != NULL);
409#endif
410
411 return pthread_cond_signal(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE;
412}
413
414static inline Eina_Bool
415eina_rwlock_new(Eina_RWLock *mutex)
416{
417#ifdef EINA_HAVE_DEBUG_THREADS
418 if (!_eina_threads_activated)
419 assert(pthread_equal(_eina_main_loop, pthread_self()));
420#endif
421
422 if (pthread_rwlock_init(&(mutex->mutex), NULL) != 0)
423 return EINA_FALSE;
424 return EINA_TRUE;
425}
426
427static inline void
428eina_rwlock_free(Eina_RWLock *mutex)
429{
430#ifdef EINA_HAVE_DEBUG_THREADS
431 if (!_eina_threads_activated)
432 assert(pthread_equal(_eina_main_loop, pthread_self()));
433#endif
434
435 pthread_rwlock_destroy(&(mutex->mutex));
436}
437
438static inline Eina_Lock_Result
439eina_rwlock_take_read(Eina_RWLock *mutex)
440{
441#ifdef EINA_HAVE_ON_OFF_THREADS
442 if (!_eina_threads_activated)
443 {
444#ifdef EINA_HAVE_DEBUG_THREADS
445 assert(pthread_equal(_eina_main_loop, pthread_self()));
446#endif
447 return EINA_LOCK_SUCCEED;
448 }
449#endif
450
451 if (pthread_rwlock_rdlock(&(mutex->mutex)) != 0)
452 return EINA_LOCK_FAIL;
453 return EINA_LOCK_SUCCEED;
454}
455
456static inline Eina_Lock_Result
457eina_rwlock_take_write(Eina_RWLock *mutex)
458{
459#ifdef EINA_HAVE_ON_OFF_THREADS
460 if (!_eina_threads_activated)
461 {
462#ifdef EINA_HAVE_DEBUG_THREADS
463 assert(pthread_equal(_eina_main_loop, pthread_self()));
464#endif
465 return EINA_LOCK_SUCCEED;
466 }
467#endif
468
469 if (pthread_rwlock_wrlock(&(mutex->mutex)) != 0)
470 return EINA_LOCK_FAIL;
471 return EINA_LOCK_SUCCEED;
472}
473
474static inline Eina_Lock_Result
475eina_rwlock_release(Eina_RWLock *mutex)
476{
477#ifdef EINA_HAVE_ON_OFF_THREADS
478 if (!_eina_threads_activated)
479 {
480#ifdef EINA_HAVE_DEBUG_THREADS
481 assert(pthread_equal(_eina_main_loop, pthread_self()));
482#endif
483 return EINA_LOCK_SUCCEED;
484 }
485#endif
486
487 if (pthread_rwlock_unlock(&(mutex->mutex)) != 0)
488 return EINA_LOCK_FAIL;
489 return EINA_LOCK_SUCCEED;
490}
491
492static inline Eina_Bool
493eina_tls_new(Eina_TLS *key)
494{
495 if (pthread_key_create(key, NULL) != 0)
496 return EINA_FALSE;
497 return EINA_TRUE;
498}
499
500static inline void
501eina_tls_free(Eina_TLS key)
502{
503 pthread_key_delete(key);
504}
505
506static inline void *
507eina_tls_get(Eina_TLS key)
508{
509 return pthread_getspecific(key);
510}
511
512static inline Eina_Bool
513eina_tls_set(Eina_TLS key, const void *data)
514{
515 if (pthread_setspecific(key, data) != 0)
516 return EINA_FALSE;
517 return EINA_TRUE;
518}
519
520static inline Eina_Bool
521eina_semaphore_new(Eina_Semaphore *sem, int count_init)
522{
523 if (!sem || (count_init <= 0))
524 return EINA_FALSE;
525
526 return (sem_init(sem, count_init, 1) == 0) ? EINA_TRUE : EINA_FALSE;
527}
528
529static inline Eina_Bool
530eina_semaphore_free(Eina_Semaphore *sem)
531{
532 if (!sem)
533 return EINA_FALSE;
534
535 return (sem_destroy(sem) == 0) ? EINA_TRUE : EINA_FALSE;
536}
537
538static inline Eina_Bool
539eina_semaphore_lock(Eina_Semaphore *sem)
540{
541 if (!sem)
542 return EINA_FALSE;
543
544 return (sem_wait(sem) == 0) ? EINA_TRUE : EINA_FALSE;
545}
546
547static inline Eina_Bool
548eina_semaphore_release(Eina_Semaphore *sem, int count_release EINA_UNUSED)
549{
550 if (!sem)
551 return EINA_FALSE;
552
553 return (sem_post(sem) == 0) ? EINA_TRUE : EINA_FALSE;
554}
555
556#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_void.x b/libraries/eina/src/include/eina_inline_lock_void.x
deleted file mode 100644
index 2f5209f..0000000
--- a/libraries/eina/src/include/eina_inline_lock_void.x
+++ /dev/null
@@ -1,273 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_VOID_X_
20#define EINA_INLINE_LOCK_VOID_X_
21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
31/**
32 * @addtogroup Eina_Lock_Group Lock
33 *
34 * @brief These functions provide Mutual Exclusion objects management.
35 *
36 * @note On Windows XP, critical sections are used, while on Windows
37 * CE, standard Mutex objects are used.
38 *
39 * @{
40 */
41
42/**
43 * @typedef Eina_Lock
44 * Abtract type for a mutual exclusive object.
45 */
46typedef void *Eina_Lock;
47typedef void *Eina_RWLock;
48typedef void *Eina_Condition;
49typedef void *Eina_TLS;
50typedef void *Eina_Semaphore;
51
52/**
53 * @brief Create a new #Eina_Lock.
54 *
55 * @param mutex A pointer to the lock object.
56 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
57 *
58 * This function creates a new #Eina_Lock object and stores it in the
59 * @p mutex buffer. On success, this function returns #EINA_TRUE and
60 * #EINA_FALSE otherwise. To free the resources allocated by this
61 * function, use eina_lock_free(). For performance reasons, no check
62 * is done on @p mutex.
63 */
64static inline Eina_Bool
65eina_lock_new(Eina_Lock *mutex EINA_UNUSED)
66{
67 return EINA_TRUE;
68}
69
70/**
71 * @brief Free the ressources of the given lock object.
72 *
73 * @param mutex The lock object to free.
74 *
75 * This function frees the resources of @p mutex allocated by
76 * eina_lock_new(). For performance reasons, no check is done on
77 * @p mutex.
78 */
79static inline void
80eina_lock_free(Eina_Lock *mutex EINA_UNUSED)
81{
82}
83
84/**
85 * @brief Lock the given mutual exclusion object.
86 *
87 * @param mutex The lock object to lock.
88 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
89 *
90 * This function locks @p mutex. @p mutex must have been created by
91 * eina_lock_new(). On success, this function returns #EINA_TRUE and
92 * #EINA_FALSE otherwise. For performance reasons, no check is done on
93 * @p mutex.
94 */
95static inline Eina_Lock_Result
96eina_lock_take(Eina_Lock *mutex EINA_UNUSED)
97{
98 return EINA_LOCK_SUCCEED;
99}
100
101/**
102 * @brief Try to lock the given mutual exclusion object.
103 *
104 * @param mutex The lock object to try to lock.
105 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
106 *
107 * This function tries to lock @p mutex. @p mutex must have been created by
108 * eina_lock_new(). If @p mutex can be locked, this function returns
109 * #EINA_TRUE; if @p mutex can not be locked, or is already locked, it
110 * returns #EINA_FALSE. This function does not block and returns
111 * immediately. For performance reasons, no check is done on
112 * @p mutex.
113 *
114 * @note On Windows CE, this function is actually eina_lock_take().
115 */
116static inline Eina_Lock_Result
117eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED)
118{
119 return EINA_LOCK_SUCCEED;
120}
121
122/**
123 * @brief Unlock the given mutual exclusion object.
124 *
125 * @param mutex The lock object to unlock.
126 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
127 *
128 * This function unlocks @p mutex. @p mutex must have been created by
129 * eina_lock_new(). On success, this function returns #EINA_TRUE and
130 * #EINA_FALSE otherwise. For performance reasons, no check is done on
131 * @p mutex.
132 */
133static inline Eina_Lock_Result
134eina_lock_release(Eina_Lock *mutex EINA_UNUSED)
135{
136 return EINA_LOCK_SUCCEED;
137}
138
139static inline void
140eina_lock_debug(const Eina_Lock *mutex EINA_UNUSED)
141{
142}
143
144static inline Eina_Bool
145eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED)
146{
147 return EINA_TRUE;
148}
149
150static inline void
151eina_condition_free(Eina_Condition *cond EINA_UNUSED)
152{
153}
154
155static inline Eina_Bool
156eina_condition_wait(Eina_Condition *cond EINA_UNUSED)
157{
158 return EINA_TRUE;
159}
160
161static inline Eina_Bool
162eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED)
163{
164 return EINA_TRUE;
165}
166
167static inline Eina_Bool
168eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED)
169{
170 return EINA_TRUE;
171}
172
173static inline Eina_Bool
174eina_condition_signal(Eina_Condition *cond EINA_UNUSED)
175{
176 return EINA_TRUE;
177}
178
179static inline Eina_Bool
180eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED)
181{
182 return EINA_TRUE;
183}
184
185static inline void
186eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED)
187{
188}
189
190static inline Eina_Lock_Result
191eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED)
192{
193 return EINA_LOCK_SUCCEED;
194}
195
196static inline Eina_Lock_Result
197eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED)
198{
199 return EINA_LOCK_SUCCEED;
200}
201
202static inline Eina_Lock_Result
203eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED)
204{
205 return EINA_LOCK_SUCCEED;
206}
207
208static inline Eina_Lock_Result
209eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED)
210{
211 return EINA_LOCK_SUCCEED;
212}
213
214static inline Eina_Lock_Result
215eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED)
216{
217 return EINA_LOCK_SUCCEED;
218}
219
220static inline Eina_Bool
221eina_tls_new(Eina_TLS *key EINA_UNUSED)
222{
223 return EINA_TRUE;
224}
225
226static inline void
227eina_tls_free(Eina_TLS key EINA_UNUSED)
228{
229}
230
231static inline void *
232eina_tls_get(Eina_TLS key EINA_UNUSED)
233{
234 return NULL;
235}
236
237static inline Eina_Bool
238eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED)
239{
240 return EINA_TRUE;
241}
242
243static inline Eina_Bool
244eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED,
245 int count_init EINA_UNUSED)
246{
247 return EINA_TRUE;
248}
249
250static inline Eina_Bool
251eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED)
252{
253 return EINA_TRUE;
254}
255
256static inline Eina_Bool
257eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED)
258{
259 return EINA_TRUE;
260}
261
262static inline Eina_Bool
263eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED,
264 int count_release EINA_UNUSED)
265{
266 return EINA_TRUE;
267}
268
269/**
270 * @}
271 */
272
273#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x
deleted file mode 100644
index 1988724..0000000
--- a/libraries/eina/src/include/eina_inline_lock_win32.x
+++ /dev/null
@@ -1,550 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_WIN32_X_
20#define EINA_INLINE_LOCK_WIN32_X_
21
22#include <windows.h>
23
24typedef CRITICAL_SECTION Eina_Lock;
25typedef struct _Eina_Condition Eina_Condition;
26typedef struct _Eina_RWLock Eina_RWLock;
27typedef DWORD Eina_TLS;
28typedef HANDLE Eina_Semaphore;
29
30#if _WIN32_WINNT >= 0x0600
31struct _Eina_Condition
32{
33 CRITICAL_SECTION *mutex;
34 CONDITION_VARIABLE condition;
35};
36
37struct _Eina_RWLock
38{
39 SRWLOCK mutex;
40
41 Eina_Bool is_read_mode : 1;
42};
43#else
44struct _Eina_Condition
45{
46 int waiters_count;
47 CRITICAL_SECTION waiters_count_lock;
48 CRITICAL_SECTION *mutex;
49 HANDLE semaphore;
50 HANDLE waiters_done;
51 Eina_Bool was_broadcast;
52};
53
54struct _Eina_RWLock
55{
56 LONG readers_count;
57 LONG writers_count;
58 int readers;
59 int writers;
60
61 Eina_Lock mutex;
62 Eina_Condition cond_read;
63 Eina_Condition cond_write;
64};
65#endif
66
67
68EAPI extern Eina_Bool _eina_threads_activated;
69
70
71static inline Eina_Bool
72eina_lock_new(Eina_Lock *mutex)
73{
74 InitializeCriticalSection(mutex);
75
76 return EINA_TRUE;
77}
78
79static inline void
80eina_lock_free(Eina_Lock *mutex)
81{
82 DeleteCriticalSection(mutex);
83}
84
85static inline Eina_Lock_Result
86eina_lock_take(Eina_Lock *mutex)
87{
88#ifdef EINA_HAVE_ON_OFF_THREADS
89 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
90#endif
91
92 EnterCriticalSection(mutex);
93
94 return EINA_LOCK_SUCCEED;
95}
96
97static inline Eina_Lock_Result
98eina_lock_take_try(Eina_Lock *mutex)
99{
100#ifdef EINA_HAVE_ON_OFF_THREADS
101 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
102#endif
103
104 return TryEnterCriticalSection(mutex) == 0 ? EINA_LOCK_FAIL : EINA_LOCK_SUCCEED;
105}
106
107static inline Eina_Lock_Result
108eina_lock_release(Eina_Lock *mutex)
109{
110#ifdef EINA_HAVE_ON_OFF_THREADS
111 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
112#endif
113
114 LeaveCriticalSection(mutex);
115
116 return EINA_LOCK_SUCCEED;
117}
118
119static inline void
120eina_lock_debug(const Eina_Lock *mutex)
121{
122 (void)mutex;
123}
124
125static inline Eina_Bool
126eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
127{
128 cond->mutex = mutex;
129#if _WIN32_WINNT >= 0x0600
130 InitializeConditionVariable(&cond->condition);
131#else
132 cond->waiters_count = 0;
133 cond->was_broadcast = EINA_FALSE;
134 cond->semaphore = CreateSemaphore(NULL, // no security
135 0, // initially 0
136 0x7fffffff, // max count
137 NULL); // unnamed
138 if (!cond->semaphore)
139 return EINA_FALSE;
140
141 InitializeCriticalSection(&cond->waiters_count_lock);
142
143 cond->waiters_done = CreateEvent(NULL, // no security
144 FALSE, // auto-reset
145 FALSE, // non-signaled initially
146 NULL); // unnamed
147 if (!cond->waiters_done)
148 {
149 CloseHandle(cond->semaphore);
150 return EINA_FALSE;
151 }
152#endif
153
154 return EINA_TRUE;
155}
156
157static inline void
158eina_condition_free(Eina_Condition *cond)
159{
160#if _WIN32_WINNT >= 0x0600
161 /* Nothing to do */
162 (void)cond;
163#else
164 CloseHandle(cond->waiters_done);
165 DeleteCriticalSection(&cond->waiters_count_lock);
166 CloseHandle(cond->semaphore);
167#endif
168}
169
170static inline Eina_Bool
171_eina_condition_internal_timedwait(Eina_Condition *cond, DWORD t)
172{
173#if _WIN32_WINNT >= 0x0600
174 SleepConditionVariableCS(&cond->condition, cond->mutex, t);
175#else
176 DWORD ret;
177 Eina_Bool last_waiter;
178
179 /* Avoid race conditions. */
180 EnterCriticalSection(&cond->waiters_count_lock);
181 cond->waiters_count++;
182 LeaveCriticalSection(&cond->waiters_count_lock);
183
184 /*
185 * This call atomically releases the mutex and waits on the
186 * semaphore until <pthread_cond_signal> or <pthread_cond_broadcast>
187 * are called by another thread.
188 */
189 ret = SignalObjectAndWait(cond->mutex, cond->semaphore, t, FALSE);
190 if (ret == WAIT_FAILED)
191 return EINA_FALSE;
192
193 /* Reacquire lock to avoid race conditions. */
194 EnterCriticalSection(&cond->waiters_count_lock);
195
196 /* We're no longer waiting... */
197 cond->waiters_count--;
198
199 /* Check to see if we're the last waiter after <pthread_cond_broadcast>. */
200 last_waiter = (cond->was_broadcast) && (cond->waiters_count == 0);
201
202 LeaveCriticalSection(&cond->waiters_count_lock);
203
204 /*
205 * If we're the last waiter thread during this particular broadcast
206 * then let all the other threads proceed.
207 */
208 if (last_waiter)
209 {
210 /*
211 * This call atomically signals the <waiters_done_> event and waits until
212 * it can acquire the <external_mutex>. This is required to ensure fairness.
213 */
214 ret = SignalObjectAndWait(cond->waiters_done, cond->mutex, t, FALSE);
215 if (ret == WAIT_FAILED)
216 return EINA_FALSE;
217 }
218 else
219 {
220 /*
221 * Always regain the external mutex since that's the guarantee we
222 * give to our callers.
223 */
224 ret = WaitForSingleObject(cond->mutex, t);
225 if (ret == WAIT_FAILED)
226 return EINA_FALSE;
227 }
228#endif
229
230 return EINA_TRUE;
231}
232
233static inline Eina_Bool
234eina_condition_timedwait(Eina_Condition *cond, double val)
235{
236 return _eina_condition_internal_timedwait(cond, (DWORD)(val * 1000));
237}
238
239static inline Eina_Bool
240eina_condition_wait(Eina_Condition *cond)
241{
242 return _eina_condition_internal_timedwait(cond, INFINITE);
243}
244
245static inline Eina_Bool
246eina_condition_broadcast(Eina_Condition *cond)
247{
248#if _WIN32_WINNT >= 0x0600
249 WakeAllConditionVariable(&cond->condition);
250 return EINA_TRUE;
251#else
252 Eina_Bool have_waiters;
253
254 /*
255 * This is needed to ensure that <waiters_count_> and <was_broadcast_> are
256 * consistent relative to each other.
257 */
258 EnterCriticalSection(&cond->waiters_count_lock);
259 have_waiters = EINA_FALSE;
260
261 if (cond->waiters_count > 0)
262 {
263 /*
264 * We are broadcasting, even if there is just one waiter...
265 * Record that we are broadcasting, which helps optimize
266 * <pthread_cond_wait> for the non-broadcast case.
267 */
268 cond->was_broadcast = EINA_TRUE;
269 have_waiters = EINA_TRUE;
270 }
271
272 if (have_waiters)
273 {
274 DWORD ret;
275
276 /* Wake up all the waiters atomically. */
277 ret = ReleaseSemaphore(cond->semaphore, cond->waiters_count, 0);
278 LeaveCriticalSection(&cond->waiters_count_lock);
279 if (!ret) return EINA_FALSE;
280
281 /*
282 * Wait for all the awakened threads to acquire the counting
283 * semaphore.
284 */
285 ret = WaitForSingleObject(cond->waiters_done, INFINITE);
286 if (ret == WAIT_FAILED)
287 return EINA_FALSE;
288 /*
289 * This assignment is okay, even without the <waiters_count_lock_> held
290 * because no other waiter threads can wake up to access it.
291 */
292 cond->was_broadcast = EINA_FALSE;
293 }
294 else
295 LeaveCriticalSection(&cond->waiters_count_lock);
296
297 return EINA_TRUE;
298#endif
299}
300
301static inline Eina_Bool
302eina_condition_signal(Eina_Condition *cond)
303{
304#if _WIN32_WINNT >= 0x0600
305 WakeConditionVariable(&cond->condition);
306#else
307 Eina_Bool have_waiters;
308
309 EnterCriticalSection(&cond->waiters_count_lock);
310 have_waiters = (cond->waiters_count > 0);
311 LeaveCriticalSection(&cond->waiters_count_lock);
312
313 /* If there aren't any waiters, then this is a no-op. */
314 if (have_waiters)
315 {
316 if (!ReleaseSemaphore(cond->semaphore, 1, 0))
317 return EINA_FALSE;
318 }
319#endif
320
321 return EINA_TRUE;
322}
323
324static inline Eina_Bool
325eina_rwlock_new(Eina_RWLock *mutex)
326{
327#if _WIN32_WINNT >= 0x0600
328 InitializeSRWLock(&mutex->mutex);
329 return EINA_TRUE;
330#else
331 if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE;
332 if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex)))
333 goto on_error1;
334 if (!eina_condition_new(&(mutex->cond_write), &(mutex->mutex)))
335 goto on_error2;
336
337 mutex->readers_count = 0;
338 mutex->writers_count = 0;
339 mutex->readers = 0;
340 mutex->writers = 0;
341
342 return EINA_TRUE;
343
344 on_error2:
345 eina_condition_free(&(mutex->cond_read));
346 on_error1:
347 eina_lock_free(&(mutex->mutex));
348 return EINA_FALSE;
349#endif
350}
351
352static inline void
353eina_rwlock_free(Eina_RWLock *mutex)
354{
355#if _WIN32_WINNT >= 0x0600
356 (void)mutex;
357#else
358 eina_condition_free(&(mutex->cond_read));
359 eina_condition_free(&(mutex->cond_write));
360 eina_lock_free(&(mutex->mutex));
361#endif
362}
363
364static inline Eina_Lock_Result
365eina_rwlock_take_read(Eina_RWLock *mutex)
366{
367#if _WIN32_WINNT >= 0x0600
368 AcquireSRWLockShared(&mutex->mutex);
369 mutex->is_read_mode = EINA_TRUE;
370#else
371 DWORD res = 0;
372
373 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
374 return EINA_LOCK_FAIL;
375
376 if (mutex->writers)
377 {
378 mutex->readers_count++;
379 while (mutex->writers)
380 {
381 EnterCriticalSection(&mutex->cond_write.waiters_count_lock);
382 mutex->cond_read.waiters_count++;
383 LeaveCriticalSection(&mutex->cond_write.waiters_count_lock);
384 res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE);
385 if (res != WAIT_OBJECT_0) break;
386 }
387 mutex->readers_count--;
388 }
389 if (res == 0)
390 mutex->readers++;
391 eina_lock_release(&(mutex->mutex));
392#endif
393
394 return EINA_LOCK_SUCCEED;
395}
396
397static inline Eina_Lock_Result
398eina_rwlock_take_write(Eina_RWLock *mutex)
399{
400#if _WIN32_WINNT >= 0x0600
401 AcquireSRWLockExclusive(&mutex->mutex);
402 mutex->is_read_mode = EINA_FALSE;
403#else
404 DWORD res = 0;
405
406 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
407 return EINA_LOCK_FAIL;
408
409 if (mutex->writers || mutex->readers > 0)
410 {
411 mutex->writers_count++;
412 while (mutex->writers || mutex->readers > 0)
413 {
414 EnterCriticalSection(&mutex->cond_write.waiters_count_lock);
415 mutex->cond_read.waiters_count++;
416 LeaveCriticalSection(&mutex->cond_write.waiters_count_lock);
417 res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE);
418 if (res != WAIT_OBJECT_0) break;
419 }
420 mutex->writers_count--;
421 }
422 if (res == 0) mutex->writers = 1;
423 eina_lock_release(&(mutex->mutex));
424#endif
425
426 return EINA_LOCK_SUCCEED;
427}
428
429static inline Eina_Lock_Result
430eina_rwlock_release(Eina_RWLock *mutex)
431{
432#if _WIN32_WINNT >= 0x0600
433 if (mutex->is_read_mode)
434 ReleaseSRWLockShared(&mutex->mutex);
435 else
436 ReleaseSRWLockExclusive(&mutex->mutex);
437#else
438 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
439 return EINA_LOCK_FAIL;
440
441 if (mutex->writers)
442 {
443 mutex->writers = 0;
444 if (mutex->readers_count == 1)
445 {
446 EnterCriticalSection(&mutex->cond_read.waiters_count_lock);
447 if (mutex->cond_read.waiters_count > 0)
448 ReleaseSemaphore(mutex->cond_read.semaphore, 1, 0);
449 LeaveCriticalSection(&mutex->cond_read.waiters_count_lock);
450 }
451 else if (mutex->readers_count > 0)
452 eina_condition_broadcast(&(mutex->cond_read));
453 else if (mutex->writers_count > 0)
454 {
455 EnterCriticalSection (&mutex->cond_write.waiters_count_lock);
456 if (mutex->cond_write.waiters_count > 0)
457 ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0);
458 LeaveCriticalSection (&mutex->cond_write.waiters_count_lock);
459 }
460 }
461 else if (mutex->readers > 0)
462 {
463 mutex->readers--;
464 if (mutex->readers == 0 && mutex->writers_count > 0)
465 {
466 EnterCriticalSection (&mutex->cond_write.waiters_count_lock);
467 if (mutex->cond_write.waiters_count > 0)
468 ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0);
469 LeaveCriticalSection (&mutex->cond_write.waiters_count_lock);
470 }
471 }
472 eina_lock_release(&(mutex->mutex));
473#endif
474
475 return EINA_LOCK_SUCCEED;
476}
477
478static inline Eina_Bool
479eina_tls_new(Eina_TLS *key)
480{
481 if ((*key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
482 return EINA_FALSE;
483 return EINA_TRUE;
484}
485
486static inline void
487eina_tls_free(Eina_TLS key)
488{
489 TlsFree(key);
490}
491
492static inline void *
493eina_tls_get(Eina_TLS key)
494{
495 return (void*)TlsGetValue(key);
496}
497
498static inline Eina_Bool
499eina_tls_set(Eina_TLS key, const void *data)
500{
501 if (TlsSetValue(key, (LPVOID)data) == 0)
502 return EINA_FALSE;
503 return EINA_TRUE;
504}
505
506static inline Eina_Bool
507eina_semaphore_new(Eina_Semaphore *sem, int count_init)
508{
509 if (!sem || (count_init <= 0))
510 return EINA_FALSE;
511
512 *sem = CreateSemaphore(NULL, count_init, 32767, NULL);
513 if (!*sem)
514 return EINA_FALSE;
515}
516
517static inline Eina_Bool
518eina_semaphore_free(Eina_Semaphore *sem)
519{
520 if (!sem)
521 return EINA_FALSE;
522
523 CloseHandle(*sem);
524}
525
526static inline Eina_Bool
527eina_semaphore_lock(Eina_Semaphore *sem)
528{
529 DWORD res;
530
531 if (!sem)
532 return EINA_FALSE;
533
534 res = WaitForSingleObject(*sem, 0L);
535 if (res == WAIT_OBJECT_0)
536 return EINA_TRUE;
537
538 return EINA_FALSE;
539}
540
541static inline Eina_Bool
542eina_semaphore_release(Eina_Semaphore *sem, int count_release)
543{
544 if (!sem)
545 return EINA_FALSE;
546
547 return ReleaseSemaphore(*sem, count_release, NULL) ? EINA_TRUE : EINA_FALSE;
548}
549
550#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x
deleted file mode 100644
index 1af1aac..0000000
--- a/libraries/eina/src/include/eina_inline_lock_wince.x
+++ /dev/null
@@ -1,212 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_WIN32_X_
20#define EINA_INLINE_LOCK_WIN32_X_
21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
31#include <windows.h>
32
33EAPI extern Eina_Bool _threads_activated;
34
35typedef HANDLE Eina_Lock;
36typedef Eina_Lock Eina_RWLock;
37typedef DWORD Eina_TLS;
38typedef void * Eina_Semaphore;
39
40static inline Eina_Bool
41eina_lock_new(Eina_Lock *mutex)
42{
43 Eina_Lock m;
44
45 m = CreateMutex(NULL, FALSE, NULL);
46 if (m) *mutex = m;
47 return (m != NULL);
48}
49
50static inline void
51eina_lock_free(Eina_Lock *mutex)
52{
53 CloseHandle(*mutex);
54}
55
56static inline Eina_Lock_Result
57eina_lock_take(Eina_Lock *mutex)
58{
59 DWORD res;
60
61#ifdef EINA_HAVE_ON_OFF_THREADS
62 if (!_eina_threads_activated) return EINA_LOCK_FAIL;
63#endif
64
65 res = WaitForSingleObject(*mutex, INFINITE);
66 if ((res == WAIT_ABANDONED) || (res == WAIT_FAILED))
67 return EINA_LOCK_FAIL;
68
69 return EINA_LOCK_SUCCEED;
70}
71
72static inline Eina_Lock_Result
73eina_lock_take_try(Eina_Lock *mutex)
74{
75 return eina_lock_take(*mutex);
76}
77
78static inline Eina_Lock_Result
79eina_lock_release(Eina_Lock *mutex)
80{
81#ifdef EINA_HAVE_ON_OFF_THREADS
82 if (!_eina_threads_activated) return ;
83#endif
84
85 return ReleaseMutex(*mutex) ? EINA_LOCK_SUCCEED : EINA_LOCK_FAIL;
86}
87
88static inline void
89eina_lock_debug(const Eina_Lock *mutex)
90{
91}
92
93static inline Eina_Bool
94eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
95{
96 return EINA_FALSE;
97}
98
99static inline void
100eina_condition_free(Eina_Condition *cond)
101{
102}
103
104static inline Eina_Bool
105eina_condition_wait(Eina_Condition *cond)
106{
107 return EINA_FALSE;
108}
109
110static inline Eina_Bool
111eina_condition_timedwait(Eina_Condition *cond, double t)
112{
113 return EINA_FALSE;
114}
115
116static inline Eina_Bool
117eina_condition_broadcast(Eina_Condition *cond)
118{
119 return EINA_FALSE;
120}
121
122static inline Eina_Bool
123eina_condition_signal(Eina_Condition *cond)
124{
125 return EINA_FALSE;
126}
127
128static inline Eina_Bool
129eina_rwlock_new(Eina_RWLock *mutex)
130{
131 return eina_lock_new(mutex);
132}
133
134static inline void
135eina_rwlock_free(Eina_RWLock *mutex)
136{
137 return eina_lock_free(mutex);
138}
139
140static inline Eina_Lock_Result
141eina_rwlock_take_read(Eina_RWLock *mutex)
142{
143 return eina_lock_take(mutex);
144}
145
146static inline Eina_Lock_Result
147eina_rwlock_take_write(Eina_RWLock *mutex)
148{
149 return eina_lock_take(mutex);
150}
151
152static inline Eina_Lock_Result
153eina_rwlock_release(Eina_RWLock *mutex)
154{
155 return eina_lock_release(mutex);
156}
157
158static inline Eina_Bool
159eina_tls_new(Eina_TLS *key)
160{
161 if (TlsAlloc() == TLS_OUT_OF_INDEXES)
162 return EINA_FALSE;
163 return EINA_TRUE;
164}
165
166static inline void
167eina_tls_free(Eina_TLS key)
168{
169 TlsFree(key);
170}
171
172static inline void *
173eina_tls_get(Eina_TLS key)
174{
175 return (void*)TlsGetValue(key);
176}
177
178static inline Eina_Bool
179eina_tls_set(Eina_TLS key, const void *data)
180{
181 if (TlsSetValue(key, (LPVOID)data) == 0)
182 return EINA_FALSE;
183 return EINA_TRUE;
184}
185
186static inline Eina_Bool
187eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED,
188 int count_init EINA_UNUSED)
189{
190 return EINA_FALSE;
191}
192
193static inline Eina_Bool
194eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED)
195{
196 return EINA_FALSE;
197}
198
199static inline Eina_Bool
200eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED)
201{
202 return EINA_FALSE;
203}
204
205static inline Eina_Bool
206eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED,
207 int count_release EINA_UNUSED)
208{
209 return EINA_FALSE;
210}
211
212#endif
diff --git a/libraries/eina/src/include/eina_inline_log.x b/libraries/eina/src/include/eina_inline_log.x
deleted file mode 100644
index 53d8afb..0000000
--- a/libraries/eina/src/include/eina_inline_log.x
+++ /dev/null
@@ -1,197 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOG_INLINE_H_
20#define EINA_LOG_INLINE_H_
21
22/**
23 * @addtogroup Eina_Log_Group Log
24 *
25 * @{
26 */
27
28/**
29 * Checks whenever the given level should be printed out.
30 *
31 * This is useful to enable certain blocks of code just when given
32 * level is to be used.
33 *
34 * @code
35 * #include <Eina.h>
36 *
37 * void my_func(void *data)
38 * {
39 * if (eina_log_level_check(EINA_LOG_LEVEL_WARN))
40 * expensive_debugging_code(data);
41 *
42 * my_func_code(data);
43 * }
44 * @endcode
45 *
46 * @return #EINA_TRUE if level is equal or smaller than the current global
47 * logging level.
48 */
49static inline Eina_Bool
50eina_log_level_check(int level)
51{
52 return eina_log_level_get() >= level;
53}
54
55/**
56 * Checks whenever the given level should be printed out.
57 *
58 * This is useful to enable certain blocks of code just when given
59 * level is to be used.
60 *
61 * @code
62 * #include <Eina.h>
63 *
64 * extern int _my_log_dom;
65 *
66 * void my_func(void *data)
67 * {
68 * if (eina_log_domain_level_check(_my_log_dom, EINA_LOG_LEVEL_WARN))
69 * expensive_debugging_code(data);
70 *
71 * my_func_code(data);
72 * }
73 * @endcode
74 *
75 * @return #EINA_TRUE if level is equal or smaller than the current
76 * domain logging level.
77 */
78static inline Eina_Bool
79eina_log_domain_level_check(int domain, int level)
80{
81 int dom_level = eina_log_domain_registered_level_get(domain);
82 if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN))
83 return EINA_FALSE;
84 return dom_level >= level;
85}
86
87/**
88 * Function to format the level as a 3 character (+1 null byte) string.
89 *
90 * This function converts the given level to a known string name (CRI,
91 * ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any
92 * case the last byte will contain a trailing null byte.
93 *
94 * If extreme level values are used (greater than 999 and smaller than
95 * -99), then the value will just consider the less significant
96 * part. This is so uncommon that users should handle this in their
97 * code.
98 *
99 * @param level what level value to use.
100 * @param name where to write the actual value.
101 *
102 * @return pointer to @p name.
103 */
104static inline const char *
105eina_log_level_name_get(int level, char name[4])
106{
107#define BCPY(A, B, C) \
108 do { name[0] = A; name[1] = B; name[2] = C; } while (0)
109
110 if (EINA_UNLIKELY(level < 0))
111 {
112 name[0] = '-';
113 name[1] = '0' + (-level / 10) % 10;
114 name[2] = '0' + (-level % 10);
115 }
116 else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
117 {
118 name[0] = '0' + (level / 100) % 10;
119 name[1] = '0' + (level / 10) % 10;
120 name[2] = '0' + level % 10;
121 }
122 else if (level == 0)
123 BCPY('C', 'R', 'I');
124 else if (level == 1)
125 BCPY('E', 'R', 'R');
126 else if (level == 2)
127 BCPY('W', 'R', 'N');
128 else if (level == 3)
129 BCPY('I', 'N', 'F');
130 else if (level == 4)
131 BCPY('D', 'B', 'G');
132 else
133 BCPY('?', '?', '?');
134
135 name[3] = '\0';
136
137 return name;
138}
139
140/**
141 * Function to get recommended color value for level.
142 *
143 * This function will not check if colors are enabled or not before
144 * returning the level color. If you desire such check, use
145 * eina_log_level_color_if_enabled_get().
146 *
147 * @param level what level value to use.
148 *
149 * @return pointer to null byte terminated ANSI color string to be
150 * used in virtual terminals supporting VT100 color codes.
151 *
152 * @see eina_log_level_color_if_enabled_get()
153 */
154static inline const char *
155eina_log_level_color_get(int level)
156{
157 if (level <= 0)
158 return EINA_COLOR_LIGHTRED;
159 else if (level == 1)
160 return EINA_COLOR_RED;
161 else if (level == 2)
162 return EINA_COLOR_YELLOW;
163 else if (level == 3)
164 return EINA_COLOR_GREEN;
165 else if (level == 4)
166 return EINA_COLOR_LIGHTBLUE;
167 else
168 return EINA_COLOR_BLUE;
169}
170
171/**
172 * Function to get recommended color value for level, if colors are
173 * enabled.
174 *
175 * This function will check if colors are enabled or not before
176 * returning the level color. If colors are disabled, then empty
177 * string is returned.
178 *
179 * @param level what level value to use.
180 *
181 * @return pointer to null byte terminated ANSI color string to be
182 * used in virtual terminals supporting VT100 color codes. If
183 * colors are disabled, the empty string is returned.
184 */
185static inline const char *
186eina_log_level_color_if_enabled_get(int level)
187{
188 if (eina_log_color_disable_get())
189 return "";
190 return eina_log_level_color_get(level);
191}
192
193/**
194 * @}
195 */
196
197#endif /* EINA_LOG_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x
deleted file mode 100644
index 729a669..0000000
--- a/libraries/eina/src/include/eina_inline_mempool.x
+++ /dev/null
@@ -1,148 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_MEMPOOL_X_
20#define EINA_INLINE_MEMPOOL_X_
21
22#include <string.h>
23
24/**
25 * @addtogroup Eina_Memory_Pool_Group Memory Pool
26 *
27 * @{
28 */
29
30/* Memory Pool */
31typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1;
32typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2;
33
34struct _Eina_Mempool_Backend
35{
36 const char *name;
37 void *(*init)(const char *context, const char *options, va_list args);
38 void (*free)(void *data, void *element);
39 void *(*alloc)(void *data, unsigned int size);
40 void *(*realloc)(void *data, void *element, unsigned int size);
41 void (*garbage_collect)(void *data);
42 void (*statistics)(void *data);
43 void (*shutdown)(void *data);
44 void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
45};
46
47struct _Eina_Mempool_Backend_ABI1
48{
49 const char *name;
50 void *(*init)(const char *context, const char *options, va_list args);
51 void (*free)(void *data, void *element);
52 void *(*alloc)(void *data, unsigned int size);
53 void *(*realloc)(void *data, void *element, unsigned int size);
54 void (*garbage_collect)(void *data);
55 void (*statistics)(void *data);
56 void (*shutdown)(void *data);
57};
58
59struct _Eina_Mempool_Backend_ABI2
60{
61 void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
62};
63
64struct _Eina_Mempool
65{
66 Eina_Mempool_Backend_ABI1 backend;
67 void *backend_data;
68 Eina_Mempool_Backend_ABI2 *backend2;
69};
70
71/**
72 * @brief Re-allocate an amount memory by the given mempool.
73 *
74 * @param mp The mempool.
75 * @param element The element to re-allocate.
76 * @param size The size in bytes to re-allocate.
77 * @return The newly re-allocated data.
78 *
79 * This function re-allocates and returns @p element with @p size bytes using the
80 * mempool @p mp. If not used anymore, the data must be freed with eina_mempool_free().
81 * @warning No checks are done for @p mp.
82 */
83static inline void *
84eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
85{
86 return mp->backend.realloc(mp->backend_data, element, size);
87}
88
89/**
90 * @brief Allocate memory using the given mempool.
91 *
92 * @param mp The mempool.
93 * @param size The size in bytes to allocate.
94 * @return The newly allocated data.
95 *
96 * This function allocates and returns @p size bytes using the mempool @p mp.
97 * If not used anymore, the data must be freed with eina_mempool_free().
98 * @warning No checks are done for @p mp.
99 */
100static inline void *
101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
102{
103 return mp->backend.alloc(mp->backend_data, size);
104}
105
106/**
107 * @brief Allocate and zero memory using the given mempool.
108 *
109 * @param mp The mempool.
110 * @param size The size in bytes to allocate.
111 * @return The newly allocated data.
112 *
113 * This function allocates, zeroes, and returns @p size bytes using the mempool @p mp.
114 * If not used anymore, the data must be freed with eina_mempool_free().
115 * @warning No checks are done for @p mp.
116 * @since 1.2
117 */
118static inline void *
119eina_mempool_calloc(Eina_Mempool *mp, unsigned int size)
120{
121 void *r = mp->backend.alloc(mp->backend_data, size);
122 if (!r) return NULL;
123 memset(r, 0, size);
124 return r;
125}
126
127/**
128 * @brief Free resources previously allocated by the given mempool.
129 *
130 * @param mp The mempool.
131 * @param element The data to free.
132 *
133 * This function frees @p element allocated by @p mp. @p element must
134 * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or
135 * eina_mempool_realloc().
136 * @warning No checks are done for @p mp.
137 */
138static inline void
139eina_mempool_free(Eina_Mempool *mp, void *element)
140{
141 mp->backend.free(mp->backend_data, element);
142}
143
144/**
145 * @}
146 */
147
148#endif
diff --git a/libraries/eina/src/include/eina_inline_rbtree.x b/libraries/eina/src/include/eina_inline_rbtree.x
deleted file mode 100644
index 954774b..0000000
--- a/libraries/eina/src/include/eina_inline_rbtree.x
+++ /dev/null
@@ -1,50 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RBTREE_INLINE_H_
20#define EINA_RBTREE_INLINE_H_
21
22/**
23 * @addtogroup Eina_Rbtree_Group Red-Black tree
24 *
25 * @brief These functions provide Red-Black trees management.
26 *
27 * @{
28 */
29
30static inline Eina_Rbtree *
31eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data)
32{
33 int result;
34
35 while (root)
36 {
37 result = cmp(root, key, length, (void*) data);
38 if (result == 0) return (Eina_Rbtree*) root;
39
40 root = root->son[result < 0 ? 0 : 1];
41 }
42
43 return NULL;
44}
45
46/**
47 * @}
48 */
49
50#endif
diff --git a/libraries/eina/src/include/eina_inline_rectangle.x b/libraries/eina/src/include/eina_inline_rectangle.x
deleted file mode 100644
index 29ad24b..0000000
--- a/libraries/eina/src/include/eina_inline_rectangle.x
+++ /dev/null
@@ -1,254 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_RECTANGLE_H__
20#define EINA_INLINE_RECTANGLE_H__
21
22/**
23 * @addtogroup Eina_Rectangle_Group Rectangle
24 *
25 * @brief These functions provide rectangle management.
26 *
27 * @{
28 */
29
30/**
31 * @brief Check if the given spans intersect.
32 *
33 * @param c1 The column of the first span.
34 * @param l1 The length of the first span.
35 * @param c2 The column of the second span.
36 * @param l2 The length of the second span.
37 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
38 *
39 * This function returns #EINA_TRUE if the given spans intersect,
40 * #EINA_FALSE otherwise.
41 */
42static inline int
43eina_spans_intersect(int c1, int l1, int c2, int l2)
44{
45 return (!(((c2 + l2) <= c1) || (c2 >= (c1 + l1))));
46}
47
48/**
49 * @brief Check if the given rectangle is empty.
50 *
51 * @param r The rectangle to check.
52 * @return #EINA_TRUE if the rectangle is empty, #EINA_FALSE otherwise.
53 *
54 * This function returns #EINA_TRUE if @p r is empty, #EINA_FALSE
55 * otherwise. No check is done on @p r, so it must be a valid
56 * rectangle.
57 */
58static inline Eina_Bool
59eina_rectangle_is_empty(const Eina_Rectangle *r)
60{
61 return ((r->w < 1) || (r->h < 1)) ? EINA_TRUE : EINA_FALSE;
62}
63
64/**
65 * @brief Set the coordinates and size of the given rectangle.
66 *
67 * @param r The rectangle.
68 * @param x The top-left x coordinate of the rectangle.
69 * @param y The top-left y coordinate of the rectangle.
70 * @param w The width of the rectangle.
71 * @param h The height of the rectangle.
72 *
73 * This function sets its top-left x coordinate to @p x, its top-left
74 * y coordinate to @p y, its width to @p w and its height to @p h. No
75 * check is done on @p r, so it must be a valid rectangle.
76 */
77static inline void
78eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h)
79{
80 r->x = x;
81 r->y = y;
82 r->w = w;
83 r->h = h;
84}
85
86/**
87 * @brief Check if the given rectangles intersect.
88 *
89 * @param r1 The first rectangle.
90 * @param r2 The second rectangle.
91 * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE otherwise.
92 *
93 * This function returns #EINA_TRUE if @p r1 and @p r2 intersect,
94 * #EINA_FALSE otherwise. No check is done on @p r1 and @p r2, so they
95 * must be valid rectangles.
96 */
97static inline Eina_Bool
98eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2)
99{
100 return (eina_spans_intersect(r1->x, r1->w, r2->x, r2->w) && eina_spans_intersect(r1->y, r1->h, r2->y, r2->h)) ? EINA_TRUE : EINA_FALSE;
101}
102
103/**
104 * @brief Check if the given x-coordinate is in the rectangle .
105 *
106 * @param r The rectangle.
107 * @param x The x coordinate.
108 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
109 *
110 * This function returns #EINA_TRUE if @p x is in @p r with respect to
111 * the horizontal direction, #EINA_FALSE otherwise. No check is done
112 * on @p r, so it must be a valid rectangle.
113 */
114static inline Eina_Bool
115eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x)
116{
117 return ((x >= r->x) && (x < (r->x + r->w))) ? EINA_TRUE : EINA_FALSE;
118}
119
120/**
121 * @brief Check if the given y-coordinate is in the rectangle .
122 *
123 * @param r The rectangle.
124 * @param y The y coordinate.
125 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
126 *
127 * This function returns #EINA_TRUE if @p y is in @p r with respect to
128 * the vertical direction, #EINA_FALSE otherwise. No check is done
129 * on @p r, so it must be a valid rectangle.
130 */
131static inline Eina_Bool
132eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y)
133{
134 return ((y >= r->y) && (y < (r->y + r->h))) ? EINA_TRUE : EINA_FALSE;
135}
136
137/**
138 * @brief Check if the given point is in the rectangle .
139 *
140 * @param r The rectangle.
141 * @param x The x coordinate of the point.
142 * @param y The y coordinate of the point.
143 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
144 *
145 * This function returns #EINA_TRUE if the point of coordinate (@p x,
146 * @p y) is in @p r, #EINA_FALSE otherwise. No check is done on @p r,
147 * so it must be a valid rectangle.
148 */
149static inline Eina_Bool
150eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y)
151{
152 return (eina_rectangle_xcoord_inside(r, x) && eina_rectangle_ycoord_inside(r, y)) ? EINA_TRUE : EINA_FALSE;
153}
154
155/**
156 * @brief Get the union of two rectangles.
157 *
158 * @param dst The first rectangle.
159 * @param src The second rectangle.
160 *
161 * This function get the union of the rectangles @p dst and @p src. The
162 * result is stored in @p dst. No check is done on @p dst or @p src,
163 * so they must be valid rectangles.
164 */
165static inline void
166eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src)
167{
168 /* left */
169 if (dst->x > src->x)
170 {
171 dst->w += dst->x - src->x;
172 dst->x = src->x;
173 }
174 /* right */
175 if ((dst->x + dst->w) < (src->x + src->w))
176 dst->w = src->x + src->w;
177 /* top */
178 if (dst->y > src->y)
179 {
180 dst->h += dst->y - src->y;
181 dst->y = src->y;
182 }
183 /* bottom */
184 if ((dst->y + dst->h) < (src->y + src->h))
185 dst->h = src->y + src->h;
186}
187
188/**
189 * @brief Get the intersection of two rectangles.
190 *
191 * @param dst The first rectangle.
192 * @param src The second rectangle.
193 * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE
194 * otherwise.
195 *
196 * This function get the intersection of the rectangles @p dst and
197 * @p src. The result is stored in @p dst. No check is done on @p dst
198 * or @p src, so they must be valid rectangles.
199 */
200static inline Eina_Bool
201eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src)
202{
203 if (!(eina_rectangles_intersect(dst, src)))
204 return EINA_FALSE;
205
206 /* left */
207 if (dst->x < src->x)
208 {
209 dst->w += dst->x - src->x;
210 dst->x = src->x;
211 if (dst->w < 0)
212 dst->w = 0;
213 }
214 /* right */
215 if ((dst->x + dst->w) > (src->x + src->w))
216 dst->w = src->x + src->w - dst->x;
217 /* top */
218 if (dst->y < src->y)
219 {
220 dst->h += dst->y - src->y;
221 dst->y = src->y;
222 if (dst->h < 0)
223 dst->h = 0;
224 }
225 /* bottom */
226 if ((dst->y + dst->h) > (src->y + src->h))
227 dst->h = src->y + src->h - dst->y;
228
229 return EINA_TRUE;
230}
231
232static inline void
233eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
234{
235 res->x = in->x - out->x;
236 res->y = in->y - out->y;
237 res->w = in->w;
238 res->h = in->h;
239}
240
241static inline void
242eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
243{
244 res->x = out->x + in->x;
245 res->y = out->y + in->y;
246 res->w = out->w;
247 res->h = out->h;
248}
249
250/**
251 * @}
252 */
253
254#endif
diff --git a/libraries/eina/src/include/eina_inline_str.x b/libraries/eina/src/include/eina_inline_str.x
deleted file mode 100644
index 2daeb85..0000000
--- a/libraries/eina/src/include/eina_inline_str.x
+++ /dev/null
@@ -1,76 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_STR_INLINE_H_
20#define EINA_STR_INLINE_H_
21
22/**
23 * @addtogroup Eina_String_Group String
24 *
25 * @{
26 */
27
28/**
29 * @brief Count up to a given amount of bytes of the given string.
30 *
31 * @param str The string pointer.
32 * @param maxlen The maximum length to allow.
33 * @return the string size or (size_t)-1 if greater than @a maxlen.
34 *
35 * This function returns the size of @p str, up to @p maxlen
36 * characters. It avoid needless iterations after that size. @p str
37 * must be a valid pointer and MUST not be @c NULL, otherwise this
38 * function will crash. This function returns the string size, or
39 * (size_t)-1 if the size is greater than @a maxlen.
40 */
41static inline size_t
42eina_strlen_bounded(const char *str, size_t maxlen)
43{
44 const char *itr, *str_maxend = str + maxlen;
45 for (itr = str; *itr != '\0'; itr++)
46 if (itr == str_maxend) return (size_t)-1;
47 return itr - str;
48}
49
50/**
51 * @brief Join two strings of known length.
52 *
53 * @param dst The buffer to store the result.
54 * @param size Size (in byte) of the buffer.
55 * @param sep The separator character to use.
56 * @param a First string to use, before @p sep.
57 * @param b Second string to use, after @p sep.
58 * @return The number of characters printed.
59 *
60 * This function is similar to eina_str_join_len(), but will compute
61 * the length of @p a and @p b using strlen().
62 *
63 * @see eina_str_join_len()
64 * @see eina_str_join_static()
65 */
66static inline size_t
67eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
68{
69 return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
70}
71
72/**
73 * @}
74 */
75
76#endif /* EINA_STR_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_stringshare.x b/libraries/eina/src/include/eina_inline_stringshare.x
deleted file mode 100644
index 19827c5..0000000
--- a/libraries/eina/src/include/eina_inline_stringshare.x
+++ /dev/null
@@ -1,91 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_STRINGSHARE_INLINE_H_
20#define EINA_STRINGSHARE_INLINE_H_
21
22#include <string.h>
23#include "eina_stringshare.h"
24/**
25 * @addtogroup Eina_Stringshare_Group Stringshare
26 *
27 * @{
28 */
29
30/**
31 * Replace the previously stringshared pointer with new content.
32 *
33 * The string pointed by @a p_str should be previously stringshared or
34 * @c NULL and it will be eina_stringshare_del(). The new string will
35 * be passed to eina_stringshare_add() and then assigned to @c *p_str.
36 *
37 * @param p_str pointer to the stringhare to be replaced. Must not be
38 * @c NULL, but @c *p_str may be @c NULL as it is a valid
39 * stringshare handle.
40 * @param news new string to be stringshared, may be @c NULL.
41 *
42 * @return #EINA_TRUE if the strings were different and thus replaced,
43 * #EINA_FALSE if the strings were the same after shared.
44 */
45static inline Eina_Bool
46eina_stringshare_replace(Eina_Stringshare **p_str, const char *news)
47{
48 if (*p_str == news) return EINA_FALSE;
49
50 news = eina_stringshare_add(news);
51 eina_stringshare_del(*p_str);
52 if (*p_str == news)
53 return EINA_FALSE;
54 *p_str = news;
55 return EINA_TRUE;
56}
57
58/**
59 * Replace the previously stringshared pointer with a new content.
60 *
61 * The string pointed by @a p_str should be previously stringshared or
62 * @c NULL and it will be eina_stringshare_del(). The new string will
63 * be passed to eina_stringshare_add_length() and then assigned to @c *p_str.
64 *
65 * @param p_str pointer to the stringhare to be replaced. Must not be
66 * @c NULL, but @c *p_str may be @c NULL as it is a valid
67 * stringshare handle.
68 * @param news new string to be stringshared, may be @c NULL.
69 * @param slen The string size (<= strlen(str)).
70 *
71 * @return #EINA_TRUE if the strings were different and thus replaced,
72 * #EINA_FALSE if the strings were the same after shared.
73 */
74static inline Eina_Bool
75eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen)
76{
77 if (*p_str == news) return EINA_FALSE;
78
79 news = eina_stringshare_add_length(news, slen);
80 eina_stringshare_del(*p_str);
81 if (*p_str == news)
82 return EINA_FALSE;
83 *p_str = news;
84 return EINA_TRUE;
85}
86
87/**
88 * @}
89 */
90
91#endif /* EINA_STRINGSHARE_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_tiler.x b/libraries/eina/src/include/eina_inline_tiler.x
deleted file mode 100644
index 2a8b205..0000000
--- a/libraries/eina/src/include/eina_inline_tiler.x
+++ /dev/null
@@ -1,151 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2009 Rafael Antognolli
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TILER_INLINE_H_
20#define EINA_TILER_INLINE_H_
21
22#include "eina_safety_checks.h"
23
24/**
25 * @cond LOCAL
26 * This struct should not be accessed directly, it is used by
27 * eina_tile_grid_slicer functions to maintain context and fill "info"
28 * member with correct values for given iteration.
29 */
30struct _Eina_Tile_Grid_Slicer
31{
32 unsigned long col1, col2, row1, row2; // initial and final col,row
33 int tile_w, tile_h; // tile width, height
34 int x_rel, y_rel; // starting x,y coordinates of the first col,row
35 int w1_rel, h1_rel; // width,height of the first col,row
36 int w2_rel, h2_rel; // width,height of the last col,row
37 struct Eina_Tile_Grid_Info info; // info about the current tile
38 Eina_Bool first;
39};
40
41/**
42 * @endcond
43 */
44
45static inline Eina_Bool
46eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect)
47{
48 EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
49
50 if (slc->first)
51 {
52 slc->first = 0;
53 *rect = &slc->info;
54 return EINA_TRUE;
55 }
56
57 slc->info.col++;
58
59 if (slc->info.col > slc->col2)
60 {
61 slc->info.row++;
62 if (slc->info.row > slc->row2)
63 return EINA_FALSE;
64 else if (slc->info.row < slc->row2)
65 slc->info.rect.h = slc->tile_h;
66 else
67 slc->info.rect.h = slc->h2_rel;
68 slc->info.rect.y = 0;
69 slc->info.col = slc->col1;
70 slc->info.rect.x = slc->x_rel;
71 slc->info.rect.w = slc->w1_rel;
72 }
73 else
74 {
75 slc->info.rect.x = 0;
76 if (slc->info.col < slc->col2)
77 slc->info.rect.w = slc->tile_w;
78 else
79 slc->info.rect.w = slc->w2_rel;
80 }
81
82 if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h)
83 slc->info.full = EINA_TRUE;
84 else
85 slc->info.full = EINA_FALSE;
86
87 *rect = &slc->info;
88
89 return EINA_TRUE;
90}
91
92static inline Eina_Bool
93eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h)
94{
95 int tx1, tx2, ty1, ty2;
96
97 EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
98
99 tx1 = x;
100 ty1 = y;
101 tx2 = x + w - 1;
102 ty2 = y + h - 1;
103
104 if (x < 0 || y < 0 || w <= 0 || h <= 0 || tile_w <= 0 || tile_h <= 0)
105 {
106 slc->first = 0;
107 slc->col1 = slc->row1 = 0;
108 slc->col2 = slc->row2 = 0;
109 slc->info.col = slc->col1;
110 slc->info.row = slc->row1;
111 return EINA_TRUE;
112 }
113
114 slc->col1 = tx1 / tile_w;
115 slc->row1 = ty1 / tile_h;
116 slc->col2 = (tx2 - 0) / tile_w;
117 slc->row2 = (ty2 - 0) / tile_h;
118 slc->x_rel = tx1 % tile_w;
119 slc->y_rel = ty1 % tile_h;
120 slc->w1_rel = tile_w - slc->x_rel;
121 slc->h1_rel = tile_h - slc->y_rel;
122 slc->w2_rel = tx2 % tile_w + 1;
123 slc->h2_rel = ty2 % tile_h + 1;
124
125 slc->tile_w = tile_w;
126 slc->tile_h = tile_h;
127
128 slc->first = 1;
129 slc->info.col = slc->col1;
130 slc->info.row = slc->row1;
131 slc->info.rect.x = slc->x_rel;
132 slc->info.rect.y = slc->y_rel;
133
134 if (slc->info.col == slc->col2)
135 slc->w1_rel = slc->w2_rel - slc->x_rel;
136
137 if (slc->info.row == slc->row2)
138 slc->h1_rel = slc->h2_rel - slc->y_rel;
139
140 slc->info.rect.w = slc->w1_rel;
141 slc->info.rect.h = slc->h1_rel;
142
143 if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h)
144 slc->info.full = EINA_TRUE;
145 else
146 slc->info.full = EINA_FALSE;
147
148 return EINA_TRUE;
149}
150
151#endif
diff --git a/libraries/eina/src/include/eina_inline_trash.x b/libraries/eina/src/include/eina_inline_trash.x
deleted file mode 100644
index 4a50611..0000000
--- a/libraries/eina/src/include/eina_inline_trash.x
+++ /dev/null
@@ -1,90 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_TRASH_X__
20#define EINA_INLINE_TRASH_X__
21
22/**
23 * @brief Initialize a trash before using it.
24 *
25 * @param trash The trash.
26 *
27 * This function just set to zero the trash to correctly
28 * initialize it.
29 *
30 * @note You can just set *trash to NULL and you will have
31 * the same result.
32 */
33static inline void
34eina_trash_init(Eina_Trash **trash)
35{
36 *trash = NULL;
37}
38
39/**
40 * @brief Push an unused pointer in the trash instead of freeing it.
41 *
42 * @param trash A pointer to an Eina_Trash.
43 * @param data An unused pointer big enougth to put a (void*).
44 *
45 * Instead of freeing a pointer and put pressure on malloc/free
46 * you can push it in a trash for a later use. This function just
47 * provide a fast way to push a now unused pointer into a trash.
48 *
49 * @note Do never use the pointer after insertion or bad things will
50 * happens.
51 *
52 * @note This trash will not resize, nor do anything with the size of
53 * the region pointed by @p data, so it's your duty to manage the size.
54 */
55static inline void
56eina_trash_push(Eina_Trash **trash, void *data)
57{
58 Eina_Trash *tmp;
59
60 tmp = (Eina_Trash *)data;
61 tmp->next = *trash;
62 *trash = tmp;
63}
64
65/**
66 * @brief Pop an available pointer from the trash if possible.
67 *
68 * @param trash A pointer to an Eina_Trash.
69 *
70 * Instead of calling malloc, and putting pressure on malloc/free
71 * you can recycle the content of the trash, if it's not empty.
72 *
73 * @note This trash will not resize, nor do anything with the size of
74 * the region pointed by pointer inside the trash, so it's your duty
75 * to manage the size of the returned pointer.
76 */
77static inline void*
78eina_trash_pop(Eina_Trash **trash)
79{
80 void *tmp;
81
82 tmp = *trash;
83
84 if (*trash)
85 *trash = (*trash)->next;
86
87 return tmp;
88}
89
90#endif
diff --git a/libraries/eina/src/include/eina_inline_ustringshare.x b/libraries/eina/src/include/eina_inline_ustringshare.x
deleted file mode 100644
index ace6fdc..0000000
--- a/libraries/eina/src/include/eina_inline_ustringshare.x
+++ /dev/null
@@ -1,93 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 Tom Hacohen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_USTRINGSHARE_INLINE_H_
21#define EINA_USTRINGSHARE_INLINE_H_
22
23#include "eina_unicode.h"
24#include "eina_ustringshare.h"
25
26/**
27 * @addtogroup Eina_UStringshare_Group Unicode Stringshare
28 *
29 * @{
30 */
31
32/**
33 * Replace the previously stringshared pointer with new content.
34 *
35 * The string pointed by @a p_str should be previously stringshared or
36 * @c NULL and it will be eina_ustringshare_del(). The new string will
37 * be passed to eina_ustringshare_add() and then assigned to @c *p_str.
38 *
39 * @param p_str pointer to the stringhare to be replaced. Must not be
40 * @c NULL, but @c *p_str may be @c NULL as it is a valid
41 * stringshare handle.
42 * @param news new string to be stringshared, may be @c NULL.
43 *
44 * @return #EINA_TRUE if the strings were different and thus replaced,
45 * #EINA_FALSE if the strings were the same after shared.
46 */
47static inline Eina_Bool
48eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news)
49{
50 if (*p_str == news) return EINA_FALSE;
51
52 news = eina_ustringshare_add(news);
53 eina_ustringshare_del(*p_str);
54 if (*p_str == news)
55 return EINA_FALSE;
56 *p_str = news;
57 return EINA_TRUE;
58}
59
60/**
61 * Replace the previously stringshared pointer with a new content.
62 *
63 * The string pointed by @a p_str should be previously stringshared or
64 * @c NULL and it will be eina_ustringshare_del(). The new string will
65 * be passed to eina_ustringshare_add_length() and then assigned to @c *p_str.
66 *
67 * @param p_str pointer to the stringhare to be replaced. Must not be
68 * @c NULL, but @c *p_str may be @c NULL as it is a valid
69 * stringshare handle.
70 * @param news new string to be stringshared, may be @c NULL.
71 * @param slen The string size (<= strlen(str)).
72 *
73 * @return #EINA_TRUE if the strings were different and thus replaced,
74 * #EINA_FALSE if the strings were the same after shared.
75 */
76static inline Eina_Bool
77eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen)
78{
79 if (*p_str == news) return EINA_FALSE;
80
81 news = eina_ustringshare_add_length(news, slen);
82 eina_ustringshare_del(*p_str);
83 if (*p_str == news)
84 return EINA_FALSE;
85 *p_str = news;
86 return EINA_TRUE;
87}
88
89/**
90 * @}
91 */
92
93#endif /* EINA_USTRINGSHARE_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_value.x b/libraries/eina/src/include/eina_inline_value.x
deleted file mode 100644
index 33c83f5..0000000
--- a/libraries/eina/src/include/eina_inline_value.x
+++ /dev/null
@@ -1,1790 +0,0 @@
1/* Eina - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_VALUE_X_
20#define EINA_INLINE_VALUE_X_
21
22#include <stdlib.h>
23#include <string.h>
24
25#include "eina_stringshare.h"
26
27/* NOTE: most of value is implemented here for performance reasons */
28
29//#define EINA_VALUE_NO_OPTIMIZE 1
30#ifdef EINA_VALUE_NO_OPTIMIZE
31#define EINA_VALUE_TYPE_DEFAULT(type) (0)
32#else
33
34/**
35 * @var _EINA_VALUE_TYPE_BASICS_START
36 * pointer to the first basic type.
37 * @since 1.2
38 * @private
39 */
40EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START;
41
42/**
43 * @var _EINA_VALUE_TYPE_BASICS_END
44 * pointer to the last (inclusive) basic type.
45 * @since 1.2
46 * @private
47 */
48EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END;
49#define EINA_VALUE_TYPE_DEFAULT(type) \
50 ((_EINA_VALUE_TYPE_BASICS_START <= type) && \
51 (type <= _EINA_VALUE_TYPE_BASICS_END))
52#endif
53
54#define EINA_VALUE_TYPE_CHECK_RETURN(value) \
55 EINA_SAFETY_ON_NULL_RETURN(value); \
56 EINA_SAFETY_ON_FALSE_RETURN(eina_value_type_check(value->type))
57
58#define EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, retval) \
59 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
60 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), retval)
61
62#define EINA_VALUE_TYPE_DISPATCH(type, method, no_method_err, ...) \
63 do \
64 { \
65 if (type->method) \
66 type->method(type, ##__VA_ARGS__); \
67 else \
68 eina_error_set(no_method_err); \
69 } \
70 while (0)
71
72#define EINA_VALUE_TYPE_DISPATCH_RETURN(value, method, no_method_err, def_ret, ...) \
73 do \
74 { \
75 if (type->method) \
76 return type->method(type, ##__VA_ARGS__); \
77 eina_error_set(no_method_err); \
78 return def_ret; \
79 } \
80 while (0)
81
82/**
83 * @brief Get memory for given value (inline or allocated buffer).
84 * @since 1.2
85 * @private
86 */
87static inline void *
88eina_value_memory_get(const Eina_Value *value)
89{
90 if (value->type->value_size <= 8)
91 return (void *)value->value.buf;
92 return value->value.ptr;
93}
94
95/**
96 * @brief Allocate memory for internal value types.
97 * @since 1.2
98 * @private
99 */
100EAPI void *eina_value_inner_alloc(size_t size);
101/**
102 * @brief Releases memory for internal value types.
103 * @since 1.2
104 * @private
105 */
106EAPI void eina_value_inner_free(size_t size, void *mem);
107
108static inline Eina_Bool
109eina_value_setup(Eina_Value *value, const Eina_Value_Type *type)
110{
111 void *mem;
112
113 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
114 EINA_SAFETY_ON_FALSE_RETURN_VAL(type->value_size > 0, EINA_FALSE);
115
116 value->type = type;
117
118 if (type->value_size <= 8) mem = &value->value;
119 else
120 {
121 mem = value->value.ptr = eina_value_inner_alloc(type->value_size);
122 EINA_SAFETY_ON_NULL_RETURN_VAL(mem, EINA_FALSE);
123 }
124
125 memset(mem, 0, type->value_size);
126
127 if (EINA_VALUE_TYPE_DEFAULT(type))
128 {
129 eina_error_set(0);
130 return EINA_TRUE;
131 }
132
133 EINA_VALUE_TYPE_DISPATCH_RETURN(type, setup,
134 EINA_ERROR_VALUE_FAILED, EINA_FALSE, mem);
135}
136
137static inline void
138eina_value_flush(Eina_Value *value)
139{
140 const Eina_Value_Type *type;
141 void *mem;
142
143 EINA_VALUE_TYPE_CHECK_RETURN(value);
144
145 type = value->type;
146 mem = eina_value_memory_get(value);
147
148 if (EINA_VALUE_TYPE_DEFAULT(type))
149 {
150 if (type == EINA_VALUE_TYPE_STRINGSHARE)
151 {
152 if (value->value.ptr) eina_stringshare_del((const char*) value->value.ptr);
153 }
154 else if (type == EINA_VALUE_TYPE_STRING)
155 {
156 if (value->value.ptr) free(value->value.ptr);
157 }
158 else if (type->value_size > 8)
159 eina_value_inner_free(type->value_size, mem);
160 eina_error_set(0);
161 return;
162 }
163
164 EINA_VALUE_TYPE_DISPATCH(type, flush, EINA_ERROR_VALUE_FAILED, mem);
165 if (type->value_size > 8)
166 eina_value_inner_free(type->value_size, mem);
167 value->type = NULL;
168}
169
170static inline int
171eina_value_compare(const Eina_Value *a, const Eina_Value *b)
172{
173 const Eina_Value_Type *type;
174 void *pa, *pb;
175
176 EINA_VALUE_TYPE_CHECK_RETURN_VAL(a, -1);
177 EINA_SAFETY_ON_NULL_RETURN_VAL(b, -1);
178 EINA_SAFETY_ON_FALSE_RETURN_VAL(a->type == b->type, -1);
179
180 eina_error_set(0);
181 type = a->type;
182 pa = eina_value_memory_get(a);
183 pb = eina_value_memory_get(b);
184
185#ifndef EINA_VALUE_NO_OPTIMIZE
186 if (type == EINA_VALUE_TYPE_UCHAR)
187 {
188 unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *) pb;
189 if (*ta < *tb)
190 return -1;
191 else if (*ta > *tb)
192 return 1;
193 return 0;
194 }
195 else if (type == EINA_VALUE_TYPE_USHORT)
196 {
197 unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short *) pb;
198 if (*ta < *tb)
199 return -1;
200 else if (*ta > *tb)
201 return 1;
202 return 0;
203 }
204 else if (type == EINA_VALUE_TYPE_UINT)
205 {
206 unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb;
207 if (*ta < *tb)
208 return -1;
209 else if (*ta > *tb)
210 return 1;
211 return 0;
212 }
213 else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
214 {
215 unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb;
216 if (*ta < *tb)
217 return -1;
218 else if (*ta > *tb)
219 return 1;
220 return 0;
221 }
222 else if (type == EINA_VALUE_TYPE_UINT64)
223 {
224 uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb;
225 if (*ta < *tb)
226 return -1;
227 else if (*ta > *tb)
228 return 1;
229 return 0;
230 }
231 else if (type == EINA_VALUE_TYPE_CHAR)
232 {
233 char *ta = (char *) pa, *tb = (char *) pb;
234 if (*ta < *tb)
235 return -1;
236 else if (*ta > *tb)
237 return 1;
238 return 0;
239 }
240 else if (type == EINA_VALUE_TYPE_SHORT)
241 {
242 short *ta = (short *) pa, *tb = (short *) pb;
243 if (*ta < *tb)
244 return -1;
245 else if (*ta > *tb)
246 return 1;
247 return 0;
248 }
249 else if (type == EINA_VALUE_TYPE_INT)
250 {
251 int *ta = (int *) pa, *tb = (int *) pb;
252 if (*ta < *tb)
253 return -1;
254 else if (*ta > *tb)
255 return 1;
256 return 0;
257 }
258 else if (type == EINA_VALUE_TYPE_LONG)
259 {
260 long *ta = (long *) pa, *tb = (long *) pb;
261 if (*ta < *tb)
262 return -1;
263 else if (*ta > *tb)
264 return 1;
265 return 0;
266 }
267 else if (type == EINA_VALUE_TYPE_INT64)
268 {
269 int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb;
270 if (*ta < *tb)
271 return -1;
272 else if (*ta > *tb)
273 return 1;
274 return 0;
275 }
276 else if (type == EINA_VALUE_TYPE_FLOAT)
277 {
278 float *ta = (float *) pa, *tb = (float *) pb;
279 if (*ta < *tb)
280 return -1;
281 else if (*ta > *tb)
282 return 1;
283 return 0;
284 }
285 else if (type == EINA_VALUE_TYPE_DOUBLE)
286 {
287 double *ta = (double *) pa, *tb = (double *) pb;
288 if (*ta < *tb)
289 return -1;
290 else if (*ta > *tb)
291 return 1;
292 return 0;
293 }
294 else if (type == EINA_VALUE_TYPE_STRINGSHARE ||
295 type == EINA_VALUE_TYPE_STRING)
296 {
297 const char *sa = *(const char **)pa;
298 const char *sb = *(const char **)pb;
299 if (sa == sb)
300 return 0;
301 if (sa == NULL)
302 return -1;
303 if (sb == NULL)
304 return 1;
305 return strcmp(sa, sb);
306 }
307#endif
308
309 EINA_VALUE_TYPE_DISPATCH_RETURN(type, compare, EINA_ERROR_VALUE_FAILED,
310 EINA_FALSE, pa, pb);
311}
312
313static inline Eina_Bool
314eina_value_set(Eina_Value *value, ...)
315{
316 va_list args;
317 Eina_Bool ret;
318 va_start(args, value);
319 ret = eina_value_vset(value, args);
320 va_end(args);
321 return ret;
322}
323
324static inline Eina_Bool
325eina_value_get(const Eina_Value *value, ...)
326{
327 va_list args;
328 Eina_Bool ret;
329 va_start(args, value);
330 ret = eina_value_vget(value, args);
331 va_end(args);
332 return ret;
333}
334
335static inline Eina_Bool
336eina_value_vset(Eina_Value *value, va_list args)
337{
338 const Eina_Value_Type *type;
339 void *mem;
340
341 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
342
343 type = value->type;
344 mem = eina_value_memory_get(value);
345 eina_error_set(0);
346#ifndef EINA_VALUE_NO_OPTIMIZE
347 if (type == EINA_VALUE_TYPE_UCHAR)
348 {
349 unsigned char *tmem = (unsigned char *) mem;
350 *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
351 return EINA_TRUE;
352 }
353 else if (type == EINA_VALUE_TYPE_USHORT)
354 {
355 unsigned short *tmem = (unsigned short *) mem;
356 *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
357 return EINA_TRUE;
358 }
359 else if (type == EINA_VALUE_TYPE_UINT)
360 {
361 unsigned int *tmem = (unsigned int *) mem;
362 *tmem = va_arg(args, unsigned int);
363 return EINA_TRUE;
364 }
365 else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
366 {
367 unsigned long *tmem = (unsigned long *) mem;
368 *tmem = va_arg(args, unsigned long);
369 return EINA_TRUE;
370 }
371 else if (type == EINA_VALUE_TYPE_UINT64)
372 {
373 uint64_t *tmem = (uint64_t *) mem;
374 *tmem = va_arg(args, uint64_t);
375 return EINA_TRUE;
376 }
377 else if (type == EINA_VALUE_TYPE_CHAR)
378 {
379 char *tmem = (char *) mem;
380 *tmem = va_arg(args, int); /* promoted by va_arg */
381 return EINA_TRUE;
382 }
383 else if (type == EINA_VALUE_TYPE_SHORT)
384 {
385 short *tmem = (short *) mem;
386 *tmem = va_arg(args, int); /* promoted by va_arg */
387 return EINA_TRUE;
388 }
389 else if (type == EINA_VALUE_TYPE_INT)
390 {
391 int *tmem = (int *) mem;
392 *tmem = va_arg(args, int);
393 return EINA_TRUE;
394 }
395 else if (type == EINA_VALUE_TYPE_LONG)
396 {
397 long *tmem = (long *) mem;
398 *tmem = va_arg(args, long);
399 return EINA_TRUE;
400 }
401 else if (type == EINA_VALUE_TYPE_INT64)
402 {
403 int64_t *tmem = (int64_t *) mem;
404 *tmem = va_arg(args, int64_t);
405 return EINA_TRUE;
406 }
407 else if (type == EINA_VALUE_TYPE_FLOAT)
408 {
409 float *tmem = (float *) mem;
410 *tmem = va_arg(args, double); /* promoted by va_arg */
411 return EINA_TRUE;
412 }
413 else if (type == EINA_VALUE_TYPE_DOUBLE)
414 {
415 double *tmem = (double *) mem;
416 *tmem = va_arg(args, double);
417 return EINA_TRUE;
418 }
419 else if (type == EINA_VALUE_TYPE_STRINGSHARE)
420 {
421 const char *str = (const char *) va_arg(args, const char *);
422 return eina_stringshare_replace((const char **)&value->value.ptr, str);
423 }
424 else if (type == EINA_VALUE_TYPE_STRING)
425 {
426 const char *str = (const char *) va_arg(args, const char *);
427 if (value->value.ptr == str) return EINA_TRUE;
428 if (!str)
429 {
430 free(value->value.ptr);
431 value->value.ptr = NULL;
432 }
433 else
434 {
435 char *tmp = strdup(str);
436 if (!tmp)
437 {
438 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
439 return EINA_FALSE;
440 }
441 free(value->value.ptr);
442 value->value.ptr = tmp;
443 }
444 return EINA_TRUE;
445 }
446#endif
447
448 EINA_VALUE_TYPE_DISPATCH_RETURN(value, vset, EINA_ERROR_VALUE_FAILED,
449 EINA_FALSE, mem, args);
450}
451
452static inline Eina_Bool
453eina_value_vget(const Eina_Value *value, va_list args)
454{
455 const Eina_Value_Type *type;
456 const void *mem;
457 void *ptr;
458
459 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
460
461 type = value->type;
462 mem = eina_value_memory_get(value);
463 ptr = va_arg(args, void *);
464 eina_error_set(0);
465 if (EINA_VALUE_TYPE_DEFAULT(type))
466 {
467 memcpy(ptr, mem, type->value_size);
468 return EINA_TRUE;
469 }
470
471 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED,
472 EINA_FALSE, mem, ptr);
473}
474
475static inline Eina_Bool
476eina_value_pset(Eina_Value *value, const void *ptr)
477{
478 const Eina_Value_Type *type;
479 void *mem;
480
481 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
482 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
483
484 type = value->type;
485 mem = eina_value_memory_get(value);
486 eina_error_set(0);
487
488 if (EINA_VALUE_TYPE_DEFAULT(type))
489 {
490 if (type == EINA_VALUE_TYPE_STRINGSHARE)
491 {
492 const char * const *pstr = (const char * const *) ptr;
493 const char *str = *pstr;
494
495 return eina_stringshare_replace((const char **)&value->value.ptr,
496 str);
497 }
498 else if (type == EINA_VALUE_TYPE_STRING)
499 {
500 const char * const * pstr = (const char * const *) ptr;
501 const char *str = *pstr;
502 if (value->value.ptr == str) return EINA_TRUE;
503 if (!str)
504 {
505 free(value->value.ptr);
506 value->value.ptr = NULL;
507 }
508 else
509 {
510 char *tmp = strdup(str);
511 if (!tmp)
512 {
513 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
514 return EINA_FALSE;
515 }
516 free(value->value.ptr);
517 value->value.ptr = tmp;
518 }
519 return EINA_TRUE;
520 }
521 else
522 memcpy(mem, ptr, type->value_size);
523 return EINA_TRUE;
524 }
525
526 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pset, EINA_ERROR_VALUE_FAILED,
527 EINA_FALSE, mem, ptr);
528}
529
530static inline Eina_Bool
531eina_value_pget(const Eina_Value *value, void *ptr)
532{
533 const Eina_Value_Type *type;
534 const void *mem;
535
536 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
537 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
538
539 type = value->type;
540 mem = eina_value_memory_get(value);
541 eina_error_set(0);
542 if (EINA_VALUE_TYPE_DEFAULT(type))
543 {
544 memcpy(ptr, mem, type->value_size);
545 return EINA_TRUE;
546 }
547
548 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED,
549 EINA_FALSE, mem, ptr);
550}
551
552static inline const Eina_Value_Type *
553eina_value_type_get(const Eina_Value *value)
554{
555 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, NULL);
556 return value->type;
557}
558
559#define EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, retval) \
560 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
561 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_ARRAY, retval)
562
563static inline Eina_Bool
564eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int step)
565{
566 Eina_Value_Array desc = { subtype, step, NULL };
567 if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY))
568 return EINA_FALSE;
569 if (!eina_value_pset(value, &desc))
570 {
571 eina_value_flush(value);
572 return EINA_FALSE;
573 }
574 return EINA_TRUE;
575}
576
577static inline unsigned int
578eina_value_array_count(const Eina_Value *value)
579{
580 Eina_Value_Array desc;
581 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
582 if (!eina_value_pget(value, &desc))
583 return 0;
584 return eina_inarray_count(desc.array);
585}
586
587static inline Eina_Bool
588eina_value_array_remove(Eina_Value *value, unsigned int position)
589{
590 Eina_Value_Array desc;
591 void *mem;
592
593 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
594 if (!eina_value_pget(value, &desc))
595 return EINA_FALSE;
596
597 mem = eina_inarray_nth(desc.array, position);
598 if (!mem)
599 return EINA_FALSE;
600
601 eina_value_type_flush(desc.subtype, mem);
602 return eina_inarray_remove_at(desc.array, position);
603}
604
605static inline Eina_Bool
606eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args)
607{
608 Eina_Value_Array desc;
609 void *mem;
610
611 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
612 if (!eina_value_pget(value, &desc))
613 return EINA_FALSE;
614
615 mem = eina_inarray_nth(desc.array, position);
616 if (!mem)
617 return EINA_FALSE;
618
619 return eina_value_type_vset(desc.subtype, mem, args);
620}
621
622static inline Eina_Bool
623eina_value_array_vget(const Eina_Value *value, unsigned int position, va_list args)
624{
625 Eina_Value_Array desc;
626 const void *mem;
627 void *ptr;
628 Eina_Bool ret;
629
630 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
631 if (!eina_value_pget(value, &desc))
632 return EINA_FALSE;
633
634 mem = eina_inarray_nth(desc.array, position);
635 if (!mem)
636 return EINA_FALSE;
637
638 ptr = va_arg(args, void *);
639 ret = eina_value_type_pget(desc.subtype, mem, ptr);
640 return ret;
641}
642
643static inline Eina_Bool
644eina_value_array_vinsert(Eina_Value *value, unsigned int position, va_list args)
645{
646 Eina_Value_Array desc;
647 void *mem;
648
649 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
650 if (!eina_value_pget(value, &desc))
651 return EINA_FALSE;
652
653 mem = eina_inarray_alloc_at(desc.array, position, 1);
654 if (!mem)
655 return EINA_FALSE;
656
657 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
658 if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
659 return EINA_TRUE;
660
661 error_set:
662 eina_value_type_flush(desc.subtype, mem);
663 error_setup:
664 eina_inarray_remove_at(desc.array, position);
665 return EINA_FALSE;
666}
667
668static inline Eina_Bool
669eina_value_array_vappend(Eina_Value *value, va_list args)
670{
671 Eina_Value_Array desc;
672 void *mem;
673 int position;
674
675 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
676 if (!eina_value_pget(value, &desc))
677 return EINA_FALSE;
678
679 position = eina_inarray_count(desc.array);
680 mem = eina_inarray_alloc_at(desc.array, position, 1);
681 if (!mem)
682 return EINA_FALSE;
683
684 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
685 if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
686 return EINA_TRUE;
687
688 error_set:
689 eina_value_type_flush(desc.subtype, mem);
690 error_setup:
691 eina_inarray_remove_at(desc.array, position);
692 return EINA_FALSE;
693}
694
695static inline Eina_Bool
696eina_value_array_set(Eina_Value *value, unsigned int position, ...)
697{
698 va_list args;
699 Eina_Bool ret;
700 va_start(args, position);
701 ret = eina_value_array_vset(value, position, args);
702 va_end(args);
703 return ret;
704}
705
706static inline Eina_Bool
707eina_value_array_get(const Eina_Value *value, unsigned int position, ...)
708{
709 va_list args;
710 Eina_Bool ret;
711 va_start(args, position);
712 ret = eina_value_array_vget(value, position, args);
713 va_end(args);
714 return ret;
715}
716
717static inline Eina_Bool
718eina_value_array_insert(Eina_Value *value, unsigned int position, ...)
719{
720 va_list args;
721 Eina_Bool ret;
722 va_start(args, position);
723 ret = eina_value_array_vinsert(value, position, args);
724 va_end(args);
725 return ret;
726}
727
728static inline Eina_Bool eina_value_array_append(Eina_Value *value, ...)
729{
730 va_list args;
731 Eina_Bool ret;
732 va_start(args, value);
733 ret = eina_value_array_vappend(value, args);
734 va_end(args);
735 return ret;
736}
737
738static inline Eina_Bool
739eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr)
740{
741 Eina_Value_Array desc;
742 void *mem;
743
744 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
745 if (!eina_value_pget(value, &desc))
746 return EINA_FALSE;
747
748 mem = eina_inarray_nth(desc.array, position);
749 if (!mem)
750 return EINA_FALSE;
751
752 return eina_value_type_pset(desc.subtype, mem, ptr);
753}
754
755static inline Eina_Bool
756eina_value_array_pget(const Eina_Value *value, unsigned int position, void *ptr)
757{
758 Eina_Value_Array desc;
759 const void *mem;
760 Eina_Bool ret;
761
762 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
763 if (!eina_value_pget(value, &desc))
764 return EINA_FALSE;
765
766 mem = eina_inarray_nth(desc.array, position);
767 if (!mem)
768 return EINA_FALSE;
769
770 ret = eina_value_type_pget(desc.subtype, mem, ptr);
771 return ret;
772}
773
774static inline Eina_Bool
775eina_value_array_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
776{
777 Eina_Value_Array desc;
778 void *mem;
779
780 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
781 if (!eina_value_pget(value, &desc))
782 return EINA_FALSE;
783
784 mem = eina_inarray_alloc_at(desc.array, position, 1);
785 if (!mem)
786 return EINA_FALSE;
787
788 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
789 if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
790 return EINA_TRUE;
791
792 error_set:
793 eina_value_type_flush(desc.subtype, mem);
794 error_setup:
795 eina_inarray_remove_at(desc.array, position);
796 return EINA_FALSE;
797}
798
799static inline Eina_Bool
800eina_value_array_pappend(Eina_Value *value, const void *ptr)
801{
802 Eina_Value_Array desc;
803 void *mem;
804 int position;
805
806 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
807 if (!eina_value_pget(value, &desc))
808 return EINA_FALSE;
809
810 position = eina_inarray_count(desc.array);
811 mem = eina_inarray_alloc_at(desc.array, position, 1);
812 if (!mem)
813 return EINA_FALSE;
814
815 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
816 if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
817 return EINA_TRUE;
818
819 error_set:
820 eina_value_type_flush(desc.subtype, mem);
821 error_setup:
822 eina_inarray_remove_at(desc.array, position);
823 return EINA_FALSE;
824}
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
849#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL
850
851#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \
852 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
853 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_LIST, retval)
854
855static inline void *
856eina_value_list_node_memory_get(const Eina_Value_Type *type, const Eina_List *node)
857{
858 if (node == NULL) return NULL;
859 if (type->value_size <= sizeof(void*))
860 return (void *)&(node->data);
861 return node->data;
862}
863
864static inline void *
865eina_value_list_node_memory_setup(const Eina_Value_Type *type, Eina_List *node)
866{
867 if (type->value_size <= sizeof(void*))
868 return (void *)&(node->data);
869 node->data = malloc(type->value_size);
870 return node->data;
871}
872
873static inline void
874eina_value_list_node_memory_flush(const Eina_Value_Type *type, Eina_List *node)
875{
876 if (type->value_size <= sizeof(void*))
877 return;
878 free(node->data);
879}
880
881static inline Eina_Bool
882eina_value_list_setup(Eina_Value *value, const Eina_Value_Type *subtype)
883{
884 Eina_Value_List desc = { subtype, NULL };
885 if (!eina_value_setup(value, EINA_VALUE_TYPE_LIST))
886 return EINA_FALSE;
887 if (!eina_value_pset(value, &desc))
888 {
889 eina_value_flush(value);
890 return EINA_FALSE;
891 }
892 return EINA_TRUE;
893}
894
895static inline unsigned int
896eina_value_list_count(const Eina_Value *value)
897{
898 Eina_Value_List *desc;
899 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
900 desc = (Eina_Value_List *)eina_value_memory_get(value);
901 if (!desc)
902 return 0;
903 return eina_list_count(desc->list);
904}
905
906static inline Eina_Bool
907eina_value_list_remove(Eina_Value *value, unsigned int position)
908{
909 Eina_Value_List *desc;
910 Eina_List *node;
911 void *mem;
912
913 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
914 desc = (Eina_Value_List *)eina_value_memory_get(value);
915 if (!desc)
916 return EINA_FALSE;
917
918 node = eina_list_nth_list(desc->list, position);
919 mem = eina_value_list_node_memory_get(desc->subtype, node);
920 if (!mem)
921 return EINA_FALSE;
922
923 eina_value_type_flush(desc->subtype, mem);
924 eina_value_list_node_memory_flush(desc->subtype, node);
925 desc->list = eina_list_remove_list(desc->list, node);
926 return EINA_TRUE;
927}
928
929static inline Eina_Bool
930eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args)
931{
932 Eina_Value_List *desc;
933 Eina_List *node;
934 void *mem;
935
936 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
937 desc = (Eina_Value_List *)eina_value_memory_get(value);
938 if (!desc)
939 return EINA_FALSE;
940
941 node = eina_list_nth_list(desc->list, position);
942 mem = eina_value_list_node_memory_get(desc->subtype, node);
943 if (!mem)
944 return EINA_FALSE;
945
946 return eina_value_type_vset(desc->subtype, mem, args);
947}
948
949static inline Eina_Bool
950eina_value_list_vget(const Eina_Value *value, unsigned int position, va_list args)
951{
952 const Eina_Value_List *desc;
953 const Eina_List *node;
954 const void *mem;
955 void *ptr;
956 Eina_Bool ret;
957
958 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
959 desc = (const Eina_Value_List *)eina_value_memory_get(value);
960 if (!desc)
961 return EINA_FALSE;
962
963 node = eina_list_nth_list(desc->list, position);
964 mem = eina_value_list_node_memory_get(desc->subtype, node);
965 if (!mem)
966 return EINA_FALSE;
967
968 ptr = va_arg(args, void *);
969 ret = eina_value_type_pget(desc->subtype, mem, ptr);
970 return ret;
971}
972
973static inline Eina_Bool
974eina_value_list_vinsert(Eina_Value *value, unsigned int position, va_list args)
975{
976 Eina_Value_List *desc;
977 Eina_List *node;
978 void *mem;
979
980 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
981 desc = (Eina_Value_List *)eina_value_memory_get(value);
982 if (!desc)
983 return EINA_FALSE;
984
985 if (!desc->list)
986 node = desc->list = eina_list_append(NULL, (void*)1L);
987 else if (position == 0)
988 node = desc->list = eina_list_prepend(desc->list, (void*)1L);
989 else
990 {
991 Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
992 desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
993 node = rel->next;
994 }
995 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
996 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
997
998 mem = eina_value_list_node_memory_setup(desc->subtype, node);
999 if (!mem)
1000 {
1001 desc->list = eina_list_remove_list(desc->list, node);
1002 return EINA_FALSE;
1003 }
1004
1005 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1006 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
1007 return EINA_TRUE;
1008
1009 error_set:
1010 eina_value_type_flush(desc->subtype, mem);
1011 error_setup:
1012 eina_value_list_node_memory_flush(desc->subtype, node);
1013 desc->list = eina_list_remove_list(desc->list, node);
1014 return EINA_FALSE;
1015}
1016
1017static inline Eina_Bool
1018eina_value_list_vappend(Eina_Value *value, va_list args)
1019{
1020 Eina_Value_List *desc;
1021 Eina_List *node;
1022 void *mem;
1023
1024 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1025 desc = (Eina_Value_List *)eina_value_memory_get(value);
1026 if (!desc)
1027 return EINA_FALSE;
1028
1029 desc->list = eina_list_append(desc->list, (void*)1L);
1030 node = eina_list_last(desc->list);
1031 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1032 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1033
1034 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1035 if (!mem)
1036 {
1037 desc->list = eina_list_remove_list(desc->list, node);
1038 return EINA_FALSE;
1039 }
1040
1041 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1042 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
1043 return EINA_TRUE;
1044
1045 error_set:
1046 eina_value_type_flush(desc->subtype, mem);
1047 error_setup:
1048 eina_value_list_node_memory_flush(desc->subtype, node);
1049 desc->list = eina_list_remove_list(desc->list, node);
1050 return EINA_FALSE;
1051}
1052
1053static inline Eina_Bool
1054eina_value_list_set(Eina_Value *value, unsigned int position, ...)
1055{
1056 va_list args;
1057 Eina_Bool ret;
1058 va_start(args, position);
1059 ret = eina_value_list_vset(value, position, args);
1060 va_end(args);
1061 return ret;
1062}
1063
1064static inline Eina_Bool
1065eina_value_list_get(const Eina_Value *value, unsigned int position, ...)
1066{
1067 va_list args;
1068 Eina_Bool ret;
1069 va_start(args, position);
1070 ret = eina_value_list_vget(value, position, args);
1071 va_end(args);
1072 return ret;
1073}
1074
1075static inline Eina_Bool
1076eina_value_list_insert(Eina_Value *value, unsigned int position, ...)
1077{
1078 va_list args;
1079 Eina_Bool ret;
1080 va_start(args, position);
1081 ret = eina_value_list_vinsert(value, position, args);
1082 va_end(args);
1083 return ret;
1084}
1085
1086static inline Eina_Bool eina_value_list_append(Eina_Value *value, ...)
1087{
1088 va_list args;
1089 Eina_Bool ret;
1090 va_start(args, value);
1091 ret = eina_value_list_vappend(value, args);
1092 va_end(args);
1093 return ret;
1094}
1095
1096static inline Eina_Bool
1097eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr)
1098{
1099 Eina_Value_List *desc;
1100 Eina_List *node;
1101 void *mem;
1102
1103 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1104 desc = (Eina_Value_List *)eina_value_memory_get(value);
1105 if (!desc)
1106 return EINA_FALSE;
1107
1108 node = eina_list_nth_list(desc->list, position);
1109 mem = eina_value_list_node_memory_get(desc->subtype, node);
1110 if (!mem)
1111 return EINA_FALSE;
1112
1113 return eina_value_type_pset(desc->subtype, mem, ptr);
1114}
1115
1116static inline Eina_Bool
1117eina_value_list_pget(const Eina_Value *value, unsigned int position, void *ptr)
1118{
1119 const Eina_Value_List *desc;
1120 const Eina_List *node;
1121 const void *mem;
1122 Eina_Bool ret;
1123
1124 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1125 desc = (const Eina_Value_List *)eina_value_memory_get(value);
1126 if (!desc)
1127 return EINA_FALSE;
1128
1129 node = eina_list_nth_list(desc->list, position);
1130 mem = eina_value_list_node_memory_get(desc->subtype, node);
1131 if (!mem)
1132 return EINA_FALSE;
1133
1134 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1135 return ret;
1136}
1137
1138static inline Eina_Bool
1139eina_value_list_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
1140{
1141 Eina_Value_List *desc;
1142 Eina_List *node;
1143 void *mem;
1144
1145 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1146 desc = (Eina_Value_List *)eina_value_memory_get(value);
1147 if (!desc)
1148 return EINA_FALSE;
1149
1150 if (!desc->list)
1151 node = desc->list = eina_list_append(NULL, (void*)1L);
1152 else if (position == 0)
1153 node = desc->list = eina_list_prepend(desc->list, (void*)1L);
1154 else
1155 {
1156 Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
1157 desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
1158 node = rel->next;
1159 }
1160 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1161 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1162
1163 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1164 if (!mem)
1165 {
1166 desc->list = eina_list_remove_list(desc->list, node);
1167 return EINA_FALSE;
1168 }
1169
1170 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1171 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1172 return EINA_TRUE;
1173
1174 error_set:
1175 eina_value_type_flush(desc->subtype, mem);
1176 error_setup:
1177 eina_value_list_node_memory_flush(desc->subtype, node);
1178 desc->list = eina_list_remove_list(desc->list, node);
1179 return EINA_FALSE;
1180}
1181
1182static inline Eina_Bool
1183eina_value_list_pappend(Eina_Value *value, const void *ptr)
1184{
1185 Eina_Value_List *desc;
1186 Eina_List *node;
1187 void *mem;
1188
1189 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1190 desc = (Eina_Value_List *)eina_value_memory_get(value);
1191 if (!desc)
1192 return EINA_FALSE;
1193
1194 desc->list = eina_list_append(desc->list, (void*)1L);
1195 node = eina_list_last(desc->list);
1196 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1197 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1198
1199 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1200 if (!mem)
1201 {
1202 desc->list = eina_list_remove_list(desc->list, node);
1203 return EINA_FALSE;
1204 }
1205
1206 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1207 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1208 return EINA_TRUE;
1209
1210 error_set:
1211 eina_value_type_flush(desc->subtype, mem);
1212 error_setup:
1213 eina_value_list_node_memory_flush(desc->subtype, node);
1214 desc->list = eina_list_remove_list(desc->list, node);
1215 return EINA_FALSE;
1216}
1217#undef EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL
1218
1219#define EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, retval) \
1220 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
1221 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_HASH, retval)
1222
1223static inline Eina_Bool
1224eina_value_hash_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size)
1225{
1226 Eina_Value_Hash desc = { subtype, buckets_power_size, NULL };
1227 if (!eina_value_setup(value, EINA_VALUE_TYPE_HASH))
1228 return EINA_FALSE;
1229 if (!eina_value_pset(value, &desc))
1230 {
1231 eina_value_flush(value);
1232 return EINA_FALSE;
1233 }
1234 return EINA_TRUE;
1235}
1236
1237static inline unsigned int
1238eina_value_hash_population(const Eina_Value *value)
1239{
1240 Eina_Value_Hash *desc;
1241 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1242 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1243 if (!desc)
1244 return 0;
1245 return eina_hash_population(desc->hash);
1246}
1247
1248static inline Eina_Bool
1249eina_value_hash_del(Eina_Value *value, const char *key)
1250{
1251 Eina_Value_Hash *desc;
1252 void *mem;
1253
1254 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1255 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1256 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1257 if (!desc)
1258 return EINA_FALSE;
1259
1260 mem = eina_hash_find(desc->hash, key);
1261 if (!mem)
1262 return EINA_FALSE;
1263
1264 eina_value_type_flush(desc->subtype, mem);
1265 free(mem);
1266 eina_hash_del_by_key(desc->hash, key);
1267 return EINA_TRUE;
1268}
1269
1270static inline Eina_Bool
1271eina_value_hash_vset(Eina_Value *value, const char *key, va_list args)
1272{
1273 Eina_Value_Hash *desc;
1274 void *mem;
1275
1276 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1277 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1278 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1279 if (!desc)
1280 return EINA_FALSE;
1281
1282 mem = eina_hash_find(desc->hash, key);
1283 if (!mem)
1284 {
1285 mem = malloc(desc->subtype->value_size);
1286 if (!mem)
1287 {
1288 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
1289 return EINA_FALSE;
1290 }
1291 if (!eina_hash_add(desc->hash, key, mem))
1292 {
1293 free(mem);
1294 return EINA_FALSE;
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 }
1303
1304 return eina_value_type_vset(desc->subtype, mem, args);
1305}
1306
1307static inline Eina_Bool
1308eina_value_hash_vget(const Eina_Value *value, const char *key, va_list args)
1309{
1310 const Eina_Value_Hash *desc;
1311 const void *mem;
1312 void *ptr;
1313 Eina_Bool ret;
1314
1315 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1316 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1317 desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
1318 if (!desc)
1319 return EINA_FALSE;
1320
1321 mem = eina_hash_find(desc->hash, key);
1322 if (!mem)
1323 return EINA_FALSE;
1324
1325 ptr = va_arg(args, void *);
1326 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1327 return ret;
1328}
1329
1330static inline Eina_Bool
1331eina_value_hash_set(Eina_Value *value, const char *key, ...)
1332{
1333 va_list args;
1334 Eina_Bool ret;
1335 va_start(args, key);
1336 ret = eina_value_hash_vset(value, key, args);
1337 va_end(args);
1338 return ret;
1339}
1340
1341static inline Eina_Bool
1342eina_value_hash_get(const Eina_Value *value, const char *key, ...)
1343{
1344 va_list args;
1345 Eina_Bool ret;
1346 va_start(args, key);
1347 ret = eina_value_hash_vget(value, key, args);
1348 va_end(args);
1349 return ret;
1350}
1351
1352static inline Eina_Bool
1353eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr)
1354{
1355 Eina_Value_Hash *desc;
1356 void *mem;
1357
1358 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1359 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1360 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1361 if (!desc)
1362 return EINA_FALSE;
1363
1364 mem = eina_hash_find(desc->hash, key);
1365 if (!mem)
1366 {
1367 mem = malloc(desc->subtype->value_size);
1368 if (!mem)
1369 {
1370 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
1371 return EINA_FALSE;
1372 }
1373 if (!eina_hash_add(desc->hash, key, mem))
1374 {
1375 free(mem);
1376 return EINA_FALSE;
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 }
1384 }
1385
1386 return eina_value_type_pset(desc->subtype, mem, ptr);
1387}
1388
1389static inline Eina_Bool
1390eina_value_hash_pget(const Eina_Value *value, const char *key, void *ptr)
1391{
1392 const Eina_Value_Hash *desc;
1393 const void *mem;
1394 Eina_Bool ret;
1395
1396 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1397 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1398 desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
1399 if (!desc)
1400 return EINA_FALSE;
1401
1402 mem = eina_hash_find(desc->hash, key);
1403 if (!mem)
1404 return EINA_FALSE;
1405
1406 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1407 return ret;
1408}
1409#undef EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL
1410
1411#define EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, retval) \
1412 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
1413 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_STRUCT, retval)
1414
1415/**
1416 * @brief Find member of struct
1417 * @since 1.2
1418 * @internal
1419 */
1420EAPI const Eina_Value_Struct_Member *eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
1421
1422static inline Eina_Bool
1423eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc)
1424{
1425 Eina_Value_Struct desc = {sdesc, NULL};
1426 if (!eina_value_setup(value, EINA_VALUE_TYPE_STRUCT))
1427 return EINA_FALSE;
1428 if (!eina_value_pset(value, &desc))
1429 {
1430 eina_value_flush(value);
1431 return EINA_FALSE;
1432 }
1433 return EINA_TRUE;
1434}
1435
1436static inline void *
1437eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
1438{
1439 unsigned char *base = (unsigned char *)st->memory;
1440 if (!base) return NULL;
1441 return base + member->offset;
1442}
1443
1444static inline Eina_Bool
1445eina_value_struct_vset(Eina_Value *value, const char *name, va_list args)
1446{
1447 const Eina_Value_Struct_Member *member;
1448 Eina_Value_Struct *st;
1449 void *mem;
1450
1451 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1452 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1453 st = (Eina_Value_Struct *)eina_value_memory_get(value);
1454 if (!st)
1455 return EINA_FALSE;
1456 member = eina_value_struct_member_find(st, name);
1457 if (!member)
1458 return EINA_FALSE;
1459 mem = eina_value_struct_member_memory_get(st, member);
1460 if (!mem)
1461 return EINA_FALSE;
1462
1463 return eina_value_type_vset(member->type, mem, args);
1464}
1465
1466static inline Eina_Bool
1467eina_value_struct_vget(const Eina_Value *value, const char *name, va_list args)
1468{
1469 const Eina_Value_Struct_Member *member;
1470 const Eina_Value_Struct *st;
1471 const void *mem;
1472 void *ptr;
1473 Eina_Bool ret;
1474
1475 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1476 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1477 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1478 if (!st)
1479 return EINA_FALSE;
1480 member = eina_value_struct_member_find(st, name);
1481 if (!member)
1482 return EINA_FALSE;
1483 mem = eina_value_struct_member_memory_get(st, member);
1484 if (!mem)
1485 return EINA_FALSE;
1486
1487 ptr = va_arg(args, void *);
1488 ret = eina_value_type_pget(member->type, mem, ptr);
1489 return ret;
1490}
1491
1492static inline Eina_Bool
1493eina_value_struct_set(Eina_Value *value, const char *name, ...)
1494{
1495 va_list args;
1496 Eina_Bool ret;
1497 va_start(args, name);
1498 ret = eina_value_struct_vset(value, name, args);
1499 va_end(args);
1500 return ret;
1501}
1502
1503static inline Eina_Bool
1504eina_value_struct_get(const Eina_Value *value, const char *name, ...)
1505{
1506 va_list args;
1507 Eina_Bool ret;
1508 va_start(args, name);
1509 ret = eina_value_struct_vget(value, name, args);
1510 va_end(args);
1511 return ret;
1512}
1513
1514static inline Eina_Bool
1515eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr)
1516{
1517 const Eina_Value_Struct_Member *member;
1518 Eina_Value_Struct *st;
1519 void *mem;
1520
1521 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1522 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1523 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
1524 st = (Eina_Value_Struct *)eina_value_memory_get(value);
1525 if (!st)
1526 return EINA_FALSE;
1527 member = eina_value_struct_member_find(st, name);
1528 if (!member)
1529 return EINA_FALSE;
1530 mem = eina_value_struct_member_memory_get(st, member);
1531 if (!mem)
1532 return EINA_FALSE;
1533
1534 return eina_value_type_pset(member->type, mem, ptr);
1535}
1536
1537static inline Eina_Bool
1538eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr)
1539{
1540 const Eina_Value_Struct_Member *member;
1541 const Eina_Value_Struct *st;
1542 const void *mem;
1543 Eina_Bool ret;
1544
1545 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1546 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1547 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
1548 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1549 if (!st)
1550 return EINA_FALSE;
1551 member = eina_value_struct_member_find(st, name);
1552 if (!member)
1553 return EINA_FALSE;
1554 mem = eina_value_struct_member_memory_get(st, member);
1555 if (!mem)
1556 return EINA_FALSE;
1557
1558 ret = eina_value_type_pget(member->type, mem, ptr);
1559 return ret;
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
1674#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
1675
1676
1677static inline Eina_Bool
1678eina_value_type_setup(const Eina_Value_Type *type, void *mem)
1679{
1680 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1681 if (!type->setup)
1682 {
1683 eina_error_set(EINA_ERROR_VALUE_FAILED);
1684 return EINA_FALSE;
1685 }
1686 return type->setup(type, mem);
1687}
1688
1689static inline Eina_Bool
1690eina_value_type_flush(const Eina_Value_Type *type, void *mem)
1691{
1692 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1693 if (!type->flush)
1694 {
1695 eina_error_set(EINA_ERROR_VALUE_FAILED);
1696 return EINA_FALSE;
1697 }
1698 return type->flush(type, mem);
1699}
1700
1701static inline Eina_Bool
1702eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst)
1703{
1704 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1705 if (!type->copy)
1706 {
1707 eina_error_set(EINA_ERROR_VALUE_FAILED);
1708 return EINA_FALSE;
1709 }
1710 return type->copy(type, src, dst);
1711}
1712
1713static inline int
1714eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b)
1715{
1716 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1717 if (!type->compare)
1718 {
1719 eina_error_set(EINA_ERROR_VALUE_FAILED);
1720 return EINA_FALSE;
1721 }
1722 return type->compare(type, a, b);
1723}
1724
1725static inline Eina_Bool
1726eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1727{
1728 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1729 if (!type->convert_to)
1730 {
1731 eina_error_set(EINA_ERROR_VALUE_FAILED);
1732 return EINA_FALSE;
1733 }
1734 return type->convert_to(type, convert, type_mem, convert_mem);
1735}
1736
1737static inline Eina_Bool
1738eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
1739{
1740 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1741 if (!type->convert_from)
1742 {
1743 eina_error_set(EINA_ERROR_VALUE_FAILED);
1744 return EINA_FALSE;
1745 }
1746 return type->convert_from(type, convert, type_mem, convert_mem);
1747}
1748
1749static inline Eina_Bool
1750eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args)
1751{
1752 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1753 if (!type->vset)
1754 {
1755 eina_error_set(EINA_ERROR_VALUE_FAILED);
1756 return EINA_FALSE;
1757 }
1758 return type->vset(type, mem, args);
1759}
1760
1761static inline Eina_Bool
1762eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr)
1763{
1764 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1765 if (!type->pset)
1766 {
1767 eina_error_set(EINA_ERROR_VALUE_FAILED);
1768 return EINA_FALSE;
1769 }
1770 return type->pset(type, mem, ptr);
1771}
1772
1773static inline Eina_Bool
1774eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr)
1775{
1776 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1777 if (!type->pget)
1778 {
1779 eina_error_set(EINA_ERROR_VALUE_FAILED);
1780 return EINA_FALSE;
1781 }
1782 return type->pget(type, mem, ptr);
1783}
1784
1785#undef EINA_VALUE_TYPE_DEFAULT
1786#undef EINA_VALUE_TYPE_CHECK_RETURN
1787#undef EINA_VALUE_TYPE_CHECK_RETURN_VAL
1788#undef EINA_VALUE_TYPE_DISPATCH
1789#undef EINA_VALUE_TYPE_DISPATCH_RETURN
1790#endif
diff --git a/libraries/eina/src/include/eina_inlist.h b/libraries/eina/src/include/eina_inlist.h
deleted file mode 100644
index cfb3159..0000000
--- a/libraries/eina/src/include/eina_inlist.h
+++ /dev/null
@@ -1,814 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLIST_H_
20#define EINA_INLIST_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_accessor.h"
25#include <stddef.h>
26
27/**
28 * @page eina_inlist_01_example_page Eina_Inlist basic usage
29 * @dontinclude eina_inlist_01.c
30 *
31 * To see the full source for this example, click here: @ref
32 * eina_inlist_01_c
33 *
34 * As explained before, inline lists mean its nodes pointers are part of same
35 * memory block/blob. This is done by using the macro @ref EINA_INLIST inside the
36 * data structure that will be used:
37 *
38 * @skip struct
39 * @until };
40 *
41 * The resulting node representing this struct can be exemplified by the
42 * following picture:
43 *
44 * @image html eina_inlist-node_eg1-my-struct.png
45 * @image rtf eina_inlist-node_eg1-my-struct.png
46 * @image latex eina_inlist-node_eg1-my-struct.eps
47 *
48 * Let's define a comparison function that will be used later during the
49 * sorting of the list:
50 *
51 * @skip int
52 * @until }
53 *
54 * The @ref Eina_Inlist can be used exactly the same way as @ref Eina_List when
55 * appending, prepending and removing items. But since we already have the node
56 * pointers inside the structure, they need to be retrieved with the macro @ref
57 * EINA_INLIST_GET :
58 *
59 * @skip malloc
60 * @until append
61 *
62 * Notice that @ref eina_inlist_append always receives the head of the list as
63 * first argument, and its return value should be used as the list pointer
64 * (head):
65 *
66 * @skip malloc
67 * @until append
68 *
69 * After appending 3 items, the list now should look similar to this:
70 *
71 * @image html eina_inlist-node_eg1-inlist.png
72 * @image rtf eina_inlist-node_eg1-inlist.png
73 * @image latex eina_inlist-node_eg1-inlist.eps width=\textwidth
74 *
75 * The macro @ref EINA_INLIST_FOREACH can be used to iterate over the list:
76 *
77 * @skip printf
78 * @until cur->a
79 *
80 * @ref eina_inlist_promote(), @ref eina_inlist_demote(), @ref
81 * eina_inlist_append_relative() and similar functions all work in the same way
82 * as the @ref Eina_List :
83 *
84 * @skip eina_inlist_promote
85 * @until eina_inlist_demote
86 *
87 * Now let's use the @c sort_cb function declared above to sort our list:
88 *
89 * @skipline eina_inlist_sort
90 *
91 * Removing an element from the inlist is also similar to @ref Eina_List :
92 *
93 * @skip inlist_remove
94 * @until free
95 *
96 * Another way of walking through the inlist.
97 *
98 * @skip for
99 * @until }
100 *
101 * Notice that in the previous piece of code, since we only have the pointers to
102 * the inlist nodes, we have to use the @ref EINA_INLIST_CONTAINER_GET macro
103 * that will return the pointer to the entire structure. Of course, in this case
104 * it is the same as the list pointer, since the @ref EINA_INLIST macro was used
105 * in the beginning of the structure.
106 *
107 * Now to finish this example, lets delete this list:
108 *
109 * @skip while
110 * @until }
111 */
112
113/**
114 * @page eina_inlist_02_example_page Eina_Inlist advanced usage - lists and inlists
115 * @dontinclude eina_inlist_02.c
116 *
117 * This example describes the usage of @ref Eina_Inlist mixed with @ref
118 * Eina_List . We create and add elements to an inlist, and the even members
119 * are also added to a normal list. Later we remove the elements divisible by 3
120 * from this normal list.
121 *
122 * The struct that is going to be used is the same used in @ref
123 * eina_inlist_01_example_page , since we still need the @ref EINA_INLIST macro to
124 * declare the inlist node info:
125 *
126 * @skip struct
127 * @until };
128 *
129 * The resulting node representing this struct can be exemplified by the
130 * following picture:
131 *
132 * @image html eina_inlist-node_eg2-my-struct.png
133 * @image rtf eina_inlist-node_eg2-my-struct.png
134 * @image latex eina_inlist-node_eg2-my-struct.eps
135 *
136 * Now we need some pointers and auxiliar variables that will help us iterate on
137 * the lists:
138 *
139 * @skip struct
140 * @until l_next;
141 *
142 * Allocating 100 elements and putting them into an inlist, and the even
143 * elements also go to the normal list:
144 *
145 * @skip for
146 * @until }
147 *
148 * After this point, what we have are two distinct lists that share some
149 * elements. The first list (inlist) is defined by the pointers inside the
150 * elements data structure, while the second list (normal list) has its own node
151 * data structure that is kept outside of the elements.
152 *
153 * The two lists, sharing some elements, can be represented by the following
154 * picture:
155 *
156 * @htmlonly
157 * <img src="eina_inlist-node_eg2-list-inlist.png" style="max-width: 100%;"/>
158 * @endhtmlonly
159 * @image rtf eina_inlist-node_eg2-list-inlist.png
160 * @image latex eina_inlist-node_eg2-list-inlist.eps width=\textwidth
161 *
162 * Accessing both lists is done normally, as if they didn't have any elements in
163 * common:
164 *
165 * @skip printf
166 * @until eina_list_count
167 *
168 * We can remove elements from the normal list, but we just don't free them
169 * because they are still stored in the inlist:
170 *
171 * @skip EINA_LIST_FOREACH_SAFE
172 * @until eina_list_count
173 *
174 * To finish this example, we want to free both lists, we can't just free all
175 * elements on the second list (normal list) because they are still being used
176 * in the inlist. So we first discard the normal list without freeing its
177 * elements, then we free all elements in the inlist (that contains all elements
178 * allocated until now):
179 *
180 * @skip eina_list_free
181 * @until }
182 *
183 * Here is the full source code for this example: @ref eina_inlist_02_c
184 */
185
186/**
187 * @page eina_inlist_03_example_page Eina_Inlist advanced usage - multi-inlists
188 * @dontinclude eina_inlist_03.c
189 *
190 * This example describes the usage of multiple inlists storing the same data.
191 * It means that some data may appear in more than one inlist at the same time.
192 * We will demonstrate this by creating an inlist with 100 numbers, and adding
193 * the odd numbers to the second inlist, then remove the numbers divisible by 3
194 * from the second list.
195 *
196 * To accomplish this, it is necessary to have two inlist pointers in the struct
197 * that is going to be stored. We are using the default inlist member @ref
198 * EINA_INLIST, and adding another member @c even that is of type @ref
199 * Eina_Inlist too:
200 *
201 * @skip struct
202 * @until };
203 *
204 * The representation for this struct is:
205 *
206 * @image html eina_inlist-node_eg3-my-struct.png
207 * @image rtf eina_inlist-node_eg3-my-struct.png
208 * @image latex eina_inlist-node_eg3-my-struct.eps
209 *
210 * And we will define some convenience macros that are equivalent to @ref
211 * EINA_INLIST_GET and @ref EINA_INLIST_CONTAINER_GET :
212 *
213 * @skip define
214 * @until offsetof
215 *
216 * We need two pointers, one for each list, and a pointer that will be used as
217 * an iterator:
218 *
219 * @skipline Eina_Inlist
220 *
221 * Now we allocate and add to the first list every number from 0 to 99. These
222 * nodes data also have the @ref Eina_Inlist node info for the second list (@c
223 * even). We will use them to add just the even numbers to the second list, the
224 * @c list_even. Also notice that we are using our macro @c EVEN_INLIST_GET to
225 * get the pointer to the even list node info:
226 *
227 * @skip for
228 * @until }
229 *
230 * And the resulting lists will be as follow:
231 *
232 * @htmlonly
233 * <img src="eina_inlist-node_eg3-two-inlists.png" style="max-width: 100%;"/>
234 * @endhtmlonly
235 * @image rtf eina_inlist-node_eg3-two-inlists.png
236 * @image latex eina_inlist-node_eg3-two-inlists.eps width=\textwidth
237 *
238 * For the first list, we can use the macro @ref EINA_INLIST_FOREACH to iterate
239 * over its elements:
240 *
241 * @skip FOREACH
242 * @until printf
243 *
244 * But for the second list, we have to do it manually. Of course we could create
245 * a similar macro to @ref EINA_INLIST_FOREACH, but since this macro is more
246 * complex than the other two and we are using it only once, it's better to just
247 * do it manually:
248 *
249 * @skip for
250 * @until }
251 *
252 * Let's just check that the two lists have the expected number of elements:
253 *
254 * @skip list count
255 * @until list_even count
256 *
257 * And removing the numbers divisible by 3 only from the second list:
258 *
259 * @skip itr
260 * @until list_even count
261 *
262 * Now that we don't need the two lists anymore, we can just free all the items.
263 * Since all of the allocated data was put into the first list, and both lists
264 * are made of pointers to inside the data structures, we can free only the
265 * first list (that contains all the elements) and the second list will be gone
266 * with it:
267 *
268 * @skip while
269 * @until free
270 *
271 * To see the full source code for this example, click here: @ref
272 * eina_inlist_03_c
273 *
274 */
275
276/**
277 * @page eina_inlist_01_c eina_inlist_01.c Eina_Inlist basic usage source
278 * @include eina_inlist_01.c
279 */
280
281/**
282 * @page eina_inlist_02_c eina_inlist_02.c Eina_Inlist advanced usage - lists and inlists source
283 * @include eina_inlist_02.c
284 */
285
286/**
287 * @page eina_inlist_03_c eina_inlist_03.c Eina_Inlist advanced usage - multi-inlists source
288 * @include eina_inlist_03.c
289 */
290
291/**
292 * @addtogroup Eina_Inline_List_Group Inline List
293 *
294 * @brief These functions provide inline list management.
295 *
296 * Inline lists mean its nodes pointers are part of same memory as
297 * data. This has the benefit of fragmenting memory less and avoiding
298 * @c node->data indirection, but has the drawback of higher cost for some
299 * common operations like count and sort.
300 *
301 * It is possible to have inlist nodes to be part of regular lists, created with
302 * @ref eina_list_append() or @ref eina_list_prepend(). It's also possible to
303 * have a structure with two inlist pointers, thus be part of two different
304 * inlists at the same time, but the current convenience macros provided won't
305 * work for both of them. Consult @ref inlist_advanced for more info.
306 *
307 * Inline lists have their purposes, but if you don't know what those purposes are, go with
308 * regular lists instead.
309 *
310 * Tip: When using inlists in more than one place (that is, passing them around
311 * functions or keeping a pointer to them in a structure) it's more correct
312 * to keep a pointer to the first container, and not a pointer to the first
313 * inlist item (mostly they are the same, but that's not always correct).
314 * This lets the compiler to do type checking and let the programmer know
315 * exactly what type this list is.
316 *
317 * A simple example demonstrating the basic usage of an inlist can be found
318 * here: @ref eina_inlist_01_example_page
319 *
320 * @section inlist_algo Algorithm
321 *
322 * The basic structure can be represented by the following picture:
323 *
324 * @image html eina_inlist-node.png
325 * @image rtf eina_inlist-node.png
326 * @image latex eina_inlist-node.eps
327 *
328 * One data structure will also have the node information, with three pointers:
329 * @a prev, @a next and @a last. The @a last pointer is just valid for the first
330 * element (the list head), otherwise each insertion in the list would have to
331 * be done updating every node with the correct pointer. This means that it's
332 * always very important to keep a pointer to the first element of the list,
333 * since it is the only one that has the correct information to allow a proper
334 * O(1) append to the list.
335 *
336 * @section inlist_perf Performance
337 *
338 * Due to the nature of the inlist, there's no accounting information, and no
339 * easy access to the last element from each list node. This means that @ref
340 * eina_inlist_count() is order-N, while @ref eina_list_count() is order-1 (constant
341 * time).
342 *
343 * For the same reasons, @ref eina_inlist_sort() is slower than @ref
344 * eina_list_sort() . If the list is intended to have faster access, be
345 * sorted/merged frequently, or needs to have other complex operations, consider
346 * using @ref Eina_List instead.
347 *
348 * @section inlist_advanced Advanced Usage
349 *
350 * The basic usage considers a struct that will have the user data, and also
351 * have an inlist node information (prev, next and last pointers) created with
352 * @ref EINA_INLIST during the struct declaration. This allows one to use the
353 * convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GET(),
354 * @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_INLIST
355 * macro declares a struct member with the name @a __inlist, and all the other
356 * macros assume that this struct member has this name.
357 *
358 * It may be the case that someone needs to have some inlist nodes added to a
359 * @ref Eina_List too. If this happens, the inlist nodes can be added to the
360 * @ref Eina_List without any problems. This example demonstrates this case:
361 * @ref inlist_02_example_page
362 *
363 * It's also possible to have some data that is part of two different inlists.
364 * If this is the case, then it won't be possible to use the convenience macros
365 * to both of the lists. It will be necessary to create a new set of macros that
366 * will allow access to the second list node info. An example for this usage can
367 * be found here:
368 * @ref inlist_03_example_page
369 *
370 * List of examples:
371 * @li @ref eina_inlist_01_example_page
372 * @li @ref eina_inlist_02_example_page
373 * @li @ref eina_inlist_03_example_page
374 */
375
376/**
377 * @addtogroup Eina_Data_Types_Group Data Types
378 *
379 * @{
380 */
381
382/**
383 * @addtogroup Eina_Containers_Group Containers
384 *
385 * @{
386 */
387
388/**
389 * @defgroup Eina_Inline_List_Group Inline List
390 *
391 * @{
392 */
393
394/**
395 * @typedef Eina_Inlist
396 * Inlined list type.
397 */
398typedef struct _Eina_Inlist Eina_Inlist;
399
400/**
401 * @typedef Eina_Inlist_Sorted_State
402 * @since 1.1.0
403 * State of sorted Eina_Inlist
404 */
405typedef struct _Eina_Inlist_Sorted_State Eina_Inlist_Sorted_State;
406
407/**
408 * @struct _Eina_Inlist
409 * Inlined list type.
410 */
411struct _Eina_Inlist
412{
413 Eina_Inlist *next; /**< next node */
414 Eina_Inlist *prev; /**< previous node */
415 Eina_Inlist *last; /**< last node */
416};
417/** Used for declaring an inlist member in a struct */
418#define EINA_INLIST Eina_Inlist __in_list
419/** Utility macro to get the inlist object of a struct */
420#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list))
421/** Utility macro to get the container object of an inlist */
422#define EINA_INLIST_CONTAINER_GET(ptr, \
423 type) ((type *)((char *)ptr - \
424 offsetof(type, __in_list)))
425
426
427/**
428 * Add a new node to end of a list.
429 *
430 * @note this code is meant to be fast: appends are O(1) and do not
431 * walk @a in_list.
432 *
433 * @note @a in_item is considered to be in no list. If it was in another
434 * list before, eina_inlist_remove() it before adding. No
435 * check of @a new_l prev and next pointers is done, so it's safe
436 * to have them uninitialized.
437 *
438 * @param in_list existing list head or NULL to create a new list.
439 * @param in_item new list node, must not be NULL.
440 *
441 * @return the new list head. Use it and not @a in_list anymore.
442 */
443EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list,
444 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
445
446/**
447 * Add a new node to beginning of list.
448 *
449 * @note this code is meant to be fast: appends are O(1) and do not
450 * walk @a in_list.
451 *
452 * @note @a new_l is considered to be in no list. If it was in another
453 * list before, eina_inlist_remove() it before adding. No
454 * check of @a new_l prev and next pointers is done, so it's safe
455 * to have them uninitialized.
456 *
457 * @param in_list existing list head or NULL to create a new list.
458 * @param in_item new list node, must not be NULL.
459 *
460 * @return the new list head. Use it and not @a in_list anymore.
461 */
462EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list,
463 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
464
465/**
466 * Add a new node after the given relative item in list.
467 *
468 * @note this code is meant to be fast: appends are O(1) and do not
469 * walk @a in_list.
470 *
471 * @note @a in_item_l is considered to be in no list. If it was in another
472 * list before, eina_inlist_remove() it before adding. No
473 * check of @a in_item prev and next pointers is done, so it's safe
474 * to have them uninitialized.
475 *
476 * @note @a in_relative is considered to be inside @a in_list, no checks are
477 * done to confirm that and giving nodes from different lists
478 * will lead to problems. Giving NULL @a in_relative is the same as
479 * eina_list_append().
480 *
481 * @param in_list existing list head or NULL to create a new list.
482 * @param in_item new list node, must not be NULL.
483 * @param in_relative reference node, @a in_item will be added after it.
484 *
485 * @return the new list head. Use it and not @a list anymore.
486 */
487EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list,
488 Eina_Inlist *in_item,
489 Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
490
491/**
492 * Add a new node before the given relative item in list.
493 *
494 * @note this code is meant to be fast: appends are O(1) and do not
495 * walk @a in_list.
496 *
497 * @note @a in_item is considered to be in no list. If it was in another
498 * list before, eina_inlist_remove() it before adding. No
499 * check of @a in_item prev and next pointers is done, so it's safe
500 * to have them uninitialized.
501 *
502 * @note @a in_relative is considered to be inside @a in_list, no checks are
503 * done to confirm that and giving nodes from different lists
504 * will lead to problems. Giving NULL @a in_relative is the same as
505 * eina_list_prepend().
506 *
507 * @param in_list existing list head or NULL to create a new list.
508 * @param in_item new list node, must not be NULL.
509 * @param in_relative reference node, @a in_item will be added before it.
510 *
511 * @return the new list head. Use it and not @a in_list anymore.
512 */
513EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list,
514 Eina_Inlist *in_item,
515 Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
516
517/**
518 * Remove node from list.
519 *
520 * @note this code is meant to be fast: appends are O(1) and do not
521 * walk @a list.
522 *
523 * @note @a in_item is considered to be inside @a in_list, no checks are
524 * done to confirm that and giving nodes from different lists
525 * will lead to problems, especially if @a in_item is the head since
526 * it will be different from @a list and the wrong new head will
527 * be returned.
528 *
529 * @param in_list existing list head, must not be NULL.
530 * @param in_item existing list node, must not be NULL.
531 *
532 * @return the new list head. Use it and not @a list anymore.
533 */
534EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list,
535 Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
536
537/**
538 * Find given node in list, returns itself if found, NULL if not.
539 *
540 * @warning this is an expensive call and has O(n) cost, possibly
541 * walking the whole list.
542 *
543 * @param in_list existing list to search @a in_item in, must not be NULL.
544 * @param in_item what to search for, must not be NULL.
545 *
546 * @return @a in_item if found, NULL if not.
547 */
548EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list,
549 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
550
551/**
552 * Move existing node to beginning of list.
553 *
554 * @note this code is meant to be fast: appends are O(1) and do not
555 * walk @a list.
556 *
557 * @note @a item is considered to be inside @a list. No checks are
558 * done to confirm this, and giving nodes from different lists
559 * will lead to problems.
560 *
561 * @param list existing list head or NULL to create a new list.
562 * @param item list node to move to beginning (head), must not be NULL.
563 *
564 * @return the new list head. Use it and not @a list anymore.
565 */
566EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist *list,
567 Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
568
569/**
570 * Move existing node to end of list.
571 *
572 * @note this code is meant to be fast: appends are O(1) and do not
573 * walk @a list.
574 *
575 * @note @a item is considered to be inside @a list. No checks are
576 * done to confirm this, and giving nodes from different lists
577 * will lead to problems.
578 *
579 * @param list existing list head or NULL to create a new list.
580 * @param item list node to move to end (tail), must not be NULL.
581 *
582 * @return the new list head. Use it and not @a list anymore.
583 */
584EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist *list,
585 Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
586
587/**
588 * @brief Get the count of the number of items in a list.
589 *
590 * @param list The list whose count to return.
591 * @return The number of members in the list.
592 *
593 * This function returns how many members @p list contains. If the
594 * list is @c NULL, 0 is returned.
595 *
596 * @warning This is an order-N operation and so the time will depend
597 * on the number of elements on the list, so, it might become
598 * slow for big lists!
599 */
600EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
601
602
603/**
604 * @brief Returns a new iterator associated to @a list.
605 *
606 * @param in_list The list.
607 * @return A new iterator.
608 *
609 * This function returns a newly allocated iterator associated to @p
610 * in_list. If @p in_list is @c NULL or the count member of @p in_list is less
611 * or equal than 0, this function still returns a valid iterator that
612 * will always return false on eina_iterator_next(), thus keeping API
613 * sane.
614 *
615 * If the memory can not be allocated, NULL is returned and
616 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
617 * returned.
618 *
619 * @warning if the list structure changes then the iterator becomes
620 * invalid, and if you add or remove nodes iterator
621 * behavior is undefined, and your program may crash!
622 */
623EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
624
625/**
626 * @brief Returns a new accessor associated to a list.
627 *
628 * @param in_list The list.
629 * @return A new accessor.
630 *
631 * This function returns a newly allocated accessor associated to
632 * @p in_list. If @p in_list is @c NULL or the count member of @p in_list is
633 * less or equal than 0, this function returns @c NULL. If the memory can
634 * not be allocated, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
635 * set. Otherwise, a valid accessor is returned.
636 */
637EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
638
639/**
640 * @brief Insert a new node into a sorted list.
641 *
642 * @param list The given linked list, @b must be sorted.
643 * @param item list node to insert, must not be NULL.
644 * @param func The function called for the sort.
645 * @return A list pointer.
646 * @since 1.1.0
647 *
648 * This function inserts item into a linked list assuming it was
649 * sorted and the result will be sorted. If @p list is @c NULLL, item
650 * is returned. On success, a new list pointer that should be
651 * used in place of the one given to this function is
652 * returned. Otherwise, the old pointer is returned. See eina_error_get().
653 *
654 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
655 * performance. As said in eina_list_search_sorted_near_list(),
656 * lists do not have O(1) access time, so walking to the correct node
657 * can be costly, consider worst case to be almost O(n) pointer
658 * dereference (list walk).
659 */
660EAPI Eina_Inlist *eina_inlist_sorted_insert(Eina_Inlist *list, Eina_Inlist *item, Eina_Compare_Cb func) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
661
662/**
663 * @brief Create state with valid data in it.
664 *
665 * @return A valid Eina_Inlist_Sorted_State.
666 * @since 1.1.0
667 *
668 * See eina_inlist_sorted_state_insert() for more information.
669 */
670EAPI Eina_Inlist_Sorted_State *eina_inlist_sorted_state_new(void);
671
672/**
673 * @brief Force an Eina_Inlist_Sorted_State to match the content of a list.
674 *
675 * @param state The state to update
676 * @param list The list to match
677 * @return The number of item in the actually in the list
678 * @since 1.1.0
679 *
680 * See eina_inlist_sorted_state_insert() for more information. This function is
681 * usefull if you didn't use eina_inlist_sorted_state_insert() at some point, but
682 * still think you have a sorted list. It will only correctly work on a sorted list.
683 */
684EAPI int eina_inlist_sorted_state_init(Eina_Inlist_Sorted_State *state, Eina_Inlist *list);
685
686/**
687 * @brief Free an Eina_Inlist_Sorted_State.
688 *
689 * @param state The state to destroy
690 * @since 1.1.0
691 *
692 * See eina_inlist_sorted_state_insert() for more information.
693 */
694EAPI void eina_inlist_sorted_state_free(Eina_Inlist_Sorted_State *state);
695
696/**
697 * @brief Insert a new node into a sorted list.
698 *
699 * @param list The given linked list, @b must be sorted.
700 * @param item list node to insert, must not be NULL.
701 * @param func The function called for the sort.
702 * @param state The current array for initial dichotomic search
703 * @return A list pointer.
704 * @since 1.1.0
705 *
706 * This function inserts item into a linked list assuming @p state match
707 * the exact content order of the list. It use @p state to do a fast
708 * first step dichotomic search before starting to walk the inlist itself.
709 * This make this code much faster than eina_inlist_sorted_insert() as it
710 * doesn't need to walk the list at all. The result is of course a sorted
711 * list with an updated state.. If @p list is @c NULLL, item
712 * is returned. On success, a new list pointer that should be
713 * used in place of the one given to this function is
714 * returned. Otherwise, the old pointer is returned. See eina_error_get().
715 *
716 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
717 * performance. As said in eina_list_search_sorted_near_list(),
718 * lists do not have O(1) access time, so walking to the correct node
719 * can be costly, but this version try to minimize that by making it a
720 * O(log2(n)) for number small number. After n == 256, it start to add a
721 * linear cost again. Consider worst case to be almost O(n) pointer
722 * dereference (list walk).
723 */
724EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list,
725 Eina_Inlist *item,
726 Eina_Compare_Cb func,
727 Eina_Inlist_Sorted_State *state);
728/**
729 * @brief Sort a list according to the ordering func will return.
730 *
731 * @param head The list handle to sort.
732 * @param func A function pointer that can handle comparing the list data
733 * nodes.
734 * @return the new head of list.
735 *
736 * This function sorts all the elements of @p head. @p func is used to
737 * compare two elements of @p head. If @p head or @p func are @c NULL,
738 * this function returns @c NULL.
739 *
740 * @note @b in-place: this will change the given list, so you should
741 * now point to the new list head that is returned by this function.
742 *
743 * @note worst case is O(n * log2(n)) comparisons (calls to func()),
744 * O(n) comparisons average case. That means that for 1,000,000 list
745 * elements, sort will usually do 1,000,000 comparisons, but may do up
746 * to 20,000,000.
747 *
748 * Example:
749 * @code
750 * typedef struct _Sort_Ex Sort_Ex;
751 * struct _Sort_Ex
752 * {
753 * INLIST;
754 * const char *text;
755 * };
756 *
757 * int
758 * sort_cb(const Inlist *l1, const Inlist *l2)
759 * {
760 * const Sort_Ex *x1;
761 * const Sort_Ex *x2;
762 *
763 * x1 = EINA_INLIST_CONTAINER_GET(l1, Sort_Ex);
764 * x2 = EINA_INLIST_CONTAINER_GET(l2, Sort_Ex);
765 *
766 * return(strcmp(x1->text, x2->text));
767 * }
768 * extern Eina_Inlist *list;
769 *
770 * list = eina_inlist_sort(list, sort_cb);
771 * @endcode
772 */
773EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func);
774
775/* This two macros are helpers for the _FOREACH ones, don't use them */
776#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
777
778#if !defined(__cplusplus)
779#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \
780 _EINA_INLIST_OFFSET(ref))
781#else
782/*
783 * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's typeof
784 * operator.
785 */
786#define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \
787 _EINA_INLIST_OFFSET(ref))
788#endif
789
790/** Macro to iterate over an inlist */
791#define EINA_INLIST_FOREACH(list, l) \
792 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \
793 l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
794#define EINA_INLIST_FOREACH_SAFE(list, list2, l) \
795 for (l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL), list2 = l ? ((EINA_INLIST_GET(l) ? EINA_INLIST_GET(l)->next : NULL)) : NULL; \
796 l; \
797 l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next : NULL)
798#define EINA_INLIST_REVERSE_FOREACH(list, l) \
799 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \
800 l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL))
801
802/**
803 * @}
804 */
805
806/**
807 * @}
808 */
809
810/**
811 * @}
812 */
813
814#endif /*EINA_INLIST_H_*/
diff --git a/libraries/eina/src/include/eina_iterator.h b/libraries/eina/src/include/eina_iterator.h
deleted file mode 100644
index 10a9ece..0000000
--- a/libraries/eina/src/include/eina_iterator.h
+++ /dev/null
@@ -1,337 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ITERATOR_H__
20#define EINA_ITERATOR_H__
21
22#include "eina_config.h"
23
24#include "eina_types.h"
25#include "eina_magic.h"
26
27/**
28 * @page eina_iterator_example_page Eina_Iterator usage
29 * @dontinclude eina_iterator_01.c
30 *
31 * As always when using eina we need to include it:
32 * @skip #include
33 * @until Eina.h
34 *
35 * Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prints
36 * some data:
37 * @until }
38 * @note Returning EINA_TRUE is important so we don't stop iterating over the
39 * container.
40 *
41 * And here a more interesting function, it uses an iterator to print the
42 * contents of a container. What's interesting about it is that it doesn't care
43 * the type of container, it works for anything that can provide an iterator:
44 * @until }
45 *
46 * And on to our main function were we declare some variables and initialize
47 * eina, nothing too special:
48 * @until eina_init
49 *
50 * Next we populate both an array and a list with our strings, for more details
51 * see @ref eina_list_01_example_page and @ref eina_array_01_example_page :
52 * @until }
53 *
54 * And now we create an array and because the first element of the container
55 * doesn't interest us we skip it:
56 * @until iterator_next
57 *
58 * Having our iterator now pointing to interesting data we go ahead and print:
59 * @until print_eina_container
60 *
61 * As always once data with a structure we free it, but just because we can we
62 * do it by asking the iterator for it's container, and then of course free the
63 * iterator itself:
64 * @until eina_iterator_free
65 *
66 * But so far you're not impressed in @ref eina_array_01_example_page an array is
67 * also printed, so now we go to the cool stuff and use an iterator to do same
68 * stuff to a list:
69 * @until eina_iterator_free
70 * @note The only significant diference to the block above is in the
71 * function used to create the iterator.
72 *
73 * And now we free the list and shut eina down:
74 * @until }
75 */
76
77/**
78 * @page eina_iterator_01_c Eina_Iterator usage
79 * @page eina_iterator_01_c Eina_Iterator usage
80 *
81 * @include eina_iterator_01.c
82 * @example eina_iterator_01.c
83 */
84
85/**
86 * @addtogroup Eina_Iterator_Group Iterator Functions
87 *
88 * @brief These functions manage iterators on containers.
89 *
90 * These functions allow to access elements of a container in a
91 * generic way, without knowing which container is used (a bit like
92 * iterators in the C++ STL). Iterators only allows sequential access
93 * (that is, from an element to the next one). For random access, see
94 * @ref Eina_Accessor_Group.
95 *
96 * An iterator is created from container data types, so no creation
97 * function is available here. An iterator is deleted with
98 * eina_iterator_free(). To get the data and iterate, use
99 * eina_iterator_next(). To call a function on all the elements of a
100 * container, use eina_iterator_foreach().
101 *
102 * Here an @ref eina_iterator_example_page "example"
103 */
104
105/**
106 * @addtogroup Eina_Content_Access_Group Content Access
107 *
108 * @{
109 */
110
111/**
112 * @defgroup Eina_Iterator_Group Iterator Functions
113 *
114 * @{
115 */
116
117/**
118 * @typedef Eina_Iterator
119 * Abstract type for iterators.
120 */
121typedef struct _Eina_Iterator Eina_Iterator;
122
123/**
124 * @typedef Eina_Iterator_Next_Callback
125 * Type for a callback that returns the next element in a container.
126 */
127typedef Eina_Bool (*Eina_Iterator_Next_Callback)(Eina_Iterator *it, void **data);
128
129/**
130 * @typedef Eina_Iterator_Get_Container_Callback
131 * Type for a callback that returns the container.
132 */
133typedef void *(*Eina_Iterator_Get_Container_Callback)(Eina_Iterator *it);
134
135/**
136 * @typedef Eina_Iterator_Free_Callback
137 * Type for a callback that frees the container.
138 */
139typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
140
141/**
142 * @typedef Eina_Iterator_Lock_Callback
143 * Type for a callback that lock the container.
144 */
145typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it);
146
147/**
148 * @struct _Eina_Iterator
149 * structure of an iterator
150 */
151struct _Eina_Iterator
152{
153#define EINA_ITERATOR_VERSION 1
154 int version; /**< Version of the Iterator API. */
155
156 Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; /**< Callback called when a next element is requested. */
157 Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */
158 Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */
159
160 Eina_Iterator_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */
161 Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */
162
163#define EINA_MAGIC_ITERATOR 0x98761233
164 EINA_MAGIC
165};
166
167/**
168 * @def FUNC_ITERATOR_NEXT(Function)
169 * Helper macro to cast @p Function to a Eina_Iterator_Next_Callback.
170 */
171#define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function)
172
173/**
174 * @def FUNC_ITERATOR_GET_CONTAINER(Function)
175 * Helper macro to cast @p Function to a Eina_Iterator_Get_Container_Callback.
176 */
177#define FUNC_ITERATOR_GET_CONTAINER(Function) ((Eina_Iterator_Get_Container_Callback)Function)
178
179/**
180 * @def FUNC_ITERATOR_FREE(Function)
181 * Helper macro to cast @p Function to a Eina_Iterator_Free_Callback.
182 */
183#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function)
184
185/**
186 * @def FUNC_ITERATOR_LOCK(Function)
187 * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
188 */
189#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback)Function)
190
191
192/**
193 * @brief Free an iterator.
194 *
195 * @param iterator The iterator to free.
196 *
197 * This function frees @p iterator if it is not @c NULL;
198 */
199EAPI void eina_iterator_free(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
200
201
202/**
203 * @brief Return the container of an iterator.
204 *
205 * @param iterator The iterator.
206 * @return The container which created the iterator.
207 *
208 * This function returns the container which created @p iterator. If
209 * @p iterator is @c NULL, this function returns @c NULL.
210 */
211EAPI void *eina_iterator_container_get(Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
212
213/**
214 * @brief Return the value of the current element and go to the next one.
215 *
216 * @param iterator The iterator.
217 * @param data The data of the element.
218 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
219 *
220 * This function returns the value of the current element pointed by
221 * @p iterator in @p data, then goes to the next element. If @p
222 * iterator is @c NULL or if a problem occurred, #EINA_FALSE is
223 * returned, otherwise #EINA_TRUE is returned.
224 */
225EAPI Eina_Bool eina_iterator_next(Eina_Iterator *iterator,
226 void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
227
228
229/**
230 * @brief Iterate over the container and execute a callback on each element.
231 *
232 * @param iterator The iterator.
233 * @param callback The callback called on each iteration.
234 * @param fdata The data passed to the callback.
235 *
236 * This function iterates over the elements pointed by @p iterator,
237 * beginning from the current element. For Each element, the callback
238 * @p cb is called with the data @p fdata. If @p iterator is @c NULL,
239 * the function returns immediately. Also, if @p cb returns @c
240 * EINA_FALSE, the iteration stops at that point, if @p cb returns @c EINA_TRUE
241 * the iteration continues.
242 */
243EAPI void eina_iterator_foreach(Eina_Iterator *iterator,
244 Eina_Each_Cb callback,
245 const void *fdata) EINA_ARG_NONNULL(1, 2);
246
247
248/**
249 * @brief Lock the container of the iterator.
250 *
251 * @param iterator The iterator.
252 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
253 *
254 * If the container of the @p iterator permits it, it will be locked. When a
255 * container is locked calling eina_iterator_foreach() on it will return
256 * immediately. If @p iterator is @c NULL or if a problem occurred, #EINA_FALSE
257 * is returned, otherwise #EINA_TRUE is returned. If the container isn't
258 * lockable, it will return EINA_TRUE.
259 *
260 * @warning None of the existing eina data structures are lockable.
261 */
262EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
263
264/**
265 * @brief Unlock the container of the iterator.
266 *
267 * @param iterator The iterator.
268 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
269 *
270 * If the container of the @p iterator permits it and was previously
271 * locked, it will be unlocked. If @p iterator is @c NULL or if a
272 * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
273 * is returned. If the container is not lockable, it will return
274 * EINA_TRUE.
275 *
276 * @warning None of the existing eina data structures are lockable.
277 */
278EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
279
280/**
281 * @def EINA_ITERATOR_FOREACH
282 * @brief Macro to iterate over all elements easily.
283 *
284 * @param itr The iterator to use.
285 * @param data Where to store * data, must be a pointer support getting
286 * its address since * eina_iterator_next() requires a pointer
287 * to pointer!
288 *
289 * This macro is a convenient way to use iterators, very similar to
290 * EINA_LIST_FOREACH().
291 *
292 * This macro can be used for freeing the data of a list, like in the
293 * following example. It has the same goal as the one documented in
294 * EINA_LIST_FOREACH(), but using iterators:
295 *
296 * @code
297 * Eina_List *list;
298 * Eina_Iterator *itr;
299 * char *data;
300 *
301 * // list is already filled,
302 * // its elements are just duplicated strings
303 *
304 * itr = eina_list_iterator_new(list);
305 * EINA_ITERATOR_FOREACH(itr, data)
306 * free(data);
307 * eina_iterator_free(itr);
308 * eina_list_free(list);
309 * @endcode
310 *
311 * @note this example is not optimal algorithm to release a list since
312 * it will walk the list twice, but it serves as an example. For
313 * optimized version use EINA_LIST_FREE()
314 *
315 * @warning The order in which the elements will be traversed depends on the
316 * underlying container and @b shouldn't be relied upon.
317 *
318 * @warning unless explicitly stated in functions returning iterators,
319 * do not modify the iterated object while you walk it, in this
320 * example using lists, do not remove list nodes or you might
321 * crash! This is not a limitiation of iterators themselves,
322 * rather in the iterators implementations to keep them as simple
323 * and fast as possible.
324 */
325#define EINA_ITERATOR_FOREACH(itr, \
326 data) while (eina_iterator_next((itr), \
327 (void **)(void *)&(data)))
328
329/**
330 * @}
331 */
332
333/**
334 * @}
335 */
336
337#endif
diff --git a/libraries/eina/src/include/eina_lalloc.h b/libraries/eina/src/include/eina_lalloc.h
deleted file mode 100644
index dcb8773..0000000
--- a/libraries/eina/src/include/eina_lalloc.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LALLOC_H_
20#define EINA_LALLOC_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Tools_Group Tools
26 *
27 * @{
28 */
29
30/**
31 * @defgroup Eina_Lalloc_Group Lazy allocator
32 *
33 * @{
34 */
35
36typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
37#define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
38typedef void (*Eina_Lalloc_Free)(void *user_data);
39#define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function)
40
41typedef struct _Eina_Lalloc Eina_Lalloc;
42
43EAPI Eina_Lalloc *eina_lalloc_new(void *data,
44 Eina_Lalloc_Alloc alloc_cb,
45 Eina_Lalloc_Free free_cb,
46 int num_init) EINA_ARG_NONNULL(2, 3);
47EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
48EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a,
49 int num) EINA_ARG_NONNULL(1);
50EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
51
52/**
53 * @}
54 */
55
56/**
57 * @}
58 */
59
60#endif /* EINA_LALLOC_H_ */
diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h
deleted file mode 100644
index c8ef06d..0000000
--- a/libraries/eina/src/include/eina_list.h
+++ /dev/null
@@ -1,1631 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LIST_H_
20#define EINA_LIST_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_iterator.h"
28#include "eina_accessor.h"
29#include "eina_magic.h"
30
31/**
32 * @page eina_list_01_example_page Adding elements to Eina_List
33 * @dontinclude eina_list_01.c
34 *
35 * Creating an @ref Eina_List and adding elements to it is very easy and can be
36 * understood from an example:
37 * First thing is always to include Eina.h, for this example we also
38 * include stdio.h so we can use printf.
39 * @skip #include
40 * @until Eina.h
41 *
42 * Just some boilerplate code, declaring some variable and initializing eina.
43 * @until eina_init
44 * Here we add a sequence of elements to our list. By using append we add
45 * elements to the end of the list, so the list will look like this:@n
46 * @htmlonly
47 * <img src="eina_list_example_01_a.png" style="max-width: 100%;" />
48 * <a href="eina_list_example_01_a.png">Full-size</a>
49 * @endhtmlonly
50 * @image rtf eina_list_example_01_a.png
51 * @image latex eina_list_example_01_a.eps width=\textwidth
52 * @until roslin
53 * There are a couple of interesting things happening here, first is that we are
54 * passing a NULL pointer to the first @ref eina_list_append() call, when this
55 * is done a list is created. The other @b very important detail to notice is
56 * that the return value is attributed to the @a list variable, this needs to
57 * be done every time we use a a function that alters the contents of the list.
58 *
59 * Now that we have a list we some elements in it we can look at it's contents.
60 * @until printf
61 *
62 * There are many ways of accessing elements in the list, including by it's
63 * index:
64 * @until nth
65 * @note It should be noted that the index starts at 0.
66 *
67 * @ref eina_list_append() is not the only way to add elements to a a list. A
68 * common requirement is to add an element in a specific position this can be
69 * accomplished using @ref eina_list_append_relative() and
70 * @ref eina_list_append_relative_list():
71 * @until zarek
72 * First @a "cain" is added after the second element(remember that indexes are
73 * 0 based) and then we add @a "zarek" after @a "cain".
74 *
75 * @ref Eina_List also has prepend analogs to append functions we have used so
76 * far:
77 * @until lampkin
78 * With this additions our list now looks like this:@n
79 * @htmlonly
80 * <img src="eina_list_example_01_b.png" style="max-width: 100%;" />
81 * <a href="eina_list_example_01_b.png">Full-size</a>
82 * @endhtmlonly
83 * @image rtf eina_list_example_01_b.png
84 * @image latex eina_list_example_01_b.eps width=\textwidth
85 *
86 * Once done using the list it needs to be freed, and since we are done with
87 * eina that also need to be shutdown:
88 * @until }
89 *
90 * The full source code can be found on the examples folder
91 * on the @ref eina_list_01_c "eina_list_01.c" file.
92 */
93
94/**
95 * @page eina_list_01_c Adding elements to Eina_List example
96 *
97 * @include eina_list_01.c
98 * @example eina_list_01.c
99 */
100
101/**
102 * @page eina_list_02_example_page Sorting Eina_List elements
103 * @dontinclude eina_list_02.c
104 *
105 * If you don't know how to create lists see
106 * @ref eina_list_01_example_page.
107 *
108 * @skip #include
109 * @until boomer
110 * This is the code we have already seen to create a list. Now if we need to
111 * search the list we can do it like this:
112 * @until return
113 *
114 * However if searching the list multiple times it probably is better to sort
115 * the list since the sorted_search functions are much faster:
116 * @until return
117 *
118 * Once the list is sorted it's not a good idea to use append/prepend functions
119 * since that would add the element in the wrong place, instead elements should
120 * be added with @ref eina_list_sorted_insert():
121 * @until sorted_insert
122 *
123 * A noteworthy use case is adding an element to a list only if it doesn't exist
124 * already, this can accomplished by searching for the element that is closest
125 * to what is being added, and if that doesn't match add:
126 * @until append
127 * @note @ref eina_list_search_sorted_near_list() will tell you not only the
128 * nearest node to what was searched for but how it compares to your term, this
129 * way it is easy to know if you have to add before or after that node.
130 *
131 * It is sometimes useful to get a portion of the list as another list, here we
132 * take every element that comes after "boomer" and split it into "other_list":
133 * @until split_list
134 *
135 * It is also possible to add entire lists of elements using
136 * @ref eina_list_sorted_merge():
137 * @until sorted_merge
138 *
139 * And as always release memory and shutdown eina before ending:
140 * @until }
141 *
142 * The full source code can be found on the examples folder
143 * on the @ref eina_list_02_c "eina_list_02.c" file.
144 */
145
146/**
147 * @page eina_list_02_c Sorting Eina_List elements example
148 *
149 * @include eina_list_02.c
150 * @example eina_list_02.c
151 */
152
153/**
154 * @page eina_list_03_example_page Reordering Eina_List elments
155 * @dontinclude eina_list_03.c
156 *
157 * If you don't know how to create lists see
158 * @ref eina_list_01_example_page.
159 *
160 * We start out with code that should be familiar by now:
161 * @skip #include
162 * @until gemenon
163 *
164 * You can move elements around in a list using @ref eina_list_move() or using
165 * @ref eina_list_promote_list() and @ref eina_list_demote_list() which move a
166 * list node to the head and end of the list respectevely:
167 * @until demote
168 *
169 * Removing elements from a list can be done with ease:
170 * @until sagitarius
171 *
172 * To replace an element in the list it is not necessary to remove it and then
173 * add with the new value, it is possible to just change the value of a node:
174 * @until aquarius
175 *
176 * We will now take a peek to see if the list still has the right number of
177 * elements:
178 * @until printf
179 *
180 * Now that the list is in alphabetical order let's create a copy of it in
181 * reverse order and print every element to see if worked as expected:
182 * @until iterator_free
183 * @note Always remember to free your iterators when done using them.
184 *
185 * And as always release memory and shutdown eina before ending:
186 * @until }
187 *
188 * The full source code can be found on the examples folder
189 * on the @ref eina_list_03_c "eina_list_03.c" file.
190 */
191
192/**
193 * @page eina_list_03_c Reordering Eina_List elments example
194 *
195 * @include eina_list_03.c
196 * @example eina_list_03.c
197 */
198
199/**
200 * @page eina_list_04_example_page Eina_List and memory allocation
201 * @dontinclude eina_list_04.c
202 *
203 * If you don't know how to create lists see
204 * @ref eina_list_01_example_page. In this example we also use
205 * @ref Eina_Stringshare_Group, however it should be possible to understand the code
206 * regardless of previous knowledge about it.
207 *
208 * Here we have the usual list creation code with a twist, now we are using as
209 * data for the list memory that has to be freed later on.
210 * @skip #include
211 * @until Sharon
212 *
213 * This time we are going to iterate over our list in a different way:
214 * @until printf
215 *
216 * And now we are going to iterate over the list backwards:
217 * @until printf
218 *
219 * And now we need to free up the memory allocated during creation of the list:
220 * @until stringshare_del
221 * @note We don't need to use eina_list_free() since @ref EINA_LIST_FREE takes
222 * care of that.
223 *
224 * And shut everything down:
225 * @until }
226 *
227 * The full source code can be found on the examples folder
228 * on the @ref eina_list_04_c "eina_list_04.c" file.
229 */
230
231/**
232 * @page eina_list_04_c Eina_List and memory allocation example
233 *
234 * @include eina_list_04.c
235 * @example eina_list_04.c
236 */
237
238/**
239 * @addtogroup Eina_List_Group List
240 *
241 * @brief These functions provide double linked list management.
242 *
243 * Eina_List is a doubly linked list. It can store data of any type in the
244 * form of void pointers. It has convenience functions to do all the common
245 * operations which means it should rarely if ever be necessary to directly
246 * access the struct's fields. Nevertheless it can be useful to understand the
247 * inner workings of the data structure being used.
248 *
249 * @ref Eina_List nodes keep references to the previous node, the next node, its
250 * data and to an accounting structure.
251 *
252 * @htmlonly
253 * <img src="eina_list.png" style="max-width: 100%;" />
254 * <a href="eina_list.png">Full-size</a>
255 * @endhtmlonly
256 * @image rtf eina_list.png
257 * @image latex eina_list.eps width=5cm
258 *
259 * @ref Eina_List_Accounting is used to improve the performance of some
260 * functions. It is private and <b>should not</b> be modified. It contains a
261 * reference to the end of the list and the number of elements in the list.
262 *
263 * @note Every function that modifies the contents of the list returns a pointer
264 * to the head of the list and it is essential that this be pointer be used in
265 * any future references to the list.
266 *
267 * Most functions have two versions that have the same effect but operate on
268 * different arguments, the @a plain functions operate over data(eg.:
269 * @ref eina_list_append_relative, @ref eina_list_remove,
270 * @ref eina_list_data_find), the @a list versions of these functions operate
271 * on @ref Eina_List nodes.
272 *
273 * @warning You must @b always use the pointer to the first element of the list
274 * as the list!
275 * @warning You must @b never use a pointer to an element in the middle of the
276 * list as the list!
277 *
278 * Here are some examples of @ref Eina_List usage:
279 * @li @ref eina_list_01_example_page
280 * @li @ref eina_list_02_example_page
281 * @li @ref eina_list_03_example_page
282 * @li @ref eina_list_04_example_page
283 */
284
285/**
286 * @addtogroup Eina_Data_Types_Group Data Types
287 *
288 * @{
289 */
290
291/**
292 * @addtogroup Eina_Containers_Group Containers
293 *
294 * @{
295 */
296
297/**
298 * @defgroup Eina_List_Group List
299 *
300 * @{
301 */
302
303/**
304 * @typedef Eina_List
305 * Type for a generic double linked list.
306 */
307typedef struct _Eina_List Eina_List;
308
309/**
310 * @typedef Eina_List_Accounting
311 * Cache used to store the last element of a list and the number of
312 * elements, for fast access.
313 */
314typedef struct _Eina_List_Accounting Eina_List_Accounting;
315
316/**
317 * @struct _Eina_List
318 * Type for a generic double linked list.
319 */
320struct _Eina_List
321{
322 void *data; /**< Pointer to list element payload */
323 Eina_List *next; /**< Next member in the list */
324 Eina_List *prev; /**< Previous member in the list */
325 Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
326
327 EINA_MAGIC
328};
329
330/**
331 * @struct _Eina_List_Accounting
332 * Cache used to store the last element of a list and the number of
333 * elements, for fast access. It is for private used and must not be
334 * touched.
335 */
336struct _Eina_List_Accounting
337{
338 Eina_List *last; /**< Pointer to the last element of the list - don't touch */
339 unsigned int count; /**< Number of elements of the list - don't touch */
340 EINA_MAGIC
341};
342
343
344/**
345 * @brief Append the given data to the given linked list.
346 *
347 * @param list The given list.
348 * @param data The data to append.
349 * @return A list pointer.
350 *
351 * This function appends @p data to @p list. If @p list is @c NULL, a
352 * new list is returned. On success, a new list pointer that should be
353 * used in place of the one given to this function is
354 * returned. Otherwise, the old pointer is returned.
355 *
356 * The following example code demonstrates how to ensure that the
357 * given data has been successfully appended.
358 *
359 * @code
360 * Eina_List *list = NULL;
361 * extern void *my_data;
362 *
363 * list = eina_list_append(list, my_data);
364 * if (eina_error_get())
365 * {
366 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
367 * exit(-1);
368 * }
369 * @endcode
370 *
371 * @warning @p list must be a pointer to the first element of the list(or NULL).
372 */
373EAPI Eina_List *eina_list_append(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
374
375
376/**
377 * @brief Prepends the given data to the given linked list.
378 *
379 * @param list The given list.
380 * @param data The data to prepend.
381 * @return A list pointer.
382 *
383 * This function prepends @p data to @p list. If @p list is @c NULL, a
384 * new list is returned. On success, a new list pointer that should be
385 * used in place of the one given to this function is
386 * returned. Otherwise, the old pointer is returned.
387 *
388 * The following example code demonstrates how to ensure that the
389 * given data has been successfully prepended.
390 *
391 * Example:
392 * @code
393 * Eina_List *list = NULL;
394 * extern void *my_data;
395 *
396 * list = eina_list_prepend(list, my_data);
397 * if (eina_error_get())
398 * {
399 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
400 * exit(-1);
401 * }
402 * @endcode
403 *
404 * @warning @p list must be a pointer to the first element of the list.
405 */
406EAPI Eina_List *eina_list_prepend(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
407
408
409/**
410 * @brief Insert the given data into the given linked list after the specified data.
411 *
412 * @param list The given linked list.
413 * @param data The data to insert.
414 * @param relative The data to insert after.
415 * @return A list pointer.
416 *
417 * This function inserts @p data to @p list after @p relative. If
418 * @p relative is not in the list, @p data is appended to the end of
419 * the list. If @p list is @c NULL, a new list is returned. If there
420 * are multiple instances of @p relative in the list, @p data is
421 * inserted after the first instance.On success, a new list pointer
422 * that should be used in place of the one given to this function is
423 * returned. Otherwise, the old pointer is returned.
424 *
425 * The following example code demonstrates how to ensure that the
426 * given data has been successfully inserted.
427 *
428 * @code
429 * Eina_List *list = NULL;
430 * extern void *my_data;
431 * extern void *relative_member;
432 *
433 * list = eina_list_append(list, relative_member);
434 * if (eina_error_get())
435 * {
436 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
437 * exit(-1);
438 * }
439 * list = eina_list_append_relative(list, my_data, relative_member);
440 * if (eina_error_get())
441 * {
442 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
443 * exit(-1);
444 * }
445 * @endcode
446 *
447 * @warning @p list must be a pointer to the first element of the list.
448 */
449EAPI Eina_List *eina_list_append_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
450
451
452/**
453 * @brief Append a list node to a linked list after the specified member
454 *
455 * @param list The given linked list.
456 * @param data The data to insert.
457 * @param relative The list node to insert after.
458 * @return A list pointer.
459 *
460 * This function inserts @p data to @p list after the list node
461 * @p relative. If @p list or @p relative are @c NULL, @p data is just
462 * appended to @p list using eina_list_append(). If @p list is
463 * @c NULL, a new list is returned. If there are multiple instances
464 * of @p relative in the list, @p data is inserted after the first
465 * instance. On success, a new list pointer that should be used in
466 * place of the one given to this function is returned. Otherwise, the
467 * old pointer is returned.
468 *
469 * @warning @p list must be a pointer to the first element of the list.
470 */
471EAPI Eina_List *eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
472
473
474/**
475 * @brief Prepend a data pointer to a linked list before the specified member
476 *
477 * @param list The given linked list.
478 * @param data The data to insert.
479 * @param relative The data to insert before.
480 * @return A list pointer.
481 *
482 * This function inserts @p data to @p list before @p relative. If
483 * @p relative is not in the list, @p data is prepended to the list
484 * with eina_list_prepend(). If @p list is @c NULL, a new list is
485 * returned. If there are multiple instances of @p relative in the
486 * list, @p data is inserted before the first instance. On success, a
487 * new list pointer that should be used in place of the one given to
488 * this function is returned. Otherwise, the old pointer is returned.
489 *
490 * The following code example demonstrates how to ensure that the
491 * given data has been successfully inserted.
492 *
493 * @code
494 * Eina_List *list = NULL;
495 * extern void *my_data;
496 * extern void *relative_member;
497 *
498 * list = eina_list_append(list, relative_member);
499 * if (eina_error_get_error())
500 * {
501 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
502 * exit(-1);
503 * }
504 * list = eina_list_prepend_relative(list, my_data, relative_member);
505 * if (eina_error_get())
506 * {
507 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
508 * exit(-1);
509 * }
510 * @endcode
511 *
512 * @warning @p list must be a pointer to the first element of the list.
513 */
514EAPI Eina_List *eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
515
516
517/**
518 * @brief Prepend a list node to a linked list before the specified member
519 *
520 * @param list The given linked list.
521 * @param data The data to insert.
522 * @param relative The list node to insert before.
523 * @return A list pointer.
524 *
525 * This function inserts @p data to @p list before the list node
526 * @p relative. If @p list or @p relative are @c NULL, @p data is just
527 * prepended to @p list using eina_list_prepend(). If @p list is
528 * @c NULL, a new list is returned. If there are multiple instances
529 * of @p relative in the list, @p data is inserted before the first
530 * instance. On success, a new list pointer that should be used in
531 * place of the one given to this function is returned. Otherwise, the
532 * old pointer is returned.
533 *
534 * @warning @p list must be a pointer to the first element of the list.
535 */
536EAPI Eina_List *eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
537
538
539/**
540 * @brief Insert a new node into a sorted list.
541 *
542 * @param list The given linked list, @b must be sorted.
543 * @param func The function called for the sort.
544 * @param data The data to insert sorted.
545 * @return A list pointer.
546 *
547 * This function inserts values into a linked list assuming it was
548 * sorted and the result will be sorted. If @p list is @c NULLL, a new
549 * list is returned. On success, a new list pointer that should be
550 * used in place of the one given to this function is
551 * returned. Otherwise, the old pointer is returned. See eina_error_get().
552 *
553 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
554 * performance as it uses eina_list_search_sorted_near_list() and thus
555 * is bounded to that. As said in eina_list_search_sorted_near_list(),
556 * lists do not have O(1) access time, so walking to the correct node
557 * can be costly, consider worst case to be almost O(n) pointer
558 * dereference (list walk).
559 *
560 * @warning @p list must be a pointer to the first element of the list.
561 */
562EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
563
564
565/**
566 * @brief Remove the first instance of the specified data from the given list.
567 *
568 * @param list The given list.
569 * @param data The specified data.
570 * @return A list pointer.
571 *
572 * This function removes the first instance of @p data from
573 * @p list. If the specified data is not in the given list (tihis
574 * include the case where @p data is @c NULL), nothing is done. If
575 * @p list is @c NULL, @c NULL is returned, otherwise a new list
576 * pointer that should be used in place of the one passed to this
577 * function.
578 *
579 * @warning @p list must be a pointer to the first element of the list.
580 */
581EAPI Eina_List *eina_list_remove(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
582
583
584/**
585 * @brief Remove the specified list node.
586 *
587 * @param list The given linked list.
588 * @param remove_list The list node which is to be removed.
589 * @return A list pointer.
590 *
591 * This function removes the list node @p remove_list from @p list and
592 * frees the list node structure @p remove_list. If @p list is
593 * @c NULL, this function returns @c NULL. If @p remove_list is
594 * @c NULL, it returns @p list, otherwise, a new list pointer that
595 * should be used in place of the one passed to this function.
596 *
597 * The following code gives an example (notice we use EINA_LIST_FOREACH
598 * instead of EINA_LIST_FOREACH_SAFE because we stop the loop after
599 * removing the current node).
600 *
601 * @code
602 * extern Eina_List *list;
603 * Eina_List *l;
604 * extern void *my_data;
605 * void *data
606 *
607 * EINA_LIST_FOREACH(list, l, data)
608 * {
609 * if (data == my_data)
610 * {
611 * list = eina_list_remove_list(list, l);
612 * break;
613 * }
614 * }
615 * @endcode
616 *
617 * @warning @p list must be a pointer to the first element of the list.
618 */
619EAPI Eina_List *eina_list_remove_list(Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
620
621
622/**
623 * @brief Move the specified data to the head of the list.
624 *
625 * @param list The list handle to move the data.
626 * @param move_list The list node to move.
627 * @return A new list handle to replace the old one
628 *
629 * This function move @p move_list to the front of @p list. If list is
630 * @c NULL, @c NULL is returned. If @p move_list is @c NULL,
631 * @p list is returned. Otherwise, a new list pointer that should be
632 * used in place of the one passed to this function.
633 *
634 * Example:
635 * @code
636 * extern Eina_List *list;
637 * Eina_List *l;
638 * extern void *my_data;
639 * void *data;
640 *
641 * EINA_LIST_FOREACH(list, l, data)
642 * {
643 * if (data == my_data)
644 * {
645 * list = eina_list_promote_list(list, l);
646 * break;
647 * }
648 * }
649 * @endcode
650 *
651 * @warning @p list must be a pointer to the first element of the list.
652 */
653EAPI Eina_List *eina_list_promote_list(Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
654
655
656/**
657 * @brief Move the specified data to the tail of the list.
658 *
659 * @param list The list handle to move the data.
660 * @param move_list The list node to move.
661 * @return A new list handle to replace the old one
662 *
663 * This function move @p move_list to the back of @p list. If list is
664 * @c NULL, @c NULL is returned. If @p move_list is @c NULL,
665 * @p list is returned. Otherwise, a new list pointer that should be
666 * used in place of the one passed to this function.
667 *
668 * Example:
669 * @code
670 * extern Eina_List *list;
671 * Eina_List *l;
672 * extern void *my_data;
673 * void *data;
674 *
675 * EINA_LIST_FOREACH(list, l, data)
676 * {
677 * if (data == my_data)
678 * {
679 * list = eina_list_demote_list(list, l);
680 * break;
681 * }
682 * }
683 * @endcode
684 *
685 * @warning @p list must be a pointer to the first element of the list.
686 */
687EAPI Eina_List *eina_list_demote_list(Eina_List *list, Eina_List *move_list);
688
689
690/**
691 * @brief Find a member of a list and return the member.
692 *
693 * @param list The list to search for a data.
694 * @param data The data pointer to find in the list.
695 * @return The found member data pointer if found, @c NULL otherwise.
696 *
697 * This function searches in @p list from beginning to end for the
698 * first member whose data pointer is @p data. If it is found, @p data
699 * will be returned, otherwise NULL will be returned.
700 *
701 * Example:
702 * @code
703 * extern Eina_List *list;
704 * extern void *my_data;
705 *
706 * if (eina_list_data_find(list, my_data) == my_data)
707 * {
708 * printf("Found member %p\n", my_data);
709 * }
710 * @endcode
711 *
712 * @warning @p list must be a pointer to the first element of the list.
713 */
714EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
715
716/**
717 * @brief Find a member of a list and return the list node containing that member.
718 *
719 * @param list The list to search for data.
720 * @param data The data pointer to find in the list.
721 * @return The found members list node on success, @c NULL otherwise.
722 *
723 * This function searches in @p list from beginning to end for the
724 * first member whose data pointer is @p data. If it is found, the
725 * list node containing the specified member is returned, otherwise
726 * @c NULL is returned.
727 *
728 * @warning @p list must be a pointer to the first element of the list.
729 */
730EAPI Eina_List *eina_list_data_find_list(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
731
732
733/**
734 * @brief Move a data pointer from one list to another
735 *
736 * @param to The list to move the data to
737 * @param from The list to move from
738 * @param data The data to move
739 * @return #EINA_TRUE on success, else #EINA_FALSE
740 *
741 * This function is a shortcut for doing the following:
742 * to = eina_list_append(to, data);
743 * from = eina_list_remove(from, data);
744 *
745 * @warning @p list must be a pointer to the first element of the list.
746 */
747EAPI Eina_Bool eina_list_move(Eina_List **to, Eina_List **from, void *data);
748
749/**
750 * @brief Move a list node from one list to another
751 *
752 * @param to The list to move the data to
753 * @param from The list to move from
754 * @param data The list node containing the data to move
755 * @return #EINA_TRUE on success, else #EINA_FALSE
756 *
757 * This function is a shortcut for doing the following:
758 * to = eina_list_append(to, data->data);
759 * from = eina_list_remove_list(from, data);
760 *
761 * @warning @p list must be a pointer to the first element of the list.
762 */
763EAPI Eina_Bool eina_list_move_list(Eina_List **to, Eina_List **from, Eina_List *data);
764
765
766/**
767 * @brief Free an entire list and all the nodes, ignoring the data contained.
768
769 * @param list The list to free
770 * @return A NULL pointer
771 *
772 * This function frees all the nodes of @p list. It does not free the
773 * data of the nodes. To free them, use #EINA_LIST_FREE.
774 */
775EAPI Eina_List *eina_list_free(Eina_List *list);
776
777
778/**
779 * @brief Get the nth member's data pointer in a list.
780 *
781 * @param list The list to get the specified member number from.
782 * @param n The number of the element (0 being the first).
783 * @return The data pointer stored in the specified element.
784 *
785 * This function returns the data pointer of element number @p n, in
786 * the @p list. The first element in the array is element number 0. If
787 * the element number @p n does not exist, @c NULL is
788 * returned. Otherwise, the data of the found element is returned.
789 *
790 * @note Worst case is O(n).
791 *
792 * @warning @p list must be a pointer to the first element of the list.
793 */
794EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
795
796
797/**
798 * @brief Get the nth member's list node in a list.
799 *
800 * @param list The list to get the specfied member number from.
801 * @param n The number of the element (0 being the first).
802 * @return The list node stored in the numbered element.
803 *
804 * This function returns the list node of element number @p n, in
805 * @p list. The first element in the array is element number 0. If the
806 * element number @p n does not exist or @p list is @c NULL or @p n is
807 * greater than the count of elements in @p list minus 1, @c NULL is
808 * returned. Otherwise the list node stored in the numbered element is
809 * returned.
810 *
811 * @note Worst case is O(n).
812 *
813 * @warning @p list must be a pointer to the first element of the list.
814 */
815EAPI Eina_List *eina_list_nth_list(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
816
817
818/**
819 * @brief Reverse all the elements in the list.
820 *
821 * @param list The list to reverse.
822 * @return The list head after it has been reversed.
823 *
824 * This function reverses the order of all elements in @p list, so the
825 * last member is now first, and so on. If @p list is @c NULL, this
826 * functon returns @c NULL.
827 *
828 * @note @b in-place: this will change the given list, so you should
829 * now point to the new list head that is returned by this function.
830 *
831 * @warning @p list must be a pointer to the first element of the list.
832 *
833 * @see eina_list_reverse_clone()
834 * @see eina_list_iterator_reversed_new()
835 */
836EAPI Eina_List *eina_list_reverse(Eina_List *list) EINA_WARN_UNUSED_RESULT;
837
838
839/**
840 * @brief Clone (copy) all the elements in the list in reverse order.
841 *
842 * @param list The list to reverse.
843 * @return The new list that has been reversed.
844 *
845 * This function reverses the order of all elements in @p list, so the
846 * last member is now first, and so on. If @p list is @c NULL, this
847 * functon returns @c NULL. This returns a copy of the given list.
848 *
849 * @note @b copy: this will copy the list and you should then
850 * eina_list_free() when it is not required anymore.
851 *
852 * @warning @p list must be a pointer to the first element of the list.
853 *
854 * @see eina_list_reverse()
855 * @see eina_list_clone()
856 */
857EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
858
859
860/**
861 * @brief Clone (copy) all the elements in the list in exactly same order.
862 *
863 * @param list The list to clone.
864 * @return The new list that has been cloned.
865 *
866 * This function clone in order of all elements in @p list. If @p list
867 * is @c NULL, this functon returns @c NULL. This returns a copy of
868 * the given list.
869 *
870 * @note @b copy: this will copy the list and you should then
871 * eina_list_free() when it is not required anymore.
872 *
873 * @warning @p list must be a pointer to the first element of the list.
874 *
875 * @see eina_list_reverse_clone()
876 */
877EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
878
879
880/**
881 * @brief Sort a list according to the ordering func will return.
882 *
883 * @param list The list handle 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
886 * nodes.
887 * @return the new head of list.
888 *
889 * This function sorts @p list. @p size if the number of the first
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
892 * compare two elements of @p list. If @p list or @p func are @c NULL,
893 * this function returns @c NULL.
894 *
895 * @note @b in-place: this will change the given list, so you should
896 * now point to the new list head that is returned by this function.
897 *
898 * @note worst case is O(n * log2(n)) comparisons (calls to func()),
899 * O(n) comparisons average case. That means that for 1,000,000 list
900 * elements, sort will usually do 1,000,000 comparisons, but may do up
901 * to 20,000,000.
902 *
903 * Example:
904 * @code
905 * int
906 * sort_cb(const void *d1, const void *d2)
907 * {
908 * const char *txt = d1;
909 * const char *txt2 = d2;
910 *
911 * if(!txt) return(1);
912 * if(!txt2) return(-1);
913 *
914 * return(strcmp(txt, txt2));
915 * }
916 * extern Eina_List *list;
917 *
918 * list = eina_list_sort(list, eina_list_count(list), sort_cb);
919 * @endcode
920 *
921 * @warning @p list must be a pointer to the first element of the list.
922 */
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
925
926/**
927 * @brief Merge two list.
928 *
929 * @param left Head list to merge.
930 * @param right Tail list to merge.
931 * @return A new merged list.
932 *
933 * This function puts right at the end of left and return the head.
934 *
935 * Both left and right does not exist anymore after the merge.
936 *
937 * @note merge cost is O(n), being @b n the size of the smallest
938 * list. This is due the need to fix accounting of that segment,
939 * making count and last access O(1).
940 *
941 * @warning @p list must be a pointer to the first element of the list.
942 */
943EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
944
945
946/**
947 * @brief Merge two sorted list according to the ordering func will return.
948 *
949 * @param left First list to merge.
950 * @param right Second list to merge.
951 * @param func A function pointer that can handle comparing the list data
952 * nodes.
953 * @return A new sorted list.
954 *
955 * This function compares the head of @p left and @p right, and choose the
956 * smallest one to be head of the returned list. It will continue this process
957 * for all entry of both list.
958 *
959 * Both left and right does not exist anymore after the merge.
960 * If @p func is NULL, it will return NULL.
961 *
962 * Example:
963 * @code
964 * int
965 * sort_cb(void *d1, void *d2)
966 * {
967 * const char *txt = NULL;
968 * const char *txt2 = NULL;
969 *
970 * if(!d1) return(1);
971 * if(!d2) return(-1);
972 *
973 * return(strcmp((const char*)d1, (const char*)d2));
974 * }
975 * extern Eina_List *sorted1;
976 * extern Eina_List *sorted2;
977 *
978 * list = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
979 * @endcode
980 *
981 * @warning @p list must be a pointer to the first element of the list.
982 */
983EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
984
985
986/**
987 * @brief Split a list into 2 lists.
988 *
989 * @param list List to split.
990 * @param relative The list will be split after @p relative.
991 * @param right The head of the new right list.
992 * @return The new left list
993 *
994 * This function splits @p list into two lists ( left and right ) after the node @p relative. @p Relative
995 * will become the last node of the left list. If @p list or @p right are NULL list is returns.
996 * If @p relative is NULL right is set to @p list and NULL is returns.
997 * If @p relative is the last node of @p list list is returns and @p right is set to NULL.
998 *
999 * list does not exist anymore after the split.
1000 *
1001 * @warning @p list must be a pointer to the first element of the list.
1002 */
1003EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
1004
1005
1006/**
1007 * @brief Returns node nearest to data is in the sorted list.
1008 *
1009 * @param list The list to search for data, @b must be sorted.
1010 * @param func A function pointer that can handle comparing the list data nodes.
1011 * @param data reference value to search.
1012 * @param result_cmp if provided returns the result of
1013 * func(node->data, data) node being the last (returned) node. If node
1014 * was found (exact match), then it is 0. If returned node is smaller
1015 * than requested data, it is less than 0 and if it's bigger it's
1016 * greater than 0. It is the last value returned by func().
1017 * @return the nearest node, NULL if not found.
1018 *
1019 * This function searches for a node containing @p data as it's data in @p list,
1020 * if such a node exists it will be returned and @p result_cmp will be @p 0. If
1021 * the data of no node in @p list is equal to @p data, the node with the nearest
1022 * value to that will be returned and @p result_cmp will be the return value of
1023 * @p func with @p data and the returned node's data as arguments.
1024 *
1025 * This function is useful for inserting an element in the list only in case it
1026 * isn't already present in the list, the naive way of doing this would be:
1027 * @code
1028 * void *ptr = eina_list_data_find(list, "my data");
1029 * if (!ptr)
1030 * eina_list_sorted_insert(list, "my data");
1031 * @endcode
1032 *
1033 * However this has the downside of walking through the list twice, once to
1034 * check if the data is already present and another to insert the element in the
1035 * corret position. This can be done more eficiently:
1036 * @code
1037 * int cmp_result;
1038 * l = eina_list_search_sorted_near_list(list, cmp_func, "my data",
1039 * &cmp_result);
1040 * if (cmp_result > 0)
1041 * list = eina_list_prepend_relative_list(list, "my data", l);
1042 * else if (cmp_result < 0)
1043 * list = eina_list_append_relative_list(list, "my data", l);
1044 * @endcode
1045 *
1046 * If @a cmp_result is 0 the element is already in the list and we need not
1047 * insert it, if @a cmp_result is greater than zero @a "my @a data" needs to
1048 * come after @a l(the nearest node present), if less than zero before.
1049 *
1050 * @note O(log2(n)) average/worst case performance, for 1,000,000
1051 * elements it will do a maximum of 20 comparisons. This is much
1052 * faster than the 1,000,000 comparisons made naively walking the list
1053 * from head to tail, so depending on the number of searches and
1054 * insertions, it may be worth to eina_list_sort() the list and do the
1055 * searches later. As lists do not have O(1) access time, walking to
1056 * the correct node can be costly, consider worst case to be almost
1057 * O(n) pointer dereference (list walk).
1058 *
1059 * @warning @p list must be a pointer to the first element of the list.
1060 *
1061 * @see eina_list_search_sorted_list()
1062 * @see eina_list_sort()
1063 * @see eina_list_sorted_merge()
1064 */
1065EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
1066
1067
1068/**
1069 * @brief Returns node if data is in the sorted list.
1070 *
1071 * @param list The list to search for data, @b must be sorted.
1072 * @param func A function pointer that can handle comparing the list data nodes.
1073 * @param data reference value to search.
1074 * @return the node if func(node->data, data) == 0, NULL if not found.
1075 *
1076 * This can be used to check if some value is inside the list and get
1077 * the container node in this case. It should be used when list is
1078 * known to be sorted as it will do binary search for results.
1079 *
1080 * Example: imagine user gives a string, you check if it's in the list
1081 * before duplicating its contents.
1082 *
1083 * @note O(log2(n)) average/worst case performance, for 1,000,000
1084 * elements it will do a maximum of 20 comparisons. This is much
1085 * faster than the 1,000,000 comparisons made by
1086 * eina_list_search_unsorted_list(), so depending on the number of
1087 * searches and insertions, it may be worth to eina_list_sort() the
1088 * list and do the searches later. As said in
1089 * eina_list_search_sorted_near_list(), lists do not have O(1) access
1090 * time, so walking to the correct node can be costly, consider worst
1091 * case to be almost O(n) pointer dereference (list walk).
1092 *
1093 * @warning @p list must be a pointer to the first element of the list.
1094 *
1095 * @see eina_list_search_sorted()
1096 * @see eina_list_sort()
1097 * @see eina_list_sorted_merge()
1098 * @see eina_list_search_unsorted_list()
1099 * @see eina_list_search_sorted_near_list()
1100 */
1101EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1102
1103
1104/**
1105 * @brief Returns node data if it is in the sorted list.
1106 *
1107 * @param list The list to search for data, @b must be sorted.
1108 * @param func A function pointer that can handle comparing the list data nodes.
1109 * @param data reference value to search.
1110 * @return the node value (@c node->data) if func(node->data, data) == 0,
1111 * NULL if not found.
1112 *
1113 * This can be used to check if some value is inside the list and get
1114 * the existing instance in this case. It should be used when list is
1115 * known to be sorted as it will do binary search for results.
1116 *
1117 * Example: imagine user gives a string, you check if it's in the list
1118 * before duplicating its contents.
1119 *
1120 * @note O(log2(n)) average/worst case performance, for 1,000,000
1121 * elements it will do a maximum of 20 comparisons. This is much
1122 * faster than the 1,000,000 comparisons made by
1123 * eina_list_search_unsorted(), so depending on the number of
1124 * searches and insertions, it may be worth to eina_list_sort() the
1125 * list and do the searches later. As said in
1126 * eina_list_search_sorted_near_list(), lists do not have O(1) access
1127 * time, so walking to the correct node can be costly, consider worst
1128 * case to be almost O(n) pointer dereference (list walk).
1129 *
1130 * @warning @p list must be a pointer to the first element of the list.
1131 *
1132 * @see eina_list_search_sorted_list()
1133 * @see eina_list_sort()
1134 * @see eina_list_sorted_merge()
1135 * @see eina_list_search_unsorted_list()
1136 */
1137EAPI void *eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1138
1139
1140/**
1141 * @brief Returns node if data is in the unsorted list.
1142 *
1143 * @param list The list to search for data, may be unsorted.
1144 * @param func A function pointer that can handle comparing the list data nodes.
1145 * @param data reference value to search.
1146 * @return the node if func(node->data, data) == 0, NULL if not found.
1147 *
1148 * This can be used to check if some value is inside the list and get
1149 * the container node in this case.
1150 *
1151 * Example: imagine user gives a string, you check if it's in the list
1152 * before duplicating its contents.
1153 *
1154 * @note this is expensive and may walk the whole list, it's order-N,
1155 * that is for 1,000,000 elements list it may walk and compare
1156 * 1,000,000 nodes.
1157 *
1158 * @warning @p list must be a pointer to the first element of the list.
1159 *
1160 * @see eina_list_search_sorted_list()
1161 * @see eina_list_search_unsorted()
1162 */
1163EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1164
1165
1166/**
1167 * @brief Returns node data if it is in the unsorted list.
1168 *
1169 * @param list The list to search for data, may be unsorted.
1170 * @param func A function pointer that can handle comparing the list data nodes.
1171 * @param data reference value to search.
1172 * @return the node value (@c node->data) if func(node->data, data) == 0,
1173 * NULL if not found.
1174 *
1175 * This can be used to check if some value is inside the list and get
1176 * the existing instance in this case.
1177 *
1178 * Example: imagine user gives a string, you check if it's in the list
1179 * before duplicating its contents.
1180 *
1181 * @note this is expensive and may walk the whole list, it's order-N,
1182 * that is for 1,000,000 elements list it may walk and compare
1183 * 1,000,000 nodes.
1184 *
1185 * @warning @p list must be a pointer to the first element of the list.
1186 *
1187 * @see eina_list_search_sorted()
1188 * @see eina_list_search_unsorted_list()
1189 */
1190EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1191
1192/**
1193 * @brief Get the last list node in the list.
1194 *
1195 * @param list The list to get the last list node from.
1196 * @return The last list node in the list.
1197 *
1198 * This function returns the last list node in the list @p list. If
1199 * @p list is @c NULL or empty, @c NULL is returned.
1200 *
1201 * This is a order-1 operation (it takes the same short time
1202 * regardless of the length of the list).
1203 *
1204 * @warning @p list must be a pointer to the first element of the list.
1205 */
1206static inline Eina_List *eina_list_last(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1207
1208/**
1209 * @brief Get the next list node after the specified list node.
1210 *
1211 * @param list The list node to get the next list node from
1212 * @return The next list node on success, @c NULL otherwise.
1213 *
1214 * This function returns the next list node after the current one in
1215 * @p list. It is equivalent to list->next. If @p list is @c NULL or
1216 * if no next list node exists, it returns @c NULL.
1217 *
1218 * @warning @p list must be a pointer to the first element of the list.
1219 */
1220static inline Eina_List *eina_list_next(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1221
1222/**
1223 * @brief Get the previous list node before the specified list node.
1224 *
1225 * @param list The list node to get the previous list node from.
1226 * @return The previous list node o success, @c NULL otherwise.
1227 * if no previous list node exists
1228 *
1229 * This function returns the previous list node before the current one
1230 * in @p list. It is equivalent to list->prev. If @p list is @c NULL or
1231 * if no previous list node exists, it returns @c NULL.
1232 *
1233 * @warning @p list must be a pointer to the first element of the list.
1234 */
1235static inline Eina_List *eina_list_prev(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1236
1237/**
1238 * @brief Get the list node data member.
1239 *
1240 * @param list The list node to get the data member of.
1241 * @return The data member from the list node.
1242 *
1243 * This function returns the data member of the specified list node @p
1244 * list. It is equivalent to list->data. If @p list is @c NULL, this
1245 * function returns @c NULL.
1246 *
1247 * @warning @p list must be a pointer to the first element of the list.
1248 */
1249static inline void *eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1250
1251/**
1252 * @brief Set the list node data member.
1253 *
1254 * @param list The list node to get the data member of.
1255 * @param data The data member to the list node.
1256 * @return The previous data value.
1257 *
1258 * This function set the data member @p data of the specified list node
1259 * @p list. It returns the previous data of the node. If @p list is
1260 * @c NULL, this function returns @c NULL.
1261 *
1262 * @warning @p list must be a pointer to the first element of the list.
1263 */
1264static inline void *eina_list_data_set(Eina_List *list, const void *data);
1265
1266/**
1267 * @brief Get the count of the number of items in a list.
1268 *
1269 * @param list The list whose count to return.
1270 * @return The number of members in the list.
1271 *
1272 * This function returns how many members @p list contains. If the
1273 * list is @c NULL, 0 is returned.
1274 *
1275 * NB: This is an order-1 operation and takes the same time regardless
1276 * of the length of the list.
1277 *
1278 * @warning @p list must be a pointer to the first element of the list.
1279 */
1280static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE;
1281
1282
1283/**
1284 * @brief Returned a new iterator associated to a list.
1285 *
1286 * @param list The list.
1287 * @return A new iterator.
1288 *
1289 * This function returns a newly allocated iterator associated to @p
1290 * list. If @p list is @c NULL or the count member of @p list is less
1291 * or equal than 0, this function still returns a valid iterator that
1292 * will always return false on eina_iterator_next(), thus keeping API
1293 * sane.
1294 *
1295 * If the memory can not be allocated, NULL is returned and
1296 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
1297 * returned.
1298 *
1299 * @warning @p list must be a pointer to the first element of the list.
1300 *
1301 * @warning if the list structure changes then the iterator becomes
1302 * invalid! That is, if you add or remove nodes this iterator
1303 * behavior is undefined and your program may crash!
1304 */
1305EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1306
1307
1308/**
1309 * @brief Returned a new reversed iterator associated to a list.
1310 *
1311 * @param list The list.
1312 * @return A new iterator.
1313 *
1314 * This function returns a newly allocated iterator associated to @p
1315 * list. If @p list is @c NULL or the count member of @p list is less
1316 * or equal than 0, this function still returns a valid iterator that
1317 * will always return false on eina_iterator_next(), thus keeping API
1318 * sane.
1319 *
1320 * Unlike eina_list_iterator_new(), this will walk the list backwards.
1321 *
1322 * If the memory can not be allocated, NULL is returned and
1323 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
1324 * returned.
1325 *
1326 * @warning @p list must be a pointer to the first element of the list.
1327 *
1328 * @warning if the list structure changes then the iterator becomes
1329 * invalid! That is, if you add or remove nodes this iterator
1330 * behavior is undefined and your program may crash!
1331 */
1332EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1333
1334
1335/**
1336 * @brief Returned a new accessor associated to a list.
1337 *
1338 * @param list The list.
1339 * @return A new accessor.
1340 *
1341 * This function returns a newly allocated accessor associated to
1342 * @p list. If @p list is @c NULL or the count member of @p list is
1343 * less or equal than 0, this function returns NULL. If the memory can
1344 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
1345 * set. Otherwise, a valid accessor is returned.
1346 *
1347 * @warning @p list must be a pointer to the first element of the list.
1348 */
1349EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1350
1351/**
1352 * @def EINA_LIST_FOREACH
1353 * @brief Macro to iterate over a list.
1354 *
1355 * @param list The list to iterate over.
1356 * @param l A list that is used as an iterator and points to the current node.
1357 * @param data Current item's data.
1358 *
1359 * This macro iterates over @p list from the first element to
1360 * the last. @p data is the data related to the current element.
1361 * @p l is an #Eina_List used as the list iterator.
1362 *
1363 * The following diagram ilustrates this macro iterating over a list of four
1364 * elements("one", "two", "three" and "four"):
1365 * @htmlonly
1366 * <img src="eina-list-foreach.png" style="max-width: 100%;" />
1367 * <a href="eina-list-foreach.png">Full-size</a>
1368 * @endhtmlonly
1369 * @image latex eina-list-foreach.eps width=\textwidth
1370 *
1371 * It can be used to free list data, as in the following example:
1372 *
1373 * @code
1374 * Eina_List *list;
1375 * Eina_List *l;
1376 * char *data;
1377 *
1378 * // list is already filled,
1379 * // its elements are just duplicated strings,
1380 * // EINA_LIST_FOREACH will be used to free those strings
1381 *
1382 * EINA_LIST_FOREACH(list, l, data)
1383 * free(data);
1384 * eina_list_free(list);
1385 * @endcode
1386 *
1387 * @note This is not the optimal way to release memory allocated to
1388 * a list, since it iterates over the list twice.
1389 * For an optimized algorithm, use EINA_LIST_FREE().
1390 *
1391 * @warning @p list must be a pointer to the first element of the list.
1392 *
1393 * @warning Be careful when deleting list nodes.
1394 * If you remove the current node and continue iterating,
1395 * the code will fail because the macro will not be able
1396 * to get the next node. Notice that it's OK to remove any
1397 * node if you stop the loop after that.
1398 * For destructive operations such as this, consider
1399 * using EINA_LIST_FOREACH_SAFE().
1400 */
1401#define EINA_LIST_FOREACH(list, l, data) \
1402 for (l = list, \
1403 data = eina_list_data_get(l); \
1404 l; \
1405 l = eina_list_next(l), \
1406 data = eina_list_data_get(l))
1407
1408/**
1409 * @def EINA_LIST_REVERSE_FOREACH
1410 * @brief Macro to iterate over a list in the reverse order.
1411 *
1412 * @param list The list to iterate over.
1413 * @param l A list that is used as an iterator and points to the current node.
1414 * @param data Current item's data.
1415 *
1416 * This macro works like EINA_LIST_FOREACH, but iterates from the
1417 * last element of a list to the first.
1418 * @p data is the data related to the current element, while @p l
1419 * is an #Eina_List that is used as the list iterator.
1420 *
1421 * The following diagram ilustrates this macro iterating over a list of four
1422 * elements("one", "two", "three" and "four"):
1423 * @htmlonly
1424 * <img src="eina-list-reverse-foreach.png" style="max-width: 100%;" />
1425 * <a href="eina-list-reverse-foreach.png">Full-size</a>
1426 * @endhtmlonly
1427 * @image latex eina-list-reverse-foreach.eps width=\textwidth
1428 *
1429 * It can be used to free list data, as in the following example:
1430 *
1431 * @code
1432 * Eina_List *list;
1433 * Eina_List *l;
1434 * char *data;
1435 *
1436 * // list is already filled,
1437 * // its elements are just duplicated strings,
1438 * // EINA_LIST_REVERSE_FOREACH will be used to free those strings
1439 *
1440 * EINA_LIST_REVERSE_FOREACH(list, l, data)
1441 * free(data);
1442 * eina_list_free(list);
1443 * @endcode
1444 *
1445 * @note This is not the optimal way to release memory allocated to
1446 * a list, since it iterates over the list twice.
1447 * For an optimized algorithm, use EINA_LIST_FREE().
1448 *
1449 * @warning @p list must be a pointer to the first element of the list.
1450 *
1451 * @warning Be careful when deleting list nodes.
1452 * If you remove the current node and continue iterating,
1453 * the code will fail because the macro will not be able
1454 * to get the next node. Notice that it's OK to remove any
1455 * node if you stop the loop after that.
1456 * For destructive operations such as this, consider
1457 * using EINA_LIST_REVERSE_FOREACH_SAFE().
1458 */
1459#define EINA_LIST_REVERSE_FOREACH(list, l, data) \
1460 for (l = eina_list_last(list), \
1461 data = eina_list_data_get(l); \
1462 l; \
1463 l = eina_list_prev(l), \
1464 data = eina_list_data_get(l))
1465
1466/**
1467 * @def EINA_LIST_FOREACH_SAFE
1468 * @brief Macro to iterate over a list with support for node deletion.
1469 *
1470 * @param list The list to iterate over.
1471 * @param l A list that is used as an iterator and points to the current node.
1472 * @param l_next A list that is used as an iterator and points to the next node.
1473 * @param data Current item's data.
1474 *
1475 * This macro iterates over @p list from the first element to
1476 * the last. @p data is the data related to the current element.
1477 * @p l is an #Eina_List used as the list iterator.
1478 *
1479 * Since this macro stores a pointer to the next list node in @p l_next,
1480 * deleting the current node and continuing looping is safe.
1481 *
1482 * The following diagram ilustrates this macro iterating over a list of four
1483 * elements("one", "two", "three" and "four"):
1484 * @htmlonly
1485 * <img src="eina-list-foreach-safe.png" style="max-width: 100%;" />
1486 * <a href="eina-list-foreach-safe.png">Full-size</a>
1487 * @endhtmlonly
1488 * @image latex eina-list-foreach-safe.eps width=\textwidth
1489 *
1490 * This macro can be used to free list nodes, as in the following example:
1491 *
1492 * @code
1493 * Eina_List *list;
1494 * Eina_List *l;
1495 * Eina_List *l_next;
1496 * char *data;
1497 *
1498 * // list is already filled,
1499 * // its elements are just duplicated strings,
1500 * // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key".
1501 *
1502 * EINA_LIST_FOREACH_SAFE(list, l, l_next, data)
1503 * if (strcmp(data, "key") == 0) {
1504 * free(data);
1505 * list = eina_list_remove_list(list, l);
1506 * }
1507 * @endcode
1508 *
1509 * @warning @p list must be a pointer to the first element of the list.
1510 */
1511#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \
1512 for (l = list, \
1513 l_next = eina_list_next(l), \
1514 data = eina_list_data_get(l); \
1515 l; \
1516 l = l_next, \
1517 l_next = eina_list_next(l), \
1518 data = eina_list_data_get(l))
1519
1520/**
1521 * @def EINA_LIST_REVERSE_FOREACH_SAFE
1522 * @brief Macro to iterate over a list in the reverse order with support
1523 * for deletion.
1524 *
1525 * @param list The list to iterate over.
1526 * @param l A list that is used as an iterator and points to the current node.
1527 * @param l_prev A list that is used as an iterator and points to the previous node.
1528 * @param data Current item's data.
1529 *
1530 * This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the
1531 * last element of a list to the first.
1532 * @p data is the data related to the current element, while @p l
1533 * is an #Eina_List that is used as the list iterator.
1534 *
1535 * Since this macro stores a pointer to the previous list node in @p l_prev,
1536 * deleting the current node and continuing looping is safe.
1537 *
1538 * The following diagram ilustrates this macro iterating over a list of four
1539 * elements("one", "two", "three" and "four"):
1540 * @htmlonly
1541 * <img src="eina-list-reverse-foreach-safe.png" style="max-width: 100%;" />
1542 * <a href="eina-list-reverse-foreach-safe.png">Full-size</a>
1543 * @endhtmlonly
1544 * @image latex eina-list-reverse-foreach-safe.eps width=\textwidth
1545 *
1546 * This macro can be used to free list nodes, as in the following example:
1547 *
1548 * @code
1549 * Eina_List *list;
1550 * Eina_List *l;
1551 * Eina_List *l_prev;
1552 * char *data;
1553 *
1554 * // list is already filled,
1555 * // its elements are just duplicated strings,
1556 * // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that match "key".
1557 *
1558 * EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data)
1559 * if (strcmp(data, "key") == 0) {
1560 * free(data);
1561 * list = eina_list_remove_list(list, l);
1562 * }
1563 * @endcode
1564 *
1565 * @warning @p list must be a pointer to the first element of the list.
1566 */
1567#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \
1568 for (l = eina_list_last(list), \
1569 l_prev = eina_list_prev(l), \
1570 data = eina_list_data_get(l); \
1571 l; \
1572 l = l_prev, \
1573 l_prev = eina_list_prev(l), \
1574 data = eina_list_data_get(l))
1575
1576/**
1577 * @def EINA_LIST_FREE
1578 * @brief Macro to remove each list node while having access to each node's data.
1579 *
1580 * @param list The list that will be cleared.
1581 * @param data Current node's data.
1582 *
1583 * This macro will call #eina_list_remove_list for each list node, and store
1584 * the data contained in the current node in @p data.
1585 *
1586 * The following diagram ilustrates this macro iterating over a list of four
1587 * elements("one", "two", "three" and "four"):
1588 * @htmlonly
1589 * <img src="eina-list-free.png" style="max-width: 100%;" />
1590 * <a href="eina-list-free.png">Full-size</a>
1591 * @endhtmlonly
1592 * @image latex eina-list-free.eps width=\textwidth
1593 *
1594 * If you do not need to release node data, it is easier to call #eina_list_free().
1595 *
1596 * @code
1597 * Eina_List *list;
1598 * char *data;
1599 *
1600 * // list is already filled,
1601 * // its elements are just duplicated strings,
1602 *
1603 * EINA_LIST_FREE(list, data)
1604 * free(data);
1605 * @endcode
1606 *
1607 * @warning @p list must be a pointer to the first element of the list.
1608 *
1609 * @see eina_list_free()
1610 */
1611#define EINA_LIST_FREE(list, data) \
1612 for (data = eina_list_data_get(list); \
1613 list; \
1614 list = eina_list_remove_list(list, list), \
1615 data = eina_list_data_get(list))
1616
1617#include "eina_inline_list.x"
1618
1619/**
1620 * @}
1621 */
1622
1623/**
1624 * @}
1625 */
1626
1627/**
1628 * @}
1629 */
1630
1631#endif /* EINA_LIST_H_ */
diff --git a/libraries/eina/src/include/eina_lock.h b/libraries/eina/src/include/eina_lock.h
deleted file mode 100644
index 16f4314..0000000
--- a/libraries/eina/src/include/eina_lock.h
+++ /dev/null
@@ -1,129 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOCK_H_
20#define EINA_LOCK_H_
21
22#include "eina_config.h"
23#include "eina_types.h"
24#include "eina_error.h"
25
26/**
27 * @addtogroup Eina_Tools_Group Tools
28 *
29 * @{
30 */
31
32/**
33 * @defgroup Eina_Lock_Group Lock
34 *
35 * @{
36 */
37
38typedef enum
39{
40 EINA_LOCK_FAIL = EINA_FALSE,
41 EINA_LOCK_SUCCEED = EINA_TRUE,
42 EINA_LOCK_DEADLOCK
43} Eina_Lock_Result;
44
45#ifdef EINA_HAVE_THREADS
46# ifdef _WIN32_WCE
47# include "eina_inline_lock_wince.x"
48# elif defined(_WIN32)
49# include "eina_inline_lock_win32.x"
50# else
51# include "eina_inline_lock_posix.x"
52# endif
53#else
54# include "eina_inline_lock_void.x"
55#endif
56
57EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP;
58
59static inline Eina_Bool eina_lock_new(Eina_Lock *mutex);
60static inline void eina_lock_free(Eina_Lock *mutex);
61static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex);
62static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex);
63static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex);
64static inline void eina_lock_debug(const Eina_Lock *mutex);
65
66static inline Eina_Bool eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex);
67static inline void eina_condition_free(Eina_Condition *cond);
68static inline Eina_Bool eina_condition_wait(Eina_Condition *cond);
69static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, double t);
70static inline Eina_Bool eina_condition_broadcast(Eina_Condition *cond);
71static inline Eina_Bool eina_condition_signal(Eina_Condition *cond);
72
73static inline Eina_Bool eina_rwlock_new(Eina_RWLock *mutex);
74static inline void eina_rwlock_free(Eina_RWLock *mutex);
75static inline Eina_Lock_Result eina_rwlock_take_read(Eina_RWLock *mutex);
76static inline Eina_Lock_Result eina_rwlock_take_write(Eina_RWLock *mutex);
77static inline Eina_Lock_Result eina_rwlock_release(Eina_RWLock *mutex);
78
79static inline Eina_Bool eina_tls_new(Eina_TLS *key);
80static inline void eina_tls_free(Eina_TLS key);
81static inline void *eina_tls_get(Eina_TLS key);
82static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data);
83
84static inline Eina_Bool eina_semaphore_new(Eina_Semaphore *sem, int count_init);
85static inline Eina_Bool eina_semaphore_free(Eina_Semaphore *sem);
86static inline Eina_Bool eina_semaphore_lock(Eina_Semaphore *sem);
87static inline Eina_Bool eina_semaphore_release(Eina_Semaphore *sem, int count_release);
88
89#ifdef EINA_HAVE_DEBUG_THREADS
90# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \
91 do { \
92 if (EINA_UNLIKELY(!eina_main_loop_is())) \
93 { \
94 eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \
95 EINA_LOG_ERR("You are calling %s from outside" \
96 "of the main loop threads in %s at line %i", \
97 __FUNCTION__, \
98 __FILE__, \
99 __LINE__); \
100 return val; \
101 } \
102 } while (0)
103# define EINA_MAIN_LOOP_CHECK_RETURN \
104 do { \
105 if (EINA_UNLIKELY(!eina_main_loop_is())) \
106 { \
107 eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \
108 EINA_LOG_ERR("You are calling %s from outside" \
109 "of the main loop threads in %s at line %i", \
110 __FUNCTION__, \
111 __FILE__, \
112 __LINE__); \
113 return ; \
114 } \
115 } while (0)
116#else
117# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val)
118# define EINA_MAIN_LOOP_CHECK_RETURN
119#endif
120
121/**
122 * @}
123 */
124
125/**
126 * @}
127 */
128
129#endif
diff --git a/libraries/eina/src/include/eina_log.h b/libraries/eina/src/include/eina_log.h
deleted file mode 100644
index 186397d..0000000
--- a/libraries/eina/src/include/eina_log.h
+++ /dev/null
@@ -1,903 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOG_H_
20#define EINA_LOG_H_
21
22#include <stdlib.h>
23#include <stdarg.h>
24#include <sys/types.h>
25
26#include "eina_types.h"
27
28#define EINA_COLOR_LIGHTRED "\033[31;1m"
29#define EINA_COLOR_RED "\033[31m"
30#define EINA_COLOR_LIGHTBLUE "\033[34;1m"
31#define EINA_COLOR_BLUE "\033[34m"
32#define EINA_COLOR_GREEN "\033[32;1m"
33#define EINA_COLOR_YELLOW "\033[33;1m"
34#define EINA_COLOR_ORANGE "\033[0;33m"
35#define EINA_COLOR_WHITE "\033[37;1m"
36#define EINA_COLOR_LIGHTCYAN "\033[36;1m"
37#define EINA_COLOR_CYAN "\033[36m"
38#define EINA_COLOR_RESET "\033[0m"
39#define EINA_COLOR_HIGH "\033[1m"
40
41
42/**
43 * @page tutorial_log_page Log Tutorial
44 *
45 * @section tutorial_log_introduction Introduction
46 *
47 * The Eina Log module provides logging facilities for libraries and
48 * applications. It provides colored logging, basic logging levels (error,
49 * warning, debug, info, critical) and loggers - called logging domains -
50 * which will be covered on next sections.
51 *
52 * @section tutorial_log_basic_usage Basic Usage
53 *
54 * Log messages can be displayed using the following macros:
55 *
56 * @li EINA_LOG_ERR(),
57 * @li EINA_LOG_INFO(),
58 * @li EINA_LOG_WARN(),
59 * @li EINA_LOG_DBG().
60 *
61 * Here is an example:
62 *
63 * @include eina_log_02.c
64 *
65 * If you compiled Eina without debug mode, execution will yield only one log
66 * message, which is "argument is negative".
67 *
68 * Here we introduce the concept of logging domains (or loggers), which might
69 * already be familiar to readers. It is basically a way to separate a set of
70 * log messages into a context (e.g. a module) and provide a way of controlling
71 * this set as a whole.
72 *
73 * For example, suppose you have 3 different modules on your application and you
74 * want to get logging only from one of them (e.g. create some sort of filter).
75 * For achieving that, all you need to do is create a logging domain for each
76 * module so that all logging inside a module can be considered as a whole.
77 *
78 * Logging domains are specified by a name, color applied to the name and the
79 * level. The first two (name and color) are set through code, that is, inside
80 * your application/module/library.
81 *
82 * The level is used for controlling which messages should appear. It
83 * specifies the lowest level that should be displayed (e.g. a message
84 * with level 11 being logged on a domain with level set to 10 would be
85 * displayed, while a message with level 9 wouldn't).
86 *
87 * The domain level is set during runtime (in contrast with the name and
88 * color) through the environment variable EINA_LOG_LEVELS. This variable
89 * expects a list in the form domain_name1:level1,domain_name2:level2,... . For
90 * example:
91 *
92 * @verbatim EINA_LOG_LEVELS=mymodule1:5,mymodule2:2,mymodule3:0 ./myapp@endverbatim
93 *
94 * This line would set mymodule1 level to 5, mymodule2 level to 2 and mymodule3
95 * level to 0.
96 *
97 * There's also a global logger to which EINA_LOG_(ERR, DBG, INFO, CRIT, WARN)
98 * macros do log on. It is a logger that is created internally by Eina Log with
99 * an empty name and can be used for general logging (where logging domains do
100 * not apply).
101 *
102 * Since this global logger doesn't have a name, you can't set its level through
103 * EINA_LOG_LEVELS variable. Here we introduce a second environment variable
104 * that is a bit more special: EINA_LOG_LEVEL.
105 *
106 * This variable specifies the level of the global logging domain and the level
107 * of domains that haven't been set through EINA_LOG_LEVELS. Here's an example:
108 *
109 * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS=module1:10,module3:2 ./myapp@endverbatim
110 *
111 * Supposing you have modules named "module1", "module2" and "module3", this
112 * line would result in module1 with level 10, module2 with level 3 and module3
113 * with level 2. Note that module2's level wasn't specified, so it's level is
114 * set to the global level. This way we can easily apply filters to multiple
115 * domains with only one parameter (EINA_LOG_LEVEL=num).
116 *
117 * The global level (EINA_LOG_LEVEL) can also be set through code, using
118 * eina_log_level_set() function.
119 *
120 * While developing your libraries or applications, you may notice that
121 * EINA_LOG_DOM_(ERR, DBG, INFO, CRIT, WARN) macros also print out
122 * messages from eina itself. Here we introduce another environment variable
123 * that is a bit more special: EINA_LOG_LEVELS_GLOB.
124 *
125 * This variable allows you to disable the logging of any/all code in eina itself.
126 * This is useful when developing your libraries or applications so that you can
127 * see your own domain's messages easier without having to sift through a lot of
128 * internal eina debug messages. Here's an example:
129 *
130 * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS_GLOB=eina_*:0 ./myapp@endverbatim
131 *
132 * This will disable eina_log output from all internal eina code thus allowing
133 * you to see your own domain messages easier.
134 *
135 * @section tutorial_log_advanced_display Advanced usage of print callbacks
136 *
137 * The log module allows the user to change the way
138 * eina_log_print() displays the messages. It suffices to pass to
139 * eina_log_print_cb_set() the function used to display the
140 * message. That function must be of type #Eina_Log_Print_Cb. As a
141 * custom data can be passed to that callback, powerful display
142 * messages can be displayed.
143 *
144 * It is suggested to not use __FILE__, __FUNCTION__ or __LINE__ when
145 * writing that callback, but when defining macros (like
146 * EINA_LOG_ERR() and other macros).
147 *
148 * Here is an example of custom callback, whose behavior can be
149 * changed at runtime:
150 *
151 * @include eina_log_03.c
152 * @example eina_log_02.c
153 * @example eina_log_03.c
154 */
155
156/**
157 * @addtogroup Eina_Log_Group Log
158 *
159 * @brief Full-featured logging system.
160 *
161 * Eina provides eina_log_print(), a standard function to manage all
162 * logging messages. This function may be called directly or using the
163 * helper macros such as EINA_LOG_DBG(), EINA_LOG_ERR() or those that
164 * take a specific domain as argument EINA_LOG_DOM_DBG(),
165 * EINA_LOG_DOM_ERR(). Internally, eina_log_print() will call the
166 * function defined with eina_log_print_cb_set(), that defaults to
167 * eina_log_print_cb_stderr(), but may be changed to do whatever you
168 * need, such as networking or syslog logging.
169 *
170 * The logging system is thread safe once initialized with
171 * eina_log_threads_enable(). The thread that calls this function
172 * first is considered "main thread" and other threads will have their
173 * thread id (pthread_self()) printed in the log message so it is easy
174 * to detect from where it is coming.
175 *
176 * Log domains is the Eina way to differentiate messages. There might
177 * be different domains to represent different modules, different
178 * feature-set, different categories and so on. Filtering can be
179 * applied to domain names by means of @c EINA_LOG_LEVELS environment
180 * variable or eina_log_domain_level_set().
181 *
182 * The different logging levels serve to customize the amount of
183 * debugging one want to take and may be used to automatically call
184 * abort() once some given level message is printed. This is
185 * controlled by environment variable @c EINA_LOG_ABORT and the level
186 * to be considered critical with @c EINA_LOG_ABORT_LEVEL. These can
187 * be changed with eina_log_abort_on_critical_set() and
188 * eina_log_abort_on_critical_level_set().
189 *
190 * The default maximum level to print is defined by environment
191 * variable @c EINA_LOG_LEVEL, but may be set per-domain with @c
192 * EINA_LOG_LEVELS. It will default to #EINA_LOG_ERR. This can be
193 * changed with eina_log_level_set().
194 *
195 * To use the log system Eina must be initialized with eina_init() and
196 * later shut down with eina_shutdown(). Here is a straightforward
197 * example:
198 *
199 * @include eina_log_01.c
200 *
201 * Compile this code with the following command:
202 *
203 * @verbatim gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --libs eina`@endverbatim
204 *
205 * Now execute the program with:
206 *
207 * @verbatim EINA_LOG_LEVEL=2 ./eina_log_01@endverbatim
208 *
209 * You should see a message displayed in the terminal.
210 *
211 * For more information, you can look at the @ref tutorial_log_page.
212 *
213 * @example eina_log_01.c
214 */
215
216/**
217 * @addtogroup Eina_Tools_Group Tools
218 *
219 * @{
220 */
221
222/**
223 * @defgroup Eina_Log_Group Log
224 *
225 * @{
226 */
227
228/**
229 * EINA_LOG_DOMAIN_GLOBAL is the general purpose log domain to be
230 * used, it is always registered and available everywhere.
231 */
232EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
233
234#ifndef EINA_LOG_DOMAIN_DEFAULT
235
236/**
237 * @def EINA_LOG_DOMAIN_DEFAULT
238 * This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(),
239 * EINA_LOG_DOM_INFO(), EINA_LOG_DOM_WARN(), EINA_LOG_DOM_ERR() and
240 * EINA_LOG_DOM_CRIT().
241 *
242 * If not defined prior to the inclusion of this header, then it
243 * defaults to #EINA_LOG_DOMAIN_GLOBAL.
244 *
245 * @note One may like to redefine this in its code to avoid typing too
246 * much. In this case the recommended way is:
247 *
248 * @code
249 * #include <Eina.h>
250 * #undef EINA_LOG_DOMAIN_DEFAULT
251 * #define EINA_LOG_DOMAIN_DEFAULT _log_dom
252 * static int _log_dom = -1;
253 *
254 * int main(void)
255 * {
256 * eina_init();
257 * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
258 * EINA_LOG_ERR("using my own domain");
259 * return 0;
260 * }
261 * @endcode
262 *
263 * @warning If one defines the domain prior to inclusion of this
264 * header, the defined log domain symbol must be defined
265 * prior as well, otherwise the inlined functions defined by
266 * Eina will fail to find the symbol, causing build failure.
267 *
268 * @code
269 * #define EINA_LOG_DOMAIN_DEFAULT _log_dom
270 * static int _log_dom = -1; // must come before inclusion of Eina.h!
271 * #include <Eina.h>
272 *
273 * int main(void)
274 * {
275 * eina_init();
276 * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
277 * EINA_LOG_ERR("using my own domain");
278 * return 0;
279 * }
280 * @endcode
281 *
282 */
283# define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
284
285#endif /* EINA_LOG_DOMAIN_DEFAULT */
286
287/**
288 * @def EINA_LOG(DOM, LEVEL, fmt, ...)
289 * Logs a message on the specified domain, level and format.
290 *
291 * @note if @c EINA_LOG_LEVEL_MAXIMUM is defined, then messages larger
292 * than this value will be ignored regardless of current domain
293 * level, the eina_log_print() is not even called! Most
294 * compilers will just detect the two integers make the branch
295 * impossible and remove the branch and function call all
296 * together. Take this as optimization tip and possible remove
297 * debug messages from binaries to be deployed, saving on hot
298 * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public
299 * header files.
300 */
301#ifdef EINA_ENABLE_LOG
302# ifdef EINA_LOG_LEVEL_MAXIMUM
303# define EINA_LOG(DOM, LEVEL, fmt, ...) \
304 do { \
305 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \
306 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
307 fmt, ## __VA_ARGS__); } \
308 } while (0)
309# else
310# define EINA_LOG(DOM, LEVEL, fmt, ...) \
311 eina_log_print(DOM, \
312 LEVEL, \
313 __FILE__, \
314 __FUNCTION__, \
315 __LINE__, \
316 fmt, \
317 ## __VA_ARGS__)
318# endif
319#else
320#define EINA_LOG(DOM, LEVEL, fmt, ...) \
321 do { (void) DOM; (void) LEVEL; (void) fmt; } while (0)
322#endif
323
324/**
325 * @def EINA_LOG_DOM_CRIT(DOM, fmt, ...)
326 * Logs a message with level CRITICAL on the specified domain and format.
327 */
328#define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \
329 EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__)
330
331/**
332 * @def EINA_LOG_DOM_ERR(DOM, fmt, ...)
333 * Logs a message with level ERROR on the specified domain and format.
334 */
335#define EINA_LOG_DOM_ERR(DOM, fmt, ...) \
336 EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
337
338/**
339 * @def EINA_LOG_DOM_INFO(DOM, fmt, ...)
340 * Logs a message with level INFO on the specified domain and format.
341 */
342#define EINA_LOG_DOM_INFO(DOM, fmt, ...) \
343 EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
344
345/**
346 * @def EINA_LOG_DOM_DBG(DOM, fmt, ...)
347 * Logs a message with level DEBUG on the specified domain and format.
348 */
349#define EINA_LOG_DOM_DBG(DOM, fmt, ...) \
350 EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
351
352/**
353 * @def EINA_LOG_DOM_WARN(DOM, fmt, ...)
354 * Logs a message with level WARN on the specified domain and format.
355 */
356#define EINA_LOG_DOM_WARN(DOM, fmt, ...) \
357 EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
358
359/**
360 * @def EINA_LOG_CRIT(fmt, ...)
361 * Logs a message with level CRITICAL on the default domain with the specified
362 * format.
363 */
364#define EINA_LOG_CRIT(fmt, ...) \
365 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
366 EINA_LOG_LEVEL_CRITICAL, \
367 fmt, \
368 ## __VA_ARGS__)
369
370/**
371 * @def EINA_LOG_ERR(fmt, ...)
372 * Logs a message with level ERROR on the default domain with the specified
373 * format.
374 */
375#define EINA_LOG_ERR(fmt, ...) \
376 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
377
378/**
379 * @def EINA_LOG_INFO(fmt, ...)
380 * Logs a message with level INFO on the default domain with the specified
381 * format.
382 */
383#define EINA_LOG_INFO(fmt, ...) \
384 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
385
386/**
387 * @def EINA_LOG_WARN(fmt, ...)
388 * Logs a message with level WARN on the default domain with the specified
389 * format.
390 */
391#define EINA_LOG_WARN(fmt, ...) \
392 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
393
394/**
395 * @def EINA_LOG_DBG(fmt, ...)
396 * Logs a message with level DEBUG on the default domain with the specified
397 * format.
398 */
399#define EINA_LOG_DBG(fmt, ...) \
400 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
401
402/**
403 * @typedef Eina_Log_Domain
404 * The domain used for logging.
405 */
406typedef struct _Eina_Log_Domain Eina_Log_Domain;
407
408/**
409 * @struct _Eina_Log_Domain
410 * The domain used for logging.
411 */
412struct _Eina_Log_Domain
413{
414 int level; /**< Max level to log */
415 const char *domain_str; /**< Formatted string with color to print */
416 const char *name; /**< Domain name */
417 size_t namelen; /**< strlen(name) */
418
419 /* Private */
420 Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
421};
422
423/**
424 * Enable logging module to handle threads.
425 *
426 * There is no disable option on purpose, if it is enabled, there is
427 * no way back until you call the last eina_shutdown().
428 *
429 * There is no function to retrieve if threads are enabled as one is
430 * not supposed to know this from outside.
431 *
432 * After this call is executed at least once, if Eina was compiled
433 * with threads support then logging will lock around debug messages
434 * and threads that are not the main thread will have its identifier
435 * printed.
436 *
437 * The main thread is considered the thread where the first
438 * eina_init() was called.
439 */
440EAPI void eina_log_threads_enable(void);
441
442/**
443 * @enum _Eina_Log_Level
444 * List of available logging levels.
445 */
446typedef enum _Eina_Log_Level
447{
448 EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
449 EINA_LOG_LEVEL_ERR, /**< Error log level */
450 EINA_LOG_LEVEL_WARN, /**< Warning log level */
451 EINA_LOG_LEVEL_INFO, /**< Information log level */
452 EINA_LOG_LEVEL_DBG, /**< Debug log level */
453 EINA_LOG_LEVELS, /**< Count of default log levels */
454 EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */
455} Eina_Log_Level;
456
457/**
458 * @typedef Eina_Log_Print_Cb
459 * Type for print callbacks.
460 */
461typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
462 Eina_Log_Level level,
463 const char *file, const char *fnc, int line,
464 const char *fmt, void *data, va_list args);
465
466/*
467 * Customization
468 */
469
470/**
471 * Sets logging method to use.
472 *
473 * @param cb The callback to call when printing a log.
474 * @param data The data to pass to the callback.
475 *
476 * By default, eina_log_print_cb_stderr() is used.
477 *
478 * @note MT: safe to call from any thread.
479 *
480 * @note MT: given function @a cb will be called protected by mutex.
481 * This means you're safe from other calls but you should never
482 * call eina_log_print(), directly or indirectly.
483 */
484EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
485
486
487/**
488 * @brief Set the default log level.
489 *
490 * @param level The log level.
491 *
492 * This function sets the log level @p level. It is used in
493 * eina_log_print().
494 *
495 * @note this is initially set to envvar EINA_LOG_LEVEL by eina_init().
496 *
497 * @see eina_log_level_get()
498 */
499EAPI void eina_log_level_set(int level);
500
501/**
502 * @brief Get the default log level.
503 *
504 * @return the log level that limits eina_log_print().
505 *
506 * @see eina_log_level_set()
507 */
508EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
509
510static inline Eina_Bool eina_log_level_check(int level);
511
512/**
513 * Checks if current thread is the main thread.
514 *
515 * @return #EINA_TRUE if threads were enabled and the current thread
516 * is the one that called eina_log_threads_init(). If there is
517 * no thread support (compiled with --disable-pthreads) or
518 * they were not enabled, then #EINA_TRUE is also
519 * returned. The only case where #EINA_FALSE is returned is
520 * when threads were successfully enabled but the current
521 * thread is not the main (one that called
522 * eina_log_threads_init()).
523 */
524EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
525
526
527/**
528 * @brief Set if color logging should be disabled.
529 *
530 * @param disabled if #EINA_TRUE, color logging should be disabled.
531 *
532 * @note this is initially set to envvar EINA_LOG_COLOR_DISABLE by eina_init().
533 *
534 * @see eina_log_color_disable_get()
535 */
536EAPI void eina_log_color_disable_set(Eina_Bool disabled);
537
538/**
539 * @brief Get if color logging should be disabled.
540 *
541 * @return if #EINA_TRUE, color logging should be disabled.
542 *
543 * @see eina_log_color_disable_set()
544 */
545EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
546
547/**
548 * @brief Set if originating file name logging should be disabled.
549 *
550 * @param disabled if #EINA_TRUE, file name logging should be disabled.
551 *
552 * @note this is initially set to envvar EINA_LOG_FILE_DISABLE by eina_init().
553 *
554 * @see eina_log_file_disable_get()
555 */
556EAPI void eina_log_file_disable_set(Eina_Bool disabled);
557
558/**
559 * @brief Get if originating file name logging should be disabled.
560 *
561 * @return if #EINA_TRUE, file name logging should be disabled.
562 *
563 * @see eina_log_file_disable_set()
564 */
565EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
566
567/**
568 * @brief Set if originating function name logging should be disabled.
569 *
570 * @param disabled if #EINA_TRUE, function name logging should be disabled.
571 *
572 * @note this is initially set to envvar EINA_LOG_FUNCTION_DISABLE by
573 * eina_init().
574 *
575 * @see eina_log_function_disable_get()
576 */
577EAPI void eina_log_function_disable_set(Eina_Bool disabled);
578
579/**
580 * @brief Get if originating function name logging should be disabled.
581 *
582 * @return if #EINA_TRUE, function name logging should be disabled.
583 *
584 * @see eina_log_function_disable_set()
585 */
586EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
587
588/**
589 * @brief Set if critical messages should abort the program.
590 *
591 * @param abort_on_critical if #EINA_TRUE, messages with level equal
592 * or smaller than eina_log_abort_on_critical_level_get() will
593 * abort the program.
594 *
595 * @note this is initially set to envvar EINA_LOG_ABORT by
596 * eina_init().
597 *
598 * @see eina_log_abort_on_critical_get()
599 * @see eina_log_abort_on_critical_level_set()
600 */
601EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
602
603/**
604 * @brief Get if critical messages should abort the program.
605 *
606 * @return if #EINA_TRUE, any messages with level equal or smaller
607 * than eina_log_abort_on_critical_level_get() will abort the
608 * program.
609 *
610 * @see eina_log_abort_on_critical_set()
611 * @see eina_log_abort_on_critical_level_set()
612 */
613EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
614
615/**
616 * @brief Set level that triggers abort if abort-on-critical is set.
617 *
618 * @param critical_level levels equal or smaller than the given value
619 * will trigger program abortion if
620 * eina_log_abort_on_critical_get() returns #EINA_TRUE.
621 *
622 * @note this is initially set to envvar EINA_LOG_ABORT_LEVEL by
623 * eina_init().
624 *
625 * @see eina_log_abort_on_critical_level_get()
626 * @see eina_log_abort_on_critical_get()
627 */
628EAPI void eina_log_abort_on_critical_level_set(int critical_level);
629
630/**
631 * @brief Get level that triggers abort if abort-on-critical is set.
632 *
633 * @return critical level equal or smaller than value will trigger
634 * program abortion if eina_log_abort_on_critical_get() returns
635 * #EINA_TRUE.
636 *
637 * @see eina_log_abort_on_critical_level_set()
638 * @see eina_log_abort_on_critical_get()
639 */
640EAPI int eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
641
642
643/**
644 * Set the domain level given its name.
645 *
646 * This call has the same effect as setting
647 * EINA_LOG_LEVELS=&lt;@p domain_name&gt;:&lt;@p level&gt;
648 *
649 * @param domain_name domain name to change the level. It may be of a
650 * still not registered domain. If the domain is not registered
651 * yet, it will be saved as a pending set and applied upon
652 * registration.
653 * @param level level to use to limit eina_log_print() for given domain.
654 */
655EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
656
657/**
658 * Get the domain level given its name.
659 *
660 * @param domain_name domain name to retrieve the level. It may be of
661 * a still not registered domain. If the domain is not
662 * registered yet, but there is a pending value, either from
663 * eina_log_domain_level_set(),EINA_LOG_LEVELS environment
664 * variable or from EINA_LOG_LEVELS_GLOB, these are
665 * returned. If nothing else was found, then the global/default
666 * level (eina_log_level_get()) is returned.
667 *
668 * @return level to use to limit eina_log_print() for given
669 * domain. On error (@p domain_name == NULL),
670 * EINA_LOG_LEVEL_UNKNOWN is returned.
671 *
672 * @see eina_log_domain_level_set()
673 * @see eina_log_domain_registered_level_get()
674 */
675EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
676
677/**
678 * Get the domain level given its identifier.
679 *
680 * @param domain identifier, so it must be previously registered with
681 * eina_log_domain_register(). It's a much faster version of
682 * eina_log_domain_level_get(), but relies on domain being
683 * present.
684 *
685 * @return level to use to limit eina_log_print() for given domain. On
686 * error EINA_LOG_LEVEL_UNKNOWN is returned.
687 */
688EAPI int eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
689
690static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
691
692/*
693 * Logging domains
694 */
695
696/**
697 * @param name Domain name
698 * @param color Color of the domain name
699 *
700 * @return Domain index that will be used as the DOMAIN parameter on log
701 * macros. A negative return value means an log occurred.
702 *
703 * @note MT: safe to call from any thread.
704 */
705EAPI int eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
706
707/**
708 * Forget about a logging domain registered by eina_log_domain_register()
709 *
710 * @param domain domain identifier as reported by eina_log_domain_register(),
711 * must be >= 0.
712 *
713 * @note MT: safe to call from any thread.
714 */
715EAPI void eina_log_domain_unregister(int domain);
716
717/*
718 * Logging functions.
719 */
720
721/**
722 * Print out log message using given domain and level.
723 *
724 * @note Usually you'll not use this function directly but the helper
725 * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
726 * so on. See eina_log.h
727 *
728 * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
729 * you registered none. It is recommended that modules and
730 * applications have their own logging domain.
731 * @param level message level, those with level greater than user
732 * specified value (eina_log_level_set() or environment
733 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
734 * @param file filename that originated the call, must @b not be @c NULL.
735 * @param function function that originated the call, must @b not be @c NULL.
736 * @param line originating line in @a file.
737 * @param fmt printf-like format to use. Should not provide trailing
738 * '\n' as it is automatically included.
739 *
740 * @note MT: this function may be called from different threads if
741 * eina_log_threads_enable() was called before.
742 */
743EAPI void eina_log_print(int domain,
744 Eina_Log_Level level,
745 const char *file,
746 const char *function,
747 int line,
748 const char *fmt,
749 ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
750
751/**
752 * Print out log message using given domain and level.
753 *
754 * @note Usually you'll not use this function directly but the helper
755 * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
756 * so on. See eina_log.h
757 *
758 * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
759 * you registered none. It is recommended that modules and
760 * applications have their own logging domain.
761 * @param level message level, those with level greater than user
762 * specified value (eina_log_level_set() or environment
763 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
764 * @param file filename that originated the call, must @b not be @c NULL.
765 * @param fnc function that originated the call, must @b not be @c NULL.
766 * @param line originating line in @a file.
767 * @param fmt printf-like format to use. Should not provide trailing
768 * '\n' as it is automatically included.
769 * @param args the arguments needed by the format.
770 *
771 * @note MT: this function may be called from different threads if
772 * eina_log_threads_enable() was called before.
773 *
774 * @see eina_log_print()
775 */
776EAPI void eina_log_vprint(int domain,
777 Eina_Log_Level level,
778 const char *file,
779 const char *fnc,
780 int line,
781 const char *fmt,
782 va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
783
784/*
785 * Logging methods (change how logging is done).
786 */
787
788/**
789 * @brief Alternative logging method, this will output to standard output stream.
790 *
791 * @param d The domain.
792 * @param level The level.
793 * @param file The file which is logged.
794 * @param fnc The function which is logged.
795 * @param line The line which is logged.
796 * @param fmt The ouptut format to use.
797 * @param data Not used.
798 * @param args The arguments needed by the format.
799 *
800 * This method will colorize output based on domain provided color and
801 * message logging level. To disable color, set environment variable
802 * EINA_LOG_COLOR_DISABLE=1. Similarly, to disable file and line
803 * information, set EINA_LOG_FILE_DISABLE=1 or
804 * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
805 * not acceptable to have both EINA_LOG_FILE_DISABLE and
806 * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
807 * EINA_LOG_FUNCTION_DISABLE will be considered and file information
808 * will be printed anyways.
809 *
810 * @note MT: if threads are enabled, this function is called within locks.
811 * @note MT: Threads different from main thread will have thread id
812 * appended to domain name.
813 */
814EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d,
815 Eina_Log_Level level,
816 const char *file,
817 const char *fnc,
818 int line,
819 const char *fmt,
820 void *data,
821 va_list args);
822
823/**
824 * @brief Default logging method, this will output to standard error stream.
825 *
826 * @param d The domain.
827 * @param level The level.
828 * @param file The file which is logged.
829 * @param fnc The function which is logged.
830 * @param line The line which is logged.
831 * @param fmt The ouptut format to use.
832 * @param data Not used.
833 * @param args The arguments needed by the format.
834 *
835 * This method will colorize output based on domain provided color and
836 * message logging level.
837 *
838 * To disable color, set environment variable
839 * EINA_LOG_COLOR_DISABLE=1. To enable color, even if directing to a
840 * file or when using a non-supported color terminal, use
841 * EINA_LOG_COLOR_DISABLE=0. If EINA_LOG_COLOR_DISABLE is unset (or
842 * -1), then Eina will disable color if terminal ($TERM) is
843 * unsupported or if redirecting to a file.
844
845 . Similarly, to disable file and line
846 * information, set EINA_LOG_FILE_DISABLE=1 or
847 * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
848 * not acceptable to have both EINA_LOG_FILE_DISABLE and
849 * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
850 * EINA_LOG_FUNCTION_DISABLE will be considered and file information
851 * will be printed anyways.
852 *
853 * @note MT: if threads are enabled, this function is called within locks.
854 * @note MT: Threads different from main thread will have thread id
855 * appended to domain name.
856 */
857EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d,
858 Eina_Log_Level level,
859 const char *file,
860 const char *fnc,
861 int line,
862 const char *fmt,
863 void *data,
864 va_list args);
865
866/**
867 * Alternative logging method, this will output to given file stream.
868 *
869 * @param d The domain.
870 * @param level Not used.
871 * @param file The file which is logged.
872 * @param fnc The function which is logged.
873 * @param line The line which is logged.
874 * @param fmt The ouptut format to use.
875 * @param data The file which will store the output (as a FILE *).
876 * @param args The arguments needed by the format.
877 *
878 * This method will never output color.
879 *
880 * @note MT: if threads are enabled, this function is called within locks.
881 * @note MT: Threads different from main thread will have thread id
882 * appended to domain name.
883 */
884EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d,
885 Eina_Log_Level level,
886 const char *file,
887 const char *fnc,
888 int line,
889 const char *fmt,
890 void *data,
891 va_list args);
892
893#include "eina_inline_log.x"
894
895/**
896 * @}
897 */
898
899/**
900 * @}
901 */
902
903#endif /* EINA_LOG_H_ */
diff --git a/libraries/eina/src/include/eina_magic.h b/libraries/eina/src/include/eina_magic.h
deleted file mode 100644
index d4909d8..0000000
--- a/libraries/eina/src/include/eina_magic.h
+++ /dev/null
@@ -1,330 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MAGIC_H_
20#define EINA_MAGIC_H_
21
22#include "eina_config.h"
23#include "eina_types.h"
24#include "eina_error.h"
25
26/**
27 * @page eina_magic_example_01_page
28 * @dontinclude eina_magic_01.c
29 *
30 * Whenever using Eina we must include it:
31 * @skipline #include
32 *
33 * For this example we are going to define two classes, person and pilot, and
34 * since every pilot is a person we use inheritance. To be type safe we are
35 * going to add EINA_MAGIC to our classes:
36 * @until struct _pilot pilot
37 * @note The values of BASETYPE_MAGIC and SUBTYPE_MAGIC have no meaning, the
38 * only important thing about them is that they be unique.
39 *
40 * Here we have a function to create a perso given a name, nothing too fancy:
41 * @until }
42 *
43 * And now the counterpart, a function the free a person.
44 * @until {
45 * Before we start releasing resources we check that the pointer we were given
46 * actually points to a person, and if not we will print an error message and
47 * quit:
48 * @until }
49 * @note EINA_MAGIC_FAIL is a macro that make's it easy to print an appropriate
50 * (and consistent) error message.
51 * Now knowing that ptr is indeed of type person we prooced to set EINA_MAGIC to
52 * EINA_MAGIC_NONE and free alocated memory:
53 * @until }
54 * @note Setting EINA_MAGIC to EINA_MAGIC_NONE is important to prevent the
55 * struct from being used after freed.
56 *
57 * Now we have our function to create a pilot, this one is a little more complex
58 * because we need to set EINA_MAGIC for the pilot and pilot->base, this is very
59 * important so that checking the EINA_MAGIC of (person*)my_pilot will work:
60 * @until }
61 *
62 * The function to free a pilot is not too different from the one that frees a
63 * person:
64 * @until }
65 * @until }
66 *
67 * We also create functions to print a person or a pilot that check the type of
68 * the pointers they receive:
69 * @until }
70 * @until }
71 *
72 * And on to our main function where we declare some variables and initialize
73 * Eina:
74 * @until eina_init
75 *
76 * For Eina to be able to provide more informative error messages we are going
77 * to give names to our EINA_MAGIC types:
78 * @until string_set
79 *
80 * Since our types won't live longer than the scope of the current function we
81 * can set the name without eina making a copy of the string:
82 * @until static_set
83 *
84 * Now we create a person, a pilot and print both as persons:
85 * @until person *
86 *
87 * Now we try to print both as pilots, which will obvisouly not work since base
88 * is not a pilot:
89 * @until pilot(sub
90 *
91 * That's all folks:
92 * @until }
93 *
94 * See full source @ref eina_magic_example_01_c "here".
95 */
96/**
97 * @page eina_magic_example_01_c Eina_Magic
98 * @include eina_magic_01.c
99 * @example eina_magic_01.c
100 */
101/**
102 * @addtogroup Eina_Tools_Group Tools
103 *
104 * @{
105 */
106/**
107 * @defgroup Eina_Magic_Group Magic
108 *
109 * @brief Eina_Magic provides run-time type-checking.
110 *
111 * C is a weak statically typed language, in other words, it will just check for
112 * types during compile time and any cast will make the compiler believe the
113 * type is correct.
114 *
115 * In real world code we often need to deal with casts, either explicit or
116 * implicit by means of @c void*. We also need to resort to casts when doing
117 * inheritance in C.
118 *
119 * Eina_Magic give us a way to do casts and still be certain of the type we are
120 * opearting on.
121 *
122 * @note It should be noted that it is considered good practice to @b disable
123 * Eina_Magic for production code. The reasoning is that any Eina_Magic errors
124 * should have been caught during testing and therefore there is no reason to
125 * incur the performance downside of Eina_Magic.
126 *
127 * An @ref eina_magic_example_01_page "example" should elucidate matters.
128 *
129 * @{
130 */
131
132/**
133 * An abstract type for a magic number.
134 */
135typedef unsigned int Eina_Magic;
136
137/**
138 * @brief Return the string associated to the given magic identifier.
139 *
140 * @param magic The magic identifier.
141 * @return The string associated to the identifier.
142 *
143 * This function returns the string associated to @p magic. Even if none are
144 * found this function still returns non @c NULL, in this case an identifier
145 * such as "(none)", "(undefined)" or "(unknown)".
146 *
147 * The following identifiers may be returned whenever magic is
148 * invalid, with their meanings:
149 *
150 * - (none): no magic was registered exists at all.
151 * - (undefined): magic was registered and found, but no string associated.
152 * - (unknown): magic was not found in the registry.
153 *
154 * @warning The returned value must not be freed.
155 */
156EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_WARN_UNUSED_RESULT;
157/**
158 * @brief Set the string associated to the given magic identifier.
159 *
160 * @param magic The magic identifier.
161 * @param magic_name The string associated to the identifier, must not
162 * be @c NULL.
163 *
164 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
165 *
166 * This function sets the string @p magic_name to @p magic. It is not
167 * checked if number or string are already set, in which case you will end with
168 * duplicates. Internally, eina will make a copy of @p magic_name.
169 *
170 * @see eina_magic_string_static_set()
171 */
172EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
173 const char *magic_name) EINA_ARG_NONNULL(2);
174
175/**
176 * @brief Set the string associated to the given magic identifier.
177 *
178 * @param magic The magic identifier.
179 * @param magic_name The string associated to the identifier, must not be
180 * @c NULL.
181 *
182 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
183 *
184 * This function sets the string @p magic_name to @p magic. It is not checked if
185 * number or string are already set, in which case you might end with
186 * duplicates. Eina will @b not make a copy of @p magic_name, this means that
187 * @p magic_name has to be a valid pointer for as long as @p magic is used.
188 *
189 * @see eina_magic_string_set()
190 */
191EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
192 const char *magic_name) EINA_ARG_NONNULL(2);
193
194/**
195 * @def EINA_MAGIC_NONE
196 * Random value for specifying that a structure using the magic
197 * feature has already been freed. It is used by eina_magic_fail().
198 *
199 * If the magic feature of Eina is disabled, #EINA_MAGIC_NONE is just
200 * @c 0.
201 */
202#define EINA_MAGIC_NONE 0x1234fedc
203
204/**
205 * @var EINA_ERROR_MAGIC_FAILED
206 * Error identifier corresponding to magic check failure.
207 */
208EAPI extern Eina_Error EINA_ERROR_MAGIC_FAILED;
209
210
211#ifdef EINA_MAGIC_DEBUG
212
213/**
214 * @def EINA_MAGIC
215 * Declaration of a variable of type #Eina_Magic. To put in a structure
216 * when one wants to use the magic feature of Eina with the functions
217 * of that structure, like that:
218 *
219 * @code
220 * struct Foo
221 * {
222 * int i;
223 *
224 * EINA_MAGIC
225 * };
226 * @endcode
227 *
228 * If the magic feature of Eina is disabled, #EINA_MAGIC does nothing.
229 */
230#define EINA_MAGIC Eina_Magic __magic;
231
232/**
233 * @def EINA_MAGIC_SET(d, m)
234 * Set the magic number of @p d to @p m. @p d must be a valid pointer
235 * to a structure holding an Eina magic number declaration. Use
236 * #EINA_MAGIC to add such declaration.
237 *
238 * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just
239 * the value @c 0.
240 */
241#define EINA_MAGIC_SET(d, m) (d)->__magic = (m)
242
243/**
244 * @def EINA_MAGIC_CHECK(d, m)
245 * Test if @p d is @c NULL or not, and if not @c NULL, if
246 * @p d->__eina_magic is equal to @p m. @p d must be a structure that
247 * holds an Eina magic number declaration. Use #EINA_MAGIC to add such
248 * declaration.
249 *
250 * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just
251 * the value @c 1.
252 */
253#define EINA_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
254
255/**
256 * @def EINA_MAGIC_FAIL(d, m)
257 * Call eina_magic_fail() with the parameters @p d, @p d->__magic, @p
258 * m, __FILE__, __FUNCTION__ and __LINE__. @p d must be a structure that
259 * holds an Eina magic number declaration. Use #EINA_MAGIC to add such
260 * declaration.
261 *
262 * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does
263 * nothing.
264 */
265#define EINA_MAGIC_FAIL(d, m) \
266 eina_magic_fail((void *)(d), \
267 (d) ? (d)->__magic : 0, \
268 (m), \
269 __FILE__, \
270 __FUNCTION__, \
271 __LINE__);
272
273/**
274 * @brief Display a message or abort if a magic check failed.
275 *
276 * @param d The checked data pointer.
277 * @param m The magic identifer to check.
278 * @param req_m The requested magic identifier to check.
279 * @param file The file in which the magic check failed.
280 * @param fnc The function in which the magic check failed.
281 * @param line The line at which the magic check failed.
282 *
283 * @warning You should @b strongly consider using @ref EINA_MAGIC_FAIL(d, m)
284 * instead.
285 *
286 * This function displays an error message if a magic check has
287 * failed, using the following logic in the following order:
288 * @li If @p d is @c NULL, a message warns about a @c NULL pointer.
289 * @li Otherwise, if @p m is equal to #EINA_MAGIC_NONE, a message
290 * warns about a handle that was already freed.
291 * @li Otherwise, if @p m is equal to @p req_m, a message warns about
292 * a handle that is of wrong type.
293 * @li Otherwise, a message warns you about ab-using that function...
294 *
295 * If the environment variable EINA_LOG_ABORT is set, abort() is
296 * called and the program stops. It is useful for debugging programs
297 * with gdb.
298 */
299EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
300 const char *file, const char *fnc,
301 int line) EINA_ARG_NONNULL(4, 5);
302
303#else
304
305/**
306 * @cond LOCAL
307 */
308
309#define EINA_MAGIC
310#define EINA_MAGIC_SET(d, m) ((void)0)
311#define EINA_MAGIC_CHECK(d, m) (1)
312#define EINA_MAGIC_FAIL(d, m) ((void)0)
313
314#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void)0)
315
316/**
317 * @endcond
318 */
319
320#endif
321
322/**
323 * @}
324 */
325
326/**
327 * @}
328 */
329
330#endif /* EINA_MAGIC_H_ */
diff --git a/libraries/eina/src/include/eina_main.h b/libraries/eina/src/include/eina_main.h
deleted file mode 100644
index 4baf40e..0000000
--- a/libraries/eina/src/include/eina_main.h
+++ /dev/null
@@ -1,165 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MAIN_H_
20#define EINA_MAIN_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Main_Group Main
26 *
27 * @brief These functions provide general initialisation and shut down
28 * functions.
29 */
30
31/**
32 * @addtogroup Eina_Core_Group Core
33 *
34 * @{
35 */
36
37/**
38 * @defgroup Eina_Main_Group Main
39 *
40 * @{
41 */
42
43/**
44 * @def EINA_VERSION_MAJOR
45 * @brief Major version of Eina
46 */
47#define EINA_VERSION_MAJOR 1
48
49/**
50 * @def EINA_VERSION_MINOR
51 * @brief Minor version of Eina
52 */
53#define EINA_VERSION_MINOR 2
54
55/**
56 * @typedef Eina_Version
57 * The version of Eina.
58 */
59typedef struct _Eina_Version
60{
61 int major; /**< Major component of the version */
62 int minor; /**< Minor component of the version */
63 int micro; /**< Micro component of the version */
64 int revision; /**< Revision component of the version */
65} Eina_Version;
66
67EAPI extern Eina_Version *eina_version;
68
69/**
70 * @brief Initialize the Eina library.
71 *
72 * @return 1 or greater on success, 0 on error.
73 *
74 * This function sets up all the eina modules. It returns 0 on
75 * failure (that is, when one of the module fails to initialize),
76 * otherwise it returns the number of times it has already been
77 * called.
78 *
79 * When Eina is not used anymore, call eina_shutdown() to shut down
80 * the Eina library.
81 */
82EAPI int eina_init(void);
83
84/**
85 * @brief Shut down the Eina library.
86 *
87 * @return 0 when all the modules is completely shut down, 1 or
88 * greater otherwise.
89 *
90 * This function shuts down the Eina library. It returns 0 when it has
91 * been called the same number of times than eina_init(). In that case
92 * it shut down all the Eina modules.
93 *
94 * Once this function succeeds (that is, @c 0 is returned), you must
95 * not call any of the Eina function anymore. You must call
96 * eina_init() again to use the Eina functions again.
97 */
98EAPI int eina_shutdown(void);
99
100/**
101 * @brief Initialize the mutexes of the Eina library.
102 *
103 * @return 1 or greater on success, 0 on error.
104 *
105 * This function sets up all the mutexes in all eina modules. It returns 0 on
106 * failure (that is, when one of the module fails to initialize),
107 * otherwise it returns the number of times it has already been
108 * called.
109 *
110 * When the mutexes are not used anymore, call eina_threads_shutdown() to shut down
111 * the mutexes.
112 *
113 * This function should never be called outside of the main loop.
114 */
115EAPI int eina_threads_init(void);
116
117/**
118 * @brief Shut down mutexes in the Eina library.
119 *
120 * @return 0 when all mutexes are completely shut down, 1 or
121 * greater otherwise.
122 *
123 * This function shuts down the mutexes in the Eina library. It returns 0 when it has
124 * been called the same number of times than eina_threads_init(). In that case
125 * it shut down all the mutexes.
126 *
127 * Once this function succeeds (that is, @c 0 is returned), you must
128 * not call any of the Eina function in a thread anymore. You must call
129 * eina_threads_init() again to use the Eina functions in a thread again.
130 *
131 * This function should never be called outside of the main loop.
132 */
133EAPI int eina_threads_shutdown(void);
134
135/**
136 * @brief Check if you are calling this function from the same thread Eina was initialized or not
137 *
138 * @return #EINA_TRUE is the calling function is the same thread, #EINA_FALSE otherwise.
139 *
140 * @since 1.1.0
141 *
142 * Most EFL function are not thread safe and all the call need to happen in
143 * the main loop. With this call you could know if you can call an EFL
144 * function or not.
145 */
146EAPI Eina_Bool eina_main_loop_is(void);
147
148/**
149 * @brief You should never use that function excpet if you really really know what your are doing.
150 * @since 1.1.0
151 *
152 * If you are reading this documentation, that certainly means you don't know what is the purpose of
153 * this call and you should just not use it.
154 */
155EAPI void eina_main_loop_define(void);
156
157/**
158 * @}
159 */
160
161/**
162 * @}
163 */
164
165#endif /* EINA_MAIN_H_ */
diff --git a/libraries/eina/src/include/eina_matrixsparse.h b/libraries/eina/src/include/eina_matrixsparse.h
deleted file mode 100644
index 97d1ca5..0000000
--- a/libraries/eina/src/include/eina_matrixsparse.h
+++ /dev/null
@@ -1,399 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2009 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MATRIXSPARSE_H_
20#define EINA_MATRIXSPARSE_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_iterator.h"
28#include "eina_accessor.h"
29
30/**
31 * @addtogroup Eina_Matrixsparse_Group Sparse Matrix
32 *
33 * @brief These functions provide matrix sparse management.
34 *
35 * For more information, you can look at the @ref tutorial_matrixsparse_page.
36 */
37
38/**
39 * @addtogroup Eina_Data_Types_Group Data Types
40 *
41 * @{
42 */
43
44/**
45 * @addtogroup Eina_Containers_Group Containers
46 *
47 * @{
48 */
49
50/**
51 * @defgroup Eina_Matrixsparse_Group Sparse Matrix
52 *
53 * @{
54 */
55
56/**
57 * @typedef Eina_Matrixsparse
58 * Type for a generic sparse matrix.
59 */
60typedef struct _Eina_Matrixsparse Eina_Matrixsparse;
61
62/**
63 * @typedef Eina_Matrixsparse_Row
64 * Type for a generic sparse matrix row, opaque for users.
65 */
66typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row;
67
68/**
69 * @typedef Eina_Matrixsparse_Cell
70 * Type for a generic sparse matrix cell, opaque for users.
71 */
72typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell;
73
74/* constructors and destructors */
75
76/**
77 * @brief Create a new Sparse Matrix.
78 *
79 * @param rows number of rows in matrix. Operations with rows greater than this
80 * value will fail.
81 * @param cols number of columns in matrix. Operations with columns greater
82 * than this value will fail.
83 * @param free_func used to delete cell data contents, used by
84 * eina_matrixsparse_free(), eina_matrixsparse_size_set(),
85 * eina_matrixsparse_row_idx_clear(),
86 * eina_matrixsparse_column_idx_clear(),
87 * eina_matrixsparse_cell_idx_clear() and possible others.
88 * @param user_data given to @a free_func as first parameter.
89 *
90 * @return newly allocated matrix or NULL if allocation failed and eina_error
91 * is set.
92 */
93EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
94 unsigned long cols,
95 void (*free_func)(void *user_data,
96 void *cell_data),
97 const void *user_data);
98
99/**
100 * @brief Free resources allocated to Sparse Matrix.
101 *
102 * @param m The Sparse Matrix instance to free, must @b not be @c NULL.
103 */
104EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m);
105
106/* size manipulation */
107
108/**
109 * @brief Get the current size of Sparse Matrix.
110 *
111 * The given parameters are guaranteed to be set if they're not NULL,
112 * even if this function fails (ie: @a m is not a valid matrix instance).
113 *
114 * @param m the sparse matrix to operate on.
115 * @param rows returns the number of rows, may be NULL. If @a m is invalid,
116 * returned value is zero, otherwise it's a positive integer.
117 * @param cols returns the number of columns, may be NULL. If @a m is
118 * invalid, returned value is zero, otherwise it's a positive integer.
119 */
120EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
121 unsigned long *rows,
122 unsigned long *cols);
123
124/**
125 * @brief Resize the Sparse Matrix.
126 *
127 * This will resize the sparse matrix, possibly freeing cells on rows
128 * and columns that will cease to exist.
129 *
130 * @param m the sparse matrix to operate on.
131 * @param rows the new number of rows, must be greater than zero.
132 * @param cols the new number of columns, must be greater than zero.
133 * @return 1 on success, 0 on failure.
134 *
135 * @warning cells, rows or columns are not reference counted and thus
136 * after this call any reference might be invalid if instance were
137 * freed.
138 */
139EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m,
140 unsigned long rows,
141 unsigned long cols);
142
143/* data getting */
144
145/**
146 * Get the cell reference inside Sparse Matrix.
147 *
148 * @param m the sparse matrix to operate on.
149 * @param row the new number of row to clear.
150 * @param col the new number of column to clear.
151 * @param cell pointer to return cell reference, if any exists.
152 *
153 * @return 1 on success, 0 on failure. It is considered success if did not
154 * exist but index is inside matrix size, in this case @c *cell == NULL
155 *
156 * @see eina_matrixsparse_cell_data_get()
157 * @see eina_matrixsparse_data_idx_get()
158 */
159EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
160
161/**
162 * Get data associated with given cell reference.
163 *
164 * @param cell given cell reference, must @b not be @c NULL.
165 *
166 * @return data associated with given cell.
167 *
168 * @see eina_matrixsparse_cell_idx_get()
169 * @see eina_matrixsparse_data_idx_get()
170 */
171EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
172
173/**
174 * Get data associated with given cell given its indexes.
175 *
176 * @param m the sparse matrix to operate on.
177 * @param row the new number of row to clear.
178 * @param col the new number of column to clear.
179 *
180 * @return data associated with given cell or NULL if nothing is associated.
181 *
182 * @see eina_matrixsparse_cell_idx_get()
183 * @see eina_matrixsparse_cell_data_get()
184 */
185EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
186
187/**
188 * Get position (indexes) of the given cell.
189 *
190 * @param cell the cell reference, must @b not be @c NULL.
191 * @param row where to store cell row number, may be @c NULL.
192 * @param col where to store cell column number, may be @c NULL.
193 *
194 * @return 1 on success, 0 otherwise (@c cell is @c NULL).
195 */
196EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
197
198/* data setting */
199
200/**
201 * Change cell reference value without freeing the possibly existing old value.
202 *
203 * @param cell the cell reference, must @b not be @c NULL.
204 * @param data new data to set.
205 * @param p_old returns the old value intact (not freed).
206 *
207 * @return 1 on success, 0 otherwise (@a cell is @c NULL).
208 *
209 * @see eina_matrixsparse_cell_data_set()
210 * @see eina_matrixsparse_data_idx_replace()
211 */
212EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
213
214/**
215 * Change cell value freeing the possibly existing old value.
216 *
217 * In contrast to eina_matrixsparse_cell_data_replace(), this function will
218 * call @c free_func() on existing value.
219 *
220 * @param cell the cell reference, must @b not be @c NULL.
221 * @param data new data to set.
222 *
223 * @return 1 on success, 0 otherwise (@a cell is @c NULL).
224 *
225 * @see eina_matrixsparse_cell_data_replace()
226 * @see eina_matrixsparse_data_idx_set()
227 */
228EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
229
230/**
231 * Change cell value without freeing the possibly existing old value, using
232 * indexes.
233 *
234 * @param m the sparse matrix, must @b not be @c NULL.
235 * @param row the row number to set the value.
236 * @param col the column number to set the value.
237 * @param data new data to set.
238 * @param p_old returns the old value intact (not freed).
239 *
240 * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid).
241 *
242 * @see eina_matrixsparse_cell_data_replace()
243 * @see eina_matrixsparse_data_idx_set()
244 */
245EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
246
247/**
248 * Change cell value freeing the possibly existing old value, using
249 * indexes.
250 *
251 * In contrast to eina_matrixsparse_data_idx_replace(), this function will
252 * call @c free_func() on existing value.
253 *
254 * @param m the sparse matrix, must @b not be @c NULL.
255 * @param row the row number to set the value.
256 * @param col the column number to set the value.
257 * @param data new data to set.
258 *
259 * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid).
260 *
261 * @see eina_matrixsparse_cell_data_replace()
262 */
263EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
264
265/* data deleting */
266
267/**
268 * Clear (erase all cells) of row given its index.
269 *
270 * Existing cells will be cleared with @c free_func() given to
271 * eina_matrixsparse_new().
272 *
273 * @param m the sparse matrix to operate on.
274 * @param row the new number of row to clear.
275 *
276 * @return 1 on success, 0 on failure. It is considered success if row
277 * had no cells filled. Failure is asking for clear row outside
278 * matrix size.
279 *
280 * @warning cells, rows or columns are not reference counted and thus
281 * after this call any reference might be invalid if instance were
282 * freed.
283 */
284EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
285
286/**
287 * Clear (erase all cells) of column given its index.
288 *
289 * Existing cells will be cleared with @c free_func() given to
290 * eina_matrixsparse_new().
291 *
292 * @param m the sparse matrix to operate on.
293 * @param col the new number of column to clear.
294 *
295 * @return 1 on success, 0 on failure. It is considered success if column
296 * had no cells filled. Failure is asking for clear column outside
297 * matrix size.
298 *
299 * @warning cells, rows or columns are not reference counted and thus
300 * after this call any reference might be invalid if instance were
301 * freed.
302 */
303EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
304
305/**
306 * Clear (erase) cell given its indexes.
307 *
308 * Existing cell will be cleared with @c free_func() given to
309 * eina_matrixsparse_new().
310 *
311 * @param m the sparse matrix to operate on.
312 * @param row the new number of row to clear.
313 * @param col the new number of column to clear.
314 *
315 * @return 1 on success, 0 on failure. It is considered success if did not
316 * exist but index is inside matrix size.
317 *
318 * @warning cells, rows or columns are not reference counted and thus
319 * after this call any reference might be invalid if instance were
320 * freed. Note that this call might delete container column and
321 * row if this cell was the last remainder.
322 */
323EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
324
325/**
326 * Clear (erase) cell given its reference.
327 *
328 * @param cell the cell reference, must @b not be @c NULL.
329 *
330 * @return 1 on success, 0 on failure.
331 *
332 * @warning cells, rows or columns are not reference counted and thus
333 * after this call any reference might be invalid if instance were
334 * freed. Note that this call might delete container column and
335 * row if this cell was the last remainder.
336 */
337EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
338
339/* iterators */
340
341/**
342 * Creates a new iterator over existing matrix cells.
343 *
344 * This is a cheap walk, it will just report existing cells and holes
345 * in the sparse matrix will be ignored. That means the reported
346 * indexes will not be sequential.
347 *
348 * The iterator data will be the cell reference, one may query current
349 * position with eina_matrixsparse_cell_position_get() and cell value
350 * with eina_matrixsparse_cell_data_get().
351 *
352 * @param m The Sparse Matrix reference, must @b not be @c NULL.
353 * @return A new iterator.
354 *
355 * @warning if the matrix structure changes then the iterator becomes
356 * invalid! That is, if you add or remove cells this iterator
357 * behavior is undefined and your program may crash!
358 */
359EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
360
361/**
362 * Creates a new iterator over all matrix cells.
363 *
364 * Unlike eina_matrixsparse_iterator_new() this one will report all
365 * matrix cells, even those that are still empty (holes). These will
366 * be reported as dummy cells that contains no data.
367 *
368 * Be aware that iterating a big matrix (1000x1000) will call your
369 * function that number of times (1000000 times in that case) even if
370 * your matrix have no elements at all!
371 *
372 * The iterator data will be the cell reference, one may query current
373 * position with eina_matrixsparse_cell_position_get() and cell value
374 * with eina_matrixsparse_cell_data_get(). If cell is empty then the
375 * reference will be a dummy/placeholder, thus setting value with
376 * eina_matrixsparse_cell_data_set() will leave pointer unreferenced.
377 *
378 * @param m The Sparse Matrix reference, must @b not be @c NULL.
379 * @return A new iterator.
380 *
381 * @warning if the matrix structure changes then the iterator becomes
382 * invalid! That is, if you add or remove cells this iterator
383 * behavior is undefined and your program may crash!
384 */
385EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
386
387/**
388 * @}
389 */
390
391/**
392 * @}
393 */
394
395/**
396 * @}
397 */
398
399#endif /* EINA_MATRIXSPARSE_H_ */
diff --git a/libraries/eina/src/include/eina_mempool.h b/libraries/eina/src/include/eina_mempool.h
deleted file mode 100644
index 796bc9e..0000000
--- a/libraries/eina/src/include/eina_mempool.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MEMPOOL_H_
20#define EINA_MEMPOOL_H_
21
22#include "eina_types.h"
23#include "eina_error.h"
24#include "eina_module.h"
25
26
27/**
28 * @addtogroup Eina_Memory_Pool_Group Memory Pool
29 *
30 * @brief These functions provide memory pool management.
31 *
32 * Several mempool are available:
33 *
34 * @li @c buddy: It uses the
35 * <a href="http://en.wikipedia.org/wiki/Buddy_memory_allocation">"buddy
36 * allocator" algorithm</a> but the Eina implementation differs in the
37 * sense that the chunk information is not stored on the chunk itself,
38 * but on another memory area. This is useful for cases where the
39 * memory to manage might be slower to access, or limited (like video
40 * memory).
41 * @li @c chained_pool: It is the default one. It allocates a big
42 * chunk of memory with malloc() and split the result in chunks of the
43 * requested size that are pushed inside a stack. When requested, it
44 * takes this pointer from the stack to give them to whoever wants
45 * them.
46 * @li @c ememoa_fixed and @c ememoa_unknown: experimental allocators
47 * which could be useful when a fixed amount of memory is needed.
48 * @li @c fixed_bitmap: It allocates with malloc) 32* the requested
49 * size and push the pool pointer in an rbtree. To find empty space in
50 * a pool, it will just search for the first bit set in an int (32
51 * bits). Then, when a pointer is freed, it will do a search inside
52 * the rbtree.
53 * @li @c pass_through: it just call malloc() and free(). It may be
54 * faster on some computers than using our own allocators (like having
55 * a huge L2 cache, over 4MB).
56 * @li @c one_big: It call just one time malloc for the requested number
57 * of items. Useful when you know in advance how many object of some
58 * type will live during the life of the mempool.
59 */
60
61/**
62 * @addtogroup Eina_Tools_Group Tools
63 *
64 * @{
65 */
66
67/**
68 * @defgroup Eina_Memory_Pool_Group Memory Pool
69 *
70 * @{
71 */
72
73/**
74 * @typedef Eina_Mempool
75 * Mempool type.
76 */
77typedef struct _Eina_Mempool Eina_Mempool;
78
79/**
80 * @typedef Eina_Mempool_Backend
81 * Mempool backend type.
82 */
83typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend;
84
85
86/**
87 * @typedef Eina_Mempool_Repack_Cb
88 * Type for a callback who need to unreference an old object from a mempool
89 * and reference the new one instead. Memcpy is taken care by the mempool.
90 */
91typedef void (*Eina_Mempool_Repack_Cb)(void *dst, void *src, void *data);
92
93EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
94
95EAPI Eina_Mempool *eina_mempool_add(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
96EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
97
98static inline void *eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
99static inline void *eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
100static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1);
101
102EAPI void eina_mempool_repack(Eina_Mempool *mp,
103 Eina_Mempool_Repack_Cb cb,
104 void *data) EINA_ARG_NONNULL(1, 2);
105EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
106EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
107
108EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
109EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
110
111EAPI unsigned int eina_mempool_alignof(unsigned int size);
112
113#include "eina_inline_mempool.x"
114
115/**
116 * @}
117 */
118
119/**
120 * @}
121 */
122
123#endif /* EINA_MEMPOOL_H_ */
diff --git a/libraries/eina/src/include/eina_mmap.h b/libraries/eina/src/include/eina_mmap.h
deleted file mode 100644
index d7e3819..0000000
--- a/libraries/eina/src/include/eina_mmap.h
+++ /dev/null
@@ -1,59 +0,0 @@
1#ifndef EINA_MMAP_H_
2#define EINA_MMAP_H_
3
4/**
5 * @addtogroup Eina_Mmap_Group Mmap Group
6 *
7 * @brief These functions provide helpers for safe mmap handling
8 *
9 * @{
10 *
11 * @since 1.1.0
12 */
13
14/**
15 * @brief Enable or disable safe mmaped IO handling
16 *
17 * @param enabled The enabled state (to enable, pass EINA_TRUE)
18 *
19 * This enables (if possible on your platform) a signal handler for
20 * SIGBUS, that replaces the "bad page" with a pzge of 0's (from /dev/zero)
21 * if a SIGBUS occurs. This allows for safe mmap() of files that may truncate
22 * or from files on devices with IO errors. Normally these cases will result
23 * in a SIGBUS being delivered (and termination of yyour process), but
24 * when "mmap safety" is enabled, this will not occur. Instead a page of
25 * bytes of the value 0 will replace the "bad page", allowing the process
26 * to continue and allow its own parsing error detection to safely abort
27 * the operation without the process falling apart.
28 *
29 * If you disable mmap safety, the SIGBUS handler will be restored to its
30 * default handler. Note that eina_file_map_all() and eina_file_map_new()
31 * will automatically enable mmap safety as they provide an mmaped file IO
32 * layer, and rely on mmap to not fail for any part of the file.
33 *
34 * If you set up your own SIGBUS handler, then this will effectively disable
35 * the safe mmap handling and make you liable to crashes on IO to or from
36 * such "damaged files" that would take down your process.
37 *
38 * @since 1.1.0
39 */
40EAPI Eina_Bool
41eina_mmap_safety_enabled_set(Eina_Bool enabled);
42
43/**
44 * @brief Get the enabled state of mmap safety.
45 *
46 * @return The safety state (EINA_TRUE if enabled)
47 *
48 * This returns the mmap safety state set by eina_mmap_safety_enabled_set().
49 * See eina_mmap_safety_enabled_set() for more information.
50 *
51 * @since 1.1.0
52 */
53EAPI Eina_Bool
54eina_mmap_safety_enabled_get(void);
55
56/**
57 * @}
58 */
59#endif
diff --git a/libraries/eina/src/include/eina_model.h b/libraries/eina/src/include/eina_model.h
deleted file mode 100644
index 0a1566e..0000000
--- a/libraries/eina/src/include/eina_model.h
+++ /dev/null
@@ -1,3105 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MODEL_H_
20#define EINA_MODEL_H_
21
22#include "eina_types.h"
23#include "eina_value.h"
24#include "eina_inlist.h"
25#include <stdarg.h>
26
27/**
28 * @page eina_model_01_c Eina_Model inheritance and function overriding
29 * @include eina_model_01.c
30 */
31
32/**
33 * @page eina_model_04_c Eina_Model inheritance, interfaces, and function overriding
34 * @include eina_model_04_main.c
35 * @include eina_model_04_animal.c
36 * @include eina_model_04_human.c
37 * @include eina_model_04_parrot.c
38 * @include eina_model_04_child.c
39 * @include eina_model_04_main.c
40 * @include eina_model_04_whistler.c
41 * @include eina_model_04_animal.h
42 * @include eina_model_04_human.h
43 * @include eina_model_04_whistler.h
44 * @include eina_model_04_child.h
45 * @include eina_model_04_parrot.h
46 */
47
48/**
49 * @page eina_model_02_example_page Creating a simple model
50 * @dontinclude eina_model_02.c
51 *
52 * This example shows the creation of a model with five properties, named:
53 * 'a', 'b', 'c', 'd' and 'e' with values 0, 1, 2, 3 and 4
54 * respectively. In addition to the 5 properties our model also add 5 children,
55 * and to each child we give a property named 'x' with a value of 1, 2, 3, 4 and
56 * 5.
57 *
58 * In other words this piece of code shows how to use eina_model to store a list
59 * of elements, given that the list itself has some properties.
60 *
61 * Now let's walk through the code and examine the interesting bits.
62 *
63 * This is some pretty standard initialization code.
64 * @until eina_init
65 *
66 * We now create our eina_model, the important detail here is the type of the
67 * model being created, for this example we use the generic type provided by
68 * eina:
69 * @until model_new
70 *
71 * Once our model has been created we can add callbacks to be notified of events
72 * that happen to our model, for this example we are just going to add a
73 * callback for the "delete" event. To get a list of events a given eina model
74 * can emit see @ref eina_model_event_names_list_get().
75 * @until callback_add
76 *
77 * Once we have a model, we need to populate it with information. There are two
78 * types of information we can store on an eina model: properties and eina
79 * models. We are going to start by looking at properties.
80 *
81 * Properties are, simply put, named values. They have a char* identifier and an
82 * Eina_Value value. This means you can store in a property almost any type of
83 * data. For this example we are going to add some very simple numeric
84 * properties which will have single letter identifiers.
85 * @until }
86 * @until }
87 *
88 * Despite being able to store almost any value properties the least flexible
89 * information unit we can put in an eina model. We can add eina models to our
90 * eina model, this allows us to represt complex information hierarchies. This
91 * example adds 5 models(with no children of their own) to our parent model @c
92 * m.
93 * @until }
94 * The code here should be pretty easy to understand, we create a model, much
95 * like we did before, and we then add a property to our model, again a task we
96 * have already done.
97 *
98 * The important issue to note here is that we could have given each of our @c c
99 * child models as complex an structure as we needed, they could each be a list
100 * or a tree on their own right.
101 *
102 * Now that we have a populated model we print a string representation of
103 * it(without forgetting to free the string):
104 * @until free
105 *
106 * And since we are done using our model we release our reference to it(and
107 * since no else holds references to it, it will be freed):
108 * @until }
109 *
110 * Note that we don't need to iterate over the children of @c m unrefing it,
111 * this is because we don't hold references to it, we freed our references right
112 * after we added them to their parent model, so when the parent model dies(and
113 * releases the references to it's children) they will be freed.
114 *
115 * The only thing we are going to look at is the callback we registered for
116 * whenever a model is deleted, since our models don't do anything fancy we are
117 * just going to print the memory address of the model being freed.
118 * @until }
119 *
120 * Note that this means the memory address is still valid, our callback is
121 * called just before the memory is freed so we could still access its
122 * information here.
123 *
124 * The full code can be seen in @ref eina_model_02_c
125 */
126
127/**
128 * @page eina_model_02_c eina_model_02.c
129 * @include eina_model_02.c
130 * @example eina_model_02.c
131 */
132
133/**
134 * @page eina_model_03_example_page Using Eina_Model and inheritance
135 * @dontinclude eina_model_03.c
136 *
137 * This example will use two custom defined eina model types: @c PERSON_TYPE to
138 * represent a person and @c ADDRESS_BOOK_TYPE to represent the an address book.
139 * Both our types inherit from EINA_MODEL_TYPE_STRUCT, and, therefore,
140 * store it's data on a struct. Our address book will be very simple it will
141 * only contain one property, the name of the file where we store our address
142 * book. The person type will contain two fields a name and en email. Let's look
143 * at the code.
144 *
145 * We'll start with declaring the variables and functions we'll need to define
146 * our custom type. This will all be explained when the variables get used.
147 * @until address_book_init
148 *
149 * We then jump into our @c main function, declare a couple of variables and
150 * initialize eina:
151 * @until eina_init
152 *
153 * After eina is initialized we'll @c address_book_init() which will initialize
154 * both our @c PERSON_TYPE and our @c ADDRESS_BOOK_TYPE. Details of this will be
155 * shown latter on:
156 * @until address_book_init
157 *
158 * Now that everything is correctly initialized we can create the model that
159 * will represent our address book's
160 * @until eina_model_new
161 *
162 * Before we can load data into our model we need to tell it where to load from,
163 * we do this by setting it's filename property:
164 * @until value_flush
165 *
166 * We then load data into our model and display it as a string:
167 * @until free
168 *
169 * While @c eina_model_to_string allows you to see the contents of the model,
170 * it's display format is not user friendly, it's best used for debugging. So
171 * let's now print our model in a user friendly way.
172 *
173 * First we see how many people are in our address book and print that:
174 * @until printf
175 *
176 * And now we iterate over every child of our address book model, which
177 * represents a person:
178 * @until person
179 *
180 * But again simply calling @c eina_model_to_string would result in not very
181 * user friendly output, so we'll need to get the properties of the person(name
182 * and email) and print them with some formatting:
183 * @until printf
184 *
185 * We then free the resources we allocated to print this person:
186 * @until }
187 *
188 * And that's it for our main function, now just freeing our resources:
189 * @until }
190 *
191 * This however obviously doesn't conclude our example we need to examine how
192 * the the loading of data works to really understand what is happening in the
193 * @c main function.
194 *
195 * Let's start with the constructors(and the variables they use). Both our
196 * constructors do two very important tasks:
197 * @li Calls our parent's constructor, and
198 * @li Sets the description of the struct on our model
199 *
200 * For these constructors that's all we need to do since most of our
201 * functionality is provided by @c EINA_MODEL_TYPE_STRUCT.
202 * @until }
203 * @until }
204 *
205 * And now we have our load function, it opens the file from which we'll
206 * read the address book:
207 * @until EINA_SAFETY_ON_NULL_RETURN_VAL
208 *
209 * Once the file has been opened we read from it line by line and for each
210 * non-blank line we get a name and an email:
211 * @until email
212 * @until email
213 *
214 * Once we have the name and email we create our person model, set it's
215 * properties and make our person a child of the address book:
216 * @until }
217 *
218 * And now that we're done reading the file we close it:
219 * @until }
220 *
221 * This next function is perphaps the most interesting one of our example, it's
222 * the one that creates the definition of our derived types.
223 *
224 * First thing we'll do is the description of the members of our person type.
225 * @until person_members[1].type
226 * Now the description of the struct itself(which uses the members):
227 * @until }
228 * And finally we define the person type itself:
229 * @until person_type.constructor
230 *
231 * With the person now described we'll do the same process for our address book
232 * type:
233 * @until address_book_type.load
234 *
235 * So far everything we created has been in the scope of our function to make
236 * this available outside(such as in the @c main function where we use @c
237 * ADDRESS_BOOK_TYPE and on @c _address_book_load function where we use @c
238 * PERSON_TYPE) we need to assign our descriptions and type to global variables:
239 * @until }
240 *
241 * This concludes this example. A good exercise for the reader is to extend this
242 * example to have the model save the addres book, for example once it's
243 * unloaded, this can be done by overriding the .unload property of @c
244 * ADDRESS_BOOK_TYPE.
245 *
246 * For the full code see: @ref eina_model_03_c
247 */
248
249/**
250 * @page eina_model_03_c eina_model_03.c
251 * @include eina_model_03.c
252 * @example eina_model_03.c
253 */
254
255/**
256 * @addtogroup Eina_Data_Types_Group Data Types
257 *
258 * @since 1.2
259 *
260 * @{
261 */
262
263/**
264 * @addtogroup Eina_Containers_Group Containers
265 *
266 * @{
267 */
268
269/**
270 * @defgroup Eina_Model_Group Data Model API
271 *
272 * Abstracts data access to hierarchical data in an efficient way,
273 * extensible to different backing stores such as database or remote
274 * access.
275 *
276 * It is heavily based on #Eina_Value, as properties are exchanged
277 * using this data type as interface, although internally models may
278 * store them as they want. See @ref Eina_Value_Group.
279 *
280 * Although extensible and easy to optimize, a simple generic type is
281 * provided as #EINA_MODEL_TYPE_GENERIC. It is recommended that people
282 * use it during development, get the logic right and just then
283 * optimize what is needed (properties or children management).
284 *
285 * Not as generic as #EINA_MODEL_TYPE_GENERIC, but way more efficient
286 * is #EINA_MODEL_TYPE_STRUCT that instead of a hash of properties of
287 * any type, it uses a struct to map properties. Its properties are
288 * fixed set of names and they have fixed type, as defined by the
289 * #Eina_Value_Struct_Desc description used internally.
290 *
291 * Examples:
292 * @li @ref eina_model_01_c inheritance example, uses #EINA_MODEL_TYPE_GENERIC
293 * @li @ref eina_model_02_example_page contains an easy to follow
294 * example that demonstrates several of the important features of
295 * eina_model, uses #EINA_MODEL_TYPE_GENERIC.
296 * @li @ref eina_model_03_example_page walk-through example on how to
297 * inherit types, a suggestion of eina_model_load() usage and uses
298 * #EINA_MODEL_TYPE_STRUCT.
299 * @li @ref eina_model_04_c Advanced inheritance, interfaces and interface
300 * function overloading example.
301 *
302 * @{
303 */
304
305/**
306 * @var EINA_ERROR_MODEL_FAILED
307 * Defined when model-specific errors happens.
308 */
309EAPI extern Eina_Error EINA_ERROR_MODEL_FAILED;
310
311/**
312 * @var EINA_ERROR_MODEL_METHOD_MISSING
313 * Defined when model-specific errors happens.
314 */
315EAPI extern Eina_Error EINA_ERROR_MODEL_METHOD_MISSING;
316
317/**
318 * @typedef Eina_Model
319 * Data Model Object.
320 *
321 * This is an opaque handle that is created with eina_model_new() and
322 * released with eina_model_unref().
323 *
324 * It contains properties, children and may emit events. See
325 * respectively:
326 * @li eina_model_property_get() and eina_model_property_set()
327 * @li eina_model_child_get() and eina_model_child_set()
328 * @li eina_model_event_names_list_get(), eina_model_event_callback_add() and eina_model_event_callback_del()
329 *
330 * @see eina_model_new()
331 * @see eina_model_ref() and eina_model_xref()
332 * @see eina_model_unref(), eina_model_xunref() and eina_model_del()
333 * @see eina_model_type_get() and eina_model_interface_get()
334 * @since 1.2
335 */
336typedef struct _Eina_Model Eina_Model;
337
338/**
339 * @typedef Eina_Model_Type
340 * Data Model Type.
341 *
342 * @see #_Eina_Model_Type explains fields.
343 * @since 1.2
344 */
345typedef struct _Eina_Model_Type Eina_Model_Type;
346
347/**
348 * @typedef Eina_Model_Interface
349 * Data Model Interface.
350 *
351 * @see #_Eina_Model_Interface explains fields.
352 * @since 1.2
353 */
354typedef struct _Eina_Model_Interface Eina_Model_Interface;
355
356/**
357 * @typedef Eina_Model_Event_Description
358 * Data Model Event Description.
359 *
360 * This is used to declare events supported by types and interfaces
361 * and also to provide introspection to receivers of signals so they
362 * can know which data they are receiving as @c event_info.
363 *
364 * @see EINA_MODEL_EVENT_DESCRIPTION()
365 * @see #EINA_MODEL_EVENT_DESCRIPTION_SENTINEL
366 * @see #_Eina_Model_Event_Description explains fields.
367 * @since 1.2
368 */
369typedef struct _Eina_Model_Event_Description Eina_Model_Event_Description;
370
371/**
372 * @brief Creates a new model of type @a Type.
373 * @param type The type of the model to create.
374 * @return If successfull pointer to model, NULL otherwise.
375 *
376 * @see _Eina_Model_Type
377 * @see eina_model_del()
378 * @since 1.2
379 */
380EAPI Eina_Model *eina_model_new(const Eina_Model_Type *type);
381/**
382 * @brief Frees the memory associated with @a model
383 * @param model The model instance.
384 *
385 * @see eina_model_new()
386 * @since 1.2
387 */
388EAPI void eina_model_del(Eina_Model *model) EINA_ARG_NONNULL(1);
389
390/**
391 * @brief Returns the type of @a model.
392 * @param model The model instance.
393 * @return The type of @a model.
394 *
395 * @see eina_model_new()
396 * @see _Eina_Model_Type
397 * @since 1.2
398 */
399EAPI const Eina_Model_Type *eina_model_type_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
400
401/**
402 * @brief Returns the interface named @a name of @a model.
403 * @param model The model instance.
404 * @param name Name of interface to get.
405 * @return If successfull requested interface, NULL otherwise.
406 *
407 * The name of every interface of @a model will be compared to @a name, the
408 * first one to match will be returned.
409 *
410 * @see eina_model_new()
411 * @see _Eina_Model_Interface
412 * @since 1.2
413 */
414EAPI const Eina_Model_Interface *eina_model_interface_get(const Eina_Model *model,
415 const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
416
417/**
418 * @brief Increases the refcount of @a model.
419 * @param model The model to increase reference.
420 * @return The @a model with reference increased.
421 * @return If successfull pointer to model, NULL otherwise.
422 *
423 * @see eina_model_new()
424 * @see eina_model_unref()
425 * @since 1.2
426 */
427EAPI Eina_Model *eina_model_ref(Eina_Model *model) EINA_ARG_NONNULL(1);
428
429/**
430 * @brief Increases the refcount of @a model, informs reference identifier.
431 * @param model The model to increase reference.
432 * @param id An identifier to mark this reference.
433 * @param label An optional label to help debug, may be @c NULL.
434 * @return The @a model with reference increased.
435 *
436 * This extended version of reference explicitly marks the origin of
437 * the reference and eina_model_xunref() should be used to check and
438 * remove it.
439 *
440 * Usually the @a id is another object, like a parent object, or some
441 * class/structure/file/function that is holding the reference for
442 * some reason.
443 *
444 * Its purpose is to help debuging if Eina was compiled with model
445 * usage debug enabled and environment variable @c EINA_MODEL_DEBUG=1
446 * is set.
447 *
448 * It is recommended to use eina_model_xref() and eina_model_xunref()
449 * pair whenever you want to be sure you released your
450 * references. Both at your own type, or using applications. As an
451 * example #EINA_MODEL_INTERFACE_CHILDREN_INARRAY will use this to
452 * make sure it deleted every managed children.
453 *
454 * In order to debug leaks, consider using eina_model_xrefs_get() or
455 * eina_models_usage_dump() for a global picture. However, some
456 * references are not tracked, namely:
457 *
458 * @li eina_model_new()
459 * @li eina_model_child_get()
460 * @li eina_model_child_iterator_get()
461 * @li eina_model_child_reversed_iterator_get()
462 * @li eina_model_child_sorted_iterator_get()
463 * @li eina_model_child_filtered_iterator_get()
464 * @li eina_model_child_slice_iterator_get()
465 * @li eina_model_child_slice_reversed_iterator_get()
466 * @li eina_model_child_slice_sorted_iterator_get()
467 * @li eina_model_child_slice_filtered_iterator_get()
468 *
469 * @note this function is slower than eina_model_ref() if
470 * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". Otherwise it
471 * should have the same performance cost.
472 *
473 * @see eina_model_ref()
474 * @see eina_model_xunref()
475 * @since 1.2
476 */
477EAPI Eina_Model *eina_model_xref(Eina_Model *model,
478 const void *id,
479 const char *label) EINA_ARG_NONNULL(1, 2);
480
481/**
482 * @brief Decreases the refcount of @a model.
483 * @param model The model to decrease reference.
484 * @return If successfull pointer to model, NULL otherwise.
485 *
486 * After this function returns, consider @a model pointer invalid.
487 *
488 * @see eina_model_ref()
489 * @see eina_model_del()
490 * @since 1.2
491 */
492EAPI void eina_model_unref(Eina_Model *model) EINA_ARG_NONNULL(1);
493
494/**
495 * @brief Decreases the refcount of @a model, informs reference identifier.
496 * @param model The model to decrease reference.
497 * @param id An identifier to mark this reference.
498 * @return If successfull pointer to model, NULL otherwise.
499 *
500 * This function will match eina_model_xref() and the @a id must match
501 * a previously call, otherwise it will produce an error if @c
502 * EINA_MODEL_DEBUG is set to "1" or "backtrace", and the reference is
503 * not decreased!
504 *
505 * After this function returns, consider @a model pointer invalid.
506 *
507 * @note this function is slower than eina_model_unref() if
508 * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". Otherwise it
509 * should have the same performance cost.
510 *
511 * @see eina_model_xref()
512 * @since 1.2
513 */
514EAPI void eina_model_xunref(Eina_Model *model,
515 const void *id) EINA_ARG_NONNULL(1, 2);
516
517
518
519/**
520 * @defgroup Eina_Model_Event_Group Data Model Events
521 * Events and their usage with models.
522 *
523 * Events are specified by each type and interface level using
524 * #Eina_Model_Event_Description. One can know all events supported by
525 * a model with eina_model_event_names_list_get() and then
526 * eina_model_event_description_get() to retrieve details.
527 *
528 * By default the following events are supported in every object:
529 * @li deleted: last reference was released or eina_model_del() was called.
530 * @li freed: memory was destroyed, destructors were called.
531 * @li property,set: eina_model_property_set() was done.
532 * @li property,deleted: eina_model_property_del() was done.
533 * @li children,changed: children was changed somehow (added, modified, deleted)
534 * @li child,inserted: new child was added (eina_model_child_append() or eina_model_child_insert_at())
535 * @li child,set: child was replaced (eina_model_child_set())
536 * @li child,deleted: eina_model_child_del() was done.
537 * @li loaded: eina_model_load() was done.
538 * @li unloaded: eina_model_unload() was done.
539 *
540 * Mix-in interfaces may emit these:
541 * @li properties,loaded
542 * @li properties,unloaded
543 * @li children,loaded
544 * @li children,unloaded
545 *
546 * One can be notified of events with eina_model_event_callback_add().
547 *
548 * Types emit these events with eina_model_event_callback_call(),
549 * these are handled asynchronously unless event is frozen with
550 * eina_model_event_callback_freeze() is blocking it. In this case the
551 * events are ignored. Usually this is used in some cases that want to
552 * avoid storm of events in batch operations.
553 *
554 * @{
555 */
556
557/**
558 * @typedef Eina_Model_Event_Cb
559 * Notifies of events in this model.
560 *
561 * @since 1.2
562 */
563typedef void (*Eina_Model_Event_Cb)(void *data, Eina_Model *model, const Eina_Model_Event_Description *desc, void *event_info);
564
565/**
566 * @brief Add a callback to be called when @a event_name is emited.
567 * @param model The model instance.
568 * @param event_name The name of event for which @a cb will be called.
569 * @param cb The function to be called.
570 * @param data Data @a cb will be called with. May be NULL.
571 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
572 *
573 * @see eina_model_event_callback_del()
574 * @since 1.2
575 */
576EAPI Eina_Bool eina_model_event_callback_add(Eina_Model *model,
577 const char *event_name,
578 Eina_Model_Event_Cb cb,
579 const void *data) EINA_ARG_NONNULL(1, 2, 3);
580/**
581 * @brief Remove a callback that was to be called when @a event_name was emited.
582 * @param model The model instance.
583 * @param event_name The name of event for which to delete callback.
584 * @param cb The function given to eina_model_event_callback_add().
585 * @param data Data given to eina_model_event_callback_add(). A NULL value means
586 * every @a data will not be compared.
587 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
588 *
589 * @see eina_model_event_callback_add()
590 * @since 1.2
591 */
592EAPI Eina_Bool eina_model_event_callback_del(Eina_Model *model,
593 const char *event_name,
594 Eina_Model_Event_Cb cb,
595 const void *data) EINA_ARG_NONNULL(1, 2, 3);
596
597/**
598 * @brief Returns a description of the event named @c event_name
599 * @param model The model instance.
600 * @param event_name Name of event whose description is wanted.
601 * @return Description of event.
602 *
603 * @see Eina_Model_Event_Description
604 * @since 1.2
605 */
606EAPI const Eina_Model_Event_Description *eina_model_event_description_get(const Eina_Model *model,
607 const char *event_name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
608
609/**
610 * @brief Returns list of events this model may emit.
611 * @param model The model whose events are to be listed.
612 * @return An Eina_List of stringshares with the name of every event. Free the
613 * list with eina_model_event_names_list_free().
614 *
615 * @since 1.2
616 */
617EAPI Eina_List *eina_model_event_names_list_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
618/**
619 * @brief Frees the list of event's names gotten from
620 * eina_model_event_names_list_get().
621 * @param list The list to free.
622 *
623 * @see eina_model_event_names_list_get()
624 * @since 1.2
625 */
626EAPI void eina_model_event_names_list_free(Eina_List *list);
627
628/**
629 * @brief Calls every callback associated to @a name on model @a model with @a
630 * event_info.
631 * @param model The model instance.
632 * @param name The event whose callbacks will be called.
633 * @param event_info The data given to the callback as event_info. May be NULL.
634 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
635 *
636 * @see eina_model_event_callback_add()
637 * @see eina_model_event_callback_del()
638 * @since 1.2
639 */
640EAPI Eina_Bool eina_model_event_callback_call(Eina_Model *model,
641 const char *name,
642 const void *event_info) EINA_ARG_NONNULL(1, 2);
643
644/**
645 * @brief Makes @a model not call the callbacks associated with @a name.
646 * @param model The model instance.
647 * @param name The event whose callbacks are to be frozen.
648 * @return Count of freezes called on this event.
649 *
650 * @see eina_model_event_callback_call()
651 * @see eina_model_event_callback_thaw()
652 * @since 1.2
653 */
654EAPI int eina_model_event_callback_freeze(Eina_Model *model,
655 const char *name) EINA_ARG_NONNULL(1, 2);
656/**
657 * @brief Makes @a model able to call the callbacks associated with @a name.
658 * @param model The model instance.
659 * @param name The event whose callbacks are to be frozen.
660 * @return Count of freezes still valid in this event.
661 *
662 * @warning Behavior is undefined if called on a @a model, @a name not frozen.
663 *
664 * @see eina_model_event_callback_call()
665 * @see eina_model_event_callback_freeze()
666 * @since 1.2
667 */
668EAPI int eina_model_event_callback_thaw(Eina_Model *model,
669 const char *name) EINA_ARG_NONNULL(1, 2);
670
671/**
672 * @}
673 */
674
675
676/**
677 * @brief Makes a shallow copy of @a model.
678 * @param model The model instance.
679 * @return Copied model.
680 *
681 * The returned model will have a copy of the properties of @a model and a
682 * reference to the children of @a model.
683 *
684 * @see eina_model_deep_copy()
685 * @since 1.2
686 */
687EAPI Eina_Model *eina_model_copy(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
688/**
689 * @brief Makes a deep(complete) copy of @a model.
690 * @param model The model instance.
691 * @return Copied model.
692 *
693 * The returned model will have a copy of the properties of @a model, its
694 * children will be created by making a deep copy of the children of @a model.
695 *
696 * @see eina_model_copy()
697 * @since 1.2
698 */
699EAPI Eina_Model *eina_model_deep_copy(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
700
701/**
702 * @brief Compares two models.
703 * @param a The first model to compare.
704 * @param b The second model to compare.
705 * @return Greater than zero if @a a > @a b, zero if @a a == @a b and less than
706 * zero if @a a < @a b
707 *
708 * The default comparison checks that the properties of @a a and @a b all have
709 * the same name and value, and then recursively compares all children.
710 *
711 * A model with less properties or children is considered smaller than one with
712 * more properties.
713 *
714 * @since 1.2
715 */
716EAPI int eina_model_compare(const Eina_Model *a, const Eina_Model *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
717
718/**
719 * @brief Loads the @a model's data.
720 * @param model The model instance.
721 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
722 *
723 * By convention this means loading data from an external source and populating
724 * the models properties and children with it. For example in the case of file
725 * system backed model, this means opening the relevant files and reading the
726 * data from them(creating the properties and children from it).
727 * @warning This convention should be followed, but no guarantees of behaviour
728 * by user defined types can be given.
729 *
730 * @note The types provided by Eina_Model don't implement this method.
731 * @note Calling this function on a model that doesn't implement it returns @c
732 * EINA_TRUE without any effect on @a model.
733 *
734 * @see eina_model_unload()
735 * @since 1.2
736 */
737EAPI Eina_Bool eina_model_load(Eina_Model *model) EINA_ARG_NONNULL(1);
738/**
739 * @brief Unloads the @a model's data.
740 * @param model The model instance.
741 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
742 *
743 * By convention this means releasing data gotten from an external source. For
744 * example of a database backed model this might mean releasing the iterator for
745 * the currently loaded data or deleting a temporary table.
746 * @warning This convention should be followed, but no guarantees of behaviour
747 * by user defined types can be given.
748 *
749 * @note The types provided by Eina_Model don't implement this method.
750 * @note Calling this function on a model that doesn't implement it returns @c
751 * EINA_TRUE without any effect on @a model.
752 *
753 * @see eina_model_load()
754 * @since 1.2
755 */
756EAPI Eina_Bool eina_model_unload(Eina_Model *model) EINA_ARG_NONNULL(1);
757
758
759/**
760 * @defgroup Eina_Model_Properties_Group Data Model Properties
761 * Properties and their usage with models.
762 *
763 * Properties are attributes of model. They have a name and contain a
764 * data value (@ref Eina_Value_Group).
765 *
766 * The actual values and their types, if it is possible to read and
767 * write them and if new properties can be created or deleted it is up
768 * to the type.
769 *
770 * @{
771 */
772/**
773 * @brief Gets the value of @a model's property named @a name.
774 * @param[in] model The model from which to get the property.
775 * @param[in] name The name of the property whose value is wanted.
776 * @param[out] value A pointer to an Eina_Value to receive the property's value.
777 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
778 *
779 * @return EINA_TRUE if @a model has a property named @a name, EINA_FALSE
780 * otherwise.
781 *
782 * @see eina_model_property_set()
783 * @see eina_model_property_del()
784 * @since 1.2
785 */
786EAPI Eina_Bool eina_model_property_get(const Eina_Model *model,
787 const char *name,
788 Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3);
789/**
790 * @brief Sets the value of @a model's property named @a name to @a value.
791 * @param model The model in which to set the property.
792 * @param name The name of the property whose value is to set.
793 * @param value A pointer to a const Eina_Value to containing the property's
794 * value.
795 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
796 *
797 * @see eina_model_property_get()
798 * @see eina_model_property_del()
799 * @since 1.2
800 */
801EAPI Eina_Bool eina_model_property_set(Eina_Model *model,
802 const char *name,
803 const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3);
804/**
805 * @brief Deletes @a model's property named @a name.
806 * @param model The model from which to delete the property.
807 * @param name The name of the property to delete.
808 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
809 *
810 * @see eina_model_property_set()
811 * @see eina_model_property_get()
812 * @since 1.2
813 */
814EAPI Eina_Bool eina_model_property_del(Eina_Model *model,
815 const char *name) EINA_ARG_NONNULL(1, 2);
816
817/**
818 * @brief Gets a list of the names of every property of @a model.
819 * @param model The model instance.
820 * @return #Eina_List of names.
821 *
822 * @note The returned list should be freed with @c
823 * eina_model_properties_names_list_free().
824 *
825 * @see eina_model_properties_names_list_free()
826 * @see eina_model_property_get()
827 * @since 1.2
828 */
829EAPI Eina_List *eina_model_properties_names_list_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
830/**
831 * @brief Frees a list of names of properties gotten with @c
832 * eina_model_properties_names_list_get().
833 * @param list The list to free.
834 *
835 * @warning Behavior is undefined if called on a list not gotten from @c
836 * eina_model_properties_names_list_get().
837 *
838 * @see eina_model_properties_names_list_get()
839 * @see eina_model_property_get()
840 * @since 1.2
841 */
842EAPI void eina_model_properties_names_list_free(Eina_List *list);
843
844/**
845 * @}
846 */
847
848/**
849 * @defgroup Eina_Model_Children_Group Data Model Children
850 * Children and their usage with models.
851 *
852 * Children are other model instances that are kept sequentially in
853 * the model. They are accessed by their integer index within the
854 * model. Their index may change if child are inserted or deleted
855 * before them, as in an array.
856 *
857 * @{
858 */
859
860/**
861 * @brief Returns the number of child models in @a model.
862 * @param model The model instance.
863 * @return Number of children in @a model.
864 *
865 * @see eina_model_child_append()
866 * @see eina_model_child_get()
867 * @see eina_model_child_del()
868 * @since 1.2
869 */
870EAPI int eina_model_child_count(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
871
872/**
873 * @brief Get the child at a given position from a model.
874 * @param model the model instance.
875 * @param position index of child to get.
876 * @return child instance with reference @b increased, or @c NULL on error.
877 *
878 * The given @a position must be valid, otherwise it may fail and
879 * return @c NULL, one should check for a valid position with
880 * eina_model_child_count().
881 *
882 * @warning The returned model has its reference increased, you must release it
883 * with eina_model_unref(). This convention is imposed to avoid the
884 * object being removed before the caller function has time to use it.
885 */
886EAPI Eina_Model *eina_model_child_get(const Eina_Model *model,
887 unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
888
889/**
890 * @brief Set the child at a given position from a model.
891 * @param model the model instance.
892 * @param position index of child to set.
893 * @param child the child to use at given position.
894 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
895 *
896 * The given @a position must be valid, otherwise it may fail and
897 * return #EINA_FALSE, one should check for a valid position with
898 * eina_model_child_count().
899 *
900 * The existing child is replaced. Its reference will be decreased
901 * automatically. To insert a new item instead of replacing, use
902 * eina_model_child_insert_at() or eina_model_child_append().
903 *
904 * The given model will be adopted by @a model, that is, the @a child
905 * will have its reference increased if this call succeeds.
906 *
907 * @see eina_model_child_append()
908 * @see eina_model_child_insert_at()
909 * @since 1.2
910 */
911EAPI Eina_Bool eina_model_child_set(Eina_Model *model,
912 unsigned int position,
913 Eina_Model *child) EINA_ARG_NONNULL(1, 3);
914
915/**
916 * @brief Deletes the child model in @a position-th of @a model.
917 * @param model The model instance.
918 * @param position The position of the child to be deleted.
919 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
920 *
921 * @warning This decrements the reference count of the child being deleted,
922 * which may, or not, cause it to be deconstructed and freed.
923 *
924 * @see eina_model_child_append()
925 * @see eina_model_child_get()
926 * @since 1.2
927 */
928EAPI Eina_Bool eina_model_child_del(Eina_Model *model,
929 unsigned int position) EINA_ARG_NONNULL(1);
930
931/**
932 * @brief Insert @a child in the @a position-th of the list of children of @a
933 * model.
934 * @param model The model instance.
935 * @param position Position in which to insert child.
936 * @param child The child to be inserted.
937 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
938 *
939 * @warning This increments the reference count of the child being inserted, if
940 * it will no longer be used by the inserting code it should call
941 * eina_model_unref() on it.
942 *
943 * @see eina_model_child_append()
944 * @see eina_model_child_set()
945 * @since 1.2
946 */
947EAPI Eina_Bool eina_model_child_insert_at(Eina_Model *model,
948 unsigned int position,
949 Eina_Model *child) EINA_ARG_NONNULL(1, 3);
950
951/**
952 * @brief Appends @a child in @a model.
953 * @param model The model instance.
954 * @param child The child to be appended.
955 * @return The position of the added child, or -1 on failure.
956 *
957 * @warning This increments the reference count of the child being inserted, if
958 * it will no longer be used by the inserting code it should call
959 * eina_model_unref() on it.
960 *
961 * @see eina_model_child_insert_at()
962 * @see eina_model_child_set()
963 * @since 1.2
964 */
965EAPI int eina_model_child_append(Eina_Model *model,
966 Eina_Model *child) EINA_ARG_NONNULL(1, 2);
967
968/**
969 * @brief Returns the position of @a other amongst the children of @a model.
970 * @param model The parent model whose children will be searched.
971 * @param start_position The first children to be compared with @a other.
972 * @param other The model whose position is desired.
973 * @return The position of the searched for child, or -1 if not found.
974 *
975 * @since 1.2
976 */
977EAPI int eina_model_child_find(const Eina_Model *model,
978 unsigned int start_position,
979 const Eina_Model *other) EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
980
981/**
982 * @brief Returns the position of a child of @a model that mathes the criteria.
983 * @param model The model whose children will be searched.
984 * @param start_position The position of the first child to be checked.
985 * @param match The function used to check if a child matches the criteria.
986 * @param data Data given the to the @a match function.
987 * @return The position of the first child to match the criteria or -1 if no
988 * child matches it.
989 *
990 * Returns the position of the first(from @a start_position) child of @a model
991 * to which @a match returns EINA_TRUE.
992 *
993 * @since 1.2
994 */
995EAPI int eina_model_child_criteria_match(const Eina_Model *model,
996 unsigned int start_position,
997 Eina_Each_Cb match,
998 const void *data) EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
999
1000/**
1001 * @brief Sorts the children of @a model according to @a compare.
1002 * @param model The model instance.
1003 * @param compare The function to be used in the comparison.
1004 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1005 *
1006 * The @a compare function receives to const pointer to eina models(const
1007 * *Eina_Model).
1008 *
1009 * @since 1.2
1010 */
1011EAPI Eina_Bool eina_model_child_sort(Eina_Model *model,
1012 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2);
1013
1014/**
1015 * @}
1016 */
1017
1018/**
1019 * @defgroup Eina_Model_Iterators_Group Data Model Iterators
1020 * Iterators and their usage with models.
1021 *
1022 * One of the most common tasks of models is to iterate over their
1023 * children, either forwards or backwards, filtering by some criteria
1024 * or a different ordering function.
1025 *
1026 * @{
1027 */
1028
1029/**
1030 * @brief create an iterator that outputs a child model on each iteration.
1031 * @param model the model instance.
1032 * @return Newly created iterator instance on success or @c NULL on failure.
1033 *
1034 * @code
1035 * Eina_Model *child;
1036 * Eina_Iterator *it = eina_model_child_iterator_get(model);
1037 * EINA_ITERATOR_FOREACH(it, child)
1038 * {
1039 * use_child(child);
1040 * eina_model_unref(child);
1041 * }
1042 * eina_iterator_free(it);
1043 * @endcode
1044 * This code shows how to use iterators to do something (in this example call
1045 * use_child()) on every child element.
1046 *
1047 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1048 * with reference @b increased! You must call eina_model_unref() after you're
1049 * done with it.
1050 *
1051 * @see eina_model_child_slice_iterator_get()
1052 * @see eina_model_child_reversed_iterator_get()
1053 * @see eina_model_child_sorted_iterator_get()
1054 * @see eina_model_child_filtered_iterator_get()
1055 * @since 1.2
1056 */
1057EAPI Eina_Iterator *eina_model_child_iterator_get(Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1058/**
1059 * @brief Gets an iterator to a slice of @a model's children.
1060 * @param model The model whose children to iterate over.
1061 * @param start The first child included in the iterator.
1062 * @param count The number of children included in the iterator.
1063 * @return Newly created iterator instance on success or @c NULL on failure.
1064 *
1065 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1066 * with reference @b increased! You must call eina_model_unref() after you're
1067 * done with it.
1068 *
1069 * @see eina_model_child_iterator_get()
1070 * @see eina_model_child_slice_reversed_iterator_get()
1071 * @since 1.2
1072 */
1073EAPI Eina_Iterator *eina_model_child_slice_iterator_get(Eina_Model *model,
1074 unsigned int start,
1075 unsigned int count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1076
1077/**
1078 * @brief create an iterator that outputs a child model in reversed order.
1079 * @param model the model instance.
1080 * @return Newly created iterator instance on success or @c NULL on failure.
1081 *
1082 * Each iteration output a child model with reference @b increased!
1083 * You must call eina_model_unref() after you're done with it.
1084 *
1085 * The order is reversed, that is, the last element is outputted first.
1086 *
1087 * @code
1088 * Eina_Model *child;
1089 * Eina_Iterator *it = eina_model_child_reversed_iterator_get(model);
1090 * EINA_ITERATOR_FOREACH(it, child)
1091 * {
1092 * use_child(child);
1093 * eina_model_unref(child);
1094 * }
1095 * eina_iterator_free(it);
1096 * @endcode
1097 * This code shows how to use iterators to do something (in this example call
1098 * use_child()) on every child element starting from last to first.
1099 *
1100 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1101 * with reference @b increased! You must call eina_model_unref() after you're
1102 * done with it.
1103 *
1104 * @see eina_model_child_slice_iterator_get()
1105 * @see eina_model_child_reversed_iterator_get()
1106 * @see eina_model_child_sorted_iterator_get()
1107 * @see eina_model_child_filtered_iterator_get()
1108 * @since 1.2
1109 */
1110EAPI Eina_Iterator *eina_model_child_reversed_iterator_get(Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1111
1112/**
1113 * @brief Gets a reversed iterator to a slice of @a model's children.
1114 * @param model The model whose children to iterate over.
1115 * @param start The first child included in the iterator.
1116 * @param count The number of children included in the iterator.
1117 * @return Newly created iterator instance on success or @c NULL on failure.
1118 *
1119 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1120 * with reference @b increased! You must call eina_model_unref() after you're
1121 * done with it.
1122 *
1123 * @see eina_model_child_reversed_iterator_get()
1124 * @see eina_model_child_slice_iterator_get()
1125 * @since 1.2
1126 */
1127EAPI Eina_Iterator *eina_model_child_slice_reversed_iterator_get(Eina_Model *model,
1128 unsigned int start,
1129 unsigned int count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1130
1131/**
1132 * @brief create an iterator that outputs a child model using sort criteria.
1133 * @param model the model instance.
1134 * @param compare compare function to use as sort criteria.
1135 * @return Newly created iterator instance on success or @c NULL on failure.
1136 *
1137 * Each iteration output a child model with reference @b increased!
1138 * You must call eina_model_unref() after you're done with it.
1139 *
1140 * The sort will not affect the main object @a model, it's just a view
1141 * of it.
1142 *
1143 * @code
1144 * Eina_Model *child;
1145 * Eina_Iterator *it = eina_model_child_sorted_iterator_get(model, EINA_COMPARE_CB(eina_model_compare));
1146 * EINA_ITERATOR_FOREACH(it, child)
1147 * {
1148 * use_child(child);
1149 * eina_model_unref(child);
1150 * }
1151 * eina_iterator_free(it);
1152 * @endcode
1153 * This bit of code shows how to use iterators to do something (in this example
1154 * call use_child()) on every child element in the order given by the @a compare
1155 * function.
1156 *
1157 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1158 * with reference @b increased! You must call eina_model_unref() after you're
1159 * done with it.
1160 *
1161 * @see eina_model_child_slice_iterator_get()
1162 * @see eina_model_child_reversed_iterator_get()
1163 * @see eina_model_child_sorted_iterator_get()
1164 * @see eina_model_child_filtered_iterator_get()
1165 * @since 1.2
1166 */
1167EAPI Eina_Iterator *eina_model_child_sorted_iterator_get(Eina_Model *model,
1168 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
1169
1170/**
1171 * @brief Returns a sorted iterator to a slice of @a model's children.
1172 * @param model The model whose children to iterate over.
1173 * @param start The position(before sorting) of the first child included in
1174 * the iterator.
1175 * @param count The number of children included in the iterator.
1176 * @param compare The function used to sort the children.
1177 * @return Newly created iterator instance on success or @c NULL on failure.
1178 *
1179 * @warning Each iteration(call to eina_iterator_next()) gives a child model
1180 * with reference @b increased! You must call eina_model_unref() after you're
1181 * done with it.
1182 *
1183 * @see eina_model_child_slice_iterator_get()
1184 * @see eina_model_child_reversed_iterator_get()
1185 * @see eina_model_child_sorted_iterator_get()
1186 * @see eina_model_child_filtered_iterator_get()
1187 * @since 1.2
1188 */
1189EAPI Eina_Iterator *eina_model_child_slice_sorted_iterator_get(Eina_Model *model,
1190 unsigned int start,
1191 unsigned int count,
1192 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 4) EINA_WARN_UNUSED_RESULT;
1193
1194/**
1195 * @brief create an iterator that indexes of children that matches.
1196 * @param model the model instance.
1197 * @param match function to select children.
1198 * @param data extra context given to @a match function.
1199 * @return Newly created iterator instance on success or @c NULL on failure.
1200 *
1201 * Unlike other iterators, each iteration output an integer index!
1202 * This is useful if you want to highlight the matching model
1203 * somewhere else.
1204 *
1205 * If no child element matches a valid, and empty, iterator will be returned.
1206 * Indexes returned by this iterator are guaranteed to exists.
1207 *
1208 * @code
1209 * unsigned int idx;
1210 * Eina_Iterator *it = eina_model_child_filtered_iterator_get(model, filter, ctx);
1211 * EINA_ITERATOR_FOREACH(it, idx)
1212 * {
1213 * Eina_Model *child = eina_model_child_get(model, idx);
1214 * printf("matches at %u %p\n", idx, child);
1215 * eina_model_unref(child);
1216 * }
1217 * eina_iterator_free(it);
1218 * @endcode
1219 * This bit of code shows how to use iterators to do something (in this example
1220 * print the address) on child elements that match the criteria given of @a match.
1221 *
1222 * @see eina_model_child_slice_iterator_get()
1223 * @see eina_model_child_reversed_iterator_get()
1224 * @see eina_model_child_sorted_iterator_get()
1225 * @see eina_model_child_filtered_iterator_get()
1226 * @since 1.2
1227 */
1228EAPI Eina_Iterator *eina_model_child_filtered_iterator_get(Eina_Model *model,
1229 Eina_Each_Cb match,
1230 const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
1231
1232/**
1233 * @brief Returns a filtered slice of the @a model's children.
1234 * @param model The model whose children to iterate over.
1235 * @param start The position of the first child to be tested for inclusion in
1236 * the iterator.
1237 * @param count The number of children to be tested for inclusion in the
1238 * iterator.
1239 * @param match The function used to decide which children will be included in
1240 * the iterator.
1241 * @param data Data passed to the @a match function.
1242 * @return Newly created iterator instance on success or @c NULL on failure.
1243 *
1244 * @note Only children for whom @a match returns EINA_TRUE will be included in
1245 * the iterator.
1246 *
1247 * @note Each iteration(call to eina_iterator_next()) gives an integer index!
1248 *
1249 * @warning The iterator may have less than @a count children, but not more.
1250 *
1251 * @see eina_model_child_slice_iterator_get()
1252 * @see eina_model_child_reversed_iterator_get()
1253 * @see eina_model_child_sorted_iterator_get()
1254 * @see eina_model_child_filtered_iterator_get()
1255 * @since 1.2
1256 */
1257EAPI Eina_Iterator *eina_model_child_slice_filtered_iterator_get(Eina_Model *model,
1258 unsigned int start,
1259 unsigned int count,
1260 Eina_Each_Cb match,
1261 const void *data) EINA_ARG_NONNULL(1, 4) EINA_WARN_UNUSED_RESULT;
1262
1263
1264/**
1265 * @}
1266 */
1267
1268/**
1269 * @brief Convert model to string.
1270 * @param model the model instance.
1271 * @return Newly allocated memory or @c NULL on failure.
1272 *
1273 * The default format of the ouput is:
1274 * Type_Name({Property_Name: Property_Value, ...}, [Child0, Child1, ...])
1275 *
1276 * Where:
1277 * @li Type_Name: eina_model_type_name_get(eina_model_type_get(model))
1278 * @li Properties are sorted alphabetically.
1279 * @li Property_Value is created using eina_value_to_string().
1280 * @li Children are converted using eina_model_to_string()
1281 *
1282 * @since 1.2
1283 */
1284EAPI char *eina_model_to_string(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
1285
1286/**
1287 * @defgroup Eina_Model_Type_Group Data Model Type management
1288 *
1289 * Functions and structures related to implementing new types or
1290 * extending existing ones.
1291 *
1292 * All eina_model_type functions takes an Eina_Model_Type or
1293 * Eina_Model_Interface as parameter and may be used to validate or
1294 * query information about them.
1295 *
1296 * The functions with prefix eina_model_type that matches eina_model
1297 * counterparts, such as eina_model_type_compare() and
1298 * eina_model_compare() are used as "super", that is, calls the @c
1299 * compare() method of the given type (or its parent) instead of the
1300 * most specific type of provided Eina_Model.
1301 *
1302 * Examples:
1303 * @li @ref eina_model_02_example_page contains an easy to follow
1304 * example that demonstrates several of the important features of
1305 * eina_model, uses #EINA_MODEL_TYPE_GENERIC.
1306 * @li @ref eina_model_03_example_page walk-through example on how to
1307 * inherit types, a suggestion of eina_model_load() usage and uses
1308 * #EINA_MODEL_TYPE_STRUCT.
1309 *
1310 * @{
1311 */
1312
1313/**
1314 * @def EINA_MODEL_TYPE_VERSION
1315 * Current API version, used to validate #_Eina_Model_Type.
1316 */
1317#define EINA_MODEL_TYPE_VERSION (1)
1318
1319/**
1320 * @struct _Eina_Model_Type
1321 * API to access models.
1322 *
1323 * Each type of the hierarchy and each interface will get its own
1324 * private data of size @c private_size (defined at each subtype or
1325 * interface), this can be retrieved with
1326 * eina_model_type_private_data_get() and
1327 * eina_model_interface_private_data_get().
1328 *
1329 * Private are created @b automatically and should be setup with @c
1330 * setup and flushed with @c flush. All types (or interfaces)
1331 * functions that exist are called! Don't call your parent's @c setup or
1332 * @c flush! The setup is done from parent to child. Flush is done from
1333 * child to parent.
1334 *
1335 * After memory setup was done, @c constructor of the toplevel type
1336 * defining it is called. If desired it may call parent's constructor
1337 * in whatever order is desired. This may be used to create
1338 * properties, children and may use parent's data if needed. The only
1339 * constructor caled is that of the most specialized type, if interface
1340 * constructors should be called, do them in the desired order from the type
1341 * constructor.
1342 *
1343 * When the model is deleted, explicitly with eina_model_del() or
1344 * implicitly with eina_model_unref() on the last reference, the @c
1345 * destructor is called. It must release references to other
1346 * models. When the last reference is dropped, every @c flush is
1347 * called from child to parent, then memory is freed. The only
1348 * destructor caled is that of the most specialized type, if interface
1349 * destructors should be called, do them in the desired order from the type
1350 * destructor.
1351 *
1352 *
1353 * @note The methods @c setup and @c flush should exist if there is
1354 * private data, otherwise memory may be uninitialized or leaks.
1355 * @note It is recommended that @c constructor and @c destructor exist
1356 * to correctly do their roles and call parents in the correct
1357 * order. Whenever they do not exist, their parent pointer is
1358 * called.
1359 * @note a runtime check will enforce just types with ABI version
1360 * #EINA_MODEL_TYPE_VERSION are used by comparing with the @c version
1361 * member.
1362 *
1363 * @since 1.2
1364 */
1365struct _Eina_Model_Type
1366{
1367 unsigned int version; /**< must be #EINA_MODEL_TYPE_VERSION */
1368 unsigned int private_size; /**< used to allocate type private data */
1369 unsigned int type_size; /**< used to know sizeof(Eina_Model_Type) or subtypes (which may be bigger, by including Eina_Model_Type as a header */
1370 const char *name; /**< name for debug and introspection */
1371 const Eina_Model_Type *parent; /**< parent type, must be EINA_MODEL_TYPE_BASE or a child of */
1372 const Eina_Model_Interface **interfaces; /**< null terminated array of interfaces */
1373 const Eina_Model_Event_Description *events; /**< null terminated array of events */
1374 Eina_Bool (*setup)(Eina_Model *model); /**< setup type private data, do @b not call parent type setup! */
1375 Eina_Bool (*flush)(Eina_Model *model); /**< flush type private data, do @b not call parent type flush! */
1376 Eina_Bool (*constructor)(Eina_Model *model); /**< construct type instance, setup was already called. Should call parent's or interfaces' constructor if needed */
1377 Eina_Bool (*destructor)(Eina_Model *model); /**< destruct type instance, flush will be called after it. Should call parent's or interfaces' destructor if needed. Release reference to other models here. */
1378 Eina_Bool (*copy)(const Eina_Model *src, Eina_Model *dst); /**< copy type private data, do @b not call parent type copy! */
1379 Eina_Bool (*deep_copy)(const Eina_Model *src, Eina_Model *dst); /**< deep copy type private data, do @b not call parent type deep copy! */
1380 Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp);
1381 Eina_Bool (*load)(Eina_Model *model);
1382 Eina_Bool (*unload)(Eina_Model *model);
1383 Eina_Bool (*property_get)(const Eina_Model *model, const char *name, Eina_Value *value);
1384 Eina_Bool (*property_set)(Eina_Model *model, const char *name, const Eina_Value *value);
1385 Eina_Bool (*property_del)(Eina_Model *model, const char *name);
1386 Eina_List *(*properties_names_list_get)(const Eina_Model *model); /**< list of stringshare */
1387 int (*child_count)(const Eina_Model *model);
1388 Eina_Model *(*child_get)(const Eina_Model *model, unsigned int position);
1389 Eina_Bool (*child_set)(Eina_Model *model, unsigned int position, Eina_Model *child);
1390 Eina_Bool (*child_del)(Eina_Model *model, unsigned int position);
1391 Eina_Bool (*child_insert_at)(Eina_Model *model, unsigned int position, Eina_Model *child);
1392 int (*child_find)(const Eina_Model *model, unsigned int start_position, const Eina_Model *other);
1393 int (*child_criteria_match)(const Eina_Model *model, unsigned int start_position, Eina_Each_Cb match, const void *data);
1394 void (*child_sort)(Eina_Model *model, Eina_Compare_Cb compare);
1395 Eina_Iterator *(*child_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count);
1396 Eina_Iterator *(*child_reversed_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count);
1397 Eina_Iterator *(*child_sorted_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count, Eina_Compare_Cb compare);
1398 Eina_Iterator *(*child_filtered_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count, Eina_Each_Cb match, const void *data);
1399 char *(*to_string)(const Eina_Model *model); /**< used to represent model as string, usually for debug purposes or user convenience */
1400 void *__extension_ptr0; /**< not to be used */
1401 void *__extension_ptr1; /**< not to be used */
1402 void *__extension_ptr2; /**< not to be used */
1403 void *__extension_ptr3; /**< not to be used */
1404};
1405
1406#define EINA_MODEL_TYPE_INIT(name, type, private_type, parent, interfaces, events) \
1407 {EINA_MODEL_TYPE_VERSION, \
1408 sizeof(private_type), \
1409 sizeof(type), \
1410 name, \
1411 parent, \
1412 interfaces, \
1413 events, \
1414 NULL, \
1415 NULL, \
1416 NULL, \
1417 NULL, \
1418 NULL, \
1419 NULL, \
1420 NULL, \
1421 NULL, \
1422 NULL, \
1423 NULL, \
1424 NULL, \
1425 NULL, \
1426 NULL, \
1427 NULL, \
1428 NULL, \
1429 NULL, \
1430 NULL, \
1431 NULL, \
1432 NULL, \
1433 NULL, \
1434 NULL, \
1435 NULL, \
1436 NULL, \
1437 NULL, \
1438 NULL, \
1439 NULL, \
1440 NULL, \
1441 NULL, \
1442 NULL, \
1443 NULL \
1444 }
1445
1446#define EINA_MODEL_TYPE_INIT_NOPRIVATE(name, type, parent, interfaces, events) \
1447 {EINA_MODEL_TYPE_VERSION, \
1448 0, \
1449 sizeof(type), \
1450 name, \
1451 parent, \
1452 interfaces, \
1453 events, \
1454 NULL, \
1455 NULL, \
1456 NULL, \
1457 NULL, \
1458 NULL, \
1459 NULL, \
1460 NULL, \
1461 NULL, \
1462 NULL, \
1463 NULL, \
1464 NULL, \
1465 NULL, \
1466 NULL, \
1467 NULL, \
1468 NULL, \
1469 NULL, \
1470 NULL, \
1471 NULL, \
1472 NULL, \
1473 NULL, \
1474 NULL, \
1475 NULL, \
1476 NULL, \
1477 NULL, \
1478 NULL, \
1479 NULL, \
1480 NULL, \
1481 NULL, \
1482 NULL, \
1483 NULL \
1484 }
1485
1486#define EINA_MODEL_TYPE_INIT_NULL \
1487 {0, \
1488 0, \
1489 0, \
1490 NULL, \
1491 NULL, \
1492 NULL, \
1493 NULL, \
1494 NULL, \
1495 NULL, \
1496 NULL, \
1497 NULL, \
1498 NULL, \
1499 NULL, \
1500 NULL, \
1501 NULL, \
1502 NULL, \
1503 NULL, \
1504 NULL, \
1505 NULL, \
1506 NULL, \
1507 NULL, \
1508 NULL, \
1509 NULL, \
1510 NULL, \
1511 NULL, \
1512 NULL, \
1513 NULL, \
1514 NULL, \
1515 NULL, \
1516 NULL, \
1517 NULL, \
1518 NULL, \
1519 NULL, \
1520 NULL, \
1521 NULL, \
1522 NULL, \
1523 NULL \
1524 }
1525
1526/**
1527 * @brief Calls the constructor of @a type for @a model.
1528 * @param type The type whose constructor will be called.
1529 * @param model The model instance.
1530 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1531 *
1532 * This should be used to call the parent's type constructor, something like:
1533 * @code
1534 * static Eina_Bool my_type_constructor(Eina_Model *m)
1535 * {
1536 * // call parents constructor:
1537 * if (!eina_model_type_constructor(MY_TYPE->parent, m))
1538 * return EINA_FALSE;
1539 * // do my stuff
1540 * return EINA_TRUE;
1541 * }
1542 * @endcode
1543 * @note You should only do your type's initialization after the parent type has
1544 * done his own(this is as to ensure you can call on your parent's methods).
1545 *
1546 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1547 * returns EINA_FALSE.
1548 *
1549 * @see eina_model_new()
1550 * @see _Eina_Model_Type
1551 * @since 1.2
1552 */
1553EAPI Eina_Bool eina_model_type_constructor(const Eina_Model_Type *type,
1554 Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
1555/**
1556 * @brief Calls the destructor of @a type for @a model.
1557 * @param type The type whose destructor will be called.
1558 * @param model The model instance.
1559 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1560 *
1561 * This should be used to call the parent's type destructor, something like:
1562 * @code
1563 * static Eina_Bool my_type_destructor(Eina_Model *m)
1564 * {
1565 * // do my stuff
1566 * // call parents destructor:
1567 * if (!eina_model_type_destructor(MY_TYPE->parent, m))
1568 * return EINA_FALSE;
1569 * return EINA_TRUE;
1570 * }
1571 * @endcode
1572 * @note It's considered good practice to free your type's resources before
1573 * calling the parent's destructor.
1574 *
1575 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1576 * returns EINA_FALSE.
1577 *
1578 * @see eina_model_del()
1579 * @see _Eina_Model_Type
1580 * @since 1.2
1581 */
1582EAPI Eina_Bool eina_model_type_destructor(const Eina_Model_Type *type,
1583 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
1584/**
1585 * @brief Calls the copy method of @a type for @a model.
1586 * @param type The type whose copy method will be called.
1587 * @param src Pointer to the model to be copied.
1588 * @param dst Pointer to where copy will be put.
1589 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1590 *
1591 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1592 * returns EINA_FALSE.
1593 *
1594 * @see eina_model_copy()
1595 * @see _Eina_Model_Type
1596 * @since 1.2
1597 */
1598EAPI Eina_Bool eina_model_type_copy(const Eina_Model_Type *type,
1599 const Eina_Model *src,
1600 Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3);
1601/**
1602 * @brief Calls the deep copy method of @a type for @a model.
1603 * @param type The type whose copy method will be called.
1604 * @param src Pointer to the model to be copied.
1605 * @param dst Pointer to where copy will be put.
1606 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1607 *
1608 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1609 * returns EINA_FALSE.
1610 *
1611 * @see eina_model_deep_copy()
1612 * @see _Eina_Model_Type
1613 * @since 1.2
1614 */
1615EAPI Eina_Bool eina_model_type_deep_copy(const Eina_Model_Type *type,
1616 const Eina_Model *src,
1617 Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3);
1618/**
1619 * @brief Calls the compare method of @a type for @a model.
1620 * @param[in] type The type whose compare method will be called.
1621 * @param[in] a Pointer to the first model to be compared.
1622 * @param[in] b Pointer to the second model to be compared.
1623 * @param[out] cmp The value of the comparison, 1 if @a b is greater than @a a,
1624 * -1 if @a b is smaller than @a a, 0 if @a a and @a b are equal.
1625 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1626 *
1627 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1628 * returns EINA_FALSE.
1629 *
1630 * @see eina_model_compare()
1631 * @see _Eina_Model_Type
1632 * @since 1.2
1633 */
1634EAPI Eina_Bool eina_model_type_compare(const Eina_Model_Type *type,
1635 const Eina_Model *a,
1636 const Eina_Model *b,
1637 int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4);
1638/**
1639 * @brief Calls the load method of @a type for @a model.
1640 * @param type The type whose load method will be called.
1641 * @param model The model instance.
1642 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1643 *
1644 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1645 * returns EINA_FALSE.
1646 *
1647 * @see eina_model_load()
1648 * @see _Eina_Model_Type
1649 * @since 1.2
1650 */
1651EAPI Eina_Bool eina_model_type_load(const Eina_Model_Type *type,
1652 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
1653/**
1654 * @brief Calls the unload method of @a type for @a model.
1655 * @param type The type whose unload method will be called.
1656 * @param model The model instance.
1657 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1658 *
1659 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1660 * returns EINA_FALSE.
1661 *
1662 * @see eina_model_unload()
1663 * @see _Eina_Model_Type
1664 * @since 1.2
1665 */
1666EAPI Eina_Bool eina_model_type_unload(const Eina_Model_Type *type,
1667 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
1668/**
1669 * @brief Calls the property get method of @a type for @a model.
1670 * @param[in] type The type whose property get method will be called.
1671 * @param[in] model The model instance.
1672 * @param[in] name Name of property to get.
1673 * @param[out] value Pointer to where value of property will be placed.
1674 * @return EINA_TRUE if able to get property, EINA_FALSE otherwise.
1675 *
1676 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1677 * returns EINA_FALSE.
1678 *
1679 * @see eina_model_property_get()
1680 * @see _Eina_Model_Type
1681 * @since 1.2
1682 */
1683EAPI Eina_Bool eina_model_type_property_get(const Eina_Model_Type *type,
1684 const Eina_Model *model,
1685 const char *name,
1686 Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4);
1687/**
1688 * @brief Calls the property set method of @a type for @a model.
1689 * @param type The type whose property set method will be called.
1690 * @param model The model instance.
1691 * @param name Name of property whose value will be set.
1692 * @param value The value to be set.
1693 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1694 *
1695 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1696 * returns EINA_FALSE.
1697 *
1698 * @see eina_model_property_set()
1699 * @see _Eina_Model_Type
1700 * @since 1.2
1701 */
1702EAPI Eina_Bool eina_model_type_property_set(const Eina_Model_Type *type,
1703 Eina_Model *model,
1704 const char *name,
1705 const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4);
1706/**
1707 * @brief Calls the property del method of @a type for @a model.
1708 * @param type The type whose property delete method will be called.
1709 * @param model The model instance.
1710 * @param name The name of the property to be deleted.
1711 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1712 *
1713 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1714 * returns EINA_FALSE.
1715 *
1716 * @see eina_model_property_del()
1717 * @see _Eina_Model_Type
1718 * @since 1.2
1719 */
1720EAPI Eina_Bool eina_model_type_property_del(const Eina_Model_Type *type,
1721 Eina_Model *model,
1722 const char *name) EINA_ARG_NONNULL(1, 2, 3);
1723/**
1724 * @brief Calls the properties name list method of @a type for @a model.
1725 * @param type The type whose property name list get method will be called.
1726 * @param model The model instance.
1727 * @return #Eina_List of properties' names.
1728 *
1729 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1730 * returns EINA_FALSE.
1731 *
1732 * @see eina_model_properties_names_list_get()
1733 * @see _Eina_Model_Type
1734 * @since 1.2
1735 */
1736EAPI Eina_List *eina_model_type_properties_names_list_get(const Eina_Model_Type *type,
1737 const Eina_Model *model) EINA_ARG_NONNULL(1, 2);
1738/**
1739 * @brief Calls the child count method of @a type for @a model.
1740 * @param type The type whose child count method will be called.
1741 * @param model The model instance.
1742 * @return Number of children in @a model.
1743 *
1744 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1745 * returns EINA_FALSE.
1746 *
1747 * @see eina_model_child_count()
1748 * @see _Eina_Model_Type
1749 * @since 1.2
1750 */
1751EAPI int eina_model_type_child_count(const Eina_Model_Type *type,
1752 const Eina_Model *model) EINA_ARG_NONNULL(1, 2);
1753/**
1754 * @brief Calls the child get method of @a type for @a model.
1755 * @param type The type whose child get method will be called.
1756 * @param model The model instance.
1757 * @param position The position of the child to get.
1758 * @return The child model, or NULL on failure.
1759 *
1760 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1761 * returns EINA_FALSE.
1762 *
1763 * @see eina_model_child_get()
1764 * @see _Eina_Model_Type
1765 * @since 1.2
1766 */
1767EAPI Eina_Model *eina_model_type_child_get(const Eina_Model_Type *type,
1768 const Eina_Model *model,
1769 unsigned int position) EINA_ARG_NONNULL(1, 2);
1770/**
1771 * @brief Calls the child set method of @a type for @a model.
1772 * @param type The type whose child set method will be called.
1773 * @param model The model instance.
1774 * @param position The position of the child to be set.
1775 * @param child Pointer to value(child) to be set.
1776 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1777 *
1778 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1779 * returns EINA_FALSE.
1780 *
1781 * @see eina_model_child_set()
1782 * @see _Eina_Model_Type
1783 * @since 1.2
1784 */
1785EAPI Eina_Bool eina_model_type_child_set(const Eina_Model_Type *type,
1786 Eina_Model *model,
1787 unsigned int position,
1788 Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4);
1789/**
1790 * @brief Calls the child del method of @a type for @a model.
1791 * @param type The type whose child delete method will be called.
1792 * @param model The model instance.
1793 * @param position Position of child to be deleted.
1794 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1795 *
1796 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1797 * returns EINA_FALSE.
1798 *
1799 * @see eina_model_child_del()
1800 * @see _Eina_Model_Type
1801 * @since 1.2
1802 */
1803EAPI Eina_Bool eina_model_type_child_del(const Eina_Model_Type *type,
1804 Eina_Model *model,
1805 unsigned int position) EINA_ARG_NONNULL(1, 2);
1806/**
1807 * @brief Calls the child insert at method of @a type for @a model.
1808 * @param type The type whose child insert method will be called.
1809 * @param model The model instance.
1810 * @param position Position in which @a child will be inserted.
1811 * @param child The child to be inserted.
1812 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
1813 *
1814 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1815 * returns EINA_FALSE.
1816 *
1817 * @see eina_model_child_insert_at()
1818 * @see _Eina_Model_Type
1819 * @since 1.2
1820 */
1821EAPI Eina_Bool eina_model_type_child_insert_at(const Eina_Model_Type *type,
1822 Eina_Model *model,
1823 unsigned int position,
1824 Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4);
1825/**
1826 * @brief Calls the child find method of @a type for @a model.
1827 * @param type The type whose find method will be called.
1828 * @param model The model instance.
1829 * @param start_position The first position to search for.
1830 * @param other The child being searched for.
1831 * @return The index of the searched child, or -1 if not found.
1832 *
1833 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1834 * returns EINA_FALSE.
1835 *
1836 * @see eina_model_child_find()
1837 * @see _Eina_Model_Type
1838 * @since 1.2
1839 */
1840EAPI int eina_model_type_child_find(const Eina_Model_Type *type,
1841 const Eina_Model *model,
1842 unsigned int start_position,
1843 const Eina_Model *other) EINA_ARG_NONNULL(1, 2, 4);
1844/**
1845 * @brief Calls the child criteria match method of @a type for @a model.
1846 * @param type The type whose child criteria match method will be called.
1847 * @param model The model instance.
1848 * @param start_position The first position to be checked.
1849 * @param match The function used to determine if a child matches the criteria.
1850 * @param data Data given to the @a match function. May be NULL.
1851 * @return The position of the first child to match the criteria or -1 if no
1852 * child matches it.
1853 *
1854 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1855 * returns EINA_FALSE.
1856 *
1857 * @see eina_model_child_criteria_match()
1858 * @see _Eina_Model_Type
1859 * @since 1.2
1860 */
1861EAPI int eina_model_type_child_criteria_match(const Eina_Model_Type *type,
1862 const Eina_Model *model,
1863 unsigned int start_position,
1864 Eina_Each_Cb match,
1865 const void *data) EINA_ARG_NONNULL(1, 2, 4);
1866/**
1867 * @brief Calls the child sort method of @a type for @a model.
1868 * @param type The type whose child sort method will be called.
1869 * @param model The model instance.
1870 * @param compare Function used to compare children.
1871 *
1872 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1873 * returns EINA_FALSE.
1874 *
1875 * @see eina_model_child_sort()
1876 * @see _Eina_Model_Type
1877 * @since 1.2
1878 */
1879EAPI void eina_model_type_child_sort(const Eina_Model_Type *type,
1880 Eina_Model *model,
1881 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
1882/**
1883 * @brief Calls the child iterator get method of @a type for @a model.
1884 * @param type The type whose child iterator get method will be called.
1885 * @param model The model instance.
1886 * @param start The first child to be a part of the iterator.
1887 * @param count The number of children included in the iterator.
1888 * @return Newly created iterator instance on success or @c NULL on failure.
1889 *
1890 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1891 * returns EINA_FALSE.
1892 *
1893 * @see eina_model_child_iterator_get()
1894 * @see _Eina_Model_Type
1895 * @since 1.2
1896 */
1897EAPI Eina_Iterator *eina_model_type_child_iterator_get(const Eina_Model_Type *type,
1898 Eina_Model *model,
1899 unsigned int start,
1900 unsigned int count) EINA_ARG_NONNULL(1, 2);
1901/**
1902 * @brief Calls the child reversed iterator get method of @a type for @a model.
1903 * @param type The type whose child reversed iterator get method will be called.
1904 * @param model The model instance.
1905 * @param start The first child to be a part of the iterator.
1906 * @param count The number of children included in the iterator.
1907 * @return Newly created iterator instance on success or @c NULL on failure.
1908 *
1909 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1910 * returns EINA_FALSE.
1911 *
1912 * @see eina_model_child_reversed_iterator_get()
1913 * @see _Eina_Model_Type
1914 * @since 1.2
1915 */
1916EAPI Eina_Iterator *eina_model_type_child_reversed_iterator_get(const Eina_Model_Type *type,
1917 Eina_Model *model,
1918 unsigned int start,
1919 unsigned int count) EINA_ARG_NONNULL(1, 2);
1920/**
1921 * @brief Calls the child sorted iterator get method of @a type for @a model.
1922 * @param type The type whose child sorted iterator get method will be called.
1923 * @param model The model instance.
1924 * @param start The first child to be a part of the iterator.
1925 * @param count The number of children included in the iterator.
1926 * @param compare Function used to compare children.
1927 * @return Newly created iterator instance on success or @c NULL on failure.
1928 *
1929 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1930 * returns EINA_FALSE.
1931 *
1932 * @see eina_model_child_sorted_iterator_get()
1933 * @see _Eina_Model_Type
1934 * @since 1.2
1935 */
1936EAPI Eina_Iterator *eina_model_type_child_sorted_iterator_get(const Eina_Model_Type *type,
1937 Eina_Model *model,
1938 unsigned int start,
1939 unsigned int count,
1940 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 5);
1941/**
1942 * @brief Calls the child filtered get method of @a type for @a model.
1943 * @param type The type whose child filtered iterator get method will be called.
1944 * @param model The model instance.
1945 * @param start The first child to be a part of the iterator.
1946 * @param count Number of children to be checked for inclusion in the iterator.
1947 * @param match Function used to check if child will be included in the iterator.
1948 * @param data Data given to the @a match function. May be NULL.
1949 * @return Newly created iterator instance on success or @c NULL on failure.
1950 *
1951 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1952 * returns EINA_FALSE.
1953 *
1954 * @see eina_model_child_filtered_iterator_get()
1955 * @see _Eina_Model_Type
1956 * @since 1.2
1957 */
1958EAPI Eina_Iterator *eina_model_type_child_filtered_iterator_get(const Eina_Model_Type *type,
1959 Eina_Model *model,
1960 unsigned int start,
1961 unsigned int count,
1962 Eina_Each_Cb match,
1963 const void *data) EINA_ARG_NONNULL(1, 2, 5);
1964/**
1965 * @brief Calls the to string method of @a type for @a model.
1966 * @param type The type whose to string method will be called.
1967 * @param model The model instance.
1968 * @return String representationof @a model.
1969 *
1970 * @warning If model doesn't inherit from(or is of) @a type does nothing and
1971 * returns EINA_FALSE.
1972 *
1973 * @see eina_model_to_string()
1974 * @see _Eina_Model_Type
1975 * @since 1.2
1976 */
1977EAPI char *eina_model_type_to_string(const Eina_Model_Type *type,
1978 const Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
1979
1980
1981/**
1982 * @brief Get resolved method from types that extend Eina_Model_Type given @a offset.
1983 * @param model the model to query the method
1984 * @param offset the byte offset in the structure given as type, it
1985 * must be bigger than Eina_Model_Type itself.
1986 * @return Address to resolved method, or @c NULL if method is not implemented.
1987 *
1988 * The use of this function is discouraged, you should use
1989 * eina_model_method_resolve() instead.
1990 *
1991 * When implementing new types that augments the basic methods from
1992 * Eina_Model_Type, the recommended structure layout is as follow:
1993 * @code
1994 * typedef struct _My_Type My_Type;
1995 * struct _My_Type {
1996 * Eina_Model_Type base;
1997 * int (*my_method)(Eina_Model *model);
1998 * };
1999 *
2000 * int my_type_my_method(Eina_Model *model);
2001 * @endcode
2002 *
2003 * Then the implementation of @c my_type_my_method() needs to get the
2004 * most specific @c my_method that is not @c NULL from type hierarchy,
2005 * also called "resolve the method".
2006 *
2007 * To do this in an efficient way, Eina_Model infrastructure
2008 * pre-resolves all methods and provides this function for efficient
2009 * query. The recommended implementation of my_type_my_method() would
2010 * be:
2011 * @code
2012 * int my_type_my_method(Eina_Model *model)
2013 * {
2014 * int (*meth)(Eina_Model *);
2015 *
2016 * EINA_SAFETY_ON_FALSE_RETURN(eina_model_instance_check(model, MY_TYPE), -1);
2017 *
2018 * meth = eina_model_method_offset_resolve(model, offsetof(My_Type, my_method));
2019 * EINA_SAFETY_ON_NULL_RETURN(meth, -1);
2020 * return meth(model);
2021 * }
2022 * @endcode
2023 *
2024 * @note offset must be bigger than Eina_Model_Type, otherwise use
2025 * specific functions such as eina_model_property_get().
2026 *
2027 * @see eina_model_method_resolve
2028 * @see eina_model_type_method_resolve
2029 * @since 1.2
2030 */
2031EAPI const void *eina_model_method_offset_resolve(const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
2032
2033/**
2034 * @brief Gets resolved method from @a type of @a model given @a offset.
2035 * @param type The type whose method offset resolve method will be called.
2036 * @param model The model instance.
2037 * @param offset The offset of the wanted method.
2038 * @return Address to resolved method, or @c NULL if method is not implemented.
2039 *
2040 * @see eina_model_method_offset_resolve()
2041 * @since 1.2
2042 */
2043EAPI const void *eina_model_type_method_offset_resolve(const Eina_Model_Type *type, const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2044
2045#define eina_model_method_resolve(model, struct_type, method) eina_model_method_offset_resolve((model), offsetof(struct_type, method))
2046
2047#define eina_model_type_method_resolve(type, model, struct_type, method) eina_model_type_method_offset_resolve((type), (model), offsetof(struct_type, method))
2048
2049/**
2050 * @def EINA_MODEL_INTERFACE_VERSION
2051 * Current API version, used to validate #_Eina_Model_Interface.
2052 */
2053#define EINA_MODEL_INTERFACE_VERSION (1)
2054
2055/**
2056 * @struct _Eina_Model_Interface
2057 * API to access models.
2058 *
2059 * Interfaces are managed by name, then multiple Eina_Model_Interface
2060 * may have the same name meaning it implements that name.
2061 *
2062 * Each interface will get its own private data of size @c
2063 * private_size (defined at each sub interface), this can be retrieved
2064 * with eina_model_interface_private_data_get().
2065 *
2066 * Private are created @b automatically and should be setup with @c
2067 * setup and flushed with @c flush. All interfaces functions that
2068 * exist are called! Don't call your parent's @c setup or @c flush!
2069 * The setup is done from parent to child. Flush is done from child to
2070 * parent (topological sort is applied to interface graph).
2071 *
2072 * @note The methods @c setup and @c flush should exist if there is
2073 * private data, otherwise memory may be uninitialized or leaks.
2074 * @note It is recommended that @c constructor and @c destructor exist
2075 * to correctly do their roles and call parents in the correct
2076 * order. Whenever they do not exist, their parent pointer is
2077 * called.
2078 * @note Interface's constructor and destructor are only called by
2079 * type counterparts. Unlike setup and flush, they are not
2080 * guaranteed to be called.
2081 * @note use the same name pointer on queries to speed up the lookups!
2082 * @note a runtime check will enforce just types with ABI version
2083 * #EINA_MODEL_INTERFACE_VERSION are used by comparing with the
2084 * @c version member.
2085 *
2086 * @since 1.2
2087 */
2088struct _Eina_Model_Interface
2089{
2090 unsigned int version; /**< must be #EINA_MODEL_INTERFACE_VERSION */
2091 unsigned int private_size; /**< used to allocate interface private data */
2092 unsigned int interface_size; /**< used to know sizeof(Eina_Model_Interface) or subtypes (which may be bigger, by including Eina_Model_Interface as header */
2093 const char *name; /**< name for debug and introspection */
2094 const Eina_Model_Interface **interfaces; /**< null terminated array of parent interfaces */
2095 const Eina_Model_Event_Description *events; /**< null terminated array of events */
2096 Eina_Bool (*setup)(Eina_Model *model); /**< setup interface private data, do @b not call parent interface setup! */
2097 Eina_Bool (*flush)(Eina_Model *model); /**< flush interface private data, do @b not call parent interface flush! */
2098 Eina_Bool (*constructor)(Eina_Model *model); /**< construct interface instance, setup was already called. Should call parent's constructor if needed */
2099 Eina_Bool (*destructor)(Eina_Model *model); /**< destruct interface instance, flush will be called after it. Should call parent's destructor if needed. Release reference to other models here. */
2100 Eina_Bool (*copy)(const Eina_Model *src, Eina_Model *dst); /**< copy interface private data, do @b not call parent interface copy! */
2101 Eina_Bool (*deep_copy)(const Eina_Model *src, Eina_Model *dst); /**< deep copy interface private data, do @b not call parent interface deep copy! */
2102 void *__extension_ptr0; /**< not to be used @internal */
2103 void *__extension_ptr1; /**< not to be used @internal */
2104 void *__extension_ptr2; /**< not to be used @internal */
2105 void *__extension_ptr3; /**< not to be used @internal */
2106};
2107
2108#define EINA_MODEL_INTERFACE_INIT(name, iface, private_type, parent, events) \
2109 {EINA_MODEL_INTERFACE_VERSION, \
2110 sizeof(private_type), \
2111 sizeof(iface), \
2112 name, \
2113 parent, \
2114 events, \
2115 NULL, \
2116 NULL, \
2117 NULL, \
2118 NULL, \
2119 NULL, \
2120 NULL, \
2121 NULL, \
2122 NULL, \
2123 NULL, \
2124 NULL \
2125 }
2126
2127#define EINA_MODEL_INTERFACE_INIT_NOPRIVATE(name, iface, parent, events) \
2128 {EINA_MODEL_INTERFACE_VERSION, \
2129 0, \
2130 sizeof(iface), \
2131 name, \
2132 parent, \
2133 events, \
2134 NULL, \
2135 NULL, \
2136 NULL, \
2137 NULL, \
2138 NULL, \
2139 NULL, \
2140 NULL, \
2141 NULL, \
2142 NULL, \
2143 NULL \
2144 }
2145
2146#define EINA_MODEL_INTERFACE_INIT_NULL \
2147 {0, \
2148 0, \
2149 0, \
2150 NULL, \
2151 NULL, \
2152 NULL, \
2153 NULL, \
2154 NULL, \
2155 NULL, \
2156 NULL, \
2157 NULL, \
2158 NULL, \
2159 NULL, \
2160 NULL, \
2161 NULL, \
2162 NULL \
2163 }
2164
2165/**
2166 * @brief Calls the constructor of @a iface on @a model.
2167 * @param iface The interface whose constructor will be called.
2168 * @param model The model instance.
2169 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2170 *
2171 * @warning If @a model doesn't implement @a iface does nothing and returns
2172 * EINA_FALSE.
2173 *
2174 * @see eina_model_new()
2175 * @see _Eina_Model_Interface
2176 * @since 1.2
2177 */
2178EAPI Eina_Bool eina_model_interface_constructor(const Eina_Model_Interface *iface,
2179 Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
2180/**
2181 * @brief Calls the destructor of @a iface on @a model.
2182 * @param iface The interface whose destructor will be called.
2183 * @param model The model instance.
2184 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2185 *
2186 * @warning If @a model doesn't implement @a iface does nothing and returns
2187 * EINA_FALSE.
2188 *
2189 * @see eina_model_del()
2190 * @see _Eina_Model_Interface
2191 * @since 1.2
2192 */
2193EAPI Eina_Bool eina_model_interface_destructor(const Eina_Model_Interface *iface,
2194 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2195/**
2196 * @brief Calls the copy method of @a iface on @a model.
2197 * @param iface The interface whose copy method will be called.
2198 * @param src Pointer to the model to be copied.
2199 * @param dst Pointer to where copy will be put.
2200 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2201 *
2202 * @warning If @a model doesn't implement @a iface does nothing and returns
2203 * EINA_FALSE.
2204 *
2205 * @see eina_model_copy()
2206 * @see _Eina_Model_Interface
2207 * @since 1.2
2208 */
2209EAPI Eina_Bool eina_model_interface_copy(const Eina_Model_Interface *iface,
2210 const Eina_Model *src,
2211 Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3);
2212/**
2213 * @brief Calls the deep copy method of @a iface on @a model.
2214 * @param iface The interface whose deep copy method will be called.
2215 * @param src Pointer to the model to be copied.
2216 * @param dst Pointer to where copy will be put.
2217 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2218 *
2219 * @warning If @a model doesn't implement @a iface does nothing and returns
2220 * EINA_FALSE.
2221 *
2222 * @see eina_model_deep_copy()
2223 * @see _Eina_Model_Interface
2224 * @since 1.2
2225 */
2226EAPI Eina_Bool eina_model_interface_deep_copy(const Eina_Model_Interface *iface,
2227 const Eina_Model *src,
2228 Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3);
2229
2230#define eina_model_interface_method_resolve(iface, model, struct_type, method) eina_model_interface_method_offset_resolve((iface), (model), offsetof(struct_type, method))
2231
2232/**
2233 * @brief Gets the @a iface's method for @a model at @a offset.
2234 * @param iface The interface whose method offset resolve method will be called.
2235 * @param model The model instance.
2236 * @param offset The offset of the wanted method.
2237 * @return Address to resolved method, or @c NULL if method is not implemented.
2238 *
2239 * @see eina_model_method_offset_resolve()
2240 * @since 1.2
2241 */
2242EAPI const void *eina_model_interface_method_offset_resolve(const Eina_Model_Interface *iface, const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2243
2244
2245/**
2246 * @struct _Eina_Model_Event_Description
2247 * Data Model Event Description.
2248 *
2249 * @see EINA_MODEL_EVENT_DESCRIPTION()
2250 * @see #EINA_MODEL_EVENT_DESCRIPTION_SENTINEL
2251 * @since 1.2
2252 */
2253struct _Eina_Model_Event_Description
2254{
2255 const char *name; /**< name used for lookups */
2256 const char *type; /**< used for introspection purposes, documents what goes as callback event information (@c event_info) */
2257 const char *doc; /**< documentation for introspection purposes */
2258};
2259
2260/**
2261 * @def EINA_MODEL_EVENT_DESCRIPTION
2262 *
2263 * Helper to define Eina_Model_Event_Description fields.
2264 *
2265 * @since 1.2
2266 */
2267#define EINA_MODEL_EVENT_DESCRIPTION(name, type, doc) {name, type, doc}
2268
2269/**
2270 * @def EINA_MODEL_EVENT_DESCRIPTION_SENTINEL
2271 *
2272 * Helper to define Eina_Model_Event_Description fields for sentinel (last
2273 * item).
2274 *
2275 * @since 1.2
2276 */
2277#define EINA_MODEL_EVENT_DESCRIPTION_SENTINEL {NULL, NULL, NULL}
2278
2279/**
2280 * @brief Check @a type is valid.
2281 * @param type The type to be checked.
2282 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2283 *
2284 * @since 1.2
2285 */
2286EAPI Eina_Bool eina_model_type_check(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
2287/**
2288 * @brief Gets the name @a type.
2289 * @param type The type whose name is wanted.
2290 * @return Name of @a type.
2291 *
2292 * @since 1.2
2293 */
2294EAPI const char *eina_model_type_name_get(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
2295/**
2296 * @brief Gets the parent type of @a type.
2297 * @param type The type whose parent is wanted.
2298 * @return Type of parent.
2299 *
2300 * @since 1.2
2301 */
2302EAPI const Eina_Model_Type *eina_model_type_parent_get(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
2303
2304/**
2305 * @brief Setup the type to be a subclass of another parent type.
2306 * @param type type to be modified
2307 * @param parent type to be used as parent
2308 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2309 *
2310 * Although @a type is modified, the following properties are not
2311 * touched or they are actually used for validation:
2312 *
2313 * @li @c type->version must be #EINA_MODEL_TYPE_VERSION;
2314 * @li @c type->private_size unmodified, should be set to type's size;
2315 * @li @c type->name unmodified, should be set to type's name.
2316 *
2317 *
2318 * All other fields are modified as follow:
2319 *
2320 * @li @c type->type_size initiated to parent->type_size
2321 * @li @c type->interfaces = NULL;
2322 * @li @c type->events = NULL;
2323 * @li @c type->setup = NULL;
2324 * @li @c type->flush = NULL;
2325 * @li @c type->constructor = NULL;
2326 * @li @c type->destructor = NULL;
2327 * @li @c type->copy = NULL;
2328 * @li @c type->deep_copy = NULL;
2329 * @li @c type->compare = NULL;
2330 * @li @c type->load = NULL;
2331 * @li @c type->unload = NULL;
2332 * @li @c type->property_get = NULL;
2333 * @li @c type->property_set = NULL;
2334 * @li @c type->property_del = NULL;
2335 * @li @c type->properties_names_list_get = NULL;
2336 * @li @c type->child_count = NULL;
2337 * @li @c type->child_get = NULL;
2338 * @li @c type->child_set = NULL;
2339 * @li @c type->child_del = NULL;
2340 * @li @c type->child_insert_at = NULL;
2341 * @li @c type->child_find = NULL;
2342 * @li @c type->child_criteria_match = NULL;
2343 * @li @c type->child_sort = NULL;
2344 * @li @c type->child_iterator_get = NULL;
2345 * @li @c type->child_reversed_iterator_get = NULL;
2346 * @li @c type->child_sorted_iterator_get = NULL;
2347 * @li @c type->child_filtered_iterator_get = NULL;
2348 * @li @c type->to_string = NULL;
2349 *
2350 * If you have custom methods, overload them afterwards
2351 * eina_model_type_subclass_setup() returns with #EINA_TRUE.
2352 *
2353 * @since 1.2
2354 */
2355EAPI Eina_Bool eina_model_type_subclass_setup(Eina_Model_Type *type,
2356 const Eina_Model_Type *parent) EINA_ARG_NONNULL(1, 2);
2357
2358/**
2359 * @brief Checks if @a type is a subclass of(or the same as) @a self_or_parent.
2360 * @param type The type to be checked.
2361 * @param self_or_parent The type being checked for.
2362 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2363 *
2364 * @since 1.2
2365 */
2366EAPI Eina_Bool eina_model_type_subclass_check(const Eina_Model_Type *type,
2367 const Eina_Model_Type *self_or_parent) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2368
2369
2370/**
2371 * @brief Gets a interface with name @a name from @a type.
2372 * @param type The type instance.
2373 * @param name The name of the desired interface.
2374 * @return The interface implemented by @a type with name @a name, or null if
2375 * this type doesn't implement any interface with name @a name.
2376 *
2377 * @since 1.2
2378 */
2379EAPI const Eina_Model_Interface *eina_model_type_interface_get(const Eina_Model_Type *type,
2380 const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2381
2382/**
2383 * @brief Gets the private date of @a model for type @a type.
2384 * @param model The model instance.
2385 * @param type The type whose private data will be gotten.
2386 * @return Pointer to type's private data.
2387 *
2388 * @since 1.2
2389 */
2390EAPI void *eina_model_type_private_data_get(const Eina_Model *model,
2391 const Eina_Model_Type *type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
2392
2393/**
2394 * @brief Checks if @a iface is a valid interface.
2395 * @param iface The interface instance.
2396 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2397 *
2398 * @since 1.2
2399 */
2400EAPI Eina_Bool eina_model_interface_check(const Eina_Model_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
2401
2402/**
2403 * @brief Gets the private date of @a model for interface @a iface.
2404 * @param model The model instance.
2405 * @param iface The interface whose private data will be gotten.
2406 * @return Pointer to interface's private data.
2407 *
2408 * @since 1.2
2409 */
2410EAPI void *eina_model_interface_private_data_get(const Eina_Model *model,
2411 const Eina_Model_Interface *iface) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
2412
2413/**
2414 * @def EINA_MODEL_INTERFACE_PROPERTIES_VERSION
2415 * Current API version, used to validate #_Eina_Model_Interface_Properties.
2416 */
2417#define EINA_MODEL_INTERFACE_PROPERTIES_VERSION (1)
2418
2419/**
2420 * @typedef Eina_Model_Interface_Properties
2421 * Interface to manage model's properties.
2422 *
2423 * This extends #Eina_Model_Interface as expected by interface name
2424 * #EINA_MODEL_INTERFACE_NAME_PROPERTIES.
2425 *
2426 * This interface is meant to help managing properties of a model, it
2427 * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for
2428 * children independently from properties.
2429 *
2430 * @see #_Eina_Model_Interface_Properties explains fields.
2431 * @since 1.2
2432 */
2433typedef struct _Eina_Model_Interface_Properties Eina_Model_Interface_Properties;
2434
2435/**
2436 * @struct _Eina_Model_Interface_Properties
2437 * Interface to manage model's properties.
2438 *
2439 * This extends #Eina_Model_Interface as expected by interface name
2440 * #EINA_MODEL_INTERFACE_NAME_PROPERTIES.
2441 *
2442 * This interface is meant to help managing properties of a model, it
2443 * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for
2444 * children independently from properties.
2445 *
2446 * @since 1.2
2447 */
2448struct _Eina_Model_Interface_Properties
2449{
2450 Eina_Model_Interface base; /**< common interface methods */
2451 unsigned int version; /**< must be #EINA_MODEL_INTERFACE_PROPERTIES_VERSION */
2452 Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp); /**< How to compare properties of this model */
2453 Eina_Bool (*load)(Eina_Model *model); /**< How to load properties of this model */
2454 Eina_Bool (*unload)(Eina_Model *model); /**< How to unload properties of this model */
2455 Eina_Bool (*get)(const Eina_Model *model, const char *name, Eina_Value *value); /**< Retrieve a property of this model given its name. The value will be returned as a copy and must be flushed with eina_value_flush(). The previous contents of value is ignored. */
2456 Eina_Bool (*set)(Eina_Model *model, const char *name, const Eina_Value *value); /**< Set a property of this model given its name. The value is assumed to be valied and is copied internally, thus it can be safely cleared with eina_value_flush() after this function returns. */
2457 Eina_Bool (*del)(Eina_Model *model, const char *name); /**< Delete a property given its name */
2458 Eina_List *(*names_list_get)(const Eina_Model *model); /**< List of stringshare with known property names */
2459};
2460
2461/**
2462 * @brief Compares properties using @a iface's comparing function.
2463 *
2464 * @param[in] iface The interface used to compare the properties.
2465 * @param[in] a The first model whose properties will be compared.
2466 * @param[in] b The second model whose properties will be compared.
2467 * @param[out] cmp A pointer to an integer which will contain the result of the
2468 * comparison.
2469 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2470 *
2471 * @warning If either model doesn't implement @a iface will do nothing and
2472 * return EINA_FALSE.
2473 *
2474 * @see eina_model_compare()
2475 * @since 1.2
2476 */
2477EAPI Eina_Bool eina_model_interface_properties_compare(const Eina_Model_Interface *iface,
2478 const Eina_Model *a,
2479 const Eina_Model *b,
2480 int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4) EINA_WARN_UNUSED_RESULT;
2481
2482/**
2483 * @brief Loads properties using @a iface's loading function.
2484 * @param iface The properties interface whose load method will be called.
2485 * @param model The model instance.
2486 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2487 *
2488 * @warning If either model doesn't implement @a iface will do nothing and
2489 * return EINA_FALSE.
2490 *
2491 * @see eina_model_load()
2492 * @since 1.2
2493 */
2494EAPI Eina_Bool eina_model_interface_properties_load(const Eina_Model_Interface *iface,
2495 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2496/**
2497 * @brief Unloads properties using @a iface's unloading function.
2498 * @param iface The properties interface whose unload method will be called.
2499 * @param model The model instance.
2500 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2501 *
2502 * @warning If either model doesn't implement @a iface will do nothing and
2503 * return EINA_FALSE.
2504 *
2505 * @see eina_model_unload()
2506 * @since 1.2
2507 */
2508EAPI Eina_Bool eina_model_interface_properties_unload(const Eina_Model_Interface *iface,
2509 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2510/**
2511 * @brief Gets property named @a name using @a iface's function to get properties.
2512 * @param iface The properties interface whose property get method will be called.
2513 * @param model The model instance.
2514 * @param name The name of the property to get.
2515 * @param value Pointer to where value will be stored.
2516 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2517 *
2518 * @warning If either model doesn't implement @a iface will do nothing and
2519 * return EINA_FALSE.
2520 *
2521 * @see eina_model_property_get()
2522 * @since 1.2
2523 */
2524EAPI Eina_Bool eina_model_interface_properties_get(const Eina_Model_Interface *iface,
2525 const Eina_Model *model,
2526 const char *name,
2527 Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4);
2528/**
2529 * @brief Sets property named @a name using @a iface's function to set properties.
2530 * @param iface The properties interface whose property set method will be called.
2531 * @param model The model instance.
2532 * @param name The name of the property to set.
2533 * @param value The value to be set.
2534 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2535 *
2536 * @warning If either model doesn't implement @a iface will do nothing and
2537 * return EINA_FALSE.
2538 *
2539 * @see eina_model_property_set()
2540 * @since 1.2
2541 */
2542EAPI Eina_Bool eina_model_interface_properties_set(const Eina_Model_Interface *iface,
2543 Eina_Model *model,
2544 const char *name,
2545 const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4);
2546/**
2547 * @brief Deletes property named @a name using @a iface's function to delete properties.
2548 * @param iface The properties interface whose property delete method will be called.
2549 * @param model The model instance.
2550 * @param name The name of the property to delete.
2551 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2552 *
2553 * @warning If either model doesn't implement @a iface will do nothing and
2554 * return EINA_FALSE.
2555 *
2556 * @see eina_model_property_del()
2557 * @since 1.2
2558 */
2559EAPI Eina_Bool eina_model_interface_properties_del(const Eina_Model_Interface *iface,
2560 Eina_Model *model,
2561 const char *name) EINA_ARG_NONNULL(1, 2, 3);
2562/**
2563 * @brief Gets properties name list using @a iface's function to get properties
2564 * name list.
2565 * @param iface The properties interface whose property name list get method
2566 * will be called.
2567 * @param model The model instance.
2568 * @return #Eina_List of properties' names.
2569 *
2570 * @warning If either model doesn't implement @a iface will do nothing and
2571 * return EINA_FALSE.
2572 *
2573 * @see eina_model_properties_names_list_get()
2574 * @since 1.2
2575 */
2576EAPI Eina_List *eina_model_interface_properties_names_list_get(const Eina_Model_Interface *iface,
2577 const Eina_Model *model) EINA_ARG_NONNULL(1, 2); /**< list of stringshare */
2578
2579/**
2580 * @typedef Eina_Model_Interface_Children
2581 * Interface to manage model's children.
2582 *
2583 * This extends #Eina_Model_Interface as expected by interface name
2584 * #EINA_MODEL_INTERFACE_NAME_CHILDREN.
2585 *
2586 * This interface is meant to help managing properties of a model, it
2587 * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for
2588 * children independently from properties.
2589 *
2590 * @see #_Eina_Model_Interface_Children explains fields.
2591 * @since 1.2
2592 */
2593typedef struct _Eina_Model_Interface_Children Eina_Model_Interface_Children;
2594
2595/**
2596 * @def EINA_MODEL_INTERFACE_CHILDREN_VERSION
2597 * Current API version, used to validate #_Eina_Model_Interface_Children.
2598 */
2599#define EINA_MODEL_INTERFACE_CHILDREN_VERSION (1)
2600
2601/**
2602 * @struct _Eina_Model_Interface_Children
2603 * Interface to manage model's children.
2604 *
2605 * This extends #Eina_Model_Interface as expected by interface name
2606 * #EINA_MODEL_INTERFACE_NAME_CHILDREN.
2607 *
2608 * This interface is meant to help managing properties of a model, it
2609 * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for
2610 * children independently from properties.
2611 *
2612 * @since 1.2
2613 */
2614struct _Eina_Model_Interface_Children
2615{
2616 Eina_Model_Interface base; /**< common interface methods */
2617 unsigned int version; /**< must be #EINA_MODEL_INTERFACE_CHILDREN_VERSION */
2618 Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp); /**< How to compare children of this model */
2619 Eina_Bool (*load)(Eina_Model *model); /**< How to load children of this model */
2620 Eina_Bool (*unload)(Eina_Model *model); /**< How to unload children of this model */
2621 int (*count)(const Eina_Model *model); /**< How many children of this model */
2622 Eina_Model *(*get)(const Eina_Model *model, unsigned int position); /**< Retrieve a child of this model, returned child must have reference increased! */
2623 Eina_Bool (*set)(Eina_Model *model, unsigned int position, Eina_Model *child); /**< Set (replace) a child of this model, given child will have reference increased! */
2624 Eina_Bool (*del)(Eina_Model *model, unsigned int position); /**< Delete a child of this model. Existing child will have reference decreased! */
2625 Eina_Bool (*insert_at)(Eina_Model *model, unsigned int position, Eina_Model *child); /**< Insert a child into this model, given child will have reference increased! All elements towards the end of the internal list will be shifted to the end to make room for the new child. */
2626 void (*sort)(Eina_Model *model, Eina_Compare_Cb compare); /**< Reorder children to be sorted respecting comparison function @c compare() */
2627};
2628
2629/**
2630 * @brief Compares children using @a iface's comparing function.
2631 *
2632 * @param[in] iface The interface used to compare the properties.
2633 * @param[in] a The first model whose properties will be compared.
2634 * @param[in] b The second model whose properties will be compared.
2635 * @param[out] cmp A pointer to an integer which will contain the result of the
2636 * comparison.
2637 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2638 *
2639 * @warning If either model doesn't implement @a iface will do nothing and
2640 * return EINA_FALSE.
2641 *
2642 * @see eina_model_compare()
2643 * @since 1.2
2644 */
2645EAPI Eina_Bool eina_model_interface_children_compare(const Eina_Model_Interface *iface,
2646 const Eina_Model *a,
2647 const Eina_Model *b,
2648 int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4) EINA_WARN_UNUSED_RESULT;
2649/**
2650 * @brief Loads children using @a iface's loading function.
2651 * @param iface The children interface whose load method will be called.
2652 * @param model The model instance.
2653 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2654 *
2655 * @warning If either model doesn't implement @a iface will do nothing and
2656 * return EINA_FALSE.
2657 *
2658 * @see eina_model_load()
2659 * @since 1.2
2660 */
2661EAPI Eina_Bool eina_model_interface_children_load(const Eina_Model_Interface *iface,
2662 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2663/**
2664 * @brief Unloads children using @a iface's unloading function.
2665 * @param iface The children interface whose unload method will be called.
2666 * @param model The model instance.
2667 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2668 *
2669 * @warning If either model doesn't implement @a iface will do nothing and
2670 * return EINA_FALSE.
2671 *
2672 * @see eina_model_unload()
2673 * @since 1.2
2674 */
2675EAPI Eina_Bool eina_model_interface_children_unload(const Eina_Model_Interface *iface,
2676 Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2677/**
2678 * @brief Count children using @a iface's counting function.
2679 * @param iface The children interface whose count method will be called.
2680 * @param model The model instance.
2681 * @return Number of children in @a model.
2682 *
2683 * @warning If either model doesn't implement @a iface will do nothing and
2684 * return -1.
2685 *
2686 * @see eina_model_child_count()
2687 * @since 1.2
2688 */
2689EAPI int eina_model_interface_children_count(const Eina_Model_Interface *iface,
2690 const Eina_Model *model) EINA_ARG_NONNULL(1, 2);
2691/**
2692 * @brief Get child using @a iface's function to get children.
2693 * @param iface The children interface whose get method will be called.
2694 * @param model The model instance.
2695 * @param position Position of child to be retrieved.
2696 * @return The requested child.
2697 *
2698 * @warning If either model doesn't implement @a iface will do nothing and
2699 * return -1.
2700 *
2701 * @see eina_model_child_get()
2702 * @since 1.2
2703 */
2704EAPI Eina_Model *eina_model_interface_children_get(const Eina_Model_Interface *iface,
2705 const Eina_Model *model,
2706 unsigned int position) EINA_ARG_NONNULL(1, 2);
2707/**
2708 * @brief Set child using @a iface's function to set children.
2709 * @param iface The children interface whose set method will be called.
2710 * @param model The model instance.
2711 * @param position Position of child to be set.
2712 * @param child Value(child) to be set.
2713 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2714 *
2715 * @warning If either model doesn't implement @a iface will do nothing and
2716 * return -1.
2717 *
2718 * @see eina_model_child_set()
2719 * @since 1.2
2720 */
2721EAPI Eina_Bool eina_model_interface_children_set(const Eina_Model_Interface *iface,
2722 Eina_Model *model,
2723 unsigned int position,
2724 Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4);
2725/**
2726 * @brief Delete child using @a iface's function to delete children.
2727 * @param iface The children interface whose delete method will be called.
2728 * @param model The model instance.
2729 * @param position Position of child to be deleted.
2730 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2731 *
2732 * @warning If either model doesn't implement @a iface will do nothing and
2733 * return -1.
2734 *
2735 * @see eina_model_child_del()
2736 * @since 1.2
2737 */
2738EAPI Eina_Bool eina_model_interface_children_del(const Eina_Model_Interface *iface,
2739 Eina_Model *model,
2740 unsigned int position) EINA_ARG_NONNULL(1, 2);
2741/**
2742 * @brief Insert child using @a iface's function to insert children.
2743 * @param iface The children interface whose insert method will be called.
2744 * @param model The model instance.
2745 * @param position Position in which to insert @a child.
2746 * @param child Value(child) to be inserted.
2747 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2748 *
2749 * @warning If either model doesn't implement @a iface will do nothing and
2750 * return -1.
2751 *
2752 * @see eina_model_child_insert_at()
2753 * @since 1.2
2754 */
2755EAPI Eina_Bool eina_model_interface_children_insert_at(const Eina_Model_Interface *iface,
2756 Eina_Model *model,
2757 unsigned int position,
2758 Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4);
2759/**
2760 * @brief Sort children using @a iface's function to sort children.
2761 * @param iface The children interface whose sort method will be called.
2762 * @param model The model instance.
2763 * @param compare Function used to compare children.
2764 *
2765 * @warning If either model doesn't implement @a iface will do nothing and
2766 * return -1.
2767 *
2768 * @see eina_model_child_sort().
2769 * @since 1.2
2770 */
2771EAPI void eina_model_interface_children_sort(const Eina_Model_Interface *iface,
2772 Eina_Model *model,
2773 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
2774
2775
2776/**
2777 * @}
2778 */
2779
2780/**
2781 * @defgroup Eina_Model_Utils_Group Data Model Utilities
2782 *
2783 * Miscellaneous utilities to help usage or debug of @ref Eina_Model_Group.
2784 *
2785 * @{
2786 */
2787
2788/**
2789 * @brief Checks if @a model is an instance of @a type.
2790 * @param model The model instance.
2791 * @param type The type being checked for.
2792 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2793 *
2794 * @see eina_model_new()
2795 * @see _Eina_Model_Type
2796 * @since 1.2
2797 */
2798EAPI Eina_Bool eina_model_instance_check(const Eina_Model *model,
2799 const Eina_Model_Type *type) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2800
2801/**
2802 * @brief Checks if @a model implements @a iface.
2803 * @param model The model instance.
2804 * @param iface The interface being checked for.
2805 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
2806 *
2807 * @see _Eina_Model_Interface
2808 * @since 1.2
2809 */
2810EAPI Eina_Bool eina_model_interface_implemented(const Eina_Model *model, const Eina_Model_Interface *iface) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE;
2811
2812/**
2813 * @brief Returns the number of references to @a model.
2814 * @param model The model to query number of references.
2815 * @return Number of references to model.
2816 *
2817 * @see eina_model_ref()
2818 * @see eina_model_unref()
2819 * @see eina_model_xref()
2820 * @see eina_model_xunref()
2821 * @see eina_model_xrefs_get()
2822 * @since 1.2
2823 */
2824EAPI int eina_model_refcount(const Eina_Model *model) EINA_ARG_NONNULL(1);
2825
2826/**
2827 * @typedef Eina_Model_XRef
2828 * Extended reference to model.
2829 *
2830 * This is returned by eina_model_xrefs_get() and should never be
2831 * modified. It is managed by eina_model_xref() and
2832 * eina_model_xunref() when @c EINA_MODEL_DEBUG is set to "1" or
2833 * "backtrace".
2834 *
2835 * @see #_Eina_Model_XRef explains fields.
2836 * @since 1.2
2837 */
2838typedef struct _Eina_Model_XRef Eina_Model_XRef;
2839
2840/**
2841 * @struct _Eina_Model_XRef
2842 * Extended reference to model.
2843 *
2844 * This is returned by eina_model_xrefs_get() and should never be
2845 * modified. It is managed by eina_model_xref() and
2846 * eina_model_xunref() when @c EINA_MODEL_DEBUG is set to "1" or
2847 * "backtrace".
2848 *
2849 * @see eina_model_xrefs_get()
2850 * @see eina_models_usage_dump()
2851 * @since 1.2
2852 */
2853struct _Eina_Model_XRef
2854{
2855 EINA_INLIST;
2856 const void *id; /**< as given to eina_model_xref() */
2857 struct {
2858 const void * const *symbols; /**< only if @c EINA_MODEL_DEBUG=backtrace is set, otherwise is @c NULL */
2859 unsigned int count; /**< only if @c EINA_MODEL_DEBUG=backtrace is set, otherwise is 0 */
2860 } backtrace;
2861 char label[]; /**< Any given label given to eina_model_xref(). */
2862};
2863
2864/**
2865 * @brief Returns the current references of this model.
2866 * @param model The model to query references.
2867 * @return List of reference holders as Eina_Model_XRef. This is the internal
2868 * list for speed purposes, do not modify or free it in anyway!
2869 *
2870 * @note This list only exist if environment variable
2871 * @c EINA_MODEL_DEBUG is set to "1" or "backtrace".
2872 *
2873 * @note The backtrace information is only available if environment
2874 * variable @c EINA_MODEL_DEBUG=backtrace is set.
2875 * @since 1.2
2876 */
2877EAPI const Eina_Inlist *eina_model_xrefs_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
2878
2879/**
2880 * @brief Dump usage of all existing modules.
2881 * @since 1.2
2882 */
2883EAPI void eina_models_usage_dump(void);
2884
2885/**
2886 * @brief Return a list of all live models.
2887 * @return a newly allocated list of Eina_Model. Free using
2888 * eina_models_list_free()
2889 *
2890 * @note this is meant to debug purposes, do not modify the models in
2891 * any way!
2892 *
2893 * @note due performance reasons, this is only @b enabled when
2894 * @c EINA_MODEL_DEBUG is set to "1" or "backtrace".
2895 *
2896 * @since 1.2
2897 */
2898EAPI Eina_List *eina_models_list_get(void);
2899
2900/**
2901 * @brief Release list returned by eina_models_list_get()
2902 * @param list the list to release.
2903 */
2904EAPI void eina_models_list_free(Eina_List *list);
2905
2906/**
2907 * @}
2908 */
2909
2910/**
2911 * @var EINA_MODEL_INTERFACE_CHILDREN_INARRAY
2912 *
2913 * Implements #Eina_Model_Interface_Children
2914 * (#EINA_MODEL_INTERFACE_NAME_CHILDREN) using #Eina_Inarray. It
2915 * should be efficient in space and time for most operations.
2916 *
2917 * @note it may become slow if eina_model_child_insert_at() is used at(or near)
2918 * the beginning of the array as the members from that position
2919 * to the end must be memmove()d.
2920 *
2921 * @since 1.2
2922 */
2923EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_CHILDREN_INARRAY;
2924
2925
2926/**
2927 * @var EINA_MODEL_TYPE_BASE
2928 * Base type for all eina model types.
2929 *
2930 * @since 1.2
2931 */
2932EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_BASE;
2933
2934/**
2935 * @var EINA_MODEL_TYPE_MIXIN
2936 *
2937 * Type that uses #EINA_MODEL_INTERFACE_NAME_PROPERTIES and
2938 * #EINA_MODEL_INTERFACE_NAME_CHILDREN to manage the model.
2939 *
2940 * This is an abstract type, it does not work out of the box as one
2941 * needs to subclass it and define the interface implementations for
2942 * properties and children, as done by #EINA_MODEL_TYPE_GENERIC
2943 *
2944 * @see EINA_MODEL_TYPE_GENERIC
2945 *
2946 * @since 1.2
2947 */
2948EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_MIXIN;
2949
2950/**
2951 * @var EINA_MODEL_TYPE_GENERIC
2952 *
2953 * Subclass of #EINA_MODEL_TYPE_MIXIN that uses
2954 * #EINA_MODEL_INTERFACE_PROPERTIES_HASH and
2955 * #EINA_MODEL_INTERFACE_CHILDREN_INARRAY.
2956 *
2957 * Should be generic enough to hold lots of items with runtime
2958 * configurable properties of any type.
2959 *
2960 * @see #EINA_MODEL_TYPE_STRUCT
2961 *
2962 * @since 1.2
2963 */
2964EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_GENERIC;
2965
2966/**
2967 * @var EINA_MODEL_TYPE_STRUCT
2968 *
2969 * Subclass of #EINA_MODEL_TYPE_MIXIN that uses
2970 * #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT and
2971 * #EINA_MODEL_INTERFACE_CHILDREN_INARRAY.
2972 *
2973 * Should be struct enough to hold lots of items with compile time
2974 * configurable properties of any type.
2975 *
2976 * @see #EINA_MODEL_TYPE_GENERIC
2977 *
2978 * @since 1.2
2979 */
2980EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_STRUCT;
2981
2982/**
2983 * @brief Create and setup an instance of #EINA_MODEL_TYPE_STRUCT.
2984 * @param desc struct description to use for properties.
2985 * @return newly created and set model, or @c NULL on errors.
2986 *
2987 * @see eina_model_type_struct_new()
2988 * @since 1.2
2989 */
2990EAPI Eina_Model *eina_model_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
2991
2992/**
2993 * @brief Create and setup an instance of type subclass of #EINA_MODEL_TYPE_STRUCT.
2994 * @param type a type which is subclass of #EINA_MODEL_TYPE_STRUCT.
2995 * @param desc struct description to use for properties.
2996 * @return newly created and set model, or @c NULL on errors.
2997 *
2998 * @see eina_model_struct_new()
2999 * @since 1.2
3000 */
3001EAPI Eina_Model *eina_model_type_struct_new(const Eina_Model_Type *type,
3002 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_MALLOC;
3003
3004
3005/**
3006 * @brief Configure the internal properties of model implementing #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT.
3007 * @param model The model instance to configure.
3008 * @param desc The structure description to use.
3009 * @param memory If not @c NULL, will be copied by model.
3010 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3011 *
3012 * This will setup the internal pointers so that the given @a desc is
3013 * used to manage the properties of this struct.
3014 *
3015 * If a given memory is provided, it will be copied (including
3016 * members) and no references are taken after this function returns.
3017 *
3018 * @see #EINA_VALUE_TYPE_STRUCT
3019 *
3020 * @since 1.2
3021 */
3022EAPI Eina_Bool eina_model_struct_set(Eina_Model *model,
3023 const Eina_Value_Struct_Desc *desc,
3024 void *memory) EINA_ARG_NONNULL(1, 2);
3025/**
3026 * @brief Get the internal properties of model implementing #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT.
3027 * @param model the model instance.
3028 * @param p_desc where to return the structure description in use.
3029 * @param p_memory where to return the structure memory in use.
3030 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
3031 *
3032 * No copies are made! The memory and description may be invalidaded
3033 * by calls to eina_model_struct_set() or eina_model_del().
3034 *
3035 * @since 1.2
3036 */
3037EAPI Eina_Bool eina_model_struct_get(const Eina_Model *model,
3038 const Eina_Value_Struct_Desc **p_desc,
3039 void **p_memory) EINA_ARG_NONNULL(1, 2);
3040
3041/**
3042 * @var EINA_MODEL_INTERFACE_NAME_PROPERTIES
3043 *
3044 * Interface that uses #Eina_Model_Interface_Properties as
3045 * #Eina_Model_Interface and can manage the model properties.
3046 *
3047 * @since 1.2
3048 */
3049EAPI extern const char *EINA_MODEL_INTERFACE_NAME_PROPERTIES;
3050
3051/**
3052 * @var EINA_MODEL_INTERFACE_PROPERTIES_HASH
3053 *
3054 * Implements #Eina_Model_Interface_Properties
3055 * (#EINA_MODEL_INTERFACE_NAME_PROPERTIES) using #Eina_Hash.
3056 *
3057 * @note This function is generic but uses too much space given the
3058 * hash data type. For huge number of elements it's better to
3059 * use custom implementation instead.
3060 *
3061 * @see EINA_MODEL_INTERFACE_PROPERTIES_STRUCT
3062 *
3063 * @since 1.2
3064 */
3065EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_PROPERTIES_HASH;
3066
3067/**
3068 * @var EINA_MODEL_INTERFACE_PROPERTIES_STRUCT
3069 *
3070 * Implements #Eina_Model_Interface_Properties
3071 * (#EINA_MODEL_INTERFACE_NAME_PROPERTIES) using #Eina_Value_Struct.
3072 *
3073 * The interface private data is #Eina_Value of type
3074 * #EINA_VALUE_TYPE_STRUCT. Properties will be accessed using
3075 * Eina_Value_Struct::desc information that can be set by types such
3076 * as #EINA_MODEL_TYPE_STRUCT
3077 *
3078 * @see EINA_MODEL_INTERFACE_PROPERTIES_HASH
3079 *
3080 * @since 1.2
3081 */
3082EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_PROPERTIES_STRUCT;
3083
3084/**
3085 * @var EINA_MODEL_INTERFACE_NAME_CHILDREN
3086 *
3087 * Interface that uses #Eina_Model_Interface_Children as
3088 * #Eina_Model_Interface and can manage the model children.
3089 *
3090 * @since 1.2
3091 */
3092EAPI extern const char *EINA_MODEL_INTERFACE_NAME_CHILDREN;
3093
3094/**
3095 * @}
3096 */
3097
3098/**
3099 * @}
3100 */
3101
3102/**
3103 * @}
3104 */
3105#endif
diff --git a/libraries/eina/src/include/eina_module.h b/libraries/eina/src/include/eina_module.h
deleted file mode 100644
index 178fa9a..0000000
--- a/libraries/eina/src/include/eina_module.h
+++ /dev/null
@@ -1,350 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MODULE_H_
20#define EINA_MODULE_H_
21
22#include "eina_types.h"
23#include "eina_array.h"
24#include "eina_error.h"
25
26/**
27 * @addtogroup Eina_Module_Group Module
28 *
29 * @brief These functions provide module management.
30 */
31
32/**
33 * @addtogroup Eina_Tools_Group Tools
34 *
35 * @{
36 */
37
38/**
39 * @defgroup Eina_Module_Group Module
40 *
41 * Eina module provides some helpers over POSIX dlopen(). It is not
42 * meant to replace, abstract or make a "portable" version of the
43 * POSIX, but enhance its usage by defining some good practices.
44 *
45 * Modules are created with eina_module_new() and later loaded with
46 * eina_module_load(). Loads are reference counted and there must be
47 * the same number of eina_module_unload() in order to have it to call
48 * dlclose(). This makes simple to have different users for the same
49 * module.
50 *
51 * The loaded shared objects may have two visible functions that will
52 * be called and might provide initialization and shutdown
53 * proceedures. The symbols are @c __eina_module_init and
54 * @c __eina_module_shutdown and will be defined by the macros
55 * EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN().
56 *
57 * There are some helpers to automatically create modules based on
58 * directory listing. See eina_module_arch_list_get(),
59 * eina_module_list_get() and eina_module_find().
60 *
61 * @{
62 */
63
64/**
65 * @typedef Eina_Module
66 * Dynamic module loader handle.
67 */
68typedef struct _Eina_Module Eina_Module;
69
70/**
71 * @typedef Eina_Module_Cb
72 * Dynamic module loader callback.
73 */
74typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data);
75
76/**
77 * @typedef Eina_Module_Init
78 * If a function with such signature is exported by module as
79 * __eina_module_init, it will be called on the first load after
80 * dlopen() and if #EINA_FALSE is returned, load will fail, #EINA_TRUE
81 * means the module was successfully initialized.
82 * @see Eina_Module_Shutdown
83 */
84typedef Eina_Bool (*Eina_Module_Init)(void);
85
86/**
87 * @typedef Eina_Module_Shutdown
88 * If a function with such signature is exported by module as
89 * __eina_module_shutdown, it will be called before calling dlclose()
90 * @see Eina_Module_Init
91 */
92typedef void (*Eina_Module_Shutdown)(void);
93
94/**
95 * @def EINA_MODULE_INIT
96 * declares the given function as the module initializer (__eina_module_init).
97 * It must be of signature #Eina_Module_Init
98 */
99#define EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f
100
101/**
102 * @def EINA_MODULE_SHUTDOWN
103 * declares the given function as the module shutdownializer
104 * (__eina_module_shutdown). It must be of signature
105 * #Eina_Module_Shutdown
106 */
107#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shutdown = &f
108
109/**
110 * @var EINA_ERROR_WRONG_MODULE
111 * Error identifier corresponding to a wrong module.
112 */
113extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE;
114
115/**
116 * @var EINA_ERROR_MODULE_INIT_FAILED
117 * Error identifier corresponding to a failure during the initialisation of a module.
118 */
119extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
120
121/**
122 * @brief Return a new module.
123 *
124 * @param file The name of the file module to load.
125 *
126 * This function returns a new module. If @p file is @c NULL, the
127 * function returns @c NULL, otherwise, it allocates an Eina_Module,
128 * stores a duplicate string of @p file, sets its reference to @c 0
129 * and its handle to @c NULL.
130 *
131 * When the new module is not needed anymore, use eina_module_free()
132 * to free the allocated memory.
133 *
134 * @see eina_module_load
135 */
136EAPI Eina_Module *
137 eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
138
139/**
140 * @brief Delete a module.
141 *
142 * @param module The module to delete.
143 * @return EINA_TRUE on success, EINA_FALSE otherwise.
144 *
145 * This function calls eina_module_unload() if @p module has been previously
146 * loaded and frees the allocated memory. On success this function
147 * returns EINA_TRUE and EINA_FALSE otherwise. If @p module is @c NULL, the
148 * function returns immediately.
149 */
150EAPI Eina_Bool
151 eina_module_free(Eina_Module *module) EINA_ARG_NONNULL(1);
152
153/**
154 * @brief Load a module.
155 *
156 * @param module The module to load.
157 * @return EINA_TRUE on success, EINA_FALSE otherwise.
158 *
159 * This function load the shared file object passed in
160 * eina_module_new(). If it is a internal Eina module (like the
161 * mempools), it also initialize it. It the shared file object can not
162 * be loaded, the error #EINA_ERROR_WRONG_MODULE is set and
163 * #EINA_FALSE is returned. If it is a internal Eina module and the
164 * module can not be initialized, the error
165 * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is
166 * returned. If the module has already been loaded, it's refeence
167 * counter is increased by one and #EINA_TRUE is returned. If @p module is
168 * @c NULL, the function returns immediately #EINA_FALSE.
169 *
170 * When the symbols of the shared file objetcts are not needed
171 * anymore, call eina_module_unload() to unload the module.
172 */
173EAPI Eina_Bool
174 eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
175
176/**
177 * @brief Unload a module.
178 *
179 * @param module The module to load.
180 * @return EINA_TRUE on success, EINA_FALSE otherwise.
181 *
182 * This function unload the module @p module that has been previously
183 * loaded by eina_module_load(). If the reference counter of @p module is
184 * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the
185 * shared object file is closed and if it is a internal Eina module, it
186 * is shutted down just before. In that case, #EINA_TRUE is
187 * returned. In all case, the reference counter is decreased. If @p module
188 * is @c NULL, the function returns immediately #EINA_FALSE.
189 */
190EAPI Eina_Bool
191 eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1);
192
193/**
194 * @brief Retrive the data associated to a symbol.
195 *
196 * @param module The module.
197 * @param symbol The symbol.
198 * @return The data associated to the symbol, or @c NULL on failure.
199 *
200 * This function returns the data associated to @p symbol of @p module. @p
201 * module must have been loaded before with eina_module_load(). If @p module
202 * is @c NULL, or if it has not been correctly loaded before, the
203 * function returns immediately @c NULL.
204 */
205EAPI void *
206 eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
207
208/**
209 * @brief Return the file name associated to the module.
210 *
211 * @param module The module.
212 * @return The file name.
213 *
214 * This function returns the file name passed in eina_module_new(). If
215 * @p module is @c NULL, the function returns immediately @c NULL. The
216 * returned value must no be freed.
217 */
218EAPI const char *
219 eina_module_file_get(const Eina_Module *module) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
220
221
222/**
223 * @brief Return the path built from the location of a library and a
224 * given sub directory.
225 *
226 * @param symbol The symbol to search for.
227 * @param sub_dir The subdirectory to append.
228 * @return The built path on success, @c NULL otherwise.
229 *
230 * This function returns the path built by concatenating the path of
231 * the library containing the symbol @p symbol and @p sub_dir. @p sub_dir
232 * can be @c NULL. The returned path must be freed when not used
233 * anymore. If the symbol is not found, or dl_addr() is not supported,
234 * or allocation fails, this function returns @c NULL.
235 */
236EAPI char *
237 eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
238
239/**
240 * @brief Return the path built from the value of an environment varialbe and a
241 * given sub directory.
242 *
243 * @param env The environment variable to expand.
244 * @param sub_dir The subdirectory to append.
245 * @return The built path on success, @c NULL otherwise.
246 *
247 * This function returns the path built by concatenating the value of
248 * the environment variable named @p env and @p sub_dir. @p sub_dir
249 * can be @c NULL. The returned path must be freed when not used
250 * anymore. If the symbol is not found, or @p env does not exist, or
251 * allocation fails, this function returns @c NULL.
252 */
253EAPI char *
254 eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
255
256
257/**
258 * @brief Get an array of modules found on the directory path matching an arch type.
259 *
260 * @param array The array that stores the list of the modules.
261 * @param path The directory's path to search for modules.
262 * @param arch The architecture string.
263 * @return The array of modules found in @p path matching @p arch.
264 *
265 * This function adds to @p array the module names found in @p path
266 * which match the cpu architecture @p arch. If @p path or @p arch is
267 * @c NULL, the function returns immediately @p array. @p array can be
268 * @c NULL. In that case, it is created with 4 elements.
269 */
270EAPI Eina_Array *
271 eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
272
273/**
274 * @brief Get a list of modules found on the directory path.
275 *
276 * @param array The array that stores the list of the modules.
277 * @param path The directory's path to search for modules.
278 * @param recursive Iterate recursively on the path.
279 * @param cb Callback function to call on each module.
280 * @param data Data passed to the callback function.
281 * @return The array of modules found in @p path.
282 *
283 * This function adds to @p array the list of modules found in
284 * @p path. If @p recursive is #EINA_TRUE, then recursive search is
285 * done. The callback @p cb is called on each module found, and @p data
286 * is passed to @p cb. If @p path is @c NULL, the function returns
287 * immediately @p array. If the returned value of @p cb is 0, the
288 * module will not be added to the list, otherwise it will be added.
289 * @p array can be @c NULL. In that case, it is created with 4
290 * elements. @p cb can be @c NULL.
291 */
292EAPI Eina_Array *
293 eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
294
295/**
296 * @brief Load every module on the list of modules.
297 *
298 * @param array The array of modules to load.
299 *
300 * This function calls eina_module_load() on each element found in
301 * @p array. If @p array is @c NULL, this function does nothing.
302 */
303EAPI void
304 eina_module_list_load(Eina_Array *array) EINA_ARG_NONNULL(1);
305
306/**
307 * @brief Unload every module on the list of modules.
308 *
309 * @param array The array of modules to unload.
310 *
311 * This function calls eina_module_unload() on each element found in
312 * @p array. If @p array is @c NULL, this function does nothing.
313 */
314EAPI void
315 eina_module_list_unload(Eina_Array *array) EINA_ARG_NONNULL(1);
316
317/**
318 * @p Free every module on the list of modules.
319 *
320 * @param array The array of modules to free.
321 *
322 * This function calls eina_module_free() on each element found in
323 * @p array. If @p array is @c NULL, this function does nothing.
324 */
325EAPI void
326 eina_module_list_free(Eina_Array *array) EINA_ARG_NONNULL(1);
327
328/**
329 * @brief Find an module in array.
330 *
331 * @param array The array to find the module.
332 * @param module The name of module to be searched.
333 * @return The module to find on success, @c NULL otherwise.
334 *
335 * This function finds an @p module in @p array.
336 * If the element is found the function returns the module, else
337 * @c NULL is returned.
338 */
339EAPI Eina_Module *
340 eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
341
342/**
343 * @}
344 */
345
346/**
347 * @}
348 */
349
350#endif /*EINA_MODULE_H_*/
diff --git a/libraries/eina/src/include/eina_prefix.h b/libraries/eina/src/include/eina_prefix.h
deleted file mode 100644
index b59080b..0000000
--- a/libraries/eina/src/include/eina_prefix.h
+++ /dev/null
@@ -1,228 +0,0 @@
1#ifndef EINA_PREFIX_H_
2#define EINA_PREFIX_H_
3
4/**
5 * @addtogroup Eina_Prefix_Group Prefix Group
6 *
7 * @brief These functions provide the ability to determine the runtime
8 * location of a software package
9 *
10 * @{
11 *
12 * @since 1.1.0
13 */
14
15/**
16 * @typedef Eina_Prefix
17 * This is a prefix object that is returned by eina_prefix_new() when trying
18 * to determine the runtime location of the software in question so other
19 * data files such as images, sound files, other executable utilities,
20 * libraries, modules and locale files can be found.
21 *
22 * @since 1.1.0
23 */
24typedef struct _Eina_Prefix Eina_Prefix;
25
26/**
27 * @brief Create a new prefix handle given some input information
28 *
29 * @param argv0 If this is an executable this is argv[0] of the binary, or NULL if it is used from a shared library
30 * @param symbol This is a symbol (function for example) inside the binary or library to find the source location of. Provide NULL if not used
31 * @param envprefix This is the prefix to any environment variables that may override prefix detection and give the exact location of the software
32 * @param sharedir This is the directory inside the standard share or data dir where the software will store data files
33 * @param magicsharefile This is a magic file to check existence of to determine the prefix find was correct, and it must be located in the data dir under the share dir provided above, or NULL if the check is not to be done
34 * @param pkg_bin This is the compile-time binary install dir
35 * @param pkg_lib This is the compile-time library install dir
36 * @param pkg_data This is the compile-time share/data install dir
37 * @param pkg_locale This is the compile-time locale install dir
38 * @return The prefix handle, or NULL on failure
39 *
40 * Applications and libraries are most often not just single executables nor
41 * single shared library binares, but also come with extra modules they
42 * have to load, extra binary utilities they need to run, or have data files
43 * they need to load. A very primitve application ASSUMES a fixed install
44 * location at compile-time, but this disallows the ability to re-locate
45 * the application (or library) somewhere else after compilation (if you run
46 * out of space on a given disk, partition etc. for example), or necessitate
47 * the need for having to maintain environment variables for every piece of
48 * software to let it know its location, or have to use large sets of
49 * symlinks pointing from the compiled location to the new one.
50 *
51 * Being re-locatable at runtime allows much easier distribution and
52 * installation into places like the users own home directory, instead of
53 * on a system partition, if the developer wishes for easier distribution
54 * of pre-compiled binaries.
55 *
56 * The prefix system is designed to locate where the given software is
57 * installed (under a common prefix) at runtime and then report specific
58 * locations of this prefix and common directories inside this prefix like
59 * the binary, library, data and locale directories.
60 *
61 * To do this some information needs to be provided to eina_prefix_new(). If
62 * you have developed a binary executable, then provide argv[0] as the @p argv0
63 * argument. This plus the PATH environment variable help the prefix system
64 * to determine its location. Call eina_prefix_new() early on before you
65 * change working directory or anything about argv[0] so it gets accurate
66 * information. It will use the first argument, being the executable itself,
67 * to look in absolute directories, relative paths and PATH to see if it
68 * finds the right executable to determine just where the actual binary is
69 * installed and being run from. If you develop a share library, just pass
70 * NULL as argv0
71 *
72 * It would prefer to use the @p symbol function to determine location as
73 * that function will be unique inside the application and try and trace
74 * back which file this function comes from (be it a binary or shared library)
75 * as this avoids more expensive searches via @p argv0. It will use this
76 * symbol if given in preference to argv0.
77 *
78 * The @p envprefix parameter, provides a string prefix to prepend before
79 * environment variables to allow a fallback to specific environment variables
80 * to locate the software. For example if "MYAPP" is provided a the prefix,
81 * then it uses "MYAPP_PREFIX" as a master environment variable to specify
82 * the exact install prefix for the software, or more specific environment
83 * variables like "MYAPP_BIN_DIR", "MYAPP_LIB_DIR", "MYAPP_DATA_DIR" and
84 * "MYAPP_LOCALE_DIR" which can be set by the user or scripts before
85 * launching. If not provided (NULL) environment variables will not be
86 * used to override compiled-in defaults or auto detections.
87 *
88 * The @p sharedir string provides a subdirectory inside the system shared
89 * data dir for data files. For example, if the system dir is
90 * /usr/local/share then this dir name is appended, creating
91 * /usr/local/share/appname if this dir was the "appname" string. It is
92 * expected the application or library installs data files in this directory.
93 *
94 * The @p magicsharefile is a filename or path of something inside the share
95 * or data dir to be used to test that the prefix detection worked. For
96 * example, your app will install a wallpaper image as
97 * /usr/local/share/appname/images/wallpaper.jpg and so to check that this
98 * worked, provide "images/wallpaper.jpg" as the @p magicsharefile string
99 * so detection can know if it worked or not.
100 *
101 * The @p pkg_bin, @p pkg_lib, @p pkg_data and @p pkg_locale are compile-time
102 * strings (the kind standard autoconf/automake define) to be passed in
103 * so there can be a fallback to compiled-in defaults as well as use them
104 * to determine actual names of directories like libdirs maybe changing to
105 * be lib32 or lib64 instead of lib etc.
106 *
107 * Compile the following defining at compile time your prefixes like (example):
108 *
109 * gcc appname.c -o appname \
110 * -DPACKAGE_BIN_DIR=/usr/local/bin \
111 * -DPACKAGE_LIB_DIR=/usr/local/lib \
112 * -DPACKAGE_DATA_DIR=/usr/local/share/appname \
113 * -DLOCALE_DIR=/usr/local/share/locale
114 *
115 * (of course add appropriate compile flags to linking etc. etc. and note that
116 * locale dir is optional. if you don't need it provide data dir as the
117 * locale dir. also note that the magicsharefile is optional for testing and
118 * ensuring that the prefix check is correct. this file must be installed
119 * in the application data dir (eg /usr/local/share/appname) and be referred
120 * to using a unix-style relative path from that dir, eg directory/filename.png)
121 *
122 * @code
123 * static Eina_Prefix *pfx = NULL;
124 *
125 * int main(argc, char **argv)
126 * {
127 * pfx = eina_prefix_new(argv[0], main, "APPNAME", "appname", NULL,
128 * PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
129 * PACKAGE_DATA_DIR, LOCALE_DIR);
130 * if (!pfx) printf("ERROR: Critical error in finding prefix\n");
131 * printf("install prefix is: %s\n", eina_prefix_get(pfx));
132 * printf("binaries are in: %s\n", eina_prefix_bin_get(pfx));
133 * printf("libraries are in: %s\n", eina_prefix_lib_get(pfx));
134 * printf("data files are in: %s\n", eina_prefix_data_get(pfx));
135 * eina_prefix_free(pfx);
136 * }
137 * @endcode
138 *
139 * @since 1.1.0
140 */
141EAPI Eina_Prefix *
142eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
143 const char *sharedir, const char *magicsharefile,
144 const char *pkg_bin, const char *pkg_lib,
145 const char *pkg_data, const char *pkg_locale);
146
147/**
148 * @brief Free the prefix object and all its contents
149 *
150 * @param pfx The prefix object
151 *
152 * Free the prefix object and all its allocated content. It will be invalid
153 * to access the object after being freed.
154 *
155 * @since 1.1.0
156 */
157EAPI void
158eina_prefix_free(Eina_Prefix *pfx);
159
160/**
161 * @brief Get the prefix base directory
162 *
163 * @param pfx The prefix object
164 *
165 * This returns the base prefix (eg "/usr/local", "/usr", "/opt/appname" or
166 * "/home/user/myapps/appname" etc.) that the software resides in at runtime.
167 *
168 * @since 1.1.0
169 */
170EAPI const char *
171eina_prefix_get(Eina_Prefix *pfx);
172
173/**
174 * @brief Get the binary installation directory
175 *
176 * @param pfx The prefix object
177 *
178 * This returns the location of installed binaries (eg "/usr/local/bin",
179 * "/usr/bin", "/opt/appname/bin", "/home/user/myapps/appname/bin" etc.).
180 *
181 * @since 1.1.0
182 */
183EAPI const char *
184eina_prefix_bin_get(Eina_Prefix *pfx);
185
186/**
187 * @brief Get the library installation directory
188 *
189 * @param pfx The prefix object
190 *
191 * This returns the location of installed binaries (eg "/usr/local/lib",
192 * "/usr/lib32", "/opt/appname/lib64", "/home/user/myapps/appname/lib" etc.).
193 *
194 * @since 1.1.0
195 */
196EAPI const char *
197eina_prefix_lib_get(Eina_Prefix *pfx);
198
199/**
200 * @brief Get the data installation directory
201 *
202 * @param pfx The prefix object
203 *
204 * This returns the location of installed binaries (eg "/usr/local/share/appname",
205 * "/usr/share/appname", "/opt/appname/share/appname", "/home/user/myapps/appname/share/appname" etc.).
206 *
207 * @since 1.1.0
208 */
209EAPI const char *
210eina_prefix_data_get(Eina_Prefix *pfx);
211
212/**
213 * @brief Get the locale installation directory
214 *
215 * @param pfx The prefix object
216 *
217 * This returns the location of installed binaries (eg "/usr/local/share/locale",
218 * "/usr/share/locale", "/opt/appname/share/locale", "/home/user/myapps/appname/share/locale" etc.).
219 *
220 * @since 1.1.0
221 */
222EAPI const char *
223eina_prefix_locale_get(Eina_Prefix *pfx);
224
225/**
226 * @}
227 */
228#endif
diff --git a/libraries/eina/src/include/eina_quadtree.h b/libraries/eina/src/include/eina_quadtree.h
deleted file mode 100644
index 2638d8b..0000000
--- a/libraries/eina/src/include/eina_quadtree.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2010 Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_QUADTREE_H_
20#define EINA_QUADTREE_H_
21
22#include "eina_config.h"
23
24#include "eina_inlist.h"
25
26typedef struct _Eina_QuadTree Eina_QuadTree;
27typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item;
28
29typedef enum {
30 EINA_QUAD_LEFT,
31 EINA_QUAD_RIGHT,
32 EINA_QUAD_BOTH
33} Eina_Quad_Direction;
34
35typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle);
36
37EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h, Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal);
38EAPI void eina_quadtree_free(Eina_QuadTree *q);
39EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
40
41EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
42EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object);
43
44EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object);
45EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
46EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
47EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
48EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
49
50EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h);
51EAPI void *eina_quadtree_object(Eina_Inlist *list);
52
53#endif
diff --git a/libraries/eina/src/include/eina_rbtree.h b/libraries/eina/src/include/eina_rbtree.h
deleted file mode 100644
index 8e5b730..0000000
--- a/libraries/eina/src/include/eina_rbtree.h
+++ /dev/null
@@ -1,271 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RBTREE_H__
20#define EINA_RBTREE_H__
21
22#include <stdlib.h>
23
24#include "eina_types.h"
25#include "eina_error.h"
26#include "eina_iterator.h"
27
28/**
29 * @addtogroup Eina_Rbtree_Group Red-Black tree
30 *
31 * @brief These functions provide Red-Black trees management.
32 *
33 * For a brief description look at http://en.wikipedia.org/wiki/Red-black_tree .
34 * This code is largely inspired from a tutorial written by Julienne Walker at :
35 * http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx . The
36 * main difference is that this set of function never allocate any data, making
37 * them particularly useful for memory management.
38 */
39
40/**
41 * @addtogroup Eina_Data_Types_Group Data Types
42 *
43 * @{
44 */
45
46/**
47 * @addtogroup Eina_Containers_Group Containers
48 *
49 * @{
50 */
51
52/**
53 * @defgroup Eina_Rbtree_Group Red-Black tree
54 *
55 * @{
56 */
57
58/**
59 * @typedef Eina_Rbtree_Color
60 * node color.
61 */
62typedef enum {
63 EINA_RBTREE_RED,
64 EINA_RBTREE_BLACK
65} Eina_Rbtree_Color;
66
67/**
68 * @typedef Eina_Rbtree_Direction
69 * walk direction.
70 */
71typedef enum {
72 EINA_RBTREE_LEFT = 0,
73 EINA_RBTREE_RIGHT = 1
74} Eina_Rbtree_Direction;
75
76/**
77 * @typedef Eina_Rbtree
78 * Type for a Red-Black tree node. It should be inlined into user's type.
79 */
80typedef struct _Eina_Rbtree Eina_Rbtree;
81struct _Eina_Rbtree
82{
83 Eina_Rbtree *son[2];
84
85 Eina_Rbtree_Color color : 1;
86};
87
88/**
89 * @def EINA_RBTREE
90 * recommended way to declare the inlined Eina_Rbtree in your type.
91 *
92 * @code
93 * struct my_type {
94 * EINA_RBTREE;
95 * int my_value;
96 * char *my_name;
97 * };
98 * @endcode
99 *
100 * @see EINA_RBTREE_GET()
101 */
102#define EINA_RBTREE Eina_Rbtree __rbtree
103
104/**
105 * @def EINA_RBTREE_GET
106 * access the inlined node if it was created with #EINA_RBTREE.
107 */
108#define EINA_RBTREE_GET(Rbtree) (&((Rbtree)->__rbtree))
109
110/**
111 * @def EINA_RBTREE_CONTAINER_GET
112 * find back the container of an red black tree.
113 */
114#define EINA_RBTREE_CONTAINER_GET(Ptr, Type) ((Type *)((char *)Ptr - offsetof(Type, __rbtree)))
115
116/**
117 * @typedef Eina_Rbtree_Cmp_Node_Cb
118 * Function used compare two nodes and see which direction to navigate.
119 */
120typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data);
121
122/**
123 * @def EINA_RBTREE_CMP_NODE_CB
124 * Cast using #Eina_Rbtree_Cmp_Node_Cb
125 */
126#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function)
127
128/**
129 * @typedef Eina_Rbtree_Cmp_Key_Cb
130 * Function used compare node with a given key of specified length.
131 */
132typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data);
133/**
134 * @def EINA_RBTREE_CMP_KEY_CB
135 * Cast using #Eina_Rbtree_Cmp_Key_Cb
136 */
137#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function)
138
139/**
140 * @typedef Eina_Rbtree_Free_Cb
141 * Function used free a node.
142 */
143typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
144/**
145 * @def EINA_RBTREE_FREE_CB
146 * Cast using #Eina_Rbtree_Free_Cb
147 */
148#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
149
150
151/**
152 * @brief Insert a new node inside an existing red black tree.
153 *
154 * @param root The root of an exisiting valid red black tree.
155 * @param node The new node to insert.
156 * @param cmp The callback that is able to compare two nodes.
157 * @param data Private data to help the compare function.
158 * @return The new root of the red black tree.
159 *
160 * This function insert a new node in a valid red black tree. NULL is
161 * an empty valid red black tree. The resulting new tree is a valid red
162 * black tree. This function doesn't allocate any data.
163 */
164EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
165
166/**
167 * @brief Remove a node from an existing red black tree.
168 *
169 * @param root The root of a valid red black tree.
170 * @param node The node to remove from the tree.
171 * @param cmp The callback that is able to compare two nodes.
172 * @param data Private data to help the compare function.
173 * @return The new root of the red black tree.
174 *
175 * This function remove a new node in a valid red black tree that should
176 * contain the node that you are removing. This function will return NULL
177 * when the red black tree got empty. This function doesn't free any data.
178 */
179EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
180
181/**
182 * @brief Delete all nodes from a valid red black tree.
183 *
184 * @param root The root of a valid red black tree.
185 * @param func The callback that will free each node.
186 * @param data Private data to help the compare function.
187 *
188 */
189EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
190
191static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
192
193
194/**
195 * @brief Returned a new prefix iterator associated to a rbtree.
196 *
197 * @param root The root of rbtree.
198 * @return A new iterator.
199 *
200 * This function returns a newly allocated iterator associated to @p
201 * root. It will iterate the tree using prefix walk. If @p root is @c
202 * NULL, this function still returns a valid iterator that will always
203 * return false on eina_iterator_next(), thus keeping API sane.
204 *
205 * If the memory can not be allocated, NULL is returned and
206 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
207 * returned.
208 *
209 * @warning if the rbtree structure changes then the iterator becomes
210 * invalid! That is, if you add or remove nodes this iterator
211 * behavior is undefined and your program may crash!
212 */
213EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
214
215/**
216 * @brief Returned a new prefix iterator associated to a rbtree.
217 *
218 * @param root The root of rbtree.
219 * @return A new iterator.
220 *
221 * This function returns a newly allocated iterator associated to @p
222 * root. It will iterate the tree using infix walk. If @p root is @c
223 * NULL, this function still returns a valid iterator that will always
224 * return false on eina_iterator_next(), thus keeping API sane.
225 *
226 * If the memory can not be allocated, NULL is returned and
227 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
228 * returned.
229 *
230 * @warning if the rbtree structure changes then the iterator becomes
231 * invalid! That is, if you add or remove nodes this iterator
232 * behavior is undefined and your program may crash!
233 */
234EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
235
236/**
237 * @brief Returned a new prefix iterator associated to a rbtree.
238 *
239 * @param root The root of rbtree.
240 * @return A new iterator.
241 *
242 * This function returns a newly allocated iterator associated to @p
243 * root. It will iterate the tree using postfix walk. If @p root is @c
244 * NULL, this function still returns a valid iterator that will always
245 * return false on eina_iterator_next(), thus keeping API sane.
246 *
247 * If the memory can not be allocated, NULL is returned and
248 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
249 * returned.
250 *
251 * @warning if the rbtree structure changes then the iterator becomes
252 * invalid! That is, if you add or remove nodes this iterator
253 * behavior is undefined and your program may crash!
254 */
255EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
256
257#include "eina_inline_rbtree.x"
258
259/**
260 * @}
261 */
262
263/**
264 * @}
265 */
266
267/**
268 * @}
269 */
270
271#endif
diff --git a/libraries/eina/src/include/eina_rectangle.h b/libraries/eina/src/include/eina_rectangle.h
deleted file mode 100644
index 57e562c..0000000
--- a/libraries/eina/src/include/eina_rectangle.h
+++ /dev/null
@@ -1,239 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RECTANGLE_H_
20#define EINA_RECTANGLE_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Rectangle_Group Rectangle
26 *
27 * @brief These functions provide rectangle management.
28 */
29
30/**
31 * @addtogroup Eina_Tools_Group Tools
32 *
33 * @{
34 */
35
36/**
37 * @defgroup Eina_Rectangle_Group Rectangle
38 *
39 * @{
40 */
41
42/**
43 * @typedef Eina_Rectangle
44 * Simple rectangle structure.
45 */
46typedef struct _Eina_Rectangle
47{
48 int x; /**< top-left x co-ordinate of rectangle */
49 int y; /**< top-left y co-ordinate of rectangle */
50 int w; /**< width of rectangle */
51 int h; /**< height of rectangle */
52} Eina_Rectangle;
53
54/**
55 * @typedef Eina_Rectangle_Pool
56 * Type for an opaque pool of rectangle.
57 */
58typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
59
60static inline int eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT;
61static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
62static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
63static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
64static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
65static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
66static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
67static inline void eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
68static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
69static inline void eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
70static inline void eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
71
72
73/**
74 * @brief Add a rectangle in a new pool.
75 *
76 * @param w The width of the rectangle.
77 * @param h The height of the rectangle.
78 * @return A newly allocated pool on success, @c NULL otherwise.
79 *
80 * This function adds the rectangle of size (@p width, @p height) to a
81 * new pool. If the pool can not be created, @c NULL is
82 * returned. Otherwise the newly allocated pool is returned.
83 */
84EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
85
86/**
87 * @brief Return the pool of the given rectangle.
88 *
89 * @param rect The rectangle.
90 * @return The pool of the given rectangle.
91 *
92 * This function returns the pool in which @p rect is. If @p rect is
93 * @c NULL, @c NULL is returned.
94 */
95EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
96
97/**
98 * @brief Return the width and height of the given pool.
99 *
100 * @param pool The pool.
101 * @param w The returned width.
102 * @param h The returned height.
103 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
104 *
105 * This function returns the width and height of @p pool and store
106 * them in respectively @p w and @p h if they are not @c NULL. If
107 * @p pool is @c NULL, #EINA_FALSE is returned. Otherwise #EINA_TRUE is
108 * returned.
109 */
110EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
111
112/**
113 * @brief Get the data from the given pool.
114 *
115 * @param pool The pool.
116 * @return The returned data.
117 *
118 * This function gets the data from @p pool set by
119 * eina_rectangle_pool_data_set(). If @p pool is @c NULL, this
120 * function returns @c NULL.
121 */
122EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
123
124/**
125 * @brief Set the data to the given pool.
126 *
127 * @param pool The pool.
128 * @param data The data to set.
129 *
130 * This function sets @p data to @p pool. If @p pool is @c NULL, this
131 * function does nothing.
132 */
133EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
134
135/**
136 * @brief Free the given pool.
137 *
138 * @param pool The pool to free.
139 *
140 * This function frees the allocated data of @p pool. If @p pool is
141 * @c NULL, ths function returned immediately.
142 */
143EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
144
145/**
146 * @brief Return the number of rectangles in the given pool.
147 *
148 * @param pool The pool.
149 * @return The number of rectangles in the pool.
150 *
151 * This function returns the number of rectangles in @p pool.
152 */
153EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
154
155/**
156 * @brief Request a rectangle of given size in the given pool.
157 *
158 * @param pool The pool.
159 * @param w The width of the rectangle to request.
160 * @param h The height of the rectangle to request.
161 * @return The requested rectangle on success, @c NULL otherwise.
162 *
163 * This function retrieve from @p pool the rectangle of width @p w and
164 * height @p h. If @p pool is @c NULL, or @p w or @p h are non-positive,
165 * the function returns @c NULL. If @p w or @p h are greater than the
166 * pool size, the function returns @c NULL. On success, the function
167 * returns the rectangle which matches the size (@p w, @p h).
168 * Otherwise it returns @c NULL.
169 */
170EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
171
172/**
173 * @brief Remove the given rectangle from the pool.
174 *
175 * @param rect The rectangle to remove from the pool.
176 *
177 * This function removes @p rect from the pool. If @p rect is
178 * @c NULL, the function returns immediately. Otherwise it remoes @p
179 * rect from the pool.
180 */
181EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
182
183/**
184 * @def EINA_RECTANGLE_SET
185 * @brief Macro to set the values of a #Eina_Rectangle.
186 *
187 * @param Rectangle The rectangle to set the values.
188 * @param X The X coordinate of the top left corner of the rectangle.
189 * @param Y The Y coordinate of the top left corner of the rectangle.
190 * @param W The width of the rectangle.
191 * @param H The height of the rectangle.
192 *
193 * This macro set the values of @p Rectangle. (@p X, @p Y) is the
194 * coordinates of the top left corner of @p Rectangle, @p W is its
195 * width and @p H is its height.
196 */
197#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
198 (Rectangle)->x = X; \
199 (Rectangle)->y = Y; \
200 (Rectangle)->w = W; \
201 (Rectangle)->h = H;
202
203
204/**
205 * @brief Create a new rectangle.
206 *
207 * @param x The X coordinate of the top left corner of the rectangle.
208 * @param y The Y coordinate of the top left corner of the rectangle.
209 * @param w The width of the rectangle.
210 * @param h The height of the rectangle.
211 * @return The new rectangle on success, @ NULL otherwise.
212 *
213 * This function creates a rectangle which top left corner has the
214 * coordinates (@p x, @p y), with height @p w and height @p h and adds
215 * it to the rectangles pool. No check is done on @p w and @p h. This
216 * function returns a new rectangle on success, @c NULL otherwhise.
217 */
218EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
219
220/**
221 * @brief Free the given rectangle.
222 *
223 * @param rect The rectangle to free.
224 *
225 * This function removes @p rect from the rectangles pool.
226 */
227EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
228
229#include "eina_inline_rectangle.x"
230
231/**
232 * @}
233 */
234
235/**
236 * @}
237 */
238
239#endif /*_EINA_RECTANGLE_H_*/
diff --git a/libraries/eina/src/include/eina_refcount.h b/libraries/eina/src/include/eina_refcount.h
deleted file mode 100644
index 6650b01..0000000
--- a/libraries/eina/src/include/eina_refcount.h
+++ /dev/null
@@ -1,76 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 20011 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_REFCOUNT_H_
20#define EINA_REFCOUNT_H_
21
22/**
23 * @addtogroup Eina_Refcount References counting
24 *
25 * @brief Small macro that simplify references counting.
26 *
27 * References counting is not a difficult task, but you must
28 * handle it correctly every where, and that the issue. This
29 * set of macro do provide helper that will force to use the
30 * correct code in most case and reduce the bug likeliness.
31 * Of course this without affecting speed !
32 */
33
34/**
35 * @addtogroup Eina_Data_Types_Group Data Types
36 *
37 * @{
38 */
39
40/**
41 * @defgroup Eina_Refcount References counting
42 *
43 * @{
44 */
45
46/**
47 * @typedef Eina_Refcount
48 * Inlined references counting type.
49 */
50typedef int Eina_Refcount;
51
52/** Used for declaring a reference counting member in a struct */
53#define EINA_REFCOUNT Eina_Refcount __refcount
54
55/** Used just after allocating a object */
56#define EINA_REFCOUNT_INIT(Variable) (Variable)->__refcount = 1
57
58/** Used when using referring to an object one more time */
59#define EINA_REFCOUNT_REF(Variable) (Variable)->__refcount++
60
61/** Used when removing a reference to an object. The code just after will automatically be called when necessary */
62#define EINA_REFCOUNT_UNREF(Variable) \
63 if (--((Variable)->__refcount) == 0)
64
65/** Get refcounting value */
66#define EINA_REFCOUNT_GET(Variable) (Variable)->__refcount
67
68/**
69 * @}
70 */
71
72/**
73 * @}
74 */
75
76#endif /* EINA_REFCOUNT_H_ */
diff --git a/libraries/eina/src/include/eina_safety_checks.h b/libraries/eina/src/include/eina_safety_checks.h
deleted file mode 100644
index 4751e5f..0000000
--- a/libraries/eina/src/include/eina_safety_checks.h
+++ /dev/null
@@ -1,254 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_SAFETY_CHECKS_H_
20#define EINA_SAFETY_CHECKS_H_
21
22/**
23 * @addtogroup Eina_Tools_Group Tools
24 *
25 * @{
26 */
27
28/**
29 * @defgroup Eina_Safety_Checks_Group Safety Checks
30 *
31 * @warning @c eina_safety_checks.h should only be included by source
32 * files, after all other includes and before the source file
33 * specific includes. By source file specific includes we
34 * mean those that define the functions that are being
35 * checked. The reason for such complexity is the trick to
36 * avoid compiler optimizations. If compilers are told that
37 * some given function will never receive @c NULL
38 * (EINA_ARG_NONNULL(), then compiler will emit a warning if
39 * it detects so (good!) but will remove any checks for that
40 * condition as it believes it will never happen, removing
41 * all safety checks! By including @c eina_safety_checks.h it
42 * will redefine EINA_ARG_NONNULL() to void and compiler
43 * warning will not be emitted, but checks will be there. The
44 * files already processed with the old macro
45 * EINA_ARG_NONNULL() will still work and emit the warnings.
46 *
47 *
48 * @code
49 *
50 * // all these files will emit warning from EINA_ARG_NONNULL()
51 * #include <Evas.h> // third party headers
52 * #include <Ecore.h>
53 * #include <eina_error.h> // eina own header
54 *
55 * #include <eina_safety_checks.h>
56 * // all these files below will NOT emit warning from EINA_ARG_NONNULL(),
57 * // but this is required to have the functions defined there to be checked
58 * // for NULL pointers
59 * #include "my_functions1.h"
60 * #include "my_functions2.h"
61 *
62 * @endcode
63 */
64
65/**
66 * @addtogroup Eina_Safety_Checks_Group Safety Checks
67 *
68 * Safety checks are a set of macros to check for parameters or values
69 * that should never happen, it is similar in concept to assert(), but
70 * will log and return instead of abort() your program.
71 *
72 * Since these cases should never happen, one may wantto keep safety
73 * checks enabled during tests but disable then during deploy, not
74 * doing any checks at all. This is a common requirement for embedded
75 * systems. Whenever to check or not should be set during compile time
76 * by using @c --disable-safety-checks or @c --enable-safety-checks
77 * options to @c configure script.
78 *
79 * Whenever these macros capture an error, EINA_LOG_ERR() will be
80 * called and @c eina_error set to @c EINA_ERROR_SAFETY_FAILED and can
81 * be checked with eina_error_get() after call.
82 *
83 * @see EINA_SAFETY_ON_NULL_RETURN(), EINA_SAFETY_ON_NULL_RETURN_VAL()
84 * and other macros.
85 *
86 * @{
87 */
88
89#include "eina_config.h"
90#include "eina_error.h"
91
92/**
93 * @var EINA_ERROR_SAFETY_FAILED
94 * Error identifier corresponding to safety check failure.
95 */
96EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
97
98#ifdef EINA_SAFETY_CHECKS
99
100#include "eina_log.h"
101
102#define EINA_SAFETY_ON_NULL_RETURN(exp) \
103 do \
104 { \
105 if (EINA_UNLIKELY((exp) == NULL)) \
106 { \
107 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
108 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
109 return; \
110 } \
111 } \
112 while (0)
113
114#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
115 do \
116 { \
117 if (EINA_UNLIKELY((exp) == NULL)) \
118 { \
119 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
120 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
121 return (val); \
122 } \
123 } \
124 while (0)
125
126#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
127 do \
128 { \
129 if (EINA_UNLIKELY((exp) == NULL)) \
130 { \
131 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
132 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
133 goto label; \
134 } \
135 } \
136 while (0)
137
138#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
139 do \
140 { \
141 if (EINA_UNLIKELY(exp)) \
142 { \
143 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
144 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
145 return; \
146 } \
147 } \
148 while (0)
149
150#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
151 do \
152 { \
153 if (EINA_UNLIKELY(exp)) \
154 { \
155 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
156 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
157 return val; \
158 } \
159 } \
160 while (0)
161
162#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
163 do \
164 { \
165 if (EINA_UNLIKELY(exp)) \
166 { \
167 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
168 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
169 goto label; \
170 } \
171 } \
172 while (0)
173
174#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
175 do \
176 { \
177 if (EINA_UNLIKELY(!(exp))) \
178 { \
179 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
180 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
181 return; \
182 } \
183 } \
184 while (0)
185
186#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
187 do \
188 { \
189 if (EINA_UNLIKELY(!(exp))) \
190 { \
191 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
192 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
193 return val; \
194 } \
195 } \
196 while (0)
197
198#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
199 do \
200 { \
201 if (EINA_UNLIKELY(!(exp))) \
202 { \
203 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
204 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
205 goto label; \
206 } \
207 } \
208 while (0)
209
210#ifdef EINA_ARG_NONNULL
211/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */
212#undef EINA_ARG_NONNULL
213#define EINA_ARG_NONNULL(idx, ...)
214#endif
215
216#else /* no safety checks */
217
218#define EINA_SAFETY_ON_NULL_RETURN(exp) \
219 do { (void)(!(exp)); } while (0)
220
221#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
222 do { if (0 && !(exp)) { (void)val; } } while (0)
223
224#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
225 do { if (0 && (exp) == NULL) { goto label; } } while (0)
226
227#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
228 do { (void)(exp); } while (0)
229
230#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
231 do { if (0 && (exp)) { (void)val; } } while (0)
232
233#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
234 do { if (0 && (exp)) { goto label; } } while (0)
235
236#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
237 do { (void)(!(exp)); } while (0)
238
239#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
240 do { if (0 && !(exp)) { (void)val; } } while (0)
241
242#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
243 do { if (0 && !(exp)) { goto label; } } while (0)
244
245#endif /* safety checks macros */
246#endif /* EINA_SAFETY_CHECKS_H_ */
247
248/**
249 * @}
250 */
251
252/**
253 * @}
254 */
diff --git a/libraries/eina/src/include/eina_sched.h b/libraries/eina/src/include/eina_sched.h
deleted file mode 100644
index 43f32b9..0000000
--- a/libraries/eina/src/include/eina_sched.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2010 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_SCHED_H_
20#define EINA_SCHED_H_
21
22#include "eina_types.h"
23
24
25/**
26 * @brief Lower priority of current thread.
27 *
28 * It's used by worker threads so they use up background cpu and do not stall
29 * the main thread If current thread is running with real-time priority, we
30 * decrease our priority by @c RTNICENESS. This is done in a portable way.
31 *
32 * Otherwise (we are running with SCHED_OTHER policy) there's no portable way to
33 * set the nice level on current thread. In Linux, it does work and it's the
34 * only one that is implemented as of now. In this case the nice level is
35 * incremented on this thread by @c NICENESS.
36 */
37EAPI void eina_sched_prio_drop(void);
38
39#endif /* EINA_SCHED_H_ */
diff --git a/libraries/eina/src/include/eina_simple_xml_parser.h b/libraries/eina/src/include/eina_simple_xml_parser.h
deleted file mode 100644
index 78660ef..0000000
--- a/libraries/eina/src/include/eina_simple_xml_parser.h
+++ /dev/null
@@ -1,390 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Gustavo Sverzut Barbieri
3 * Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_SIMPLE_XML_H_
21#define EINA_SIMPLE_XML_H_
22
23#include "eina_config.h"
24
25#include "eina_types.h"
26#include "eina_magic.h"
27#include "eina_inlist.h"
28
29/**
30 * @defgroup Eina_Simple_XML_Group Simple_XML
31 *
32 * Simplistic relaxed SAX-like XML parser.
33 *
34 * This parser is far from being compliant with XML standard, but will
35 * do for most XMLs out there. If you know that your format is simple
36 * and will not vary in future with strange corner cases, then you can
37 * use it safely.
38 *
39 * The parser is SAX like, that is, it will tokenize contents and call
40 * you back so you can take some action. No contents are allocated
41 * during this parser work and it's not recursive, so you can use it
42 * with a very large document without worries.
43 *
44 * It will not validate the document anyhow, neither it will create a
45 * tree hierarchy. That's up to you.
46 *
47 * Accordingly to XML, open tags may contain attributes. This parser
48 * will not tokenize this. If you want you can use
49 * eina_simple_xml_tag_attributes_find() and then
50 * eina_simple_xml_attributes_parse().
51 */
52
53/**
54 * @addtogroup Eina_Tools_Group Tools
55 *
56 * @{
57 */
58
59/**
60 * @defgroup Eina_Simple_XML_Group Simple_XML
61 *
62 * @{
63 */
64
65typedef struct _Eina_Simple_XML_Node Eina_Simple_XML_Node;
66typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Root;
67typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Tag;
68typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Data;
69typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_CData;
70typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Processing;
71typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Doctype;
72typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Comment;
73typedef struct _Eina_Simple_XML_Attribute Eina_Simple_XML_Attribute;
74
75struct _Eina_Simple_XML_Attribute
76{
77 EINA_INLIST;
78 EINA_MAGIC;
79
80 Eina_Simple_XML_Node_Tag *parent;
81 const char *key;
82 const char *value;
83};
84
85typedef enum _Eina_Simple_XML_Node_Type
86{
87 EINA_SIMPLE_XML_NODE_ROOT = 0,
88 EINA_SIMPLE_XML_NODE_TAG,
89 EINA_SIMPLE_XML_NODE_DATA,
90 EINA_SIMPLE_XML_NODE_CDATA,
91 EINA_SIMPLE_XML_NODE_PROCESSING,
92 EINA_SIMPLE_XML_NODE_DOCTYPE,
93 EINA_SIMPLE_XML_NODE_COMMENT
94} Eina_Simple_XML_Node_Type;
95
96struct _Eina_Simple_XML_Node
97{
98 EINA_INLIST;
99 EINA_MAGIC;
100
101 Eina_Simple_XML_Node_Tag *parent;
102 Eina_Simple_XML_Node_Type type;
103};
104
105struct _Eina_Simple_XML_Node_Tag
106{
107 Eina_Simple_XML_Node base;
108 Eina_Inlist *children;
109 Eina_Inlist *attributes;
110 const char *name;
111};
112
113struct _Eina_Simple_XML_Node_Data
114{
115 Eina_Simple_XML_Node base;
116 size_t length;
117 char data[];
118};
119
120typedef enum _Eina_Simple_XML_Type
121{
122 EINA_SIMPLE_XML_OPEN = 0, /*!< <tag attribute="value"> */
123 EINA_SIMPLE_XML_OPEN_EMPTY, /*!< <tag attribute="value" /> */
124 EINA_SIMPLE_XML_CLOSE, /*!< </tag> */
125 EINA_SIMPLE_XML_DATA, /*!< tag text data */
126 EINA_SIMPLE_XML_CDATA, /*!< <![CDATA[something]]> */
127 EINA_SIMPLE_XML_ERROR, /*!< error contents */
128 EINA_SIMPLE_XML_PROCESSING, /*!< <?xml ... ?> <?php .. ?> */
129 EINA_SIMPLE_XML_DOCTYPE, /*!< <!DOCTYPE html */
130 EINA_SIMPLE_XML_COMMENT, /*!< <!-- something --> */
131 EINA_SIMPLE_XML_IGNORED /*!< whatever is ignored by parser, like whitespace */
132} Eina_Simple_XML_Type;
133
134typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length);
135typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *key, const char *value);
136
137
138/**
139 * Parse a section of XML string text
140 *
141 * @param buf the input string. May not contain \0 terminator.
142 * @param buflen the input string size.
143 * @param strip whenever this parser should strip leading and trailing
144 * whitespace. These whitespace will still be issued, but as type
145 * #EINA_SIMPLE_XML_IGNORED.
146 * @param func what to call back while parse to do some action. The
147 * first parameter is the given user @a data, the second is the
148 * token type, the third is the pointer to content start (it's
149 * not a NULL terminated string!), the forth is where this
150 * content is located inside @a buf (does not include tag
151 * start, for instance "<!DOCTYPE value>" the offset points at
152 * "value"), the fifth is the size of the content. Whenever this
153 * function return EINA_FALSE the parser will abort. @param
154 * data what to give as context to @a func.
155 *
156 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or
157 * parsing error.
158 */
159EAPI Eina_Bool eina_simple_xml_parse(const char *buf, unsigned buflen,
160 Eina_Bool strip,
161 Eina_Simple_XML_Cb func, const void *data);
162
163
164/**
165 * Given the contents of a tag, find where the attributes start.
166 *
167 * @param buf the input string. May not contain \0 terminator.
168 * @param buflen the input string size.
169 * @return pointer to the start of attributes, it can be used
170 * to feed eina_simple_xml_attributes_parse(). NULL is returned
171 * if no attributes were found.
172 *
173 * The tag contents is returned by eina_simple_xml_parse() when
174 * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY.
175 *
176 */
177EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen);
178
179/**
180 * Given a buffer with xml attributes, parse them to key=value pairs.
181 *
182 * @param buf the input string. May not contain \0 terminator.
183 * @param buflen the input string size.
184 * @param func what to call back while parse to do some action. The
185 * first parameter is the given user @a data, the second is the
186 * key (null-terminated) and the last is the value (null
187 * terminated). These strings should not be modified and
188 * reference is just valid until the function return.
189 * @param data data to pass to the callback function.
190 *
191 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or
192 * parsing error.
193 */
194EAPI Eina_Bool eina_simple_xml_attributes_parse(const char *buf, unsigned buflen,
195 Eina_Simple_XML_Attribute_Cb func, const void *data);
196
197/**
198 * Create (and append) new attribute to tag.
199 *
200 * @param parent if provided, will be set in the resulting structure
201 * as well as the attribute will be appended to attributes list.
202 * @param key null-terminated string. Must not be NULL.
203 * @param value null-terminated string. If NULL, the empty string will be used.
204 *
205 * @return newly allocated memory or NULL on error. This memory should be
206 * released with eina_simple_xml_attribute_free() or indirectly
207 * with eina_simple_xml_node_tag_free().
208 */
209EAPI Eina_Simple_XML_Attribute * eina_simple_xml_attribute_new(Eina_Simple_XML_Node_Tag *parent, const char *key, const char *value);
210
211/**
212 * Remove attribute from parent and delete it.
213 *
214 * @param attr attribute to release memory.
215 */
216EAPI void eina_simple_xml_attribute_free(Eina_Simple_XML_Attribute *attr);
217
218
219/**
220 * Create new tag. If parent is provided, it is automatically appended.
221 *
222 * @param parent if provided, will be set in the resulting structure
223 * as well as the tag will be appended to children list.
224 * @param name null-terminated string. Must not be NULL.
225 *
226 * @return newly allocated memory or NULL on error. This memory should be
227 * released with eina_simple_xml_node_tag_free() or indirectly
228 * with eina_simple_xml_node_tag_free() of the parent.
229 */
230EAPI Eina_Simple_XML_Node_Tag * eina_simple_xml_node_tag_new(Eina_Simple_XML_Node_Tag *parent, const char *name);
231
232/**
233 * Remove tag from parent and delete it.
234 *
235 * @param tag to release memory.
236 */
237EAPI void eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag);
238
239
240/**
241 * Create new data. If parent is provided, it is automatically appended.
242 *
243 * @param parent if provided, will be set in the resulting structure
244 * as well as the data will be appended to children list.
245 * @param contents string to be used. Must not be NULL.
246 * @param length size in bytes of @a contents.
247 *
248 * @return newly allocated memory or NULL on error. This memory should be
249 * released with eina_simple_xml_node_data_free() or indirectly
250 * with eina_simple_xml_node_tag_free() of the parent.
251 */
252EAPI Eina_Simple_XML_Node_Data * eina_simple_xml_node_data_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
253
254/**
255 * Remove data from parent and delete it.
256 *
257 * @param node to release memory.
258 */
259EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node);
260
261
262/**
263 * Create new cdata. If parent is provided, it is automatically appended.
264 *
265 * @param parent if provided, will be set in the resulting structure
266 * as well as the cdata will be appended to children list.
267 * @param contents string to be used. Must not be NULL.
268 * @param length size in bytes of @a content.
269 *
270 * @return newly allocated memory or NULL on error. This memory should be
271 * released with eina_simple_xml_node_cdata_free() or indirectly
272 * with eina_simple_xml_node_tag_free() of the parent.
273 */
274EAPI Eina_Simple_XML_Node_CData * eina_simple_xml_node_cdata_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
275
276/**
277 * Remove cdata from parent and delete it.
278 *
279 * @param node to release memory.
280 */
281EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node);
282
283
284/**
285 * Create new processing. If parent is provided, it is automatically appended.
286 *
287 * @param parent if provided, will be set in the resulting structure
288 * as well as the processing will be appended to children list.
289 * @param contents string to be used. Must not be NULL.
290 * @param length size in bytes of @a contents.
291 *
292 * @return newly allocated memory or NULL on error. This memory should be
293 * released with eina_simple_xml_node_processing_free() or indirectly
294 * with eina_simple_xml_node_tag_free() of the parent.
295 */
296EAPI Eina_Simple_XML_Node_Processing * eina_simple_xml_node_processing_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
297
298/**
299 * Remove processing from parent and delete it.
300 *
301 * @param node processing to release memory.
302 */
303EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node);
304
305
306/**
307 * Create new doctype. If parent is provided, it is automatically appended.
308 *
309 * @param parent if provided, will be set in the resulting structure
310 * as well as the doctype will be appended to children list.
311 * @param contents string to be used. Must not be NULL.
312 * @param length size in bytes of @a contents.
313 *
314 * @return newly allocated memory or NULL on error. This memory should be
315 * released with eina_simple_xml_node_doctype_free() or indirectly
316 * with eina_simple_xml_node_tag_free() of the parent.
317 */
318EAPI Eina_Simple_XML_Node_Doctype * eina_simple_xml_node_doctype_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
319
320/**
321 * Remove doctype from parent and delete it.
322 *
323 * @param node doctype to release memory.
324 */
325EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node);
326
327
328/**
329 * Create new comment. If parent is provided, it is automatically appended.
330 *
331 * @param parent if provided, will be set in the resulting structure
332 * as well as the comment will be appended to children list.
333 * @param contents string to be used. Must not be NULL.
334 * @param length size in bytes of @a contents.
335 *
336 * @return newly allocated memory or NULL on error. This memory should be
337 * released with eina_simple_xml_node_comment_free() or indirectly
338 * with eina_simple_xml_node_tag_free() of the parent.
339 */
340EAPI Eina_Simple_XML_Node_Comment * eina_simple_xml_node_comment_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
341
342/**
343 * Remove comment from parent and delete it.
344 *
345 * @param node comment to release memory.
346 */
347EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node);
348
349
350/**
351 * Load a XML node tree based on the given string.
352 *
353 * @param buf the input string. May not contain \0 terminator.
354 * @param buflen the input string size.
355 * @param strip whenever this parser should strip leading and trailing
356 * whitespace.
357 *
358 * @return document root with children tags, or NULL on errors.
359 * Document with errors may return partial tree instead of NULL,
360 * we'll do our best to avoid returning nothing.
361 */
362EAPI Eina_Simple_XML_Node_Root * eina_simple_xml_node_load(const char *buf, unsigned buflen, Eina_Bool strip);
363
364/**
365 * Free node tree build with eina_simple_xml_node_load()
366 *
367 * @param root memory returned by eina_simple_xml_node_load()
368 */
369EAPI void eina_simple_xml_node_root_free(Eina_Simple_XML_Node_Root *root);
370
371/**
372 * Converts the node tree under the given element to a XML string.
373 *
374 * @param node the base node to convert.
375 * @param indent indentation string, or NULL to disable it.
376 *
377 * @return NULL on errors or a newly allocated string on success.
378 */
379EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent);
380
381
382/**
383 * @}
384 */
385
386/**
387 * @}
388 */
389
390#endif /* EINA_SIMPLE_XML_H_ */
diff --git a/libraries/eina/src/include/eina_str.h b/libraries/eina/src/include/eina_str.h
deleted file mode 100644
index 2913fbf..0000000
--- a/libraries/eina/src/include/eina_str.h
+++ /dev/null
@@ -1,325 +0,0 @@
1#ifndef _EINA_STR_H
2#define _EINA_STR_H
3
4#include <stddef.h>
5#include <string.h>
6
7#include "eina_types.h"
8
9/**
10 * @page tutorial_eina_string Eina String example
11 * @dontinclude eina_str_01.c
12 *
13 * Whenever using eina we need to include it:
14 * @skipline #include
15 * @line #include
16 *
17 * In our main function we declare(and initialize) some variables and initialize
18 * eina:
19 * @until eina_init
20 *
21 * It's frequentely necessary to split a string into its constituent parts,
22 * eina_str_split() make's it easy to do so:
23 * @until printf
24 *
25 * Another common need is to make a string uppercase or lowercase, so let's
26 * create a string and make it uppercase and then make it lowercase again:
27 * @until printf
28 * @until printf
29 *
30 * Next we use eina to check if our @p names string starts or ends with some
31 * values:
32 * @until Has
33 *
34 * When strings will be used in a terminal(or a number of other places) it
35 * necessary to escape certain characters that appear in them:
36 * @until printf
37 *
38 * Much as we previously split a string we will now join two strings:
39 * @until printf
40 *
41 * With strlcpy() we can copy what portion of the @p prologue fits in @p str and
42 * be sure that it's still NULL terminated:
43 * @until printf
44 *
45 * Since we are done with @p prologue and @p str we should free them:
46 * @until free(str
47 *
48 * Finally we see strlcat in action:
49 * @until printf("
50 *
51 * And then shut eina down and exit:
52 * @until }
53 * @example eina_str_01.c
54 */
55/**
56 * @addtogroup Eina_String_Group String
57 *
58 * @brief Provide useful functions for C string manipulation.
59 *
60 * This group of functions allow you to more easily manipulate strings, they
61 * provide functionality not available through string.h.
62 *
63 * @warning Since these functions modify the strings they can't be used with
64 * shared strings(eina_stringshare).
65 *
66 * See an example @ref tutorial_eina_string "here".
67 */
68
69/**
70 * @addtogroup Eina_Tools_Group Tools
71 *
72 * For more information refer to the @ref tutorial_eina_string "string example".
73 *
74 * @{
75 */
76
77/**
78 * @defgroup Eina_String_Group String
79 *
80 * @{
81 */
82
83/* strlcpy implementation for libc's lacking it */
84
85/**
86 * @brief Copy a c-string to another.
87 *
88 * @param dst The destination string.
89 * @param src The source string.
90 * @param siz The size of the destination string.
91 * @return The length of the source string.
92 *
93 * This function copies up to @p siz - 1 characters from the
94 * NUL-terminated string @p src to @p dst, NUL-terminating the result
95 * (unless @p siz is equal to 0). The returned value is the length of
96 * @p src. If the returned value is greater than @p siz, truncation
97 * occurred.
98 *
99 * @note The main difference between eina_strlcpy and strncpy is that this
100 * ensures @p dst is NULL terminated even if no NULL byte is found in the first
101 * @p siz bytes of src.
102 */
103EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
104
105/**
106 * @brief Append a c-string.
107 *
108 * @param dst The destination string.
109 * @param src The source string.
110 * @param siz The size of the destination string.
111 * @return The length of the source string plus MIN(siz, strlen(initial dst))
112 *
113 * This function appends @p src to @p dst of size @p siz (unlike
114 * strncat, @p siz is the full size of @p dst, not space left). At
115 * most @p siz - 1 characters will be copied. Always NUL terminates
116 * (unless @p siz <= strlen(dst)). This function returns strlen(src) +
117 * MIN(siz, strlen(initial dst)). If the returned value is greater or
118 * equal than @p siz, truncation occurred.
119 */
120EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
121
122
123/**
124 * @brief Check if the given string has the given prefix.
125 *
126 * @param str The string to work with.
127 * @param prefix The prefix to check for.
128 * @return #EINA_TRUE if the string has the given prefix, #EINA_FALSE otherwise.
129 *
130 * This function returns #EINA_TRUE if @p str has the prefix
131 * @p prefix, #EINA_FALSE otherwise. If the length of @p prefix is
132 * greater than @p str, #EINA_FALSE is returned.
133 */
134EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
135
136/**
137 * @brief Check if the given string has the given suffix.
138 *
139 * @param str The string to work with.
140 * @param suffix The suffix to check for.
141 * @return #EINA_TRUE if the string has the given suffix, #EINA_FALSE otherwise.
142 *
143 * This function returns #EINA_TRUE if @p str has the suffix
144 * @p suffix, #EINA_FALSE otherwise. If the length of @p suffix is
145 * greater than @p str, #EINA_FALSE is returned.
146 */
147EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
148
149/**
150 * @brief Check if the given string has the given extension.
151 *
152 * @param str The string to work with.
153 * @param ext The extension to check for.
154 * @return #EINA_TRUE if the string has the given extension, #EINA_FALSE otherwise.
155 *
156 * This function does the same as eina_str_has_suffix(), except it's case
157 * insensitive.
158 */
159EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
160
161/**
162 * @brief Split a string using a delimiter.
163 *
164 * @param string The string to split.
165 * @param delimiter The string which specifies the places at which to split the string.
166 * @param max_tokens The maximum number of strings to split string into.
167 * @return A newly-allocated NULL-terminated array of strings or NULL if it
168 * fails to allocate the array.
169 *
170 * This functin splits @p string into a maximum of @p max_tokens pieces,
171 * using the given delimiter @p delimiter. @p delimiter is not included in any
172 * of the resulting strings, unless @p max_tokens is reached. If
173 * @p max_tokens is less than @c 1, the string is splitted completely. If
174 * @p max_tokens is reached, the last string in the returned string
175 * array contains the remainder of string. The returned value is a
176 * newly allocated NULL-terminated array of strings or NULL if it fails to
177 * allocate the array. To free it, free the first element of the array and the
178 * array itself.
179 *
180 * @note If you need the number of elements in the returned array see
181 * eina_str_split_full().
182 */
183EAPI char **eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
184
185/**
186 * @brief Split a string using a delimiter and returns number of elements.
187 *
188 * @param string The string to split.
189 * @param delimiter The string which specifies the places at which to split the string.
190 * @param max_tokens The maximum number of strings to split string into.
191 * @param elements Where to return the number of elements in returned
192 * array (not counting the terminating @c NULL). May be @c NULL.
193 * @return A newly-allocated NULL-terminated array of strings or NULL if it
194 * fails to allocate the array.
195 *
196 * This function splits @p string into a maximum of @p max_tokens pieces,
197 * using the given delimiter @p delimiter. @p delimiter is not included in any
198 * of the resulting strings, unless @p max_tokens is reached. If
199 * @p max_tokens is less than @c 1, the string is splitted completely. If
200 * @p max_tokens is reached, the last string in the returned string
201 * array contains the remainder of string. The returned value is a
202 * newly allocated NULL-terminated array of strings or NULL if it fails to
203 * allocate the array. To free it, free the first element of the array and the
204 * array itself.
205 *
206 * @see eina_str_split()
207 */
208EAPI char **eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
209
210
211/**
212 * @brief Join two strings of known length.
213 *
214 * @param dst The buffer to store the result.
215 * @param size Size (in byte) of the buffer.
216 * @param sep The separator character to use.
217 * @param a First string to use, before @p sep.
218 * @param a_len length of @p a.
219 * @param b Second string to use, after @p sep.
220 * @param b_len length of @p b.
221 * @return The number of characters printed.
222 *
223 * This function joins the strings @p a and @p b (in that order) and
224 * separate them with @p sep. The result is stored in the buffer
225 * @p dst and at most @p size - 1 characters will be written and the
226 * string is NULL-terminated. @p a_len is the length of @p a (not
227 * including '\\0') and @p b_len is the length of @p b (not including
228 * '\\0'). This function returns the number of characters printed (not
229 * including the trailing '\\0' used to end output to strings). Just
230 * like snprintf(), it will not write more than @p size bytes, thus a
231 * returned value of @p size or more means that the output was
232 * truncated.
233 *
234 * @see eina_str_join()
235 * @see eina_str_join_static()
236 */
237EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
238
239
240/**
241 * @brief Use Iconv to convert a text string from one encoding to another.
242 *
243 * @param enc_from Encoding to convert from.
244 * @param enc_to Encoding to convert to.
245 * @param text The text to convert.
246 * @return The converted text.
247 *
248 * This function converts @p text, encoded in @p enc_from. On success,
249 * the converted text is returned and is encoded in @p enc_to. On
250 * failure, @c NULL is returned. Iconv is used to convert @p text. If
251 * Iconv is not available, @c NULL is returned. When not used anymore,
252 * the returned value must be freed.
253 */
254EAPI char *eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
255
256
257/**
258 * @brief Escape slashes, spaces and apostrophes in strings.
259 *
260 * @param str The string to escape.
261 * @return The escaped string.
262 *
263 * Escaping is done by adding a slash "\" before any occurrence of slashes "\",
264 * spaces " " or apostrophes "'". This function returns a newly allocated
265 * escaped string on success, @c NULL on failure. When not used anymore, the
266 * returned value must be freed.
267 */
268EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
269
270
271/**
272 * @brief Lowercase all the characters in range [A-Z] in the given string.
273 *
274 * @param str The string to lowercase.
275 *
276 * This function modifies the original string, changing all characters
277 * in [A-Z] to lowercase. If @p str is @c NULL or is an empty string,
278 * this function does nothing.
279 */
280EAPI void eina_str_tolower(char **str);
281
282/**
283 * @brief Uppercase all the characters in range [a-z] in the given string.
284 *
285 * @param str The string to uppercase.
286 *
287 * This function modifies the original string, changing all characters
288 * in [a-z] to uppercase. If @p str is @c NULL or is an empty string,
289 * this function does nothing.
290 */
291EAPI void eina_str_toupper(char **str);
292
293static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
294
295/**
296 * @def eina_str_join_static(dst, sep, a, b)
297 * @brief Join two static strings and store the result in a static buffer.
298 *
299 * @param dst The buffer to store the result.
300 * @param sep The separator character to use.
301 * @param a First string to use, before @p sep.
302 * @param b Second string to use, after @p sep.
303 * @return The number of characters printed.
304 *
305 * This function is similar to eina_str_join_len(), but will assume
306 * string sizes are know using sizeof(X).
307 *
308 * @see eina_str_join()
309 * @see eina_str_join_static()
310 */
311#define eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0)
312
313static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
314
315#include "eina_inline_str.x"
316
317/**
318 * @}
319 */
320
321/**
322 * @}
323 */
324
325#endif /* EINA_STR_H */
diff --git a/libraries/eina/src/include/eina_strbuf.h b/libraries/eina/src/include/eina_strbuf.h
deleted file mode 100644
index 34c200f..0000000
--- a/libraries/eina/src/include/eina_strbuf.h
+++ /dev/null
@@ -1,623 +0,0 @@
1#ifndef EINA_STRBUF_H
2#define EINA_STRBUF_H
3
4#include <stddef.h>
5#include <stdarg.h>
6
7#include "eina_types.h"
8
9
10/**
11 * @page tutorial_strbuf Eina_Strbuf example
12 * @dontinclude eina_strbuf_01.c
13 *
14 * First thing always is including Eina:
15 * @skipline #include
16 * @until #include
17 *
18 * Next we initialize eina and create a string buffer to play with:
19 * @until strbuf_new
20 *
21 * Here you can see two different ways of creating a buffer with the same
22 * contents. We could create them in simpler ways, but this gives us an
23 * opportunity to demonstrate several functions in action:
24 * @until strbuf_reset
25 * @until strbuf_reset
26 *
27 * Next we use the printf family of functions to create a formated string,
28 * add, remove and replace some content:
29 * @until strbuf_string_get
30 * @until strbuf_string_get
31 * @until strbuf_string_get
32 *
33 * Once done we free our string buffer, shut down Eina and end the application:
34 * @until }
35 *
36 * @example eina_strbuf_01.c
37 */
38/**
39 * @addtogroup Eina_String_Buffer_Group String Buffer
40 *
41 * @brief These functions provide string buffers management.
42 *
43 * The String Buffer data type is designed to be a mutable string,
44 * allowing to append, prepend or insert a string to a buffer.
45 *
46 * For more information see @ref tutorial_strbuf "this example".
47 */
48
49/**
50 * @addtogroup Eina_Data_Types_Group Data Types
51 *
52 * @{
53 */
54
55/**
56 * @defgroup Eina_String_Buffer_Group String Buffer
57 *
58 * @{
59 */
60
61/**
62 * @typedef Eina_Strbuf
63 * Type for a string buffer.
64 */
65typedef struct _Eina_Strbuf Eina_Strbuf;
66
67/**
68 * @brief Create a new string buffer.
69 *
70 * @return Newly allocated string buffer instance.
71 *
72 * This function creates a new string buffer. On error, @c NULL is
73 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
74 * free the resources, use eina_strbuf_free().
75 *
76 * @see eina_strbuf_free()
77 * @see eina_strbuf_append()
78 * @see eina_strbuf_string_get()
79 */
80EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
81
82/**
83 * @brief Create a new string buffer using the passed string. The passed
84 * string is used directly as the buffer, it's somehow the opposite function of
85 * @ref eina_strbuf_string_steal . The passed string must be malloced.
86 *
87 * @param str the string to manage
88 * @return Newly allocated string buffer instance.
89 *
90 * This function creates a new string buffer. On error, @c NULL is
91 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
92 * free the resources, use eina_strbuf_free().
93 *
94 * @see eina_strbuf_free()
95 * @see eina_strbuf_append()
96 * @see eina_strbuf_string_get()
97 * @since 1.1.0
98 */
99EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
100
101/**
102 * @brief Create a new string buffer using the passed string. The passed
103 * string is used directly as the buffer, it's somehow the opposite function of
104 * @ref eina_strbuf_string_steal . The passed string must be malloced.
105 *
106 * @param str the string to manage
107 * @param length the length of the string.
108 * @return Newly allocated string buffer instance.
109 *
110 * This function creates a new string buffer. On error, @c NULL is
111 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
112 * free the resources, use eina_strbuf_free().
113 *
114 * @see eina_strbuf_manage_new()
115 * @since 1.2.0
116 */
117EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
118
119/**
120 * @brief Free a string buffer.
121 *
122 * @param buf The string buffer to free.
123 *
124 * This function frees the memory of @p buf. @p buf must have been
125 * created by eina_strbuf_new().
126 */
127EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
128
129/**
130 * @brief Reset a string buffer.
131 *
132 * @param buf The string buffer to reset.
133 *
134 * This function reset @p buf: the buffer len is set to 0, and the
135 * string is set to '\\0'. No memory is free'd.
136 */
137EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
138
139/**
140 * @brief Append a string to a buffer, reallocating as necessary.
141 *
142 * @param buf The string buffer to append to.
143 * @param str The string to append.
144 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
145 *
146 * This function appends @p str to @p buf. It computes the length of
147 * @p str, so is slightly slower than eina_strbuf_append_length(). If
148 * the length is known beforehand, consider using that variant. If
149 * @p buf can't append it, #EINA_FALSE is returned, otherwise
150 * #EINA_TRUE is returned.
151 *
152 * @see eina_strbuf_append()
153 * @see eina_strbuf_append_length()
154 */
155EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
156
157/**
158 * @brief Append an escaped string to a buffer, reallocating as necessary.
159 *
160 * @param buf The string buffer to append to.
161 * @param str The string to append.
162 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
163 *
164 * This function escapes and then appends the string @p str to @p buf. If @p str
165 * can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
166 * returned.
167 */
168EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
169
170/**
171 * @brief Append a string to a buffer, reallocating as necessary,
172 * limited by the given length.
173 *
174 * @param buf The string buffer to append to.
175 * @param str The string to append.
176 * @param maxlen The maximum number of characters to append.
177 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
178 *
179 * This function appends at most @p maxlen characters of @p str to
180 * @p buf. It can't append more than the length of @p str. It
181 * computes the length of @p str, so it is slightly slower than
182 * eina_strbuf_append_length(). If the length is known beforehand,
183 * consider using that variant (@p maxlen should then be checked so
184 * that it is greater than the size of @p str). If @p str can not be
185 * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
186 * returned.
187 *
188 * @see eina_strbuf_append()
189 * @see eina_strbuf_append_length()
190 */
191EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
192
193/**
194 * @brief Append a string of exact length to a buffer, reallocating as necessary.
195 *
196 * @param buf The string buffer to append to.
197 * @param str The string to append.
198 * @param length The exact length to use.
199 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
200 *
201 * This function appends @p str to @p buf. @p str must be of size at
202 * most @p length. It is slightly faster than eina_strbuf_append() as
203 * it does not compute the size of @p str. It is useful when dealing
204 * with strings of known size, such as eina_stringshare. If @p buf
205 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
206 * returned.
207 *
208 * @see eina_stringshare_length()
209 * @see eina_strbuf_append()
210 * @see eina_strbuf_append_n()
211 */
212EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
213
214/**
215 * @brief Append a character to a string buffer, reallocating as
216 * necessary.
217 *
218 * @param buf The string buffer to append to.
219 * @param c The char to append.
220 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
221 *
222 * This function inserts @p c to @p buf. If it can not insert it,
223 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
224 */
225EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
226
227/**
228 * @brief Append a string to a buffer, reallocating as necessary.
229 *
230 * @param buf The string buffer to append to.
231 * @param fmt The string to append.
232 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
233 *
234 * This function appends the string defined by the format @p fmt to @p buf. @p
235 * fmt must be of a valid format for printf family of functions. If it can't
236 * insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
237 *
238 * @see eina_strbuf_append()
239 */
240EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
241
242/**
243 * @brief Append a string to a buffer, reallocating as necessary.
244 *
245 * @param buf The string buffer to append to.
246 * @param fmt The string to append.
247 * @param args The variable arguments.
248 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
249 *
250 * @see eina_strbuf_append_printf()
251 */
252EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
253
254/**
255 * @brief Insert a string to a buffer, reallocating as necessary.
256 *
257 * @param buf The string buffer to insert.
258 * @param str The string to insert.
259 * @param pos The position to insert the string.
260 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
261 *
262 * This function inserts @p str to @p buf at position @p pos. It
263 * computes the length of @p str, so is slightly slower than
264 * eina_strbuf_insert_length(). If the length is known beforehand,
265 * consider using that variant. If @p buf can't insert it, #EINA_FALSE
266 * is returned, otherwise #EINA_TRUE is returned.
267 */
268EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
269
270/**
271 * @brief Insert an escaped string to a buffer, reallocating as
272 * necessary.
273 *
274 * @param buf The string buffer to insert to.
275 * @param str The string to insert.
276 * @param pos The position to insert the string.
277 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
278 *
279 * This function escapes and inserts the string @p str to @p buf at
280 * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
281 * returned, otherwise #EINA_TRUE is returned.
282 */
283EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
284
285/**
286 * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
287 *
288 * @param buf The string buffer to insert to.
289 * @param str The string to insert.
290 * @param maxlen The maximum number of chars to insert.
291 * @param pos The position to insert the string.
292 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
293 *
294 * This function inserts @p str to @p buf at position @p pos, with at
295 * most @p maxlen bytes. The number of inserted characters can not be
296 * greater than the length of @p str. It computes the length of
297 * @p str, so is slightly slower than eina_strbuf_insert_length(). If the
298 * length is known beforehand, consider using that variant (@p maxlen
299 * should then be checked so that it is greater than the size of
300 * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
301 * otherwise, #EINA_TRUE is returned.
302 */
303EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
304
305/**
306 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
307 *
308 * @param buf The string buffer to insert to.
309 * @param str The string to insert.
310 * @param length The exact length to use.
311 * @param pos The position to insert the string.
312 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
313 *
314 * This function inserts @p str to @p buf. @p str must be of size at
315 * most @p length. It is slightly faster than eina_strbuf_insert() as
316 * it does not compute the size of @p str. It is useful when dealing
317 * with strings of known size, such as eina_strngshare. If @p buf
318 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
319 * returned.
320 *
321 * @see eina_stringshare_length()
322 * @see eina_strbuf_insert()
323 * @see eina_strbuf_insert_n()
324 */
325EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
326
327/**
328 * @brief Insert a character to a string buffer, reallocating as
329 * necessary.
330 *
331 * @param buf The string buffer to insert to.
332 * @param c The char to insert.
333 * @param pos The position to insert the char.
334 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
335 *
336 * This function inserts @p c to @p buf at position @p pos. If @p buf
337 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
338 * returned.
339 */
340EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
341
342/**
343 * @brief Insert a string to a buffer, reallocating as necessary.
344 *
345 * @param buf The string buffer to insert.
346 * @param fmt The string to insert.
347 * @param pos The position to insert the string.
348 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
349 *
350 * This function insert a string as described by the format @p fmt to @p buf at
351 * the position @p pos. @p fmt must be of a valid format for printf family of
352 * functions. If it can't insert it, #EINA_FALSE is returned, otherwise
353 * #EINA_TRUE is returned.
354 */
355EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
356
357/**
358 * @brief Insert a string to a buffer, reallocating as necessary.
359 *
360 * @param buf The string buffer to insert.
361 * @param fmt The string to insert.
362 * @param pos The position to insert the string.
363 * @param args The variable arguments.
364 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
365 *
366 * @see eina_strbuf_insert_printf
367 */
368EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
369
370/**
371 * @def eina_strbuf_prepend(buf, str)
372 * @brief Prepend the given string to the given buffer
373 *
374 * @param buf The string buffer to prepend to.
375 * @param str The string to prepend.
376 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
377 *
378 * This macro is calling eina_strbuf_insert() at position 0. If @p buf
379 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
380 * returned.
381 */
382#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf, str, 0)
383
384/**
385 * @def eina_strbuf_prepend_escaped(buf, str)
386 * @brief Prepend the given escaped string to the given buffer
387 *
388 * @param buf The string buffer to prepend to.
389 * @param str The string to prepend.
390 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
391 *
392 * This macro is calling eina_strbuf_insert_escaped() at position 0. If
393 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
394 * #EINA_TRUE is returned.
395 */
396#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0)
397
398/**
399 * @def eina_strbuf_prepend_n(buf, str)
400 * @brief Prepend the given escaped string to the given buffer
401 *
402 * @param buf The string buffer to prepend to.
403 * @param str The string to prepend.
404 * @param maxlen The maximum number of chars to prepend.
405 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
406 *
407 * This macro is calling eina_strbuf_insert_n() at position 0. If
408 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
409 * #EINA_TRUE is returned.
410 */
411#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0)
412
413/**
414 * @def eina_strbuf_prepend_length(buf, str)
415 * @brief Prepend the given escaped string to the given buffer
416 *
417 * @param buf The string buffer to prepend to.
418 * @param str The string to prepend.
419 * @param length The exact length to use.
420 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
421 *
422 * This macro is calling eina_strbuf_insert_length() at position 0. If
423 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
424 * #EINA_TRUE is returned.
425 */
426#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0)
427
428/**
429 * @def eina_strbuf_prepend_char(buf, str)
430 * @brief Prepend the given character to the given buffer
431 *
432 * @param buf The string buffer to prepend to.
433 * @param c The character to prepend.
434 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
435 *
436 * This macro is calling eina_strbuf_insert_char() at position 0. If
437 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
438 * #EINA_TRUE is returned.
439 */
440#define eina_strbuf_prepend_char(buf, c) eina_strbuf_insert_char(buf, c, 0)
441
442/**
443 * @def eina_strbuf_prepend_printf(buf, fmt, ...)
444 * @brief Prepend the given string to the given buffer
445 *
446 * @param buf The string buffer to prepend to.
447 * @param fmt The string to prepend.
448 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
449 *
450 * This macro is calling eina_strbuf_insert_printf() at position 0.If @p buf
451 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
452 * returned.
453 */
454#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
455
456/**
457 * @def eina_strbuf_prepend_vprintf(buf, fmt, args)
458 * @brief Prepend the given string to the given buffer
459 *
460 * @param buf The string buffer to prepend to.
461 * @param fmt The string to prepend.
462 * @param args The variable arguments.
463 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
464 *
465 * This macro is calling eina_strbuf_insert_vprintf() at position 0.If @p buf
466 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
467 * returned.
468 */
469#define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args)
470
471/**
472 * @brief Remove a slice of the given string buffer.
473 *
474 * @param buf The string buffer to remove a slice.
475 * @param start The initial (inclusive) slice position to start
476 * removing, in bytes.
477 * @param end The final (non-inclusive) slice position to finish
478 * removing, in bytes.
479 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
480 *
481 * This function removes a slice of @p buf, starting at @p start
482 * (inclusive) and ending at @p end (non-inclusive). Both values are
483 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
484 */
485
486EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
487
488/**
489 * @brief Retrieve a pointer to the contents of a string buffer
490 *
491 * @param buf The string buffer.
492 * @return The current string in the string buffer.
493 *
494 * This function returns the string contained in @p buf. The returned
495 * value must not be modified and will no longer be valid if @p buf is
496 * modified. In other words, any eina_strbuf_append() or similar will
497 * make that pointer invalid. The pointer returned by this function <b>must
498 * not</b> be freed.
499 *
500 * @see eina_strbuf_string_steal()
501 */
502EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
503
504/**
505 * @brief Steal the contents of a string buffer.
506 *
507 * @param buf The string buffer to steal.
508 * @return The current string in the string buffer.
509 *
510 * This function returns the string contained in @p buf. @p buf is
511 * then initialized and does not own the returned string anymore. The
512 * caller must release the memory of the returned string by calling
513 * free().
514 *
515 * @see eina_strbuf_string_get()
516 */
517EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
518
519/**
520 * @brief Free the contents of a string buffer but not the buffer.
521 *
522 * @param buf The string buffer to free the string of.
523 *
524 * This function frees the string contained in @p buf without freeing
525 * @p buf.
526 */
527EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
528
529/**
530 * @brief Retrieve the length of the string buffer content.
531 *
532 * @param buf The string buffer.
533 * @return The current length of the string, in bytes.
534 *
535 * This function returns the length of @p buf.
536 */
537EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
538
539
540/**
541 * @brief Replace the n-th string with an other string.
542 *
543 * @param buf The string buffer to work with.
544 * @param str The string to replace.
545 * @param with The replaceing string.
546 * @param n The number of the fitting string.
547 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
548 *
549 * This function replaces the n-th occurrence of @p str in @p buf with
550 * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
551 */
552EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
553
554/**
555 * @def eina_strbuf_replace_first(buf, str, with)
556 * @brief Prepend the given character to the given buffer
557 *
558 * @param buf The string buffer to work with.
559 * @param str The string to replace.
560 * @param with The replaceing string.
561 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
562 *
563 * This macro is calling eina_strbuf_replace() with the n-th occurrence
564 * equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned,
565 * otherwise #EINA_TRUE is returned.
566 */
567#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1)
568
569
570/**
571 * @brief Replace all strings with an other string.
572
573 * @param buf the string buffer to work with.
574 * @param str The string to replace.
575 * @param with The replaceing string.
576 * @return How often the string was replaced.
577 *
578 * This function replaces all the occurrences of @p str in @p buf with
579 * the string @p with. This function returns the number of times @p str
580 * has been replaced. On failure, it returns 0.
581 */
582EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3);
583
584/**
585 * @brief Trim the string buffer
586
587 * @param buf the string buffer to work with.
588 *
589 * This function skips whitespaces in the beginning and the end of the buffer.
590 */
591EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
592
593/**
594 * @brief Left trim the string buffer
595
596 * @param buf the string buffer to work with.
597 *
598 * This function skips whitespaces in the beginning of the buffer.
599 */
600EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
601
602/**
603 * @brief Right trim the string buffer
604
605 * @param buf the string buffer to work with.
606 *
607 * This function skips whitespaces in the end of the buffer.
608 */
609EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
610
611/**
612 * @}
613 */
614
615/**
616 * @}
617 */
618
619/**
620 * @}
621 */
622
623#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h
deleted file mode 100644
index 8edadd2..0000000
--- a/libraries/eina/src/include/eina_stringshare.h
+++ /dev/null
@@ -1,345 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_STRINGSHARE_H_
52#define EINA_STRINGSHARE_H_
53
54#include <stdarg.h>
55
56#include "eina_types.h"
57
58/**
59 * @page eina_stringshare_example_01_page
60 * @dontinclude eina_stringshare_01.c
61 *
62 * Like all examples we start by including Eina:
63 * @skip #include
64 * @line #include
65 *
66 * Here we declare some variables and initialize eina:
67 * @until eina_init
68 *
69 * We start the substantive part of the example by showing how to make a part
70 * of a string shared and how to get the length of a shared string:
71 * @until stringshare_strlen
72 * As we add shared strings we also need to delete them when done using them:
73 * @line del
74 *
75 * There are many ways of creating shared strings including an equivalent to
76 * sprintf:
77 * @until del
78 *
79 * An equivalent to snprintf:
80 * @until printf
81 *
82 * But the simplest way of creating a shared string is through
83 * eina_stringshare_add():
84 * @until printf
85 *
86 * Sometimes you already have a pointer to a shared string and want to use it,
87 * so to make sure the provider of the pointer won't free it while you're using
88 * it you can increase the shared string's ref count:
89 * @until printf
90 *
91 * Whenever you have a pointer to a shared string and would like to change it's
92 * value you should use eina_stringshare_replace():
93 * @until printf
94 * @warning @b Don't use eina_stringshare_del() followed by
95 * eina_share_common_add(), under some circunstances you might end up deleting
96 * a shared string some other piece of code is using.
97 *
98 * We created str but haven't deleted it yet, and while we called
99 * eina_stringshare_del() on str2, we created it and then increased the ref
100 * count so it's still alive:
101 * @until str2
102 *
103 * You can see the full source code @ref eina_stringshare_example_01 "here".
104 */
105/**
106 * @page eina_stringshare_example_01
107 * @include eina_stringshare_01.c
108 * @example eina_stringshare_01.c
109 */
110/**
111 * @addtogroup Eina_Stringshare_Group Stringshare
112 *
113 * These functions allow you to store a single copy of a string, and use in
114 * multiple places throughout your program.
115 *
116 * This is a method to reduce the number of duplicated strings kept in
117 * memory. It's pretty common for the same strings to be dynamically
118 * allocated repeatedly between applications and libraries, especially in
119 * circumstances where you could have multiple copies of a structure that
120 * allocates the string. So rather than duplicating and freeing these
121 * strings, you request a read-only pointer to an existing string and
122 * only incur the overhead of a hash lookup.
123 *
124 * It sounds like micro-optimizing, but profiling has shown this can have
125 * a significant impact as you scale the number of copies up. It improves
126 * string creation/destruction speed, reduces memory use and decreases
127 * memory fragmentation, so a win all-around.
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 *
143 * The following diagram gives an idea of what happens as you create strings
144 * with eina_stringshare_add():
145 *
146 * @image html eina_stringshare.png
147 * @image latex eina_stringshare.eps height=\textheight
148 *
149 * For more information, see @ref eina_stringshare_example_01_page
150 * "this example".
151 */
152
153/**
154 * @addtogroup Eina_Data_Types_Group Data Types
155 *
156 * @{
157 */
158
159/**
160 * @defgroup Eina_Stringshare_Group Stringshare
161 *
162 * @{
163 */
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;
174
175/**
176 * @brief Retrieve an instance of a string for use in a program.
177 *
178 * @param str The string to retrieve an instance of.
179 * @param slen The string size (<= strlen(str)).
180 * @return A pointer to an instance of the string on success.
181 * @c NULL on failure.
182 *
183 * This function retrieves an instance of @p str. If @p str is
184 * @c NULL, then @c NULL is returned. If @p str is already stored, it
185 * is just returned and its reference counter is increased. Otherwise
186 * a duplicated string of @p str is returned.
187 *
188 * This function does not check string size, but uses the
189 * exact given size. This can be used to share_common part of a larger
190 * buffer or substring.
191 *
192 * @see eina_share_common_add()
193 */
194EAPI Eina_Stringshare *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
195
196/**
197 * @brief Retrieve an instance of a string for use in a program.
198 *
199 * @param str The NULL terminated string to retrieve an instance of.
200 * @return A pointer to an instance of the string on success.
201 * @c NULL on failure.
202 *
203 * This function retrieves an instance of @p str. If @p str is
204 * @c NULL, then @c NULL is returned. If @p str is already stored, it
205 * is just returned and its reference counter is increased. Otherwise
206 * a duplicated string of @p str is returned.
207 *
208 * The string @p str must be NULL terminated ('@\0') and its full
209 * length will be used. To use part of the string or non-null
210 * terminated, use eina_stringshare_add_length() instead.
211 *
212 * @see eina_stringshare_add_length()
213 */
214EAPI Eina_Stringshare *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
215
216/**
217 * @brief Retrieve an instance of a string for use in a program
218 * from a format string.
219 *
220 * @param fmt The NULL terminated format string to retrieve an instance of.
221 * @return A pointer to an instance of the string on success.
222 * @c NULL on failure.
223 *
224 * This function retrieves an instance of @p fmt. If @p fmt is
225 * @c NULL, then @c NULL is returned. If @p fmt is already stored, it
226 * is just returned and its reference counter is increased. Otherwise
227 * a duplicated string is returned.
228 *
229 * The format string @p fmt must be NULL terminated ('@\0') and its full
230 * length will be used. To use part of the format string or non-null
231 * terminated, use eina_stringshare_nprintf() instead.
232 *
233 * @see eina_stringshare_nprintf()
234 */
235EAPI Eina_Stringshare *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
236
237/**
238 * @brief Retrieve an instance of a string for use in a program
239 * from a format string.
240 *
241 * @param fmt The NULL terminated format string to retrieve an instance of.
242 * @param args The va_args for @p fmt
243 * @return A pointer to an instance of the string on success.
244 * @c NULL on failure.
245 *
246 * This function retrieves an instance of @p fmt with @p args. If @p fmt is
247 * @c NULL, then @c NULL is returned. If @p fmt with @p args is already stored, it
248 * is just returned and its reference counter is increased. Otherwise
249 * a duplicated string is returned.
250 *
251 * The format string @p fmt must be NULL terminated ('@\0') and its full
252 * length will be used. To use part of the format string or non-null
253 * terminated, use eina_stringshare_nprintf() instead.
254 *
255 * @see eina_stringshare_nprintf()
256 */
257EAPI Eina_Stringshare *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
258
259/**
260 * @brief Retrieve an instance of a string for use in a program
261 * from a format string with size limitation.
262 * @param len The length of the format string to use
263 * @param fmt The format string to retrieve an instance of.
264 * @return A pointer to an instance of the string on success.
265 * @c NULL on failure.
266 *
267 * This function retrieves an instance of @p fmt limited by @p len. If @p fmt is
268 * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting string
269 * is already stored, it is returned and its reference counter is increased.
270 * Otherwise a duplicated string is returned.
271 *
272 * @p len length of the format string will be used. To use the
273 * entire format string, use eina_stringshare_printf() instead.
274 *
275 * @see eina_stringshare_printf()
276 */
277EAPI Eina_Stringshare *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
278
279/**
280 * Increment references of the given shared string.
281 *
282 * @param str The shared string.
283 * @return A pointer to an instance of the string on success.
284 * @c NULL on failure.
285 *
286 * This is similar to eina_share_common_add(), but it's faster since it will
287 * avoid lookups if possible, but on the down side it requires the parameter
288 * to be shared string. In other words, it must be the return of a previous
289 * call to one of the stringshare functions.
290 *
291 * There is no unref since this is the work of eina_share_common_del().
292 */
293EAPI Eina_Stringshare *eina_stringshare_ref(Eina_Stringshare *str);
294
295/**
296 * @brief Note that the given string has lost an instance.
297 *
298 * @param str string The given string.
299 *
300 * This function decreases the reference counter associated to @p str
301 * if it exists. If that counter reaches 0, the memory associated to
302 * @p str is freed. If @p str is NULL, the function returns
303 * immediately.
304 *
305 * Note that if the given pointer is not shared or NULL, bad things
306 * will happen, likely a segmentation fault.
307 */
308EAPI void eina_stringshare_del(Eina_Stringshare *str);
309
310/**
311 * @brief Note that the given string @b must be shared.
312 *
313 * @param str the shared string to know the length. It is safe to
314 * give NULL, in that case -1 is returned.
315 * @return The length of a shared string.
316 *
317 * This function is a cheap way to known the length of a shared
318 * string. Note that if the given pointer is not shared, bad
319 * things will happen, likely a segmentation fault. If in doubt, try
320 * strlen().
321 */
322EAPI int eina_stringshare_strlen(Eina_Stringshare *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
323
324/**
325 * @brief Dump the contents of the share_common.
326 *
327 * This function dumps all strings in the share_common to stdout with a
328 * DDD: prefix per line and a memory usage summary.
329 */
330EAPI void eina_stringshare_dump(void);
331
332static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, const char *news) 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);
334
335#include "eina_inline_stringshare.x"
336
337/**
338 * @}
339 */
340
341/**
342 * @}
343 */
344
345#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_tiler.h b/libraries/eina/src/include/eina_tiler.h
deleted file mode 100644
index 5272099..0000000
--- a/libraries/eina/src/include/eina_tiler.h
+++ /dev/null
@@ -1,310 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TILER_H_
20#define EINA_TILER_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_rectangle.h"
25
26/**
27 * @page eina_tiler_example_01
28 * @dontinclude eina_tiler_01.c
29 *
30 * This is an example that illustrates how Eina_Tiler works for a given set of
31 * rectangles. The rectangles must be given in the command line in the form:
32 * <width>x<height>+<x offset>+<y offset>
33 * The example will show two panels, the first(input) will show the given
34 * rectangles(in different colors) and in the seconds(output) it will show the
35 * rectangles given by the tiler. The rectangles will be added one by one every
36 * two seconds. A lot of the example deals with actually painting the rectangles
37 * so we'll skip over quite a bit of code, but you can see all of it in @ref
38 * eina_tiler_01.c "eina_tiler_01.c".
39 *
40 * The first thing of note in our example is the creation of the tiler:
41 * @skipline eina_tiler_new
42 * @note @p maxw and @p maxh are calculated such that the tiler's size will
43 * fully encompass all given rectangles.
44 *
45 * We'll now look at the function that actually adds rectangles to our tiler. It
46 * first checks if we added all rectangles already and if so stops right there:
47 * @dontinclude eina_tiler_01.c
48 * @skip static Eina_Bool
49 * @until }
50 *
51 * Our function then clears all rectangles given to us by tiler from the last
52 * execution. It does this because each rectangle we add may change everything
53 * about the output of eina_tiler:
54 * @until output_rects_reset
55 *
56 * Next we get another rectangle, print it and show it in the input panel:
57 * @until add_input_rect
58 *
59 * We now come to the tiler stuff, we add our new rectangle to it and get a new
60 * iterator for the tiler:
61 * @until itr
62 *
63 * We now iterate over our tiler printing every rect it gives us and sowing it
64 * in the output panel:
65 * @until }
66 *
67 * We of course must remember to free our iterator and that's it for this
68 * function:
69 * @until }
70 *
71 * You should try many different inputs to see how the tiler works, here are a
72 * few suggestions:
73 * @li 100x100+0+0 100x100+200+200
74 * @li 100x100+0+0 100x100+5+5 100x100+10+10 100x100+15+15 100x100+20+20
75 * @li 100x100+0+0 100x100+100+100 100x100+200+0 100x100+0+200 100x100+200+200
76 * @li 10x10+0+0 10x10+10+10 10x10+20+0 10x10+0+20 10x10+20+20
77 *
78 * @example eina_tiler_01.c
79 */
80/**
81 * @addtogroup Eina_Data_Types_Group Data Types
82 *
83 * @{
84 */
85
86/**
87 * @defgroup Eina_Tiler_Group Tiler
88 *
89 * @warning This is a very low level tool, in most situations(for example if
90 * you're using evas) you won't need this.
91 *
92 * @section basic Basic usage
93 *
94 * Eina_Tiler is a tool to facilitate calculations of which areas are damaged
95 * and thus need to be re-rendered. The basic usage of Eina_Tiler is to give it
96 * the size of your canvas and a set of rectangular areas that need
97 * re-rendering, from that and using heuristics it'll tell you an efficient way
98 * to re-render in the form of a set of non-overlapping rectangles that covers
99 * the whole area that needs re-rendering.
100 *
101 * The following is pseudo-code showing some simple use of Eina_Tiler:
102 * @code
103 * tiler = eina_tiler_new(MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT);
104 * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering, l, rect)
105 * eina_tiler_add(tiler, rect);
106 * itr = eina_tiler_iterator_new(tiler);
107 * EINA_ITERATOR_FOREACH(itr, rect)
108 * my_function_that_repaints_areas_of_the_canvas(rect);
109 * @endcode
110 *
111 * @see eina_tiler_new()
112 * @see eina_tiler_rect_add()
113 * @see eina_tiler_iterator_new()
114 *
115 * @warning There are no guarantees that this will be the most efficient way to
116 * re-render for any particular case.
117 *
118 * @section grid_slicer Grid Slicer
119 *
120 * Grid slicer and Eina_Tiler are usually used together, that is however @b not
121 * nescessary, they can be used independently. Grid slicer provides an easy API
122 * to divide an area in tiles which is usefull in certain applications to divide
123 * the area that will be rendered into tiles. It's customary to, then create one
124 * Eina_Tiler for each tile.
125 *
126 * The following is pseudo-code showing a very simplified use of grid slicer
127 * together with Eina_Tiler:
128 * @code
129 * itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
130 * EINA_ITERATOR_FOREACH(itr, grid_info)
131 * {
132 * tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w);
133 * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering_in_this_tile, l, rect)
134 * eina_tiler_add(tiler, rect);
135 * itr = eina_tiler_iterator_new(tiler);
136 * EINA_ITERATOR_FOREACH(itr, rect)
137 * my_function_that_repaints_areas_of_the_canvas(rect);
138 * }
139 * @endcode
140 *
141 * @see eina_tiler_new()
142 * @see eina_tiler_rect_add()
143 * @see eina_tile_grid_slicer_setup()
144 * @see eina_tile_grid_slicer_next()
145 * @see eina_tile_grid_slicer_iterator_new()
146 *
147 * @{
148 */
149
150/**
151 * @typedef Eina_Tiler
152 * Tiler type.
153 */
154typedef struct _Eina_Tiler Eina_Tiler;
155
156/**
157 * @typedef Eina_Tile_Grid_Info
158 * Grid type of a tiler.
159 */
160typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info;
161
162/**
163 * @struct Eina_Tile_Grid_Info
164 * Grid type of a tiler.
165 */
166struct Eina_Tile_Grid_Info
167{
168 unsigned long col; /**< column of the tile grid */
169 unsigned long row; /**< row of the tile grid*/
170 Eina_Rectangle rect; /**< rectangle of the tile grid, coordinates are
171 relative to tile*/
172 Eina_Bool full; /**< whether the grid is full or not */
173};
174
175typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
176
177/**
178 * @brief Creates a new tiler with @p w width and @p h height.
179 *
180 * @param w Width of the tiler
181 * @param h Height of the tiler
182 * @return The newly created tiler
183 *
184 * @see eina_tiler_free()
185 */
186EAPI Eina_Tiler *eina_tiler_new(int w, int h);
187/**
188 * @brief Frees a tiler.
189 *
190 * @param t The tiler to free.
191 *
192 * This function frees @p t. It does not free the memory allocated for the
193 * elements of @p t.
194 */
195EAPI void eina_tiler_free(Eina_Tiler *t);
196/**
197 * @brief Sets the size of tiles for a tiler.
198 *
199 * @param t The tiler whose tile size will be set.
200 * @param w Width of the tiles.
201 * @param h Height of the tiles.
202 *
203 * @warning @p w and @p h @b must be greater than zero, otherwise tile size
204 * won't be changed.
205 * @warning Tile size is not used!
206 */
207EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
208/**
209 * @brief Adds a rectangle to a tiler.
210 *
211 * @param t The tiler in which to add a container.
212 * @param r The rectangle to be added.
213 *
214 * @see eina_tiler_rect_del()
215 */
216EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
217/**
218 * @brief Removes a rectangle from a tiler.
219 *
220 * @param t The tiler in which to add a container.
221 * @param r The rectangle to be removed.
222 *
223 * @see eina_tiler_rect_add()
224 * @see eina_tiler_clear()
225 */
226EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
227/**
228 * @brief Removes all rectangles from tiles.
229 *
230 * @param t The tiler to clear.
231 *
232 * @see eina_tiler_rect_del()
233 */
234EAPI void eina_tiler_clear(Eina_Tiler *t);
235/**
236 * @brief Create a iterator to access the tilers calculated rectangles.
237 *
238 * @param t The tiler to iterate over.
239 * @return A iterator containing Eina_Rectangle.
240 */
241EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
242
243/**
244 * @brief Creates a new Eina_Iterator that iterates over a list of tiles.
245 *
246 * @param x X axis coordinate.
247 * @param y Y axis coordinate.
248 * @param w width.
249 * @param h height.
250 * @param tile_w tile width.
251 * @param tile_h tile height.
252 * @return A pointer to the Eina_Iterator. @c NULL on failure.
253 *
254 * The region defined by @a x, @a y, @a w, @a h will be divided in to a grid of
255 * tiles of width @a tile_w and height @p tile_h, the returned iterator will
256 * iterate over every tile in the grid having as its data a
257 * #Eina_Tile_Grid_Info.
258 *
259 * @note This is a convinience function, iterating over the returned iterator is
260 * equivalent to calling eina_tile_grid_slicer_setup() and calling
261 * eina_tile_grid_slicer_next() untill it returns EINA_FALSE.
262 */
263EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
264/**
265 * @brief Iterates over the tiles set by eina_tile_grid_slicer_setup().
266 *
267 * @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
268 * @param rect Pointer to a struct Eina_Tile_Grid_Info *.
269 * @return @c EINA_TRUE if the current rect is valid.
270 * @c EINA_FALSE if there is no more rects to iterate over (and
271 * thus the current one isn't valid).
272 *
273 * This functions iterates over each Eina_Tile_Grid_Info *rect of the grid.
274 * eina_tile_grid_slicer_setup() must be called first, and *rect is only valid
275 * if this function returns EINA_TRUE. Its content shouldn't be modified.
276 *
277 * @note Consider using eina_tile_grid_slicer_iterator_new() instead.
278 */
279static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect);
280/**
281 * @brief Setup an Eina_Tile_Grid_Slicer struct.
282 *
283 * @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
284 * @param x X axis coordinate.
285 * @param y Y axis coordinate.
286 * @param w width.
287 * @param h height.
288 * @param tile_w tile width.
289 * @param tile_h tile height.
290 * @return A pointer to the Eina_Iterator. @c NULL on failure.
291 *
292 * The region defined by @a x, @a y, @a w, @a h will be divided in to a grid of
293 * tiles of width @a tile_w and height @p tile_h, @p slc can then be used with
294 * eina_tile_grid_slicer_next() to access each tile.
295 *
296 * @note Consider using eina_tile_grid_slicer_iterator_new() instead.
297 */
298static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h);
299
300#include "eina_inline_tiler.x"
301
302/**
303 * @}
304 */
305
306/**
307 * @}
308 */
309
310#endif /* EINA_TILER_H_ */
diff --git a/libraries/eina/src/include/eina_trash.h b/libraries/eina/src/include/eina_trash.h
deleted file mode 100644
index f53d99e..0000000
--- a/libraries/eina/src/include/eina_trash.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TRASH_H__
20#define EINA_TRASH_H__
21
22/**
23 * @addtogroup Eina_Data_Types_Group Data Types
24 *
25 * @{
26 */
27
28/**
29 * @addtogroup Eina_Containers_Group Containers
30 *
31 * @{
32 */
33
34/**
35 * @defgroup Eina_Trash_Group Trash
36 *
37 * @{
38 */
39
40/**
41 * @typedef Eina_Trash
42 * Type for a generic container of unused allocated pointer.
43 */
44typedef struct _Eina_Trash Eina_Trash;
45
46/**
47 * @struct _Eina_Trash
48 * Type for a generic container of unused allocated pointer.
49 */
50struct _Eina_Trash
51{
52 Eina_Trash *next; /**< next item in trash. */
53};
54
55static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
56static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
57static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
58
59/**
60 * @def EINA_TRASH_CLEAN
61 * @brief Macro to remove all pointer from the trash.
62 *
63 * @param trash The trash to clean.
64 * @param data The pointer extracted from the trash.
65 *
66 * This macro allow the cleaning of @p trash in an easy way. It will
67 * remove all pointers from @p trash until it's empty.
68 *
69 * This macro can be used for freeing the data in the trash, like in
70 * the following example:
71 *
72 * @code
73 * Eina_Trash *trash = NULL;
74 * char *data;
75 *
76 * // trash is filled with pointer to some duped strings.
77 *
78 * EINA_TRASH_CLEAN(&trash, data)
79 * free(data);
80 * @endcode
81 *
82 * @note this macro is useful when you implement some memory pool.
83 */
84#define EINA_TRASH_CLEAN(trash, data) while ((data = eina_trash_pop(trash)))
85
86#include "eina_inline_trash.x"
87
88/**
89 * @}
90 */
91
92/**
93 * @}
94 */
95
96/**
97 * @}
98 */
99
100#endif /* EINA_TRASH_H_ */
diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h
deleted file mode 100644
index b0a7cf8..0000000
--- a/libraries/eina/src/include/eina_types.h
+++ /dev/null
@@ -1,300 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TYPES_H_
20#define EINA_TYPES_H_
21
22/**
23 * @addtogroup Eina_Core_Group Core
24 *
25 * @{
26 */
27
28/**
29 * @defgroup Eina_Types_Group Types
30 *
31 * @{
32 */
33
34#ifdef EAPI
35# undef EAPI
36#endif
37
38#ifdef _WIN32
39# ifdef EFL_EINA_BUILD
40# ifdef DLL_EXPORT
41# define EAPI __declspec(dllexport)
42# else
43# define EAPI
44# endif /* ! DLL_EXPORT */
45# else
46# define EAPI __declspec(dllimport)
47# endif /* ! EFL_EINA_BUILD */
48#else
49# ifdef __GNUC__
50# if __GNUC__ >= 4
51# define EAPI __attribute__ ((visibility("default")))
52# else
53# define EAPI
54# endif
55# else
56# define EAPI
57# endif
58#endif
59
60#include "eina_config.h"
61
62#ifdef EINA_WARN_UNUSED_RESULT
63# undef EINA_WARN_UNUSED_RESULT
64#endif
65#ifdef EINA_ARG_NONNULL
66# undef EINA_ARG_NONNULL
67#endif
68#ifdef EINA_DEPRECATED
69# undef EINA_DEPRECATED
70#endif
71#ifdef EINA_MALLOC
72# undef EINA_MALLOC
73#endif
74#ifdef EINA_PURE
75# undef EINA_PURE
76#endif
77#ifdef EINA_PRINTF
78# undef EINA_PRINTF
79#endif
80#ifdef EINA_SCANF
81# undef EINA_SCANF
82#endif
83#ifdef EINA_FORMAT
84# undef EINA_FORMAT
85#endif
86#ifdef EINA_CONST
87# undef EINA_CONST
88#endif
89#ifdef EINA_NOINSTRUMENT
90# undef EINA_NOINSTRUMENT
91#endif
92#ifdef EINA_UNLIKELY
93# undef EINA_UNLIKELY
94#endif
95#ifdef EINA_LIKELY
96# undef EINA_LIKELY
97#endif
98
99#ifdef __GNUC__
100# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
101# define EINA_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
102# else
103# define EINA_WARN_UNUSED_RESULT
104# endif
105
106# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
107# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((__nonnull__(idx, ## __VA_ARGS__)))
108# else
109# define EINA_ARG_NONNULL(idx, ...)
110# endif
111
112# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
113# define EINA_DEPRECATED __attribute__ ((__deprecated__))
114# else
115# define EINA_DEPRECATED
116# endif
117
118# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
119# define EINA_MALLOC __attribute__ ((__malloc__))
120# define EINA_PURE __attribute__ ((__pure__))
121# else
122# define EINA_MALLOC
123# define EINA_PURE
124# endif
125
126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
127# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3)
128# define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__gnu_printf__, fmt, arg)))
129# else
130# define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__printf__, fmt, arg)))
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__))
136# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
137# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
138# else
139# define EINA_PRINTF(fmt, arg)
140# define EINA_SCANF(fmt, arg)
141# define EINA_FORMAT(fmt)
142# define EINA_CONST
143# define EINA_NOINSTRUMENT
144# define EINA_UNLIKELY(exp) exp
145# define EINA_LIKELY(exp) exp
146# endif
147
148#elif defined(_WIN32)
149# define EINA_WARN_UNUSED_RESULT
150# define EINA_ARG_NONNULL(idx, ...)
151# if defined(_MSC_VER) && _MSC_VER >= 1300
152# define EINA_DEPRECATED __declspec(deprecated)
153# else
154# define EINA_DEPRECATED
155# endif
156# define EINA_MALLOC
157# define EINA_PURE
158# define EINA_PRINTF(fmt, arg)
159# define EINA_SCANF(fmt, arg)
160# define EINA_FORMAT(fmt)
161# define EINA_CONST
162# define EINA_NOINSTRUMENT
163# define EINA_UNLIKELY(exp) exp
164# define EINA_LIKELY(exp) exp
165
166#elif defined(__SUNPRO_C)
167# define EINA_WARN_UNUSED_RESULT
168# define EINA_ARG_NONNULL(...)
169# define EINA_DEPRECATED
170# if __SUNPRO_C >= 0x590
171# define EINA_MALLOC __attribute__ ((malloc))
172# define EINA_PURE __attribute__ ((pure))
173# else
174# define EINA_MALLOC
175# define EINA_PURE
176# endif
177# define EINA_PRINTF(fmt, arg)
178# define EINA_SCANF(fmt, arg)
179# define EINA_FORMAT(fmt)
180# if __SUNPRO_C >= 0x590
181# define EINA_CONST __attribute__ ((const))
182# else
183# define EINA_CONST
184# endif
185# define EINA_NOINSTRUMENT
186# define EINA_UNLIKELY(exp) exp
187# define EINA_LIKELY(exp) exp
188
189#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
190
191/**
192 * @def EINA_WARN_UNUSED_RESULT
193 * Used to warn when the returned value of the function is not used.
194 */
195# define EINA_WARN_UNUSED_RESULT
196
197/**
198 * @def EINA_ARG_NONNULL
199 * Used to warn when the specified arguments of the function are @c NULL.
200 */
201# define EINA_ARG_NONNULL(idx, ...)
202
203/**
204 * @def EINA_DEPRECATED
205 * Used to warn when the function is considered as deprecated.
206 */
207# define EINA_DEPRECATED
208# define EINA_MALLOC
209# define EINA_PURE
210# define EINA_PRINTF(fmt, arg)
211# define EINA_SCANF(fmt, arg)
212# define EINA_FORMAT(fmt)
213# define EINA_CONST
214# define EINA_NOINSTRUMENT
215# define EINA_UNLIKELY(exp) exp
216# define EINA_LIKELY(exp) exp
217#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
218
219/**
220 * @typedef Eina_Bool
221 * Type to mimic a boolean.
222 *
223 * @note it differs from stdbool.h as this is defined as an unsigned
224 * char to make it usable by bitfields (Eina_Bool name:1) and
225 * also take as few bytes as possible.
226 */
227typedef unsigned char Eina_Bool;
228
229/**
230 * @def EINA_FALSE
231 * boolean value FALSE (numerical value 0)
232 */
233#define EINA_FALSE ((Eina_Bool)0)
234
235/**
236 * @def EINA_TRUE
237 * boolean value TRUE (numerical value 1)
238 */
239#define EINA_TRUE ((Eina_Bool)1)
240
241EAPI extern const unsigned int eina_prime_table[];
242
243/**
244 * @typedef Eina_Compare_Cb
245 * Function used in functions using sorting. It compares @p data1 and
246 * @p data2. If @p data1 is 'less' than @p data2, -1 must be returned,
247 * if it is 'greater', 1 must be returned, and if they are equal, 0
248 * must be returned.
249 */
250typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
251
252/**
253 * @def EINA_COMPARE_CB
254 * Macro to cast to Eina_Compare_Cb.
255 */
256#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
257
258/**
259 * @typedef Eina_Each_Cb
260 * A callback type used when iterating over a container.
261 */
262typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata);
263
264/**
265 * @def EINA_EACH_CB
266 * Macro to cast to Eina_Each.
267 */
268#define EINA_EACH_CB(Function) ((Eina_Each_Cb)Function)
269
270/**
271 * @typedef Eina_Free_Cb
272 * A callback type used to free data when iterating over a container.
273 */
274typedef void (*Eina_Free_Cb)(void *data);
275
276/**
277 * @def EINA_FREE_CB
278 * Macro to cast to Eina_Free_Cb.
279 */
280#define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function)
281
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/**
293 * @}
294 */
295
296/**
297 * @}
298 */
299
300#endif /* EINA_TYPES_H_ */
diff --git a/libraries/eina/src/include/eina_unicode.h b/libraries/eina/src/include/eina_unicode.h
deleted file mode 100644
index 2bbfe45..0000000
--- a/libraries/eina/src/include/eina_unicode.h
+++ /dev/null
@@ -1,186 +0,0 @@
1#ifndef EINA_UNICODE_H
2#define EINA_UNICODE_H
3
4#include <stdlib.h>
5
6#include "eina_config.h"
7#include "eina_types.h"
8
9/**
10 * @addtogroup Eina_Data_Types_Group Data Types
11 *
12 * @{
13 */
14/**
15 * @addtogroup Eina_Unicode_String Unicode String
16 *
17 * @brief These functions provide basic unicode string handling
18 *
19 * Eina_Unicode is a type that holds unicode codepoints.
20 *
21 * @{
22 */
23
24/**
25 * @typedef Eina_Unicode
26 * A type that holds Unicode codepoints.
27 */
28#if EINA_SIZEOF_WCHAR_T >= 4
29# include <wchar.h>
30typedef wchar_t Eina_Unicode;
31#elif defined(EINA_HAVE_INTTYPES_H)
32# include <inttypes.h>
33typedef uint32_t Eina_Unicode;
34#elif defined(EINA_HAVE_STDINT_H)
35# include <stdint.h>
36typedef uint32_t Eina_Unicode;
37#else
38/* Hope that int is big enough */
39typedef unsigned int Eina_Unicode;
40#endif
41
42
43/**
44 * @brief Same as the standard strlen just with Eina_Unicode instead of char.
45 */
46EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
47
48EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
49
50/**
51 * @brief Returns the length of a Eina_Unicode string, up to a limit.
52 *
53 * This function returns the number of characters in string, up to a maximum
54 * of n. If the terminating character is not found in the string, it returns
55 * n.
56 *
57 * @param ustr String to search
58 * @param n Max length to search
59 * @return Number of characters or n.
60 */
61EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
62
63
64/**
65 * @brief Same as the standard strdup just with Eina_Unicode instead of char.
66 */
67EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
68
69
70/**
71 * @brief Same as strdup but cuts on the given size. Assumes n < len
72 *
73 * @param text The text to duplicate.
74 * @param n The maximum size of the text to duplicate.
75 * @return The duplicated string.
76 *
77 * This function duplicates @p text. The resuting string is cut on @p
78 * n. @p n is assumed to be lesser (<) than the length of @p
79 * text. When not needed anymore, the returned string must be freed.
80 *
81 * @since 1.1.0
82 */
83EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
84
85
86/**
87 * @brief Same as the standard strcmp just with Eina_Unicode instead of char.
88 */
89EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
90
91
92/**
93 * @brief Same as the standard strcpy just with Eina_Unicode instead of char.
94 */
95EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source) EINA_ARG_NONNULL(1, 2);
96
97
98/**
99 * @brief Same as the standard strstr just with Eina_Unicode instead of char.
100 */
101EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
102
103
104/**
105 * @brief Same as the standard strncpy just with Eina_Unicode instead of char.
106 */
107EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n) EINA_ARG_NONNULL(1, 2);
108
109
110/**
111 * @see eina_str_escape()
112 */
113EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
114
115/* UTF-8 Handling */
116
117
118/**
119 * Reads UTF8 bytes from @p buf, starting at @p iindex and returns
120 * the decoded code point at @p iindex offset, and advances @p iindex
121 * to the next code point after this. @p iindex is always advanced,
122 * unless if the advancement is after the NULL.
123 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
124 * are the byte's value.
125 *
126 * @param buf the string
127 * @param iindex the index to look at and return by.
128 * @return the codepoint found.
129 * @since 1.1.0
130 */
131EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2);
132
133/**
134 * Reads UTF8 bytes from @p buf, starting at @p iindex and returns
135 * the decoded code point at @p iindex offset, and moves Ă p iindex
136 * to the previous code point. @p iindex is always moved, as long
137 * as it's not past the start of the string.
138 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
139 * are the byte's value.
140 *
141 * @param buf the string
142 * @param iindex the index to look at and return by.
143 * @return the codepoint found.
144 * @since 1.1.0
145 */
146EAPI Eina_Unicode eina_unicode_utf8_get_prev(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2);
147
148/**
149 * Returns the number of unicode characters in the string. That is,
150 * the number of Eina_Unicodes it'll take to store this string in
151 * an Eina_Unicode string.
152 *
153 * @param buf the string
154 * @return the number of unicode characters (not bytes) in the string
155 * @since 1.1.0
156 */
157EAPI int eina_unicode_utf8_get_len(const char *buf) EINA_ARG_NONNULL(1);
158
159/**
160 * Converts a utf-8 string to a newly allocated Eina_Unicode string.
161 *
162 * @param utf the string in utf-8
163 * @param _len the length of the returned Eina_Unicode string.
164 * @return the newly allocated Eina_Unicode string.
165 * @since 1.1.0
166 */
167EAPI Eina_Unicode *eina_unicode_utf8_to_unicode(const char *utf, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
168
169/**
170 * Converts an Eina_Unicode string to a newly allocated utf-8 string.
171 *
172 * @param uni the Eina_Unicode string
173 * @param _len the length byte length of the return utf8 string.
174 * @return the newly allocated utf-8 string.
175 * @since 1.1.0
176 */
177EAPI char * eina_unicode_unicode_to_utf8(const Eina_Unicode *uni, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
178
179/**
180 * @}
181 */
182/**
183 * @}
184 */
185
186#endif
diff --git a/libraries/eina/src/include/eina_ustrbuf.h b/libraries/eina/src/include/eina_ustrbuf.h
deleted file mode 100644
index 9710c42..0000000
--- a/libraries/eina/src/include/eina_ustrbuf.h
+++ /dev/null
@@ -1,464 +0,0 @@
1#ifndef EINA_USTRBUF_H
2#define EINA_USTRBUF_H
3
4#include <stddef.h>
5
6#include "eina_types.h"
7#include "eina_unicode.h"
8
9/**
10 * @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
11 *
12 * @brief These functions provide unicode string buffers management.
13 *
14 * The Unicode String Buffer data type is designed to be a mutable string,
15 * allowing to append, prepend or insert a string to a buffer.
16 */
17
18/**
19 * @addtogroup Eina_Data_Types_Group Data Types
20 *
21 * @{
22 */
23
24/**
25 * @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_UStrbuf
32 * Type for a string buffer.
33 */
34typedef struct _Eina_Strbuf Eina_UStrbuf;
35
36/**
37 * @brief Create a new string buffer.
38 *
39 * @return Newly allocated string buffer instance.
40 *
41 * This function creates a new string buffer. On error, @c NULL is
42 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
43 * free the resources, use eina_ustrbuf_free().
44 *
45 * @see eina_ustrbuf_free()
46 * @see eina_ustrbuf_append()
47 * @see eina_ustrbuf_string_get()
48 */
49EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
50
51/**
52 * @brief Create a new string buffer using the passed string. The passed
53 * string is used directly as the buffer, it's somehow the opposite function of
54 * @ref eina_ustrbuf_string_steal . The passed string must be malloced.
55 *
56 * @param str the string to manage
57 * @return Newly allocated string buffer instance.
58 *
59 * This function creates a new string buffer. On error, @c NULL is
60 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
61 * free the resources, use eina_strbuf_free().
62 *
63 * @see eina_ustrbuf_free()
64 * @see eina_ustrbuf_append()
65 * @see eina_ustrbuf_string_get()
66 * @since 1.1.0
67 */
68EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
69
70/**
71 * @brief Create a new string buffer using the passed string. The passed
72 * string is used directly as the buffer, it's somehow the opposite function of
73 * @ref eina_ustrbuf_string_steal . The passed string must be malloced.
74 *
75 * @param str the string to manage
76 * @param length the length of the string.
77 * @return Newly allocated string buffer instance.
78 *
79 * This function creates a new string buffer. On error, @c NULL is
80 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
81 * free the resources, use eina_ustrbuf_free().
82 *
83 * @see eina_ustrbuf_manage_new()
84 * @since 1.2.0
85 */
86EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
87
88/**
89 * @brief Free a string buffer.
90 *
91 * @param buf The string buffer to free.
92 *
93 * This function frees the memory of @p buf. @p buf must have been
94 * created by eina_ustrbuf_new().
95 */
96EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
97
98/**
99 * @brief Reset a string buffer.
100 *
101 * @param buf The string buffer to reset.
102 *
103 * This function reset @p buf: the buffer len is set to 0, and the
104 * string is set to '\\0'. No memory is free'd.
105 */
106EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
107
108/**
109 * @brief Append a string to a buffer, reallocating as necessary.
110 *
111 * @param buf The string buffer to append to.
112 * @param str The string to append.
113 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
114 *
115 * This function appends @p str to @p buf. It computes the length of
116 * @p str, so is slightly slower than eina_ustrbuf_append_length(). If
117 * the length is known beforehand, consider using that variant. If
118 * @p buf can't append it, #EINA_FALSE is returned, otherwise
119 * #EINA_TRUE is returned.
120 *
121 * @see eina_ustrbuf_append()
122 * @see eina_ustrbuf_append_length()
123 */
124EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
125
126/**
127 * @brief Append an escaped string to a buffer, reallocating as necessary.
128 *
129 * @param buf The string buffer to append to.
130 * @param str The string to append.
131 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
132 *
133 * This function appends the escaped string @p str to @p buf. If @p
134 * str can not be appended, #EINA_FALSE is returned, otherwise,
135 * #EINA_TRUE is returned.
136 */
137EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
138
139/**
140 * @brief Append a string to a buffer, reallocating as necessary,
141 * limited by the given length.
142 *
143 * @param buf The string buffer to append to.
144 * @param str The string to append.
145 * @param maxlen The maximum number of characters to append.
146 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
147 *
148 * This function appends at most @p maxlen characters of @p str to
149 * @p buf. It can't appends more than the length of @p str. It
150 * computes the length of @p str, so is slightly slower than
151 * eina_ustrbuf_append_length(). If the length is known beforehand,
152 * consider using that variant (@p maxlen should then be checked so
153 * that it is greater than the size of @p str). If @p str can not be
154 * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
155 * returned.
156 *
157 * @see eina_ustrbuf_append()
158 * @see eina_ustrbuf_append_length()
159 */
160EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
161
162/**
163 * @brief Append a string of exact length to a buffer, reallocating as necessary.
164 *
165 * @param buf The string buffer to append to.
166 * @param str The string to append.
167 * @param length The exact length to use.
168 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
169 *
170 * This function appends @p str to @p buf. @p str must be of size at
171 * most @p length. It is slightly faster than eina_ustrbuf_append() as
172 * it does not compute the size of @p str. It is useful when dealing
173 * with strings of known size, such as eina_strngshare. If @p buf
174 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
175 * returned.
176 *
177 * @see eina_stringshare_length()
178 * @see eina_ustrbuf_append()
179 * @see eina_ustrbuf_append_n()
180 */
181EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2);
182
183/**
184 * @brief Append a character to a string buffer, reallocating as
185 * necessary.
186 *
187 * @param buf The string buffer to append to.
188 * @param c The char to append.
189 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
190 *
191 * This function inserts @p c to @p buf. If it can not insert it,
192 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
193 */
194EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1);
195
196/**
197 * @brief Insert a string to a buffer, reallocating as necessary.
198 *
199 * @param buf The string buffer to insert.
200 * @param str The string to insert.
201 * @param pos The position to insert the string.
202 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
203 *
204 * This function inserts @p str to @p buf at position @p pos. It
205 * computes the length of @p str, so is slightly slower than
206 * eina_ustrbuf_insert_length(). If the length is known beforehand,
207 * consider using that variant. If @p buf can't insert it, #EINA_FALSE
208 * is returned, otherwise #EINA_TRUE is returned.
209 */
210EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
211
212/**
213 * @brief Insert an escaped string to a buffer, reallocating as
214 * necessary.
215 *
216 * @param buf The string buffer to insert to.
217 * @param str The string to insert.
218 * @param pos The position to insert the string.
219 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
220 *
221 * This function inserts the escaped string @p str to @p buf at
222 * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
223 * returned, otherwise #EINA_TRUE is returned.
224 */
225EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
226
227/**
228 * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
229 *
230 * @param buf The string buffer to insert to.
231 * @param str The string to insert.
232 * @param maxlen The maximum number of chars to insert.
233 * @param pos The position to insert the string.
234 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
235 *
236 * This function inserts @p str ot @p buf at position @p pos, with at
237 * most @p maxlen bytes. The number of inserted characters can not be
238 * greater than the length of @p str. It computes the length of
239 * @p str, so is slightly slower than eina_ustrbuf_insert_length(). If the
240 * length is known beforehand, consider using that variant (@p maxlen
241 * should then be checked so that it is greater than the size of
242 * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
243 * otherwise, #EINA_TRUE is returned.
244 */
245EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
246
247/**
248 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
249 *
250 * @param buf The string buffer to insert to.
251 * @param str The string to insert.
252 * @param length The exact length to use.
253 * @param pos The position to insert the string.
254 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
255 *
256 * This function inserts @p str to @p buf. @p str must be of size at
257 * most @p length. It is slightly faster than eina_ustrbuf_insert() as
258 * it does not compute the size of @p str. It is useful when dealing
259 * with strings of known size, such as eina_strngshare. If @p buf
260 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
261 * returned.
262 *
263 * @see eina_stringshare_length()
264 * @see eina_ustrbuf_insert()
265 * @see eina_ustrbuf_insert_n()
266 */
267EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
268
269/**
270 * @brief Insert a character to a string buffer, reallocating as
271 * necessary.
272 *
273 * @param buf The string buffer to insert to.
274 * @param c The char to insert.
275 * @param pos The position to insert the char.
276 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
277 *
278 * This function inserts @p c to @p buf at position @p pos. If @p buf
279 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
280 * returned.
281 */
282EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1);
283
284/**
285 * @def eina_ustrbuf_prepend(buf, str)
286 * @brief Prepend the given string to the given buffer
287 *
288 * @param buf The string buffer to prepend to.
289 * @param str The string to prepend.
290 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
291 *
292 * This macro is calling eina_ustrbuf_insert() at position 0.If @p buf
293 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
294 * returned.
295 */
296#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0)
297
298/**
299 * @def eina_ustrbuf_prepend_escaped(buf, str)
300 * @brief Prepend the given escaped string to the given buffer
301 *
302 * @param buf The string buffer to prepend to.
303 * @param str The string to prepend.
304 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
305 *
306 * This macro is calling eina_ustrbuf_insert_escaped() at position 0. If
307 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
308 * #EINA_TRUE is returned.
309 */
310#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0)
311
312/**
313 * @def eina_ustrbuf_prepend_n(buf, str)
314 * @brief Prepend the given escaped string to the given buffer
315 *
316 * @param buf The string buffer to prepend to.
317 * @param str The string to prepend.
318 * @param maxlen The maximum number of Eina_Unicode *s to prepend.
319 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
320 *
321 * This macro is calling eina_ustrbuf_insert_n() at position 0. If
322 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
323 * #EINA_TRUE is returned.
324 */
325#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0)
326
327/**
328 * @def eina_ustrbuf_prepend_length(buf, str)
329 * @brief Prepend the given escaped string to the given buffer
330 *
331 * @param buf The string buffer to prepend to.
332 * @param str The string to prepend.
333 * @param length The exact length to use.
334 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
335 *
336 * This macro is calling eina_ustrbuf_insert_length() at position 0. If
337 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
338 * #EINA_TRUE is returned.
339 */
340#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0)
341
342/**
343 * @def eina_ustrbuf_prepend_char(buf, c)
344 * @brief Prepend the given unicode character to the given buffer
345 *
346 * @param buf The string buffer to prepend to.
347 * @param c The Eina_Unicode character to prepend.
348 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
349 *
350 * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0. If
351 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
352 * #EINA_TRUE is returned.
353 */
354#define eina_ustrbuf_prepend_char(buf, c) eina_ustrbuf_insert_char(buf, c, 0)
355
356/**
357 * @def eina_ustrbuf_prepend_printf(buf, fmt, ...)
358 * @brief Prepend the given string to the given buffer
359 *
360 * @param buf The string buffer to prepend to.
361 * @param fmt The string to prepend.
362 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
363 *
364 * This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p buf
365 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
366 * returned.
367 */
368#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
369
370/**
371 * @def eina_ustrbuf_prepend_vprintf(buf, fmt, args)
372 * @brief Prepend the given string to the given buffer
373 *
374 * @param buf The string buffer to prepend to.
375 * @param fmt The string to prepend.
376 * @param args The variable arguments.
377 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
378 *
379 * This macro is calling eina_ustrbuf_insert_vprintf() at position 0.If @p buf
380 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
381 * returned.
382 */
383#define eina_ustrbuf_prepend_vprintf(buf, fmt, args) eina_ustrbuf_insert_vprintf(buf, fmt, 0, args)
384
385/**
386 * @brief Remove a slice of the given string buffer.
387 *
388 * @param buf The string buffer to remove a slice.
389 * @param start The initial (inclusive) slice position to start
390 * removing, in bytes.
391 * @param end The final (non-inclusive) slice position to finish
392 * removing, in bytes.
393 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
394 *
395 * This function removes a slice of @p buf, starting at @p start
396 * (inclusive) and ending at @p end (non-inclusive). Both values are
397 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
398 */
399EAPI Eina_Bool
400eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
401
402/**
403 * @brief Retrieve a pointer to the contents of a string buffer
404 *
405 * @param buf The string buffer.
406 * @return The current string in the string buffer.
407 *
408 * This function returns the string contained in @p buf. The returned
409 * value must not be modified and will no longer be valid if @p buf is
410 * modified. In other words, any eina_ustrbuf_append() or similar will
411 * make that pointer invalid.
412 *
413 * @see eina_ustrbuf_string_steal()
414 */
415EAPI const Eina_Unicode *
416eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
417
418/**
419 * @brief Steal the contents of a string buffer.
420 *
421 * @param buf The string buffer to steal.
422 * @return The current string in the string buffer.
423 *
424 * This function returns the string contained in @p buf. @p buf is
425 * then initialized and does not own the returned string anymore. The
426 * caller must release the memory of the returned string by calling
427 * free().
428 *
429 * @see eina_ustrbuf_string_get()
430 */
431EAPI Eina_Unicode *
432eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
433
434/**
435 * @brief Free the contents of a string buffer but not the buffer.
436 *
437 * @param buf The string buffer to free the string of.
438 *
439 * This function frees the string contained in @p buf without freeing
440 * @p buf.
441 */
442EAPI void
443eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
444
445/**
446 * @brief Retrieve the length of the string buffer content.
447 *
448 * @param buf The string buffer.
449 * @return The current length of the string, in bytes.
450 *
451 * This function returns the length of @p buf.
452 */
453EAPI size_t
454eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
455
456/**
457 * @}
458 */
459
460/**
461 * @}
462 */
463
464#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_ustringshare.h b/libraries/eina/src/include/eina_ustringshare.h
deleted file mode 100644
index 1036573..0000000
--- a/libraries/eina/src/include/eina_ustringshare.h
+++ /dev/null
@@ -1,200 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_USTRINGSHARE_H_
52#define EINA_USTRINGSHARE_H_
53
54#include "eina_types.h"
55#include "eina_unicode.h"
56
57/**
58 * @addtogroup Eina_UStringshare_Group Unicode Stringshare
59 *
60 * These functions allow you to store one copy of a string, and use it
61 * throughout your program.
62 *
63 * This is a method to reduce the number of duplicated strings kept in
64 * memory. It's pretty common for the same strings to be dynamically
65 * allocated repeatedly between applications and libraries, especially in
66 * circumstances where you could have multiple copies of a structure that
67 * allocates the string. So rather than duplicating and freeing these
68 * strings, you request a read-only pointer to an existing string and
69 * only incur the overhead of a hash lookup.
70 *
71 * It sounds like micro-optimizing, but profiling has shown this can have
72 * a significant impact as you scale the number of copies up. It improves
73 * string creation/destruction speed, reduces memory use and decreases
74 * memory fragmentation, so a win all-around.
75 *
76 * For more information, you can look at the @ref tutorial_ustringshare_page.
77 */
78
79/**
80 * @addtogroup Eina_Data_Types_Group Data Types
81 *
82 * @{
83 */
84
85/**
86 * @defgroup Eina_UStringshare_Group Unicode Stringshare
87 *
88 * @{
89 */
90
91
92/**
93 * @brief Retrieve an instance of a string for use in a program.
94 *
95 * @param str The string to retrieve an instance of.
96 * @param slen The string size (<= strlen(str)).
97 * @return A pointer to an instance of the string on success.
98 * @c NULL on failure.
99 *
100 * This function retrieves an instance of @p str. If @p str is
101 * @c NULL, then @c NULL is returned. If @p str is already stored, it
102 * is just returned and its reference counter is increased. Otherwise
103 * it is added to the strings to be searched and a duplicated string
104 * of @p str is returned.
105 *
106 * This function does not check string size, but uses the
107 * exact given size. This can be used to share_common part of a larger
108 * buffer or substring.
109 *
110 * @see eina_ustringshare_add()
111 */
112EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
113
114/**
115 * @brief Retrieve an instance of a string for use in a program.
116 *
117 * @param str The NULL terminated string to retrieve an instance of.
118 * @return A pointer to an instance of the string on success.
119 * @c NULL on failure.
120 *
121 * This function retrieves an instance of @p str. If @p str is
122 * @c NULL, then @c NULL is returned. If @p str is already stored, it
123 * is just returned and its reference counter is increased. Otherwise
124 * it is added to the strings to be searched and a duplicated string
125 * of @p str is returned.
126 *
127 * The string @p str must be NULL terminated ('@\0') and its full
128 * length will be used. To use part of the string or non-null
129 * terminated, use eina_stringshare_add_length() instead.
130 *
131 * @see eina_ustringshare_add_length()
132 */
133EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT;
134
135/**
136 * Increment references of the given shared string.
137 *
138 * @param str The shared string.
139 * @return A pointer to an instance of the string on success.
140 * @c NULL on failure.
141 *
142 * This is similar to eina_share_common_add(), but it's faster since it will
143 * avoid lookups if possible, but on the down side it requires the parameter
144 * to be shared before, in other words, it must be the return of a previous
145 * eina_ustringshare_add().
146 *
147 * There is no unref since this is the work of eina_ustringshare_del().
148 */
149EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
150
151/**
152 * @brief Note that the given string has lost an instance.
153 *
154 * @param str string The given string.
155 *
156 * This function decreases the reference counter associated to @p str
157 * if it exists. If that counter reaches 0, the memory associated to
158 * @p str is freed. If @p str is NULL, the function returns
159 * immediately.
160 *
161 * Note that if the given pointer is not shared or NULL, bad things
162 * will happen, likely a segmentation fault.
163 */
164EAPI void eina_ustringshare_del(const Eina_Unicode *str);
165
166/**
167 * @brief Note that the given string @b must be shared.
168 *
169 * @param str the shared string to know the length. It is safe to
170 * give NULL, in that case -1 is returned.
171 *
172 * This function is a cheap way to known the length of a shared
173 * string. Note that if the given pointer is not shared, bad
174 * things will happen, likely a segmentation fault. If in doubt, try
175 * strlen().
176 */
177EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
178
179/**
180 * @brief Dump the contents of the share_common.
181 *
182 * This function dumps all strings in the share_common to stdout with a
183 * DDD: prefix per line and a memory usage summary.
184 */
185EAPI void eina_ustringshare_dump(void);
186
187static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
188static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1);
189
190#include "eina_inline_ustringshare.x"
191
192/**
193 * @}
194 */
195
196/**
197 * @}
198 */
199
200#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_value.h b/libraries/eina/src/include/eina_value.h
deleted file mode 100644
index 341781f..0000000
--- a/libraries/eina/src/include/eina_value.h
+++ /dev/null
@@ -1,3533 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_VALUE_H_
20#define EINA_VALUE_H_
21
22#include <stdarg.h>
23
24#include "eina_types.h"
25#include "eina_fp.h" /* defines int64_t and uint64_t */
26#include "eina_inarray.h"
27#include "eina_list.h"
28#include "eina_hash.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 */
260
261/**
262 * @addtogroup Eina_Data_Types_Group Data Types
263 *
264 * @since 1.2
265 *
266 * @{
267 */
268
269/**
270 * @addtogroup Eina_Containers_Group Containers
271 *
272 * @{
273 */
274
275/**
276 * @defgroup Eina_Value_Group Generic Value Storage
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 *
296 * @{
297 */
298
299
300/**
301 * @typedef Eina_Value
302 * Store generic values.
303 *
304 * @since 1.2
305 */
306typedef struct _Eina_Value Eina_Value;
307
308/**
309 * @typedef Eina_Value_Type
310 * Describes the data contained by the value
311 *
312 * @since 1.2
313 */
314typedef struct _Eina_Value_Type Eina_Value_Type;
315
316/**
317 * @typedef Eina_Value_Union
318 * Union of all known value types.
319 *
320 * This is only used to specify the minimum payload memory for #Eina_Value.
321 *
322 * @internal
323 * @since 1.2
324 */
325typedef union _Eina_Value_Union Eina_Value_Union;
326
327/**
328 * @union _Eina_Value_Union
329 * All possible value types.
330 *
331 * This is only used to specify the minimum payload memory for #Eina_Value.
332 *
333 * @internal
334 * @since 1.2
335 */
336union _Eina_Value_Union
337{
338 unsigned char buf[8]; /**< just hold 8-bytes, more goes into ptr */
339 void *ptr; /**< used as generic pointer */
340 uint64_t _guarantee; /**< guarantees 8-byte alignment */
341};
342
343/**
344 * @var EINA_VALUE_TYPE_UCHAR
345 * manages unsigned char type.
346 *
347 * @since 1.2
348 */
349EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR;
350
351/**
352 * @var EINA_VALUE_TYPE_USHORT
353 * manages unsigned short type.
354 *
355 * @since 1.2
356 */
357EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_USHORT;
358
359/**
360 * @var EINA_VALUE_TYPE_UINT
361 * manages unsigned int type.
362 *
363 * @since 1.2
364 */
365EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT;
366
367/**
368 * @var EINA_VALUE_TYPE_ULONG
369 * manages unsigned long type.
370 *
371 * @since 1.2
372 */
373EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG;
374
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/**
385 * @var EINA_VALUE_TYPE_UINT64
386 * manages unsigned integer of 64 bits type.
387 *
388 * @since 1.2
389 */
390EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT64;
391
392/**
393 * @var EINA_VALUE_TYPE_CHAR
394 * manages char type.
395 *
396 * @since 1.2
397 */
398EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_CHAR;
399
400/**
401 * @var EINA_VALUE_TYPE_SHORT
402 * manages short type.
403 *
404 * @since 1.2
405 */
406EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_SHORT;
407
408/**
409 * @var EINA_VALUE_TYPE_INT
410 * manages int type.
411 *
412 * @since 1.2
413 */
414EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT;
415
416/**
417 * @var EINA_VALUE_TYPE_LONG
418 * manages long type.
419 *
420 * @since 1.2
421 */
422EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LONG;
423
424/**
425 * @var EINA_VALUE_TYPE_INT64
426 * manages integer of 64 bits type.
427 *
428 * @since 1.2
429 */
430EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT64;
431
432/**
433 * @var EINA_VALUE_TYPE_FLOAT
434 * manages float type.
435 *
436 * @since 1.2
437 */
438EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT;
439
440/**
441 * @var EINA_VALUE_TYPE_DOUBLE
442 * manages double type.
443 *
444 * @since 1.2
445 */
446EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE;
447
448/**
449 * @var EINA_VALUE_TYPE_STRINGSHARE
450 * manages stringshared string type.
451 *
452 * @since 1.2
453 */
454EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE;
455
456/**
457 * @var EINA_VALUE_TYPE_STRING
458 * manages string type.
459 *
460 * @since 1.2
461 */
462EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING;
463
464
465/**
466 * @var EINA_VALUE_TYPE_ARRAY
467 *
468 * manages array type. Use the value get/set for arrays:
469 * @li eina_value_array_get() and eina_value_array_set()
470 * @li eina_value_array_vget() and eina_value_array_vset()
471 * @li eina_value_array_pget() and eina_value_array_pset()
472 *
473 * eina_value_set() takes an #Eina_Value_Array where just @c subtype
474 * and @c step are used. If there is an @c array, it will be copied
475 * (including each item) and its contents must be properly
476 * configurable as @c subtype expects. eina_value_pset() takes a
477 * pointer to an #Eina_Value_Array. For your convenience, use
478 * eina_value_array_setup().
479 *
480 * eina_value_get() and eina_value_pget() takes a pointer to
481 * #Eina_Value_Array, it's an exact copy of the current structure in
482 * use by value, no copies are done.
483 *
484 * @since 1.2
485 */
486EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY;
487
488/**
489 * @var EINA_VALUE_TYPE_LIST
490 *
491 * manages list type. Use the value get/set for lists:
492 * @li eina_value_list_get() and eina_value_list_set()
493 * @li eina_value_list_vget() and eina_value_list_vset()
494 * @li eina_value_list_pget() and eina_value_list_pset()
495 *
496 * eina_value_set() takes an #Eina_Value_List where just @c subtype is
497 * used. If there is an @c list, it will be copied (including each
498 * item) and its contents must be properly configurable as @c
499 * subtype expects. eina_value_pset() takes a pointer to an
500 * #Eina_Value_List. For your convenience, use
501 * eina_value_list_setup().
502 *
503 * eina_value_get() and eina_value_pget() takes a pointer to
504 * #Eina_Value_List, it's an exact copy of the current structure in
505 * use by value, no copies are done.
506 *
507 * @since 1.2
508 */
509EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST;
510
511/**
512 * @var EINA_VALUE_TYPE_HASH
513 *
514 * manages hash type. Use the value get/set for hashes:
515 * @li eina_value_hash_get() and eina_value_hash_set()
516 * @li eina_value_hash_vget() and eina_value_hash_vset()
517 * @li eina_value_hash_pget() and eina_value_hash_pset()
518 *
519 * eina_value_set() takes an #Eina_Value_Hash where just @c subtype
520 * and @c buckets_power_size are used. If there is an @c hash, it will
521 * be copied (including each item) and its contents must be
522 * properly configurable as @c subtype expects. eina_value_pset()
523 * takes a pointer to an #Eina_Value_Hash. For your convenience, use
524 * eina_value_hash_setup().
525 *
526 * eina_value_get() and eina_value_pget() takes a pointer to
527 * #Eina_Value_Hash, it's an exact copy of the current structure in
528 * use by value, no copies are done.
529 *
530 * @note be aware that hash data is always an allocated memory of size
531 * defined by @c subtype->value_size. If your @c subtype is an
532 * integer, add as data malloc(sizeof(int)). If your @c subtype
533 * is an string, add as data malloc(sizeof(char*)) and this data
534 * value must point to strdup(string)!
535 *
536 * @since 1.2
537 */
538EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_HASH;
539
540/**
541 * @var EINA_VALUE_TYPE_TIMEVAL
542 * manages 'struct timeval' type
543 *
544 * eina_value_set() takes a "struct timeval" from sys/time.h.
545 * eina_value_pset() takes a pointer to "struct timeval".
546 *
547 * eina_value_get() and eina_value_pget() takes a pointer to "struct
548 * timeval" and it's an exact copy of value.
549 *
550 * @since 1.2
551 */
552EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL;
553
554/**
555 * @var EINA_VALUE_TYPE_BLOB
556 * manages blob of bytes type, see @ref Eina_Value_Blob
557 *
558 * eina_value_set() takes an #Eina_Value_Blob
559 * eina_value_pset() takes a pointer to #Eina_Value_Blob.
560 *
561 * eina_value_get() and eina_value_pget() takes a pointer to
562 * #Eina_Value_Blob and it's an exact copy of value, no allocations
563 * are made.
564 *
565 * Memory is untouched unless you provide @c ops (operations) pointer.
566 *
567 * @since 1.2
568 */
569EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB;
570
571/**
572 * @var EINA_VALUE_TYPE_STRUCT
573 *
574 * manages struct type. Use the value get/set for structs:
575 * @li eina_value_struct_get() and eina_value_struct_set()
576 * @li eina_value_struct_vget() and eina_value_struct_vset()
577 * @li eina_value_struct_pget() and eina_value_struct_pset()
578 *
579 * eina_value_set() takes an #Eina_Value_Struct where just @c desc is
580 * used. If there is an @c memory, it will be copied (including each
581 * member) and its contents must be properly configurable as @c desc
582 * expects. eina_value_pset() takes a pointer to an
583 * #Eina_Value_Struct. For your convenience, use
584 * eina_value_struct_setup().
585 *
586 * eina_value_get() and eina_value_pget() takes a pointer to
587 * #Eina_Value_Struct, it's an exact copy of the current structure in
588 * use by value, no copies are done.
589 *
590 * @since 1.2
591 */
592EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT;
593
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/**
612 * @var EINA_ERROR_VALUE_FAILED
613 * Error identifier corresponding to value check failure.
614 *
615 * @since 1.2
616 */
617EAPI extern int EINA_ERROR_VALUE_FAILED;
618
619/**
620 * @defgroup Eina_Value_Value_Group Generic Value management
621 *
622 * @{
623 */
624
625/**
626 * @struct _Eina_Value
627 * defines the contents of a value
628 *
629 * @since 1.2
630 */
631struct _Eina_Value
632{
633 const Eina_Value_Type *type; /**< how to access values */
634 Eina_Value_Union value; /**< to be accessed with type descriptor */
635};
636
637/**
638 * @brief Create generic value storage.
639 * @param type how to manage this value.
640 * @return The new value or @c NULL on failure.
641 *
642 * Create a new generic value storage. The members are managed using
643 * the description specified by @a type.
644 *
645 * Some types may specify more operations:
646 * eg. #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(),
647 * eina_value_array_get() and so on.
648 *
649 * On failure, @c NULL is returned and either #EINA_ERROR_OUT_OF_MEMORY or
650 * #EINA_ERROR_VALUE_FAILED is set.
651 *
652 * @note this calls creates from mempool and then uses
653 * eina_value_setup(). Consider using eina_value_flush() and
654 * eina_value_setup() instead to avoid memory allocations.
655 *
656 * @see eina_value_free()
657 *
658 * @since 1.2
659 */
660EAPI Eina_Value *eina_value_new(const Eina_Value_Type *type) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
661
662/**
663 * @brief Free value and its data.
664 * @param value value object
665 *
666 * @see eina_value_flush()
667 *
668 * @since 1.2
669 */
670EAPI void eina_value_free(Eina_Value *value) EINA_ARG_NONNULL(1);
671
672
673/**
674 * @brief Initialize generic value storage.
675 * @param value value object
676 * @param type how to manage this value.
677 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
678 *
679 * Initializes existing generic value storage. The members are managed using the
680 * description specified by @a type.
681 *
682 * Some types may specify more operations, as an example
683 * #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(),
684 * eina_value_array_get() and so on.
685 *
686 * @note Existing contents are ignored! If the value was previously used, then
687 * use eina_value_flush() first.
688 *
689 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
690 * or #EINA_ERROR_VALUE_FAILED is set.
691 *
692 * @see eina_value_flush()
693 *
694 * @since 1.2
695 */
696static inline Eina_Bool eina_value_setup(Eina_Value *value,
697 const Eina_Value_Type *type) EINA_ARG_NONNULL(1, 2);
698
699/**
700 * @brief Create generic value storage.
701 * @param value value object
702 *
703 * Releases all the resources associated with an #Eina_Value. The
704 * value must be already set with eina_value_setup() or
705 * eina_value_new().
706 *
707 * After this call returns, the contents of the value are undefined,
708 * but the value can be reused by calling eina_value_setup() again.
709 *
710 * @see eina_value_setup()
711 * @see eina_value_free()
712 *
713 * @since 1.2
714 */
715static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1);
716
717/**
718 * @brief Copy generic value storage.
719 * @param value source value object
720 * @param copy destination value object
721 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
722 *
723 * The @a copy object is considered uninitialized and its existing
724 * contents are overwritten (just as if eina_value_flush() was called on
725 * it).
726 *
727 * The copy happens by calling eina_value_setup() on @a copy, followed
728 * by getting the contents of @a value and setting it to @a copy.
729 *
730 * @since 1.2
731 */
732EAPI Eina_Bool eina_value_copy(const Eina_Value *value,
733 Eina_Value *copy) EINA_ARG_NONNULL(1, 2);
734
735/**
736 * @brief Compare generic value storage.
737 * @param a left side of comparison
738 * @param b right side of comparison
739 * @return less than zero if a < b, greater than zero if a > b, zero
740 * if a == b
741 *
742 * @since 1.2
743 */
744static inline int eina_value_compare(const Eina_Value *a,
745 const Eina_Value *b) EINA_ARG_NONNULL(1, 2);
746
747/**
748 * @brief Set the generic value.
749 * @param value source value object
750 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
751 *
752 * The variable argument is dependent on chosen type. The list for
753 * basic types:
754 *
755 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
756 * @li EINA_VALUE_TYPE_USHORT: unsigned short
757 * @li EINA_VALUE_TYPE_UINT: unsigned int
758 * @li EINA_VALUE_TYPE_ULONG: unsigned long
759 * @li EINA_VALUE_TYPE_UINT64: uint64_t
760 * @li EINA_VALUE_TYPE_CHAR: char
761 * @li EINA_VALUE_TYPE_SHORT: short
762 * @li EINA_VALUE_TYPE_INT: int
763 * @li EINA_VALUE_TYPE_LONG: long
764 * @li EINA_VALUE_TYPE_INT64: int64_t
765 * @li EINA_VALUE_TYPE_FLOAT: float
766 * @li EINA_VALUE_TYPE_DOUBLE: double
767 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
768 * @li EINA_VALUE_TYPE_STRING: const char *
769 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
770 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
771 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
772 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
773 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
774 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
775 *
776 * @code
777 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
778 * int x = 567;
779 * eina_value_set(value, 1234);
780 * eina_value_set(value, x);
781 *
782 * eina_value_flush(value);
783 *
784 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
785 * eina_value_set(value, "hello world!");
786 *
787 * eina_value_free(value);
788 * @endcode
789 *
790 * @note for array member see eina_value_array_set()
791 * @note for list member see eina_value_list_set()
792 * @note for hash member see eina_value_hash_set()
793 *
794 * @see eina_value_get()
795 * @see eina_value_vset()
796 * @see eina_value_pset()
797 *
798 * @since 1.2
799 */
800static inline Eina_Bool eina_value_set(Eina_Value *value,
801 ...) EINA_ARG_NONNULL(1);
802
803/**
804 * @brief Get the generic value.
805 * @param value source value object
806 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
807 *
808 * The value is returned in the variable argument parameter, the
809 * actual value is type-dependent, but usually it will be what is
810 * stored inside the object. There shouldn't be any memory allocation,
811 * thus the contents should @b not be freed.
812 *
813 * The variable argument is dependent on chosen type. The list for
814 * basic types:
815 *
816 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
817 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
818 * @li EINA_VALUE_TYPE_UINT: unsigned int*
819 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
820 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
821 * @li EINA_VALUE_TYPE_CHAR: char*
822 * @li EINA_VALUE_TYPE_SHORT: short*
823 * @li EINA_VALUE_TYPE_INT: int*
824 * @li EINA_VALUE_TYPE_LONG: long*
825 * @li EINA_VALUE_TYPE_INT64: int64_t*
826 * @li EINA_VALUE_TYPE_FLOAT: float*
827 * @li EINA_VALUE_TYPE_DOUBLE: double*
828 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
829 * @li EINA_VALUE_TYPE_STRING: const char **
830 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
831 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
832 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
833 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
834 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
835 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
836 *
837 * @code
838 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
839 * int x;
840 * const char *s;
841 *
842 * eina_value_set(value, 1234);
843 * eina_value_get(value, &x);
844 *
845 * eina_value_flush(value);
846 *
847 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
848 * eina_value_set(value, "hello world!");
849 * eina_value_get(value, &s);
850 *
851 * eina_value_free(value);
852 * @endcode
853 *
854 * @note for array member see eina_value_array_get()
855 * @note for list member see eina_value_list_get()
856 * @note for hash member see eina_value_hash_get()
857 *
858 * @see eina_value_set()
859 * @see eina_value_vset()
860 * @see eina_value_pset()
861 *
862 * @since 1.2
863 */
864static inline Eina_Bool eina_value_get(const Eina_Value *value,
865 ...) EINA_ARG_NONNULL(1);
866
867/**
868 * @brief Set the generic value.
869 * @param value source value object
870 * @param args variable argument
871 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
872 *
873 * @note for array member see eina_value_array_vset()
874 * @note for list member see eina_value_list_vset()
875 * @note for hash member see eina_value_hash_vset()
876 *
877 * @see eina_value_vget()
878 * @see eina_value_set()
879 * @see eina_value_pset()
880 *
881 * @since 1.2
882 */
883static inline Eina_Bool eina_value_vset(Eina_Value *value,
884 va_list args) EINA_ARG_NONNULL(1);
885
886/**
887 * @brief Get the generic value.
888 * @param value source value object
889 * @param args variable argument
890 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
891 *
892 * The value is returned in the variable argument parameter, the
893 * actual value is type-dependent, but usually it will be what is
894 * stored inside the object. There shouldn't be any memory allocation,
895 * thus the contents should @b not be freed.
896 *
897 * @note for array member see eina_value_array_vget()
898 * @note for list member see eina_value_list_vget()
899 * @note for hash member see eina_value_hash_vget()
900 *
901 * @see eina_value_vset()
902 * @see eina_value_get()
903 * @see eina_value_pget()
904 *
905 * @since 1.2
906 */
907static inline Eina_Bool eina_value_vget(const Eina_Value *value,
908 va_list args) EINA_ARG_NONNULL(1);
909
910/**
911 * @brief Set the generic value from pointer.
912 * @param value source value object
913 * @param ptr pointer to specify the contents.
914 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
915 *
916 * The pointer type is dependent on chosen value type. The list for
917 * basic types:
918 *
919 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
920 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
921 * @li EINA_VALUE_TYPE_UINT: unsigned int*
922 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
923 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
924 * @li EINA_VALUE_TYPE_CHAR: char*
925 * @li EINA_VALUE_TYPE_SHORT: short*
926 * @li EINA_VALUE_TYPE_INT: int*
927 * @li EINA_VALUE_TYPE_LONG: long*
928 * @li EINA_VALUE_TYPE_INT64: int64_t*
929 * @li EINA_VALUE_TYPE_FLOAT: float*
930 * @li EINA_VALUE_TYPE_DOUBLE: double*
931 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
932 * @li EINA_VALUE_TYPE_STRING: const char **
933 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
934 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
935 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
936 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
937 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
938 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
939 *
940 * @note the pointer contents are written using the size defined by
941 * type. It can be larger than void* or uint64_t.
942 *
943 * @code
944 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
945 * int x = 567;
946 * const char *s = "hello world!";
947 *
948 * eina_value_pset(value, &x);
949 *
950 * eina_value_flush(value);
951 *
952 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
953 * eina_value_pset(value, &s);
954 *
955 * eina_value_free(value);
956 * @endcode
957 *
958 * @note for array member see eina_value_array_pset()
959 * @note for list member see eina_value_list_pset()
960 * @note for hash member see eina_value_hash_pset()
961 *
962 * @see eina_value_pget()
963 * @see eina_value_set()
964 * @see eina_value_vset()
965 *
966 * @since 1.2
967 */
968static inline Eina_Bool eina_value_pset(Eina_Value *value,
969 const void *ptr) EINA_ARG_NONNULL(1, 2);
970
971/**
972 * @brief Get the generic value to pointer.
973 * @param value source value object
974 * @param ptr pointer to receive the contents.
975 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
976 *
977 * The value is returned in pointer contents, the actual value is
978 * type-dependent, but usually it will be what is stored inside the
979 * object. There shouldn't be any memory allocation, thus the contents
980 * should @b not be freed.
981 *
982 * The pointer type is dependent on chosen value type. The list for
983 * basic types:
984 *
985 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
986 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
987 * @li EINA_VALUE_TYPE_UINT: unsigned int*
988 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
989 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
990 * @li EINA_VALUE_TYPE_CHAR: char*
991 * @li EINA_VALUE_TYPE_SHORT: short*
992 * @li EINA_VALUE_TYPE_INT: int*
993 * @li EINA_VALUE_TYPE_LONG: long*
994 * @li EINA_VALUE_TYPE_INT64: int64_t*
995 * @li EINA_VALUE_TYPE_FLOAT: float*
996 * @li EINA_VALUE_TYPE_DOUBLE: double*
997 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
998 * @li EINA_VALUE_TYPE_STRING: const char **
999 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1000 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1001 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1002 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1003 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1004 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1005 *
1006 * @code
1007 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
1008 * int x;
1009 * const char *s;
1010 *
1011 * eina_value_set(value, 1234);
1012 * eina_value_pget(value, &x);
1013 *
1014 * eina_value_flush(value);
1015 *
1016 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
1017 * eina_value_set(value, "hello world!");
1018 * eina_value_pget(value, &s);
1019 *
1020 * eina_value_free(value);
1021 * @endcode
1022 *
1023 * @note for array member see eina_value_array_get()
1024 * @note for list member see eina_value_list_get()
1025 * @note for hash member see eina_value_hash_get()
1026 *
1027 * @see eina_value_set()
1028 * @see eina_value_vset()
1029 * @see eina_value_pset()
1030 *
1031 * @since 1.2
1032 */
1033static inline Eina_Bool eina_value_pget(const Eina_Value *value,
1034 void *ptr) EINA_ARG_NONNULL(1, 2);
1035
1036/**
1037 * @brief Convert one value to another type.
1038 * @param value source value object.
1039 * @param convert destination value object.
1040 * @return #EINA_TRUE if converted, #EINA_FALSE otherwise.
1041 *
1042 * Converts one value to another trying first @a value type
1043 * @c convert_to() function. If unsuccessful, tries using @c convert_from()
1044 * function in @a convert.
1045 *
1046 * Conversion functions are type defined, and the basic types can convert
1047 * between themselves, but conversion is strict! That is, if
1048 * converting from negative value to unsigned type, it will fail. It
1049 * also fails on value overflow.
1050 *
1051 * It is recommended that all types implement at least convert to
1052 * string, used by eina_value_to_string().
1053 *
1054 * @note Both objects must have eina_value_setup() called on them beforehand!
1055 *
1056 * @since 1.2
1057 */
1058EAPI Eina_Bool eina_value_convert(const Eina_Value *value,
1059 Eina_Value *convert) EINA_ARG_NONNULL(1, 2);
1060
1061
1062/**
1063 * @brief Convert value to string.
1064 * @param value value object.
1065 * @return newly allocated memory or @c NULL on failure.
1066 *
1067 * @see eina_value_convert()
1068 * @since 1.2
1069 */
1070EAPI char *eina_value_to_string(const Eina_Value *value) EINA_ARG_NONNULL(1);
1071
1072/**
1073 * @brief Query value type.
1074 * @param value value object.
1075 * @return type instance or @c NULL if type is invalid.
1076 *
1077 * Check if value type is valid and returns it. A type is invalid if
1078 * it does not exist or if it is using a different version field.
1079 *
1080 * @see eina_value_type_check()
1081 *
1082 * @since 1.2
1083 */
1084static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
1085
1086/**
1087 * @}
1088 */
1089
1090
1091/**
1092 * @defgroup Eina_Value_Array_Group Generic Value Array management
1093 *
1094 * @{
1095 */
1096
1097
1098/**
1099 * @typedef Eina_Value_Array
1100 * Value type for #EINA_VALUE_TYPE_ARRAY.
1101 *
1102 * @see #_Eina_Value_Array explains fields.
1103 * @since 1.2
1104 */
1105typedef struct _Eina_Value_Array Eina_Value_Array;
1106
1107/**
1108 * @struct _Eina_Value_Array
1109 * Used to store the array and its subtype.
1110 * @since 1.2
1111 */
1112struct _Eina_Value_Array
1113{
1114 const Eina_Value_Type *subtype; /**< how to allocate and access items */
1115 unsigned int step; /**< how to grow the members array */
1116 Eina_Inarray *array; /**< the array that holds data, members are of subtype->value_size bytes. */
1117};
1118
1119/**
1120 * @brief Create generic value storage of type array.
1121 * @param subtype how to manage this array members.
1122 * @param step how to grow the members array.
1123 * @return The new value or @c NULL on failure.
1124 *
1125 * Create a new generic value storage of type array. The members are
1126 * managed using the description specified by @a subtype.
1127 *
1128 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
1129 * #EINA_ERROR_VALUE_FAILED is set.
1130 *
1131 * @note this creates from mempool and then uses
1132 * eina_value_array_setup(). @see eina_value_free() @see
1133 * eina_value_array_setup()
1134 *
1135 * @since 1.2
1136 */
1137EAPI Eina_Value *eina_value_array_new(const Eina_Value_Type *subtype,
1138 unsigned int step) EINA_ARG_NONNULL(1);
1139
1140/**
1141 * @brief Initialize generic value storage of type array.
1142 * @param value value object
1143 * @param subtype how to manage array members.
1144 * @param step how to grow the members array.
1145 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1146 *
1147 * Initializes new generic value storage of type array with the given
1148 * @a subtype.
1149 *
1150 * This is the same as calling eina_value_set() with
1151 * #EINA_VALUE_TYPE_ARRAY followed by eina_value_pset() with the
1152 * #Eina_Value_Array description configured.
1153 *
1154 * @note Existing contents are ignored! If the value was previously used, then
1155 * use eina_value_flush() first.
1156 *
1157 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
1158 * or #EINA_ERROR_VALUE_FAILED is set.
1159 *
1160 * @see eina_value_flush()
1161 *
1162 * @since 1.2
1163 */
1164static inline Eina_Bool eina_value_array_setup(Eina_Value *value,
1165 const Eina_Value_Type *subtype,
1166 unsigned int step) EINA_ARG_NONNULL(1, 2);
1167
1168/**
1169 * @brief Query number of elements in value of array type.
1170 * @param value value object.
1171 * @return number of child elements.
1172 * @since 1.2
1173 */
1174static inline unsigned int eina_value_array_count(const Eina_Value *value);
1175
1176/**
1177 * @brief Remove element at given position in value of array type.
1178 * @param value value object.
1179 * @param position index of the member
1180 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1181 * @since 1.2
1182 */
1183static inline Eina_Bool eina_value_array_remove(Eina_Value *value,
1184 unsigned int position) EINA_ARG_NONNULL(1);
1185
1186/**
1187 * @brief Set the generic value in an array member.
1188 * @param value source value object
1189 * @param position index of the member
1190 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1191 *
1192 * The variable argument is dependent on chosen subtype. The list for
1193 * basic types:
1194 *
1195 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1196 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1197 * @li EINA_VALUE_TYPE_UINT: unsigned int
1198 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1199 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1200 * @li EINA_VALUE_TYPE_CHAR: char
1201 * @li EINA_VALUE_TYPE_SHORT: short
1202 * @li EINA_VALUE_TYPE_INT: int
1203 * @li EINA_VALUE_TYPE_LONG: long
1204 * @li EINA_VALUE_TYPE_INT64: int64_t
1205 * @li EINA_VALUE_TYPE_FLOAT: float
1206 * @li EINA_VALUE_TYPE_DOUBLE: double
1207 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1208 * @li EINA_VALUE_TYPE_STRING: const char *
1209 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1210 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1211 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1212 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1213 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1214 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1215 *
1216 * @code
1217 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1218 * int x;
1219 *
1220 * eina_value_array_append(value, 1234);
1221 * eina_value_array_set(value, 0, 5678);
1222 * eina_value_array_get(value, 0, &x);
1223 * eina_value_free(value);
1224 * @endcode
1225 *
1226 * @see eina_value_array_get()
1227 * @see eina_value_array_vset()
1228 * @see eina_value_array_pset()
1229 * @see eina_value_array_insert()
1230 * @see eina_value_array_vinsert()
1231 * @see eina_value_array_pinsert()
1232 * @see eina_value_array_append()
1233 * @see eina_value_array_vappend()
1234 * @see eina_value_array_pappend()
1235 *
1236 * @since 1.2
1237 */
1238static inline Eina_Bool eina_value_array_set(Eina_Value *value,
1239 unsigned int position,
1240 ...) EINA_ARG_NONNULL(1);
1241
1242/**
1243 * @brief Get the generic value from an array member.
1244 * @param value source value object
1245 * @param position index of the member
1246 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1247 *
1248 * The value is returned in the variable argument parameter, and the
1249 * actual value is type-dependent, but usually it will be what is
1250 * stored inside the object. There shouldn't be any memory allocation;
1251 * thus the contents should @b not be freed.
1252 *
1253 * The variable argument is dependent on chosen subtype. The list for
1254 * basic types:
1255 *
1256 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1257 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1258 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1259 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1260 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1261 * @li EINA_VALUE_TYPE_CHAR: char*
1262 * @li EINA_VALUE_TYPE_SHORT: short*
1263 * @li EINA_VALUE_TYPE_INT: int*
1264 * @li EINA_VALUE_TYPE_LONG: long*
1265 * @li EINA_VALUE_TYPE_INT64: int64_t*
1266 * @li EINA_VALUE_TYPE_FLOAT: float*
1267 * @li EINA_VALUE_TYPE_DOUBLE: double*
1268 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1269 * @li EINA_VALUE_TYPE_STRING: const char **
1270 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1271 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1272 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1273 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1274 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1275 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1276 *
1277 * @code
1278 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1279 * int x;
1280 *
1281 * eina_value_array_append(value, 1234);
1282 * eina_value_array_get(value, 0, &x);
1283 * eina_value_free(value);
1284 * @endcode
1285 *
1286 * @see eina_value_array_set()
1287 * @see eina_value_array_vset()
1288 * @see eina_value_array_pset()
1289 *
1290 * @since 1.2
1291 */
1292static inline Eina_Bool eina_value_array_get(const Eina_Value *value,
1293 unsigned int position,
1294 ...) EINA_ARG_NONNULL(1);
1295
1296/**
1297 * @brief Insert a generic value in an array member position.
1298 * @param value source value object
1299 * @param position index of the member
1300 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1301 *
1302 * The variable argument is dependent on chosen subtype. The list for
1303 * basic types:
1304 *
1305 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1306 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1307 * @li EINA_VALUE_TYPE_UINT: unsigned int
1308 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1309 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1310 * @li EINA_VALUE_TYPE_CHAR: char
1311 * @li EINA_VALUE_TYPE_SHORT: short
1312 * @li EINA_VALUE_TYPE_INT: int
1313 * @li EINA_VALUE_TYPE_LONG: long
1314 * @li EINA_VALUE_TYPE_INT64: int64_t
1315 * @li EINA_VALUE_TYPE_FLOAT: float
1316 * @li EINA_VALUE_TYPE_DOUBLE: double
1317 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1318 * @li EINA_VALUE_TYPE_STRING: const char *
1319 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1320 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1321 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1322 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1323 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1324 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1325 *
1326 * @code
1327 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1328 * int x;
1329 *
1330 * eina_value_array_insert(value, 0, 1234);
1331 * eina_value_array_get(value, 0, &x);
1332 * eina_value_free(value);
1333 * @endcode
1334 *
1335 * @see eina_value_array_set()
1336 * @see eina_value_array_get()
1337 * @see eina_value_array_vset()
1338 * @see eina_value_array_pset()
1339 * @see eina_value_array_vinsert()
1340 * @see eina_value_array_pinsert()
1341 * @see eina_value_array_append()
1342 * @see eina_value_array_vappend()
1343 * @see eina_value_array_pappend()
1344 *
1345 * @since 1.2
1346 */
1347static inline Eina_Bool eina_value_array_insert(Eina_Value *value,
1348 unsigned int position,
1349 ...) EINA_ARG_NONNULL(1);
1350
1351
1352/**
1353 * @brief Append a generic value in an array.
1354 * @param value source value object
1355 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1356 *
1357 * The variable argument is dependent on chosen subtype. The list for
1358 * basic types:
1359 *
1360 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1361 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1362 * @li EINA_VALUE_TYPE_UINT: unsigned int
1363 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1364 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1365 * @li EINA_VALUE_TYPE_CHAR: char
1366 * @li EINA_VALUE_TYPE_SHORT: short
1367 * @li EINA_VALUE_TYPE_INT: int
1368 * @li EINA_VALUE_TYPE_LONG: long
1369 * @li EINA_VALUE_TYPE_INT64: int64_t
1370 * @li EINA_VALUE_TYPE_FLOAT: float
1371 * @li EINA_VALUE_TYPE_DOUBLE: double
1372 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1373 * @li EINA_VALUE_TYPE_STRING: const char *
1374 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1375 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1376 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1377 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1378 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1379 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1380 *
1381 * @code
1382 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1383 * int x;
1384 *
1385 * eina_value_array_append(value, 1234);
1386 * eina_value_array_get(value, 0, &x);
1387 * eina_value_free(value);
1388 * @endcode
1389 *
1390 * @see eina_value_array_set()
1391 * @see eina_value_array_get()
1392 * @see eina_value_array_vset()
1393 * @see eina_value_array_pset()
1394 * @see eina_value_array_vinsert()
1395 * @see eina_value_array_pinsert()
1396 * @see eina_value_array_append()
1397 * @see eina_value_array_vappend()
1398 * @see eina_value_array_pappend()
1399 *
1400 * @since 1.2
1401 */
1402static inline Eina_Bool eina_value_array_append(Eina_Value *value,
1403 ...) EINA_ARG_NONNULL(1);
1404
1405/**
1406 * @brief Set a generic value to an array member.
1407 * @param value source value object
1408 * @param position index of the member
1409 * @param args variable argument
1410 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1411 * @see eina_value_array_set()
1412 * @see eina_value_array_get()
1413 * @see eina_value_array_pset()
1414 * @see eina_value_array_insert()
1415 * @see eina_value_array_vinsert()
1416 * @see eina_value_array_pinsert()
1417 * @see eina_value_array_append()
1418 * @see eina_value_array_vappend()
1419 * @see eina_value_array_pappend()
1420 *
1421 * @since 1.2
1422 */
1423static inline Eina_Bool eina_value_array_vset(Eina_Value *value,
1424 unsigned int position,
1425 va_list args) EINA_ARG_NONNULL(1);
1426
1427/**
1428 * @brief Get the generic value from an array member.
1429 * @param value source value object
1430 * @param position index of the member
1431 * @param args variable argument
1432 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1433 *
1434 * The value is returned in the variable argument parameter, the
1435 * actual value is type-dependent, but usually it will be what is
1436 * stored inside the object. There shouldn't be any memory allocation,
1437 * thus the contents should @b not be freed.
1438 *
1439 * @see eina_value_array_vset()
1440 * @see eina_value_array_get()
1441 * @see eina_value_array_pget()
1442 *
1443 * @since 1.2
1444 */
1445static inline Eina_Bool eina_value_array_vget(const Eina_Value *value,
1446 unsigned int position,
1447 va_list args) EINA_ARG_NONNULL(1);
1448/**
1449 * @brief Insert a generic value to an array member position.
1450 * @param value source value object
1451 * @param position index of the member
1452 * @param args variable argument
1453 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1454 * @see eina_value_array_set()
1455 * @see eina_value_array_get()
1456 * @see eina_value_array_vset()
1457 * @see eina_value_array_pset()
1458 * @see eina_value_array_insert()
1459 * @see eina_value_array_pinsert()
1460 * @see eina_value_array_append()
1461 * @see eina_value_array_vappend()
1462 * @see eina_value_array_pappend()
1463 *
1464 * @since 1.2
1465 */
1466static inline Eina_Bool eina_value_array_vinsert(Eina_Value *value,
1467 unsigned int position,
1468 va_list args) EINA_ARG_NONNULL(1);
1469
1470/**
1471 * @brief Append a generic value to an array.
1472 * @param value source value object
1473 * @param args variable argument
1474 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1475 * @see eina_value_array_set()
1476 * @see eina_value_array_get()
1477 * @see eina_value_array_vget()
1478 * @see eina_value_array_pset()
1479 * @see eina_value_array_insert()
1480 * @see eina_value_array_vinsert()
1481 * @see eina_value_array_pinsert()
1482 * @see eina_value_array_append()
1483 * @see eina_value_array_pappend()
1484 *
1485 * @since 1.2
1486 */
1487static inline Eina_Bool eina_value_array_vappend(Eina_Value *value,
1488 va_list args) EINA_ARG_NONNULL(1);
1489
1490
1491/**
1492 * @brief Set a generic value to an array member from a pointer.
1493 * @param value source value object
1494 * @param position index of the member
1495 * @param ptr pointer to specify the contents.
1496 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1497 *
1498 * The pointer type is dependent on chosen value type. The list for
1499 * basic types:
1500 *
1501 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1502 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1503 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1504 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1505 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1506 * @li EINA_VALUE_TYPE_CHAR: char*
1507 * @li EINA_VALUE_TYPE_SHORT: short*
1508 * @li EINA_VALUE_TYPE_INT: int*
1509 * @li EINA_VALUE_TYPE_LONG: long*
1510 * @li EINA_VALUE_TYPE_INT64: int64_t*
1511 * @li EINA_VALUE_TYPE_FLOAT: float*
1512 * @li EINA_VALUE_TYPE_DOUBLE: double*
1513 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1514 * @li EINA_VALUE_TYPE_STRING: const char **
1515 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1516 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1517 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1518 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1519 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1520 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1521 *
1522 * @note the pointer contents are written using the size defined by
1523 * type. It can be larger than void* or uint64_t.
1524 *
1525 * @code
1526 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1527 * int x = 1234;
1528 *
1529 * eina_value_array_append(value, 1234);
1530 * eina_value_array_pset(value, 0, &x);
1531 * eina_value_array_pget(value, 0, &x);
1532 * eina_value_free(value);
1533 * @endcode
1534 *
1535 * @see eina_value_array_set()
1536 * @see eina_value_array_get()
1537 * @see eina_value_array_vset()
1538 * @see eina_value_array_insert()
1539 * @see eina_value_array_vinsert()
1540 * @see eina_value_array_pinsert()
1541 * @see eina_value_array_append()
1542 * @see eina_value_array_vappend()
1543 * @see eina_value_array_pappend()
1544 *
1545 * @since 1.2
1546 */
1547static inline Eina_Bool eina_value_array_pset(Eina_Value *value,
1548 unsigned int position,
1549 const void *ptr) EINA_ARG_NONNULL(1, 3);
1550
1551/**
1552 * @brief Retrieve a generic value into a pointer from an array member.
1553 * @param value source value object
1554 * @param position index of the member
1555 * @param ptr pointer to receive the contents.
1556 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1557 *
1558 * The value is returned in pointer contents, the actual value is
1559 * type-dependent, but usually it will be what is stored inside the
1560 * object. There shouldn't be any memory allocation, thus the contents
1561 * should @b not be freed.
1562 *
1563 * The pointer type is dependent on chosen value type. The list for
1564 * basic types:
1565 *
1566 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1567 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1568 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1569 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1570 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1571 * @li EINA_VALUE_TYPE_CHAR: char*
1572 * @li EINA_VALUE_TYPE_SHORT: short*
1573 * @li EINA_VALUE_TYPE_INT: int*
1574 * @li EINA_VALUE_TYPE_LONG: long*
1575 * @li EINA_VALUE_TYPE_INT64: int64_t*
1576 * @li EINA_VALUE_TYPE_FLOAT: float*
1577 * @li EINA_VALUE_TYPE_DOUBLE: double*
1578 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1579 * @li EINA_VALUE_TYPE_STRING: const char **
1580 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1581 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1582 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1583 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1584 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1585 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1586 *
1587 * @code
1588 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1589 * int x;
1590 *
1591 * eina_value_array_append(value, 1234);
1592 * eina_value_array_pget(value, 0, &x);
1593 * eina_value_free(value);
1594 * @endcode
1595 *
1596 * @see eina_value_array_set()
1597 * @see eina_value_array_vset()
1598 * @see eina_value_array_pset()
1599 *
1600 * @since 1.2
1601 */
1602static inline Eina_Bool eina_value_array_pget(const Eina_Value *value,
1603 unsigned int position,
1604 void *ptr) EINA_ARG_NONNULL(1, 3);
1605
1606/**
1607 * @brief Insert a generic value to an array member position from a pointer.
1608 * @param value source value object
1609 * @param position index of the member
1610 * @param ptr pointer to specify the contents.
1611 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1612 *
1613 * The pointer type is dependent on chosen value type. The list for
1614 * basic types:
1615 *
1616 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1617 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1618 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1619 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1620 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1621 * @li EINA_VALUE_TYPE_CHAR: char*
1622 * @li EINA_VALUE_TYPE_SHORT: short*
1623 * @li EINA_VALUE_TYPE_INT: int*
1624 * @li EINA_VALUE_TYPE_LONG: long*
1625 * @li EINA_VALUE_TYPE_INT64: int64_t*
1626 * @li EINA_VALUE_TYPE_FLOAT: float*
1627 * @li EINA_VALUE_TYPE_DOUBLE: double*
1628 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1629 * @li EINA_VALUE_TYPE_STRING: const char **
1630 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1631 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1632 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1633 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1634 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1635 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1636 *
1637 * @note the pointer contents are written using the size defined by
1638 * type. It can be larger than void* or uint64_t.
1639 *
1640 * @code
1641 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1642 * int x = 1234;
1643 *
1644 * eina_value_array_pinsert(value, 0, &x);
1645 * eina_value_array_pget(value, 0, &x);
1646 * eina_value_free(value);
1647 * @endcode
1648 *
1649 * @see eina_value_array_set()
1650 * @see eina_value_array_get()
1651 * @see eina_value_array_vset()
1652 * @see eina_value_array_insert()
1653 * @see eina_value_array_vinsert()
1654 * @see eina_value_array_pinsert()
1655 * @see eina_value_array_append()
1656 * @see eina_value_array_vappend()
1657 * @see eina_value_array_pappend()
1658 *
1659 * @since 1.2
1660 */
1661static inline Eina_Bool eina_value_array_pinsert(Eina_Value *value,
1662 unsigned int position,
1663 const void *ptr) EINA_ARG_NONNULL(1);
1664
1665/**
1666 * @brief Append a generic value to an array from a pointer.
1667 * @param value source value object
1668 * @param ptr pointer to specify the contents.
1669 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1670 *
1671 * The pointer type is dependent on chosen value type. The list for
1672 * basic types:
1673 *
1674 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1675 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1676 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1677 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1678 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1679 * @li EINA_VALUE_TYPE_CHAR: char*
1680 * @li EINA_VALUE_TYPE_SHORT: short*
1681 * @li EINA_VALUE_TYPE_INT: int*
1682 * @li EINA_VALUE_TYPE_LONG: long*
1683 * @li EINA_VALUE_TYPE_INT64: int64_t*
1684 * @li EINA_VALUE_TYPE_FLOAT: float*
1685 * @li EINA_VALUE_TYPE_DOUBLE: double*
1686 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1687 * @li EINA_VALUE_TYPE_STRING: const char **
1688 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1689 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1690 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1691 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1692 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1693 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1694 *
1695 * @note the pointer contents are written using the size defined by
1696 * type. It can be larger than void* or uint64_t.
1697 *
1698 * @code
1699 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1700 * int x = 1234;
1701 *
1702 * eina_value_array_pappend(value, &x);
1703 * eina_value_array_pget(value, 0, &x);
1704 * eina_value_free(value);
1705 * @endcode
1706 *
1707 * @see eina_value_array_set()
1708 * @see eina_value_array_get()
1709 * @see eina_value_array_vset()
1710 * @see eina_value_array_insert()
1711 * @see eina_value_array_vinsert()
1712 * @see eina_value_array_pinsert()
1713 * @see eina_value_array_append()
1714 * @see eina_value_array_vappend()
1715 * @see eina_value_array_pappend()
1716 *
1717 * @since 1.2
1718 */
1719static inline Eina_Bool eina_value_array_pappend(Eina_Value *value,
1720 const void *ptr) EINA_ARG_NONNULL(1);
1721
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/**
1739 * @}
1740 */
1741
1742
1743/**
1744 * @defgroup Eina_Value_List_Group Generic Value List management
1745 *
1746 * @{
1747 */
1748
1749
1750/**
1751 * @typedef Eina_Value_List
1752 * Value type for #EINA_VALUE_TYPE_LIST.
1753 *
1754 * @see #_Eina_Value_List explains fields.
1755 * @since 1.2
1756 */
1757typedef struct _Eina_Value_List Eina_Value_List;
1758
1759/**
1760 * @struct _Eina_Value_List
1761 * Used to store the list and its subtype.
1762 * @since 1.2
1763 */
1764struct _Eina_Value_List
1765{
1766 const Eina_Value_Type *subtype; /**< how to allocate and access items */
1767 Eina_List *list; /**< the list that holds data, members are of subtype->value_size bytes. */
1768};
1769
1770/**
1771 * @brief Create generic value storage of type list.
1772 * @param subtype how to manage this list members.
1773 * @return The new value or @c NULL on failure.
1774 *
1775 * Create a new generic value storage of type list. The members are
1776 * managed using the description specified by @a subtype.
1777 *
1778 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
1779 * #EINA_ERROR_VALUE_FAILED is set.
1780 *
1781 * @note this creates from mempool and then uses
1782 * eina_value_list_setup().
1783 *
1784 * @see eina_value_free()
1785 * @see eina_value_list_setup()
1786 *
1787 * @since 1.2
1788 */
1789EAPI Eina_Value *eina_value_list_new(const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1);
1790
1791/**
1792 * @brief Initialize generic value storage of type list.
1793 * @param value value object
1794 * @param subtype how to manage this list members.
1795 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1796 *
1797 * Initializes new generic value storage of type list with the given
1798 * @a subtype.
1799 *
1800 * This is the same as calling eina_value_set() with
1801 * #EINA_VALUE_TYPE_LIST followed by eina_value_pset() with the
1802 * #Eina_Value_List description configured.
1803 *
1804 * @note Existing contents are ignored! If the value was previously used, then
1805 * use eina_value_flush() first.
1806 *
1807 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
1808 * or #EINA_ERROR_VALUE_FAILED is set.
1809 *
1810 * @see eina_value_flush()
1811 *
1812 * @since 1.2
1813 */
1814static inline Eina_Bool eina_value_list_setup(Eina_Value *value,
1815 const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1, 2);
1816
1817/**
1818 * @brief Query number of elements in value of list type.
1819 * @param value value object.
1820 * @return number of child elements.
1821 * @since 1.2
1822 */
1823static inline unsigned int eina_value_list_count(const Eina_Value *value);
1824
1825/**
1826 * @brief Remove element at given position in value of list type.
1827 * @param value value object.
1828 * @param position index of the member
1829 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1830 * @since 1.2
1831 */
1832static inline Eina_Bool eina_value_list_remove(Eina_Value *value,
1833 unsigned int position) EINA_ARG_NONNULL(1);
1834
1835/**
1836 * @brief Set the generic value in an list member.
1837 * @param value source value object
1838 * @param position index of the member
1839 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1840 *
1841 * The variable argument is dependent on chosen subtype. The list for
1842 * basic types:
1843 *
1844 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1845 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1846 * @li EINA_VALUE_TYPE_UINT: unsigned int
1847 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1848 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1849 * @li EINA_VALUE_TYPE_CHAR: char
1850 * @li EINA_VALUE_TYPE_SHORT: short
1851 * @li EINA_VALUE_TYPE_INT: int
1852 * @li EINA_VALUE_TYPE_LONG: long
1853 * @li EINA_VALUE_TYPE_INT64: int64_t
1854 * @li EINA_VALUE_TYPE_FLOAT: float
1855 * @li EINA_VALUE_TYPE_DOUBLE: double
1856 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1857 * @li EINA_VALUE_TYPE_STRING: const char *
1858 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1859 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1860 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1861 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1862 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1863 *
1864 * @code
1865 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1866 * int x;
1867 *
1868 * eina_value_list_append(value, 1234);
1869 * eina_value_list_set(value, 0, 5678);
1870 * eina_value_list_get(value, 0, &x);
1871 * eina_value_free(value);
1872 * @endcode
1873 *
1874 * @see eina_value_list_get()
1875 * @see eina_value_list_vset()
1876 * @see eina_value_list_pset()
1877 * @see eina_value_list_insert()
1878 * @see eina_value_list_vinsert()
1879 * @see eina_value_list_pinsert()
1880 * @see eina_value_list_append()
1881 * @see eina_value_list_vappend()
1882 * @see eina_value_list_pappend()
1883 *
1884 * @since 1.2
1885 */
1886static inline Eina_Bool eina_value_list_set(Eina_Value *value,
1887 unsigned int position,
1888 ...) EINA_ARG_NONNULL(1);
1889
1890/**
1891 * @brief Get the generic value from an list member.
1892 * @param value source value object
1893 * @param position index of the member
1894 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1895 *
1896 * The value is returned in the variable argument parameter, the
1897 * actual value is type-dependent, but usually it will be what is
1898 * stored inside the object. There shouldn't be any memory allocation,
1899 * thus the contents should @b not be freed.
1900 *
1901 * The variable argument is dependent on chosen subtype. The list for
1902 * basic types:
1903 *
1904 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1905 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1906 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1907 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1908 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1909 * @li EINA_VALUE_TYPE_CHAR: char*
1910 * @li EINA_VALUE_TYPE_SHORT: short*
1911 * @li EINA_VALUE_TYPE_INT: int*
1912 * @li EINA_VALUE_TYPE_LONG: long*
1913 * @li EINA_VALUE_TYPE_INT64: int64_t*
1914 * @li EINA_VALUE_TYPE_FLOAT: float*
1915 * @li EINA_VALUE_TYPE_DOUBLE: double*
1916 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1917 * @li EINA_VALUE_TYPE_STRING: const char **
1918 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1919 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1920 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1921 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1922 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1923 *
1924 * @code
1925 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1926 * int x;
1927 *
1928 * eina_value_list_append(value, 1234);
1929 * eina_value_list_get(value, 0, &x);
1930 * eina_value_free(value);
1931 * @endcode
1932 *
1933 * @see eina_value_list_set()
1934 * @see eina_value_list_vset()
1935 * @see eina_value_list_pset()
1936 *
1937 * @since 1.2
1938 */
1939static inline Eina_Bool eina_value_list_get(const Eina_Value *value,
1940 unsigned int position,
1941 ...) EINA_ARG_NONNULL(1);
1942
1943/**
1944 * @brief Insert the generic value in an list member position.
1945 * @param value source value object
1946 * @param position index of the member
1947 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1948 *
1949 * The variable argument is dependent on chosen subtype. The list for
1950 * basic types:
1951 *
1952 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1953 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1954 * @li EINA_VALUE_TYPE_UINT: unsigned int
1955 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1956 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1957 * @li EINA_VALUE_TYPE_CHAR: char
1958 * @li EINA_VALUE_TYPE_SHORT: short
1959 * @li EINA_VALUE_TYPE_INT: int
1960 * @li EINA_VALUE_TYPE_LONG: long
1961 * @li EINA_VALUE_TYPE_INT64: int64_t
1962 * @li EINA_VALUE_TYPE_FLOAT: float
1963 * @li EINA_VALUE_TYPE_DOUBLE: double
1964 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1965 * @li EINA_VALUE_TYPE_STRING: const char *
1966 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1967 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1968 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1969 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1970 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1971 *
1972 * @code
1973 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1974 * int x;
1975 *
1976 * eina_value_list_insert(value, 0, 1234);
1977 * eina_value_list_get(value, 0, &x);
1978 * eina_value_free(value);
1979 * @endcode
1980 *
1981 * @see eina_value_list_set()
1982 * @see eina_value_list_get()
1983 * @see eina_value_list_vset()
1984 * @see eina_value_list_pset()
1985 * @see eina_value_list_vinsert()
1986 * @see eina_value_list_pinsert()
1987 * @see eina_value_list_append()
1988 * @see eina_value_list_vappend()
1989 * @see eina_value_list_pappend()
1990 *
1991 * @since 1.2
1992 */
1993static inline Eina_Bool eina_value_list_insert(Eina_Value *value,
1994 unsigned int position,
1995 ...) EINA_ARG_NONNULL(1);
1996
1997
1998/**
1999 * @brief Append the generic value in an list.
2000 * @param value source value object
2001 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2002 *
2003 * The variable argument is dependent on chosen subtype. The list for
2004 * basic types:
2005 *
2006 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2007 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2008 * @li EINA_VALUE_TYPE_UINT: unsigned int
2009 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2010 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2011 * @li EINA_VALUE_TYPE_CHAR: char
2012 * @li EINA_VALUE_TYPE_SHORT: short
2013 * @li EINA_VALUE_TYPE_INT: int
2014 * @li EINA_VALUE_TYPE_LONG: long
2015 * @li EINA_VALUE_TYPE_INT64: int64_t
2016 * @li EINA_VALUE_TYPE_FLOAT: float
2017 * @li EINA_VALUE_TYPE_DOUBLE: double
2018 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
2019 * @li EINA_VALUE_TYPE_STRING: const char *
2020 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
2021 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2022 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
2023 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
2024 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
2025 *
2026 * @code
2027 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2028 * int x;
2029 *
2030 * eina_value_list_append(value, 1234);
2031 * eina_value_list_get(value, 0, &x);
2032 * eina_value_free(value);
2033 * @endcode
2034 *
2035 * @see eina_value_list_set()
2036 * @see eina_value_list_get()
2037 * @see eina_value_list_vset()
2038 * @see eina_value_list_pset()
2039 * @see eina_value_list_vinsert()
2040 * @see eina_value_list_pinsert()
2041 * @see eina_value_list_append()
2042 * @see eina_value_list_vappend()
2043 * @see eina_value_list_pappend()
2044 *
2045 * @since 1.2
2046 */
2047static inline Eina_Bool eina_value_list_append(Eina_Value *value,
2048 ...) EINA_ARG_NONNULL(1);
2049
2050/**
2051 * @brief Set the generic value in an list member.
2052 * @param value source value object
2053 * @param position index of the member
2054 * @param args variable argument
2055 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2056 * @see eina_value_list_set()
2057 * @see eina_value_list_get()
2058 * @see eina_value_list_pset()
2059 * @see eina_value_list_insert()
2060 * @see eina_value_list_vinsert()
2061 * @see eina_value_list_pinsert()
2062 * @see eina_value_list_append()
2063 * @see eina_value_list_vappend()
2064 * @see eina_value_list_pappend()
2065 *
2066 * @since 1.2
2067 */
2068static inline Eina_Bool eina_value_list_vset(Eina_Value *value,
2069 unsigned int position,
2070 va_list args) EINA_ARG_NONNULL(1);
2071
2072/**
2073 * @brief Get the generic value from an list member.
2074 * @param value source value object
2075 * @param position index of the member
2076 * @param args variable argument
2077 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2078 *
2079 * The value is returned in the variable argument parameter, the
2080 * actual value is type-dependent, but usually it will be what is
2081 * stored inside the object. There shouldn't be any memory allocation,
2082 * thus the contents should @b not be freed.
2083 *
2084 * @see eina_value_list_vset()
2085 * @see eina_value_list_get()
2086 * @see eina_value_list_pget()
2087 *
2088 * @since 1.2
2089 */
2090static inline Eina_Bool eina_value_list_vget(const Eina_Value *value,
2091 unsigned int position,
2092 va_list args) EINA_ARG_NONNULL(1);
2093/**
2094 * @brief Insert the generic value in an list member position.
2095 * @param value source value object
2096 * @param position index of the member
2097 * @param args variable argument
2098 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2099 * @see eina_value_list_set()
2100 * @see eina_value_list_get()
2101 * @see eina_value_list_vset()
2102 * @see eina_value_list_pset()
2103 * @see eina_value_list_insert()
2104 * @see eina_value_list_pinsert()
2105 * @see eina_value_list_append()
2106 * @see eina_value_list_vappend()
2107 * @see eina_value_list_pappend()
2108 *
2109 * @since 1.2
2110 */
2111static inline Eina_Bool eina_value_list_vinsert(Eina_Value *value,
2112 unsigned int position,
2113 va_list args) EINA_ARG_NONNULL(1);
2114
2115/**
2116 * @brief Append the generic value in an list.
2117 * @param value source value object
2118 * @param args variable argument
2119 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2120 * @see eina_value_list_set()
2121 * @see eina_value_list_get()
2122 * @see eina_value_list_vget()
2123 * @see eina_value_list_pset()
2124 * @see eina_value_list_insert()
2125 * @see eina_value_list_vinsert()
2126 * @see eina_value_list_pinsert()
2127 * @see eina_value_list_append()
2128 * @see eina_value_list_pappend()
2129 *
2130 * @since 1.2
2131 */
2132static inline Eina_Bool eina_value_list_vappend(Eina_Value *value,
2133 va_list args) EINA_ARG_NONNULL(1);
2134
2135
2136/**
2137 * @brief Set the generic value in an list member from pointer.
2138 * @param value source value object
2139 * @param position index of the member
2140 * @param ptr pointer to specify the contents.
2141 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2142 *
2143 * The pointer type is dependent on chosen value type. The list for
2144 * basic types:
2145 *
2146 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2147 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2148 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2149 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2150 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2151 * @li EINA_VALUE_TYPE_CHAR: char*
2152 * @li EINA_VALUE_TYPE_SHORT: short*
2153 * @li EINA_VALUE_TYPE_INT: int*
2154 * @li EINA_VALUE_TYPE_LONG: long*
2155 * @li EINA_VALUE_TYPE_INT64: int64_t*
2156 * @li EINA_VALUE_TYPE_FLOAT: float*
2157 * @li EINA_VALUE_TYPE_DOUBLE: double*
2158 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2159 * @li EINA_VALUE_TYPE_STRING: const char **
2160 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2161 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2162 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2163 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2164 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2165 *
2166 * @note the pointer contents are written using the size defined by
2167 * type. It can be larger than void* or uint64_t.
2168 *
2169 * @code
2170 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2171 * int x = 1234;
2172 *
2173 * eina_value_list_append(value, 1234);
2174 * eina_value_list_pset(value, 0, &x);
2175 * eina_value_list_pget(value, 0, &x);
2176 * eina_value_free(value);
2177 * @endcode
2178 *
2179 * @see eina_value_list_set()
2180 * @see eina_value_list_get()
2181 * @see eina_value_list_vset()
2182 * @see eina_value_list_insert()
2183 * @see eina_value_list_vinsert()
2184 * @see eina_value_list_pinsert()
2185 * @see eina_value_list_append()
2186 * @see eina_value_list_vappend()
2187 * @see eina_value_list_pappend()
2188 *
2189 * @since 1.2
2190 */
2191static inline Eina_Bool eina_value_list_pset(Eina_Value *value,
2192 unsigned int position,
2193 const void *ptr) EINA_ARG_NONNULL(1, 3);
2194
2195/**
2196 * @brief Get the generic value to pointer from an list member.
2197 * @param value source value object
2198 * @param position index of the member
2199 * @param ptr pointer to receive the contents.
2200 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2201 *
2202 * The value is returned in pointer contents, the actual value is
2203 * type-dependent, but usually it will be what is stored inside the
2204 * object. There shouldn't be any memory allocation, thus the contents
2205 * should @b not be freed.
2206 *
2207 * The pointer type is dependent on chosen value type. The list for
2208 * basic types:
2209 *
2210 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2211 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2212 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2213 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2214 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2215 * @li EINA_VALUE_TYPE_CHAR: char*
2216 * @li EINA_VALUE_TYPE_SHORT: short*
2217 * @li EINA_VALUE_TYPE_INT: int*
2218 * @li EINA_VALUE_TYPE_LONG: long*
2219 * @li EINA_VALUE_TYPE_INT64: int64_t*
2220 * @li EINA_VALUE_TYPE_FLOAT: float*
2221 * @li EINA_VALUE_TYPE_DOUBLE: double*
2222 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2223 * @li EINA_VALUE_TYPE_STRING: const char **
2224 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2225 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2226 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2227 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2228 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2229 *
2230 * @code
2231 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2232 * int x;
2233 *
2234 * eina_value_list_append(value, 1234);
2235 * eina_value_list_pget(value, 0, &x);
2236 * eina_value_free(value);
2237 * @endcode
2238 *
2239 * @see eina_value_list_set()
2240 * @see eina_value_list_vset()
2241 * @see eina_value_list_pset()
2242 *
2243 * @since 1.2
2244 */
2245static inline Eina_Bool eina_value_list_pget(const Eina_Value *value,
2246 unsigned int position,
2247 void *ptr) EINA_ARG_NONNULL(1, 3);
2248
2249/**
2250 * @brief Insert the generic value in an list member position from pointer.
2251 * @param value source value object
2252 * @param position index of the member
2253 * @param ptr pointer to specify the contents.
2254 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2255 *
2256 * The pointer type is dependent on chosen value type. The list for
2257 * basic types:
2258 *
2259 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2260 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2261 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2262 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2263 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2264 * @li EINA_VALUE_TYPE_CHAR: char*
2265 * @li EINA_VALUE_TYPE_SHORT: short*
2266 * @li EINA_VALUE_TYPE_INT: int*
2267 * @li EINA_VALUE_TYPE_LONG: long*
2268 * @li EINA_VALUE_TYPE_INT64: int64_t*
2269 * @li EINA_VALUE_TYPE_FLOAT: float*
2270 * @li EINA_VALUE_TYPE_DOUBLE: double*
2271 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2272 * @li EINA_VALUE_TYPE_STRING: const char **
2273 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2274 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2275 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2276 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2277 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2278 *
2279 * @note the pointer contents are written using the size defined by
2280 * type. It can be larger than void* or uint64_t.
2281 *
2282 * @code
2283 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2284 * int x = 1234;
2285 *
2286 * eina_value_list_pinsert(value, 0, &x);
2287 * eina_value_list_pget(value, 0, &x);
2288 * eina_value_free(value);
2289 * @endcode
2290 *
2291 * @see eina_value_list_set()
2292 * @see eina_value_list_get()
2293 * @see eina_value_list_vset()
2294 * @see eina_value_list_insert()
2295 * @see eina_value_list_vinsert()
2296 * @see eina_value_list_pinsert()
2297 * @see eina_value_list_append()
2298 * @see eina_value_list_vappend()
2299 * @see eina_value_list_pappend()
2300 *
2301 * @since 1.2
2302 */
2303static inline Eina_Bool eina_value_list_pinsert(Eina_Value *value,
2304 unsigned int position,
2305 const void *ptr) EINA_ARG_NONNULL(1);
2306
2307/**
2308 * @brief Append the generic value in an list from pointer.
2309 * @param value source value object
2310 * @param ptr pointer to specify the contents.
2311 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2312 *
2313 * The pointer type is dependent on chosen value type. The list for
2314 * basic types:
2315 *
2316 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2317 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2318 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2319 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2320 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2321 * @li EINA_VALUE_TYPE_CHAR: char*
2322 * @li EINA_VALUE_TYPE_SHORT: short*
2323 * @li EINA_VALUE_TYPE_INT: int*
2324 * @li EINA_VALUE_TYPE_LONG: long*
2325 * @li EINA_VALUE_TYPE_INT64: int64_t*
2326 * @li EINA_VALUE_TYPE_FLOAT: float*
2327 * @li EINA_VALUE_TYPE_DOUBLE: double*
2328 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2329 * @li EINA_VALUE_TYPE_STRING: const char **
2330 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2331 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2332 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2333 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2334 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2335 *
2336 * @note the pointer contents are written using the size defined by
2337 * type. It can be larger than void* or uint64_t.
2338 *
2339 * @code
2340 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2341 * int x = 1234;
2342 *
2343 * eina_value_list_pappend(value, &x);
2344 * eina_value_list_pget(value, 0, &x);
2345 * eina_value_free(value);
2346 * @endcode
2347 *
2348 * @see eina_value_list_set()
2349 * @see eina_value_list_get()
2350 * @see eina_value_list_vset()
2351 * @see eina_value_list_insert()
2352 * @see eina_value_list_vinsert()
2353 * @see eina_value_list_pinsert()
2354 * @see eina_value_list_append()
2355 * @see eina_value_list_vappend()
2356 * @see eina_value_list_pappend()
2357 *
2358 * @since 1.2
2359 */
2360static inline Eina_Bool eina_value_list_pappend(Eina_Value *value,
2361 const void *ptr) EINA_ARG_NONNULL(1);
2362
2363/**
2364 * @}
2365 */
2366
2367/**
2368 * @defgroup Eina_Value_Hash_Group Generic Value Hash management
2369 *
2370 * @{
2371 */
2372
2373/**
2374 * @typedef Eina_Value_Hash
2375 * Value type for #EINA_VALUE_TYPE_HASH.
2376 *
2377 * @see #_Eina_Value_Hash explains fields.
2378 * @since 1.2
2379 */
2380typedef struct _Eina_Value_Hash Eina_Value_Hash;
2381
2382/**
2383 * @struct _Eina_Value_Hash
2384 * Used to store the hash and its subtype.
2385 * @since 1.2
2386 */
2387struct _Eina_Value_Hash
2388{
2389 const Eina_Value_Type *subtype; /**< how to allocate and access items */
2390 unsigned int buckets_power_size; /**< how to allocate hash buckets, if zero a sane default is chosen. */
2391 Eina_Hash *hash; /**< the hash that holds data, members are of subtype->value_size bytes. */
2392};
2393
2394/**
2395 * @brief Create generic value storage of type hash.
2396 * @param subtype how to manage this hash members.
2397 * @param buckets_power_size how to allocate hash buckets (2 ^
2398 * buckets_power_size), if zero then a sane value is chosen.
2399 * @return The new value or @c NULL on failure.
2400 *
2401 * Create a new generic value storage of type hash. The members are
2402 * managed using the description specified by @a subtype.
2403 *
2404 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
2405 * #EINA_ERROR_VALUE_FAILED is set.
2406 *
2407 * @note this creates from mempool and then uses
2408 * eina_value_hash_setup().
2409 *
2410 * @see eina_value_free()
2411 * @see eina_value_hash_setup()
2412 *
2413 * @since 1.2
2414 */
2415EAPI Eina_Value *eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size) EINA_ARG_NONNULL(1);
2416
2417/**
2418 * @brief Initialize generic value storage of type hash.
2419 * @param value value object
2420 * @param subtype how to manage this hash members.
2421 * @param buckets_power_size how to allocate hash buckets (2 ^
2422 * buckets_power_size), if zero then a sane value is chosen.
2423 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2424 *
2425 * Initializes new generic value storage of type hash with the given
2426 * @a subtype.
2427 *
2428 * This is the same as calling eina_value_set() with
2429 * #EINA_VALUE_TYPE_HASH followed by eina_value_pset() with the
2430 * #Eina_Value_Hash description configured.
2431 *
2432 * @note Existing contents are ignored! If the value was previously used, then
2433 * use eina_value_flush() first.
2434 *
2435 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2436 * or #EINA_ERROR_VALUE_FAILED is set.
2437 *
2438 * @see eina_value_flush()
2439 *
2440 * @since 1.2
2441 */
2442static inline Eina_Bool eina_value_hash_setup(Eina_Value *value,
2443 const Eina_Value_Type *subtype,
2444 unsigned int buckets_power_size) EINA_ARG_NONNULL(1, 2);
2445
2446/**
2447 * @brief Query number of elements in value of hash type.
2448 * @param value value object.
2449 * @return number of child elements.
2450 * @since 1.2
2451 */
2452static inline unsigned int eina_value_hash_population(const Eina_Value *value);
2453
2454/**
2455 * @brief Remove element at given position in value of hash type.
2456 * @param value value object.
2457 * @param key key to find the member
2458 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2459 * @since 1.2
2460 */
2461static inline Eina_Bool eina_value_hash_del(Eina_Value *value,
2462 const char *key) EINA_ARG_NONNULL(1);
2463
2464/**
2465 * @brief Set the generic value in an hash member.
2466 * @param value source value object
2467 * @param key key to find the member
2468 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2469 *
2470 * The variable argument is dependent on chosen subtype. The list for
2471 * basic types:
2472 *
2473 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2474 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2475 * @li EINA_VALUE_TYPE_UINT: unsigned int
2476 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2477 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2478 * @li EINA_VALUE_TYPE_CHAR: char
2479 * @li EINA_VALUE_TYPE_SHORT: short
2480 * @li EINA_VALUE_TYPE_INT: int
2481 * @li EINA_VALUE_TYPE_LONG: long
2482 * @li EINA_VALUE_TYPE_INT64: int64_t
2483 * @li EINA_VALUE_TYPE_FLOAT: float
2484 * @li EINA_VALUE_TYPE_DOUBLE: double
2485 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
2486 * @li EINA_VALUE_TYPE_STRING: const char *
2487 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2488 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2489 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2490 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2491 *
2492 * @code
2493 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2494 * int x;
2495 *
2496 * eina_value_hash_set(value, "abc", 5678);
2497 * eina_value_hash_get(value, "abc", &x);
2498 * eina_value_free(value);
2499 * @endcode
2500 *
2501 * @see eina_value_hash_get()
2502 * @see eina_value_hash_vset()
2503 * @see eina_value_hash_pset()
2504 * @see eina_value_hash_del()
2505 *
2506 * @since 1.2
2507 */
2508static inline Eina_Bool eina_value_hash_set(Eina_Value *value,
2509 const char *key,
2510 ...) EINA_ARG_NONNULL(1);
2511
2512/**
2513 * @brief Get the generic value from an hash member.
2514 * @param value source value object
2515 * @param key key to find the member
2516 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2517 *
2518 * The value is returned in the variable argument parameter, the
2519 * actual value is type-dependent, but usually it will be what is
2520 * stored inside the object. There shouldn't be any memory allocation,
2521 * thus the contents should @b not be freed.
2522 *
2523 * The variable argument is dependent on chosen subtype. The list for
2524 * basic types:
2525 *
2526 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2527 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2528 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2529 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2530 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2531 * @li EINA_VALUE_TYPE_CHAR: char*
2532 * @li EINA_VALUE_TYPE_SHORT: short*
2533 * @li EINA_VALUE_TYPE_INT: int*
2534 * @li EINA_VALUE_TYPE_LONG: long*
2535 * @li EINA_VALUE_TYPE_INT64: int64_t*
2536 * @li EINA_VALUE_TYPE_FLOAT: float*
2537 * @li EINA_VALUE_TYPE_DOUBLE: double*
2538 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2539 * @li EINA_VALUE_TYPE_STRING: const char **
2540 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2541 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2542 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2543 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2544 *
2545 * @code
2546 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2547 * int x;
2548 *
2549 * eina_value_hash_set(value, "abc", 1234);
2550 * eina_value_hash_get(value, "abc", &x);
2551 * eina_value_free(value);
2552 * @endcode
2553 *
2554 * @see eina_value_hash_set()
2555 * @see eina_value_hash_vset()
2556 * @see eina_value_hash_pset()
2557 *
2558 * @since 1.2
2559 */
2560static inline Eina_Bool eina_value_hash_get(const Eina_Value *value,
2561 const char *key,
2562 ...) EINA_ARG_NONNULL(1);
2563
2564/**
2565 * @brief Set the generic value in an hash member.
2566 * @param value source value object
2567 * @param key key to find the member
2568 * @param args variable argument
2569 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2570 * @see eina_value_hash_set()
2571 * @see eina_value_hash_get()
2572 * @see eina_value_hash_pset()
2573 *
2574 * @since 1.2
2575 */
2576static inline Eina_Bool eina_value_hash_vset(Eina_Value *value,
2577 const char *key,
2578 va_list args) EINA_ARG_NONNULL(1);
2579
2580/**
2581 * @brief Get the generic value from an hash member.
2582 * @param value source value object
2583 * @param key key to find the member
2584 * @param args variable argument
2585 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2586 *
2587 * The value is returned in the variable argument parameter, the
2588 * actual value is type-dependent, but usually it will be what is
2589 * stored inside the object. There shouldn't be any memory allocation,
2590 * thus the contents should @b not be freed.
2591 *
2592 * @see eina_value_hash_vset()
2593 * @see eina_value_hash_get()
2594 * @see eina_value_hash_pget()
2595 *
2596 * @since 1.2
2597 */
2598static inline Eina_Bool eina_value_hash_vget(const Eina_Value *value,
2599 const char *key,
2600 va_list args) EINA_ARG_NONNULL(1);
2601
2602/**
2603 * @brief Set the generic value in an hash member from pointer.
2604 * @param value source value object
2605 * @param key key to find the member
2606 * @param ptr pointer to specify the contents.
2607 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2608 *
2609 * The pointer type is dependent on chosen value type. The list for
2610 * basic types:
2611 *
2612 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2613 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2614 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2615 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2616 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2617 * @li EINA_VALUE_TYPE_CHAR: char*
2618 * @li EINA_VALUE_TYPE_SHORT: short*
2619 * @li EINA_VALUE_TYPE_INT: int*
2620 * @li EINA_VALUE_TYPE_LONG: long*
2621 * @li EINA_VALUE_TYPE_INT64: int64_t*
2622 * @li EINA_VALUE_TYPE_FLOAT: float*
2623 * @li EINA_VALUE_TYPE_DOUBLE: double*
2624 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2625 * @li EINA_VALUE_TYPE_STRING: const char **
2626 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2627 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2628 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2629 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2630 *
2631 * @note the pointer contents are written using the size defined by
2632 * type. It can be larger than void* or uint64_t.
2633 *
2634 * @code
2635 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2636 * int x = 1234;
2637 *
2638 * eina_value_hash_pset(value, "abc", &x);
2639 * eina_value_hash_pget(value, "abc", &x);
2640 * eina_value_free(value);
2641 * @endcode
2642 *
2643 * @see eina_value_hash_set()
2644 * @see eina_value_hash_get()
2645 * @see eina_value_hash_vset()
2646 *
2647 * @since 1.2
2648 */
2649static inline Eina_Bool eina_value_hash_pset(Eina_Value *value,
2650 const char *key,
2651 const void *ptr) EINA_ARG_NONNULL(1, 3);
2652
2653/**
2654 * @brief Get the generic value to pointer from an hash member.
2655 * @param value source value object
2656 * @param key key to find the member
2657 * @param ptr pointer to receive the contents.
2658 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2659 *
2660 * The value is returned in pointer contents, the actual value is
2661 * type-dependent, but usually it will be what is stored inside the
2662 * object. There shouldn't be any memory allocation, thus the contents
2663 * should @b not be freed.
2664 *
2665 * The pointer type is dependent on chosen value type. The list for
2666 * basic types:
2667 *
2668 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2669 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2670 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2671 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2672 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2673 * @li EINA_VALUE_TYPE_CHAR: char*
2674 * @li EINA_VALUE_TYPE_SHORT: short*
2675 * @li EINA_VALUE_TYPE_INT: int*
2676 * @li EINA_VALUE_TYPE_LONG: long*
2677 * @li EINA_VALUE_TYPE_INT64: int64_t*
2678 * @li EINA_VALUE_TYPE_FLOAT: float*
2679 * @li EINA_VALUE_TYPE_DOUBLE: double*
2680 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2681 * @li EINA_VALUE_TYPE_STRING: const char **
2682 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2683 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2684 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2685 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2686 *
2687 * @code
2688 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2689 * int x;
2690 *
2691 * eina_value_hash_set(value, "abc", 1234);
2692 * eina_value_hash_pget(value, "abc", &x);
2693 * eina_value_free(value);
2694 * @endcode
2695 *
2696 * @see eina_value_hash_set()
2697 * @see eina_value_hash_vset()
2698 * @see eina_value_hash_pset()
2699 *
2700 * @since 1.2
2701 */
2702static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value,
2703 const char *key,
2704 void *ptr) EINA_ARG_NONNULL(1, 3);
2705
2706/**
2707 * @}
2708 */
2709
2710/**
2711 * @defgroup Eina_Value_Blob_Group Generic Value Blob management
2712 *
2713 * @{
2714 */
2715
2716/**
2717 * @typedef Eina_Value_Blob_Operations
2718 * How to manage blob. Any @c NULL callback is ignored.
2719 * @see #_Eina_Value_Blob_Operations explains fields.
2720 * @since 1.2
2721 */
2722typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations;
2723
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/**
2731 * @struct _Eina_Value_Blob_Operations
2732 * How to manage blob. Any @c NULL callback is ignored.
2733 * @since 1.2
2734 */
2735struct _Eina_Value_Blob_Operations
2736{
2737 unsigned int version; /**< must be #EINA_VALUE_BLOB_OPERATIONS_VERSION */
2738 void (*free)(const Eina_Value_Blob_Operations *ops, void *memory, size_t size);
2739 void *(*copy)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2740 int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2);
2741 char *(*to_string)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2742};
2743
2744/**
2745 * @var EINA_VALUE_BLOB_OPERATIONS_MALLOC
2746 *
2747 * Assumes @c memory was create with malloc() and applies free() to it
2748 * during flush (Eina_Value_Blob_Operations::free). Copy is done with
2749 * malloc() as well.
2750 *
2751 * No compare or to_string are provided, defaults will be used.
2752 */
2753EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC;
2754
2755/**
2756 * @typedef Eina_Value_Blob
2757 * Value type for #EINA_VALUE_TYPE_BLOB.
2758 *
2759 * @see #_Eina_Value_Blob explains fields.
2760 * @since 1.2
2761 */
2762typedef struct _Eina_Value_Blob Eina_Value_Blob;
2763
2764/**
2765 * @struct _Eina_Value_Blob
2766 * Used to store the blob information and management operations.
2767 * @since 1.2
2768 */
2769struct _Eina_Value_Blob
2770{
2771 const Eina_Value_Blob_Operations *ops; /**< if @c NULL, nothing is freed, copy will just copy the memory pointer, not its value. */
2772 const void *memory;
2773 unsigned int size;
2774};
2775
2776/**
2777 * @}
2778 */
2779
2780/**
2781 * @defgroup Eina_Value_Struct_Group Generic Value Struct management
2782 *
2783 * @{
2784 */
2785
2786/**
2787 * @typedef Eina_Value_Struct_Operations
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.
2794 * @since 1.2
2795 */
2796typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations;
2797
2798/**
2799 * @typedef Eina_Value_Struct_Member
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.
2807 * @since 1.2
2808 */
2809typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member;
2810
2811/**
2812 * @typedef Eina_Value_Struct_Desc
2813 * Describes the struct by listing its size, members and operations.
2814 * @see #_Eina_Value_Struct_Desc explains fields.
2815 * @since 1.2
2816 */
2817typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc;
2818
2819/**
2820 * @typedef Eina_Value_Struct
2821 * Value type for #EINA_VALUE_TYPE_STRUCT.
2822 *
2823 * @see #_Eina_Value_Struct explains fields.
2824 * @since 1.2
2825 */
2826typedef struct _Eina_Value_Struct Eina_Value_Struct;
2827
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/**
2835 * @struct _Eina_Value_Struct_Operations
2836 * How to manage struct. Any @c NULL callback is ignored.
2837 * @since 1.2
2838 */
2839struct _Eina_Value_Struct_Operations
2840{
2841 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 */
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 */
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. */
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 */
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(). */
2847};
2848
2849/**
2850 * @var EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH
2851 *
2852 * Assumes @c members is sorted by name and applies binary search for
2853 * names.
2854 *
2855 * Ideally the @c member_count field is set to speed it up.
2856 *
2857 * No other methods are set (alloc, free, copy, compare), then it uses
2858 * the default operations.
2859 */
2860EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
2861
2862/**
2863 * @var EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE
2864 *
2865 * Assumes @c members name are stringshared and can be compared for
2866 * equality without using its contents (simple pointer comparison).
2867 *
2868 * Ideally the search @c name will be stringshared as well, but it
2869 * will do a second loop with a forced stringshare if it did not find
2870 * the member.
2871 *
2872 * No other methods are set (alloc, free, copy, compare), then it uses
2873 * the default operations.
2874 */
2875EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
2876
2877/**
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 *
2893 * @since 1.2
2894 */
2895struct _Eina_Value_Struct_Member
2896{
2897 const char *name; /**< member name, used in lookups such as eina_value_struct_get() */
2898 const Eina_Value_Type *type; /**< how to use this member */
2899 unsigned int offset; /**< where this member is located within the structure memory */
2900};
2901
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/**
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 *
2916 * @since 1.2
2917 */
2918struct _Eina_Value_Struct_Desc
2919{
2920 unsigned int version; /**< must be #EINA_VALUE_STRUCT_DESC_VERSION */
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. */
2922 const Eina_Value_Struct_Member *members; /**< array of member descriptions, if @c member_count is zero, then it must be @c NULL terminated. */
2923 unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */
2924 unsigned int size; /**< byte size to allocate, may be bigger than sum of members */
2925};
2926
2927/**
2928 * @def EINA_VALUE_STRUCT_MEMBER
2929 *
2930 * Helper to define Eina_Value_Struct_Member fields, uses offsetof()
2931 * with type and member.
2932 *
2933 * @since 1.2
2934 */
2935#define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member) \
2936 {#member, eina_value_type, offsetof(type, member)}
2937
2938/**
2939 * @def EINA_VALUE_STRUCT_MEMBER_SENTINEL
2940 *
2941 * Helper to define Eina_Value_Struct_Member fields for sentinel (last
2942 * item), useful if you did not define @c member_count.
2943 *
2944 * @since 1.2
2945 */
2946#define EINA_VALUE_STRUCT_MEMBER_SENTINEL {NULL, NULL, 0}
2947
2948
2949/**
2950 * @struct _Eina_Value_Struct
2951 * Used to store the memory and its description.
2952 * @since 1.2
2953 */
2954struct _Eina_Value_Struct
2955{
2956 const Eina_Value_Struct_Desc *desc; /**< How to manage the structure */
2957 void *memory; /**< The managed structure memory */
2958};
2959
2960/**
2961 * @brief Create generic value storage of type struct.
2962 * @param desc how to manage this struct members.
2963 * @return The new value or @c NULL on failure.
2964 *
2965 * Create a new generic value storage of type struct. The members are
2966 * managed using the description specified by @a desc.
2967 *
2968 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
2969 * #EINA_ERROR_VALUE_FAILED is set.
2970 *
2971 * @note this creates from mempool and then uses
2972 * eina_value_struct_setup().
2973 *
2974 * @see eina_value_free()
2975 * @see eina_value_struct_setup()
2976 *
2977 * @since 1.2
2978 */
2979EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1);
2980
2981/**
2982 * @brief Initialize generic value storage of type struct.
2983 * @param value value object
2984 * @param desc how to manage this struct members.
2985 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2986 *
2987 * Initializes new generic value storage of type struct with the given
2988 * @a desc.
2989 *
2990 * This is the same as calling eina_value_set() with
2991 * #EINA_VALUE_TYPE_STRUCT followed by eina_value_pset() with the
2992 * #Eina_Value_Struct description configured.
2993 *
2994 * @note Existing contents are ignored! If the value was previously used, then
2995 * use eina_value_flush() first.
2996 *
2997 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2998 * or #EINA_ERROR_VALUE_FAILED is set.
2999 *
3000 * @see eina_value_flush()
3001 *
3002 * @since 1.2
3003 */
3004static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
3005 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
3006
3007/**
3008 * @brief Set the generic value in an struct member.
3009 * @param value source value object
3010 * @param name name to find the member
3011 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3012 *
3013 * The variable argument is dependent on chosen member type. The list
3014 * for basic types:
3015 *
3016 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
3017 * @li EINA_VALUE_TYPE_USHORT: unsigned short
3018 * @li EINA_VALUE_TYPE_UINT: unsigned int
3019 * @li EINA_VALUE_TYPE_ULONG: unsigned long
3020 * @li EINA_VALUE_TYPE_UINT64: uint64_t
3021 * @li EINA_VALUE_TYPE_CHAR: char
3022 * @li EINA_VALUE_TYPE_SHORT: short
3023 * @li EINA_VALUE_TYPE_INT: int
3024 * @li EINA_VALUE_TYPE_LONG: long
3025 * @li EINA_VALUE_TYPE_INT64: int64_t
3026 * @li EINA_VALUE_TYPE_FLOAT: float
3027 * @li EINA_VALUE_TYPE_DOUBLE: double
3028 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
3029 * @li EINA_VALUE_TYPE_STRING: const char *
3030 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
3031 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3032 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3033 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3034 *
3035 * @code
3036 * struct myst {
3037 * int i;
3038 * char c;
3039 * };
3040 * const Eina_Value_Struct_Member myst_members[] = {
3041 * {"i", EINA_VALUE_TYPE_INT, 0},
3042 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3043 * {NULL, NULL, 0}
3044 * };
3045 * const Eina_Value_Struct_Desc myst_desc = {
3046 * EINA_VALUE_STRUCT_DESC_VERSION,
3047 * NULL, myst_members, 2, sizeof(struct myst)
3048 * };
3049 * Eina_Value *value = eina_value_struct_new(&my_desc);
3050 * int x;
3051 * char y;
3052 *
3053 * eina_value_struct_set(value, "i", 5678);
3054 * eina_value_struct_get(value, "i", &x);
3055 * eina_value_struct_set(value, "c", 0xf);
3056 * eina_value_struct_get(value, "c", &y);
3057 * eina_value_free(value);
3058 * @endcode
3059 *
3060 * @see eina_value_struct_get()
3061 * @see eina_value_struct_vset()
3062 * @see eina_value_struct_pset()
3063 *
3064 * @since 1.2
3065 */
3066static inline Eina_Bool eina_value_struct_set(Eina_Value *value,
3067 const char *name,
3068 ...) EINA_ARG_NONNULL(1, 2);
3069
3070/**
3071 * @brief Get the generic value from an struct member.
3072 * @param value source value object
3073 * @param name name to find the member
3074 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3075 *
3076 * The value is returned in the variable argument parameter, the
3077 * actual value is type-dependent, but usually it will be what is
3078 * stored inside the object. There shouldn't be any memory allocation,
3079 * thus the contents should @b not be freed.
3080 *
3081 * The variable argument is dependent on chosen member type. The list
3082 * for basic types:
3083 *
3084 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3085 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3086 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3087 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3088 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3089 * @li EINA_VALUE_TYPE_CHAR: char*
3090 * @li EINA_VALUE_TYPE_SHORT: short*
3091 * @li EINA_VALUE_TYPE_INT: int*
3092 * @li EINA_VALUE_TYPE_LONG: long*
3093 * @li EINA_VALUE_TYPE_INT64: int64_t*
3094 * @li EINA_VALUE_TYPE_FLOAT: float*
3095 * @li EINA_VALUE_TYPE_DOUBLE: double*
3096 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3097 * @li EINA_VALUE_TYPE_STRING: const char **
3098 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3099 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3100 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3101 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3102 *
3103 * @code
3104 * struct myst {
3105 * int i;
3106 * char c;
3107 * };
3108 * const Eina_Value_Struct_Member myst_members[] = {
3109 * {"i", EINA_VALUE_TYPE_INT, 0},
3110 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3111 * {NULL, NULL, 0}
3112 * };
3113 * const Eina_Value_Struct_Desc myst_desc = {
3114 * EINA_VALUE_STRUCT_DESC_VERSION,
3115 * NULL, myst_members, 2, sizeof(struct myst)
3116 * };
3117 * Eina_Value *value = eina_value_struct_new(&my_desc);
3118 * int x;
3119 * char y;
3120 *
3121 * eina_value_struct_set(value, "i", 5678);
3122 * eina_value_struct_get(value, "i", &x);
3123 * eina_value_struct_set(value, "c", 0xf);
3124 * eina_value_struct_get(value, "c", &y);
3125 * eina_value_free(value);
3126 * @endcode
3127 *
3128 * @see eina_value_struct_set()
3129 * @see eina_value_struct_vset()
3130 * @see eina_value_struct_pset()
3131 *
3132 * @since 1.2
3133 */
3134static inline Eina_Bool eina_value_struct_get(const Eina_Value *value,
3135 const char *name,
3136 ...) EINA_ARG_NONNULL(1, 2);
3137
3138/**
3139 * @brief Set the generic value in an struct member.
3140 * @param value source value object
3141 * @param name name to find the member
3142 * @param args variable argument
3143 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3144 * @see eina_value_struct_set()
3145 * @see eina_value_struct_get()
3146 * @see eina_value_struct_pset()
3147 *
3148 * @since 1.2
3149 */
3150static inline Eina_Bool eina_value_struct_vset(Eina_Value *value,
3151 const char *name,
3152 va_list args) EINA_ARG_NONNULL(1, 2);
3153
3154/**
3155 * @brief Get the generic value from an struct member.
3156 * @param value source value object
3157 * @param name name to find the member
3158 * @param args variable argument
3159 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3160 *
3161 * The value is returned in the variable argument parameter, the
3162 * actual value is type-dependent, but usually it will be what is
3163 * stored inside the object. There shouldn't be any memory allocation,
3164 * thus the contents should @b not be freed.
3165 *
3166 * @see eina_value_struct_vset()
3167 * @see eina_value_struct_get()
3168 * @see eina_value_struct_pget()
3169 *
3170 * @since 1.2
3171 */
3172static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value,
3173 const char *name,
3174 va_list args) EINA_ARG_NONNULL(1, 2);
3175
3176/**
3177 * @brief Set the generic value in an struct member from pointer.
3178 * @param value source value object
3179 * @param name name to find the member
3180 * @param ptr pointer to specify the contents.
3181 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3182 *
3183 * The pointer type is dependent on chosen value type. The list for
3184 * basic types:
3185 *
3186 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3187 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3188 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3189 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3190 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3191 * @li EINA_VALUE_TYPE_CHAR: char*
3192 * @li EINA_VALUE_TYPE_SHORT: short*
3193 * @li EINA_VALUE_TYPE_INT: int*
3194 * @li EINA_VALUE_TYPE_LONG: long*
3195 * @li EINA_VALUE_TYPE_INT64: int64_t*
3196 * @li EINA_VALUE_TYPE_FLOAT: float*
3197 * @li EINA_VALUE_TYPE_DOUBLE: double*
3198 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3199 * @li EINA_VALUE_TYPE_STRING: const char **
3200 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3201 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3202 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3203 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3204 *
3205 * @note the pointer contents are written using the size defined by
3206 * type. It can be larger than void* or uint64_t.
3207 *
3208 * @code
3209 * struct myst {
3210 * int i;
3211 * char c;
3212 * };
3213 * const Eina_Value_Struct_Member myst_members[] = {
3214 * {"i", EINA_VALUE_TYPE_INT, 0},
3215 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3216 * {NULL, NULL, 0}
3217 * };
3218 * const Eina_Value_Struct_Desc myst_desc = {
3219 * EINA_VALUE_STRUCT_DESC_VERSION,
3220 * NULL, myst_members, 2, sizeof(struct myst)
3221 * };
3222 * Eina_Value *value = eina_value_struct_new(&my_desc);
3223 * int x = 5678;
3224 * char y = 0xf;
3225 *
3226 * eina_value_struct_pset(value, "i", &);
3227 * eina_value_struct_pget(value, "i", &x);
3228 * eina_value_struct_pset(value, "c", &y);
3229 * eina_value_struct_pget(value, "c", &y);
3230 * eina_value_free(value);
3231 * @endcode
3232 *
3233 * @see eina_value_struct_set()
3234 * @see eina_value_struct_get()
3235 * @see eina_value_struct_vset()
3236 *
3237 * @since 1.2
3238 */
3239static inline Eina_Bool eina_value_struct_pset(Eina_Value *value,
3240 const char *name,
3241 const void *ptr) EINA_ARG_NONNULL(1, 2, 3);
3242
3243/**
3244 * @brief Get the generic value to pointer from an struct member.
3245 * @param value source value object
3246 * @param name name to find the member
3247 * @param ptr pointer to receive the contents.
3248 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3249 *
3250 * The value is returned in pointer contents, the actual value is
3251 * type-dependent, but usually it will be what is stored inside the
3252 * object. There shouldn't be any memory allocation, thus the contents
3253 * should @b not be freed.
3254 *
3255 * The pointer type is dependent on chosen value type. The list for
3256 * basic types:
3257 *
3258 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
3259 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
3260 * @li EINA_VALUE_TYPE_UINT: unsigned int*
3261 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
3262 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
3263 * @li EINA_VALUE_TYPE_CHAR: char*
3264 * @li EINA_VALUE_TYPE_SHORT: short*
3265 * @li EINA_VALUE_TYPE_INT: int*
3266 * @li EINA_VALUE_TYPE_LONG: long*
3267 * @li EINA_VALUE_TYPE_INT64: int64_t*
3268 * @li EINA_VALUE_TYPE_FLOAT: float*
3269 * @li EINA_VALUE_TYPE_DOUBLE: double*
3270 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
3271 * @li EINA_VALUE_TYPE_STRING: const char **
3272 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
3273 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
3274 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
3275 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
3276 *
3277 * @code
3278 * struct myst {
3279 * int i;
3280 * char c;
3281 * };
3282 * const Eina_Value_Struct_Member myst_members[] = {
3283 * {"i", EINA_VALUE_TYPE_INT, 0},
3284 * {"c", EINA_VALUE_TYPE_CHAR, 4},
3285 * {NULL, NULL, 0}
3286 * };
3287 * const Eina_Value_Struct_Desc myst_desc = {
3288 * EINA_VALUE_STRUCT_DESC_VERSION,
3289 * NULL, myst_members, 2, sizeof(struct myst)
3290 * };
3291 * Eina_Value *value = eina_value_struct_new(&my_desc);
3292 * int x = 5678;
3293 * char y = 0xf;
3294 *
3295 * eina_value_struct_pset(value, "i", &);
3296 * eina_value_struct_pget(value, "i", &x);
3297 * eina_value_struct_pset(value, "c", &y);
3298 * eina_value_struct_pget(value, "c", &y);
3299 * eina_value_free(value);
3300 * @endcode
3301 *
3302 * @see eina_value_struct_set()
3303 * @see eina_value_struct_vset()
3304 * @see eina_value_struct_pset()
3305 *
3306 * @since 1.2
3307 */
3308static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
3309 const char *name,
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
3366
3367/**
3368 * @}
3369 */
3370
3371
3372/**
3373 * @defgroup Eina_Value_Type_Group Generic Value Type management
3374 *
3375 * @{
3376 */
3377
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/**
3385 * @struct _Eina_Value_Type
3386 * API to access values.
3387 *
3388 * @since 1.2
3389 */
3390struct _Eina_Value_Type
3391{
3392 unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */
3393 unsigned int value_size; /**< byte size of value */
3394 const char *name; /**< name for debug and introspection */
3395 Eina_Bool (*setup)(const Eina_Value_Type *type, void *mem); /**< mem will be malloc(value_size) and should be configured */
3396 Eina_Bool (*flush)(const Eina_Value_Type *type, void *mem); /**< clear any values from mem */
3397 Eina_Bool (*copy)(const Eina_Value_Type *type, const void *src, void *dst); /**< how to copy values, both memory are @c value_size */
3398 int (*compare)(const Eina_Value_Type *type, const void *a, const void *b); /**< how to compare values, both memory are @c value_size */
3399 Eina_Bool (*convert_to)(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); /**< how to convert values, both memory are @c value_size */
3400 Eina_Bool (*convert_from)(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); /**< how to convert values, both memory are @c value_size */
3401 Eina_Bool (*vset)(const Eina_Value_Type *type, void *mem, va_list args); /**< how to set memory from variable argument */
3402 Eina_Bool (*pset)(const Eina_Value_Type *type, void *mem, const void *ptr); /**< how to set memory from pointer */
3403 Eina_Bool (*pget)(const Eina_Value_Type *type, const void *mem, void *ptr); /**< how to read memory */
3404};
3405
3406/**
3407 * @brief Query type name.
3408 * @param type type reference.
3409 * @return string or @c NULL if type is invalid.
3410 * @since 1.2
3411 */
3412EAPI const char *eina_value_type_name_get(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3413
3414/**
3415 * @brief Check if type is valid.
3416 * @param type type reference.
3417 * @return #EINA_TRUE if valid, #EINA_FALSE otherwise.
3418 *
3419 * A type is invalid if it's NULL or if version field is not the same
3420 * as runtime #EINA_VALUE_TYPE_VERSION.
3421 *
3422 * @since 1.2
3423 */
3424EAPI Eina_Bool eina_value_type_check(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3425
3426/**
3427 * @brief Initialize memory using type descriptor.
3428 * @param type type reference.
3429 * @param mem memory to operate, must be of size @c type->value_size.
3430 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3431 * @since 1.2
3432 */
3433static inline Eina_Bool eina_value_type_setup(const Eina_Value_Type *type, void *mem);
3434
3435/**
3436 * @brief Flush (clear) memory using type descriptor.
3437 * @param type type reference.
3438 * @param mem memory to operate, must be of size @c type->value_size.
3439 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3440 * @since 1.2
3441 */
3442static inline Eina_Bool eina_value_type_flush(const Eina_Value_Type *type, void *mem);
3443
3444/**
3445 * @brief Copy memory using type descriptor.
3446 * @param type type reference.
3447 * @param src memory to operate, must be of size @c type->value_size.
3448 * @param dst memory to operate, must be of size @c type->value_size.
3449 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3450 * @since 1.2
3451 */
3452static inline Eina_Bool eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst);
3453
3454/**
3455 * @brief Compare memory using type descriptor.
3456 * @param type type reference.
3457 * @param a memory to operate, must be of size @c type->value_size.
3458 * @param b memory to operate, must be of size @c type->value_size.
3459 * @return less than zero if a < b, greater than zero if a > b, zero if equal.
3460 * @since 1.2
3461 */
3462static inline int eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b);
3463
3464/**
3465 * @brief Convert memory using type descriptor.
3466 * @param type type reference of the source.
3467 * @param convert type reference of the destination.
3468 * @param type_mem memory to operate, must be of size @c type->value_size.
3469 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3470 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3471 * @since 1.2
3472 */
3473static inline Eina_Bool eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem);
3474
3475/**
3476 * @brief Convert memory using type descriptor.
3477 * @param type type reference of the destination.
3478 * @param convert type reference of the source.
3479 * @param type_mem memory to operate, must be of size @c type->value_size.
3480 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3481 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3482 * @since 1.2
3483 */
3484static inline Eina_Bool eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem);
3485
3486/**
3487 * @brief Set memory using type descriptor and variable argument.
3488 * @param type type reference of the source.
3489 * @param mem memory to operate, must be of size @c type->value_size.
3490 * @param args input value.
3491 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3492 * @since 1.2
3493 */
3494static inline Eina_Bool eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args);
3495
3496/**
3497 * @brief Set memory using type descriptor and pointer.
3498 * @param type type reference of the source.
3499 * @param mem memory to operate, must be of size @c type->value_size.
3500 * @param ptr pointer to input value.
3501 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3502 * @since 1.2
3503 */
3504static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr);
3505
3506/**
3507 * @brief Get memory using type descriptor.
3508 * @param type type reference of the source.
3509 * @param mem memory to operate, must be of size @c type->value_size.
3510 * @param ptr pointer to output.
3511 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3512 * @since 1.2
3513 */
3514static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr);
3515
3516/**
3517 * @}
3518 */
3519
3520#include "eina_inline_value.x"
3521
3522/**
3523 * @}
3524 */
3525
3526/**
3527 * @}
3528 */
3529
3530/**
3531 * @}
3532 */
3533#endif
diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h
deleted file mode 100644
index 0f89cc3..0000000
--- a/libraries/eina/src/include/eina_xattr.h
+++ /dev/null
@@ -1,215 +0,0 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_XATTR_H_
20#define EINA_XATTR_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Tools_Group Tools
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_Xattr_Flags
32 * define extended attribute creation
33 *
34 * @since 1.1
35 */
36typedef enum {
37 EINA_XATTR_INSERT, /**< This is the default behaviour, it will either create or replace the extended attribute */
38 EINA_XATTR_REPLACE, /**< This will only succeed if the extended attribute previously existed */
39 EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */
40} Eina_Xattr_Flags;
41
42typedef struct _Eina_Xattr Eina_Xattr;
43struct _Eina_Xattr
44{
45 const char *name; /**< The eXtended attribute name @since 1.2 */
46 const char *value; /**< The eXtended attribute value @since 1.2 */
47
48 size_t length; /**< The length of the eXtended attribute value @since 1.2 */
49};
50
51/**
52 * @brief Get an iterator that list all extended attribute of a file.
53 *
54 * @param file The filename to retrieve the extended attribute list from.
55 * @return an iterator.
56 *
57 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
58 * if you need.
59 *
60 * @since 1.1
61 */
62EAPI Eina_Iterator *eina_xattr_ls(const char *file);
63
64/**
65 * @brief Get an iterator that list all extended attribute value related to a fd.
66 *
67 * @param file The filename to retrieve the extended attribute list from.
68 * @return an iterator.
69 *
70 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
71 * if you need. The iterator will provide an Eina_Xattr structure.
72 *
73 * @since 1.2
74 */
75EAPI Eina_Iterator *eina_xattr_value_ls(const char *file);
76
77/**
78 * @brief Get an iterator that list all extended attribute related to a fd.
79 *
80 * @param fd The file descriptor to retrieve the extended attribute list from.
81 * @return an iterator.
82 *
83 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
84 * if you need.
85 *
86 * @since 1.2
87 */
88EAPI Eina_Iterator *eina_xattr_fd_ls(int fd);
89
90/**
91 * @brief Get an iterator that list all extended attribute value related to a fd.
92 *
93 * @param fd The file descriptor to retrieve the extended attribute list from.
94 * @return an iterator.
95 *
96 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
97 * if you need. The iterator will provide an Eina_Xattr structure.
98 *
99 * @since 1.2
100 */
101EAPI Eina_Iterator *eina_xattr_value_fd_ls(int fd);
102
103/**
104 * @brief Retrieve an extended attribute from a file.
105 *
106 * @param file The file to retrieve the extended attribute from.
107 * @param attribute The extended attribute name to retrieve.
108 * @param size The size of the retrieved extended attribute.
109 * @return the allocated data that hold the extended attribute value.
110 *
111 * It will return NULL and *size will be @c 0 if it fails.
112 *
113 * @since 1.1
114 */
115EAPI void *eina_xattr_get(const char *file, const char *attribute, ssize_t *size);
116
117/**
118 * @brief Set an extended attribute on a file.
119 *
120 * @param file The file to set the extended attribute to.
121 * @param attribute The attribute to set.
122 * @param data The data to set.
123 * @param length The length of the data to set.
124 * @param flags Define the set policy.
125 * @return EINA_TRUE on success, EINA_FALSE otherwise.
126 *
127 * @since 1.1
128 */
129EAPI Eina_Bool eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags);
130
131/**
132 * @brief Set a string as a extended attribute properties.
133 *
134 * @param file The file to set the string to.
135 * @param attribute The attribute to set.
136 * @param data The NULL terminated string to set.
137 * @param flags Define the set policy.
138 * @return EINA_TRUE on success, EINA_FALSE otherwise.
139 *
140 * @since 1.1
141 */
142EAPI Eina_Bool eina_xattr_string_set(const char *file, const char *attribute, const char *data, Eina_Xattr_Flags flags);
143
144/**
145 * @brief Get a string from an extended attribute properties.
146 *
147 * @param file The file to get the string from.
148 * @param attribute The attribute to get.
149 * @return a valid string on success, NULL otherwise.
150 *
151 * This call check that the string is properly NULL-terminated before returning it.
152 *
153 * @since 1.1
154 */
155EAPI char *eina_xattr_string_get(const char *file, const char *attribute);
156
157/**
158 * @brief Set a double as a extended attribute properties.
159 *
160 * @param file The file to set the double to.
161 * @param attribute The attribute to set.
162 * @param value The NULL terminated double to set.
163 * @param flags Define the set policy.
164 * @return EINA_TRUE on success, EINA_FALSE otherwise.
165 *
166 * @since 1.1
167 */
168EAPI Eina_Bool eina_xattr_double_set(const char *file, const char *attribute, double value, Eina_Xattr_Flags flags);
169
170/**
171 * @brief Get a double from an extended attribute properties.
172 *
173 * @param file The file to get the string from.
174 * @param attribute The attribute to get.
175 * @param value Where to put the extracted value
176 * @return EINA_TRUE on success, EINA_FALSE otherwise.
177 *
178 * This call check that the double is correctly set.
179 *
180 * @since 1.1
181 */
182EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, double *value);
183
184/**
185 * @brief Set an int as a extended attribute properties.
186 *
187 * @param file The file to set the int to.
188 * @param attribute The attribute to set.
189 * @param value The NULL terminated int to set.
190 * @param flags Define the set policy.
191 * @return EINA_TRUE on success, EINA_FALSE otherwise.
192 *
193 * @since 1.1
194 */
195EAPI Eina_Bool eina_xattr_int_set(const char *file, const char *attribute, int value, Eina_Xattr_Flags flags);
196
197/**
198 * @brief Get a int from an extended attribute properties.
199 *
200 * @param file The file to get the string from.
201 * @param attribute The attribute to get.
202 * @param value Where to put the extracted value
203 * @return EINA_TRUE on success, EINA_FALSE otherwise.
204 *
205 * This call check that the int is correctly set.
206 *
207 * @since 1.1
208 */
209EAPI Eina_Bool eina_xattr_int_get(const char *file, const char *attribute, int *value);
210
211/**
212 * @}
213 */
214
215#endif