| Eina.h | | Eina.h | |
| /* EINA - EFL data type library | | /* EINA - EFL data type library | |
|
| * Copyright (C) 2008-2011 Enlightenment Developers: | | * Copyright (C) 2008-2012 Enlightenment Developers: | |
| * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> | | * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> | |
| * Alexandre "diaxen" Becoulet <diaxen@free.fr> | | * Alexandre "diaxen" Becoulet <diaxen@free.fr> | |
| * Andre Dieb <andre.dieb@gmail.com> | | * Andre Dieb <andre.dieb@gmail.com> | |
| * Arnaud de Turckheim "quarium" <quarium@gmail.com> | | * Arnaud de Turckheim "quarium" <quarium@gmail.com> | |
| * Carsten Haitzler <raster@rasterman.com> | | * Carsten Haitzler <raster@rasterman.com> | |
| * Cedric Bail <cedric.bail@free.fr> | | * Cedric Bail <cedric.bail@free.fr> | |
| * Corey "atmos" Donohoe <atmos@atmos.org> | | * Corey "atmos" Donohoe <atmos@atmos.org> | |
| * Fabiano Fidêncio <fidencio@profusion.mobi> | | * Fabiano Fidêncio <fidencio@profusion.mobi> | |
| * Gustavo Chaves <glima@profusion.mobi> | | * Gustavo Chaves <glima@profusion.mobi> | |
| * Gustavo Sverzut Barbieri <barbieri@gmail.com> | | * Gustavo Sverzut Barbieri <barbieri@gmail.com> | |
| * Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com> | | * Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com> | |
| * Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de> | | * Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de> | |
| * Raphael Kubo da Costa <kubo@profusion.mobi> | | * Raphael Kubo da Costa <kubo@profusion.mobi> | |
| * Tilman Sauerbeck <tilman@code-monkey.de> | | * Tilman Sauerbeck <tilman@code-monkey.de> | |
| * Vincent "caro" Torri <vtorri at univ-evry dot fr> | | * Vincent "caro" Torri <vtorri at univ-evry dot fr> | |
| * Tom Hacohen <tom@stosb.com> | | * Tom Hacohen <tom@stosb.com> | |
|
| | | * Jonas M. Gastal <jgastal@profusion.mobi> | |
| * | | * | |
| * This library is free software; you can redistribute it and/or | | * This library is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU Lesser General Public | | * modify it under the terms of the GNU Lesser General Public | |
| * License as published by the Free Software Foundation; either | | * License as published by the Free Software Foundation; either | |
| * version 2.1 of the License, or (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
| * This library is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * Lesser General Public License for more details. | | * Lesser General Public License for more details. | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 50 | |
| * @file | | * @file | |
| * @brief Eina Utility library | | * @brief Eina Utility library | |
| * | | * | |
| * These routines are used for Eina. | | * These routines are used for Eina. | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @mainpage Eina | | * @mainpage Eina | |
| * | | * | |
| * @version 1.1 | | * @version 1.1 | |
|
| * @date 2008-2011 | | * @date 2008-2012 | |
| * | | * | |
| * @section eina_intro_sec Introduction | | * @section eina_intro_sec Introduction | |
| * | | * | |
| * The Eina library is a library that implements an API for data types | | * The Eina library is a library that implements an API for data types | |
| * in an efficient way. It also provides some useful tools like | | * in an efficient way. It also provides some useful tools like | |
| * opening shared libraries, errors management, type conversion, | | * opening shared libraries, errors management, type conversion, | |
| * time accounting and memory pool. | | * time accounting and memory pool. | |
| * | | * | |
| * This library is cross-platform and can be compiled and used on | | * This library is cross-platform and can be compiled and used on | |
| * Linux, BSD, Opensolaris and Windows (XP and CE). | | * Linux, BSD, Opensolaris and Windows (XP and CE). | |
| * | | * | |
| * The data types that are available are (see @ref Eina_Data_Types_Group): | | * The data types that are available are (see @ref Eina_Data_Types_Group): | |
|
| | | * @li @ref Eina_Inline_Array_Group standard array of inlined members. | |
| * @li @ref Eina_Array_Group standard array of @c void* data. | | * @li @ref Eina_Array_Group standard array of @c void* data. | |
| * @li @ref Eina_Hash_Group standard hash of @c void* data. | | * @li @ref Eina_Hash_Group standard hash of @c void* data. | |
| * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. | | * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. | |
| * @li @ref Eina_CList_Group Compact List. | | * @li @ref Eina_CList_Group Compact List. | |
| * @li @ref Eina_List_Group standard list of @c void* data. | | * @li @ref Eina_List_Group standard list of @c void* data. | |
| * @li @ref Eina_Iterator_Group Iterator functions. | | * @li @ref Eina_Iterator_Group Iterator functions. | |
| * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. | | * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. | |
| * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user t
ype. | | * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user t
ype. | |
| * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or a
ppend strings to a buffer. | | * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or a
ppend strings to a buffer. | |
| * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string
references. | | * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string
references. | |
| * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regio
ns. | | * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regio
ns. | |
| * @li @ref Eina_Trash_Group container of unused but allocated data. | | * @li @ref Eina_Trash_Group container of unused but allocated data. | |
|
| | | * @li @ref Eina_Value_Group container for generic value storage and access | |
| | | . | |
| | | * @li @ref Eina_Model_Group container for data with user defined hierarchy | |
| | | /structure. | |
| * | | * | |
| * The tools that are available are (see @ref Eina_Tools_Group): | | * The tools that are available are (see @ref Eina_Tools_Group): | |
| * @li @ref Eina_Benchmark_Group helper to write benchmarks. | | * @li @ref Eina_Benchmark_Group helper to write benchmarks. | |
| * @li @ref Eina_Convert_Group faster conversion from strings to integers,
double, etc. | | * @li @ref Eina_Convert_Group faster conversion from strings to integers,
double, etc. | |
| * @li @ref Eina_Counter_Group measures number of calls and their time. | | * @li @ref Eina_Counter_Group measures number of calls and their time. | |
| * @li @ref Eina_Error_Group error identifiers. | | * @li @ref Eina_Error_Group error identifiers. | |
| * @li @ref Eina_File_Group simple file list and path split. | | * @li @ref Eina_File_Group simple file list and path split. | |
| * @li @ref Eina_Lalloc_Group simple lazy allocator. | | * @li @ref Eina_Lalloc_Group simple lazy allocator. | |
| * @li @ref Eina_Log_Group full-featured logging system. | | * @li @ref Eina_Log_Group full-featured logging system. | |
| * @li @ref Eina_Magic_Group provides runtime type checking. | | * @li @ref Eina_Magic_Group provides runtime type checking. | |
| | | | |
| skipping to change at line 103 | | skipping to change at line 107 | |
| * | | * | |
| * Eina provide easy to use and optimized data types and structures. | | * Eina provide easy to use and optimized data types and structures. | |
| * | | * | |
| * | | * | |
| * @defgroup Eina_Containers_Group Containers | | * @defgroup Eina_Containers_Group Containers | |
| * | | * | |
| * Containers are data types that hold data and allow iteration over | | * Containers are data types that hold data and allow iteration over | |
| * their elements with an @ref Eina_Iterator_Group, or eventually an | | * their elements with an @ref Eina_Iterator_Group, or eventually an | |
| * @ref Eina_Accessor_Group. | | * @ref Eina_Accessor_Group. | |
| * | | * | |
|
| | | * The containers in eina are designed with performance in mind, one conseq | |
| | | uence | |
| | | * of this is that they @b don't check the validity of data structures give | |
| | | n to | |
| | | * them(@ref Eina_Magic_Group). | |
| | | * | |
| | | * The choice of which container to use in each situation is very important | |
| | | in | |
| | | * achieving good performance and readable code. The most common container | |
| | | types | |
| | | * to be used are: | |
| | | * @li List | |
| | | * @li Inline list | |
| | | * @li Array | |
| | | * @li Inline array | |
| | | * @li Hash | |
| | | * | |
| | | * All types have virtues and vices. The following considerations are good | |
| | | * starting point in deciding which container to use: | |
| | | * @li Hashes are appropriate for datasets which will be searched often; | |
| | | * @li arrays are good when accessing members by position; | |
| | | * @li lists provide good versatility for adding elements in any position w | |
| | | ith | |
| | | * minimal overhead; | |
| | | * @li inline arrays use very little memory and don't cause fragmentation a | |
| | | nd | |
| | | * therefore are a good option in memory constrained systems; | |
| | | * @li inline lists are the appropriate type to use when the flexibility of | |
| | | a | |
| | | * list is required but the overhead of pointer indirection is not acceptab | |
| | | le. | |
| | | * @warning These are general considerations, every situation is different, | |
| | | * don't follow these recommendations blindly. | |
| * | | * | |
| * @defgroup Eina_Tools_Group Tools | | * @defgroup Eina_Tools_Group Tools | |
| * | | * | |
| * Eina tools aims to help application development, providing ways to | | * Eina tools aims to help application development, providing ways to | |
| * make it safer, log errors, manage memory more efficiently and more. | | * make it safer, log errors, manage memory more efficiently and more. | |
| * | | * | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * | | * | |
| * @page authors Authors | | * @page authors Authors | |
| * | | * | |
| * @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com> | | * @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com> | |
| * @author Alexandre "diaxen" Becoulet <diaxen@@free.fr> | | * @author Alexandre "diaxen" Becoulet <diaxen@@free.fr> | |
| * @author Andre Dieb <andre.dieb@@gmail.com> | | * @author Andre Dieb <andre.dieb@@gmail.com> | |
| * @author Arnaud de Turckheim "quarium" <quarium@@gmail.com> | | * @author Arnaud de Turckheim "quarium" <quarium@@gmail.com> | |
| * @author Carsten Haitzler <raster@@rasterman.com> | | * @author Carsten Haitzler <raster@@rasterman.com> | |
| * @author Cedric Bail <cedric.bail@@free.fr> | | * @author Cedric Bail <cedric.bail@@free.fr> | |
| * @author Corey "atmos" Donohoe <atmos@@atmos.org> | | * @author Corey "atmos" Donohoe <atmos@@atmos.org> | |
|
| | | * @author Vincent "caro" Torri <vtorri at univ-evry dot fr> | |
| * @author Fabiano Fidêncio <fidencio@@profusion.mobi> | | * @author Fabiano Fidêncio <fidencio@@profusion.mobi> | |
| * @author Gustavo Chaves <glima@@profusion.mobi> | | * @author Gustavo Chaves <glima@@profusion.mobi> | |
| * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi> | | * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi> | |
| * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com> | | * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com> | |
|
| | | * @author Tilman Sauerbeck <tilman@@code-monkey.de> | |
| * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de> | | * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de> | |
| * @author Raphael Kubo da Costa <kubo@@profusion.mobi> | | * @author Raphael Kubo da Costa <kubo@@profusion.mobi> | |
|
| * @author Tilman Sauerbeck <tilman@@code-monkey.de> | | | |
| * @author Vincent "caro" Torri <vtorri at univ-evry dot fr> | | | |
| * @author Tom Hacohen <tom@@stosb.com> | | * @author Tom Hacohen <tom@@stosb.com> | |
|
| | | * @author Brett Nash <nash@@nash.id.au> | |
| | | * @author Sebastian Dransfeld <sd@@tango.flipp.net> | |
| | | * @author Myungjae Lee <mjae.lee@@samsung.com> | |
| | | * @author Youness Alaoui <kakaroto@@kakaroto.homelinux.net> | |
| | | * @author Boris "billiob" Faure <billiob@@gmail.com> | |
| | | * @author Sung W. Park <sungwoo@@gmail.com> | |
| | | * @author Guillaume Friloux <guillaume.friloux@@asp64.com> | |
| * | | * | |
| * Please contact <enlightenment-devel@lists.sourceforge.net> to get in | | * Please contact <enlightenment-devel@lists.sourceforge.net> to get in | |
| * contact with the developers and maintainers. | | * contact with the developers and maintainers. | |
| * | | * | |
| */ | | */ | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| # include <Evil.h> | | # include <Evil.h> | |
| #endif | | #endif | |
| | | | |
| | | | |
| skipping to change at line 161 | | skipping to change at line 197 | |
| #include "eina_inlist.h" | | #include "eina_inlist.h" | |
| #include "eina_file.h" | | #include "eina_file.h" | |
| #include "eina_list.h" | | #include "eina_list.h" | |
| #include "eina_hash.h" | | #include "eina_hash.h" | |
| #include "eina_trash.h" | | #include "eina_trash.h" | |
| #include "eina_lalloc.h" | | #include "eina_lalloc.h" | |
| #include "eina_module.h" | | #include "eina_module.h" | |
| #include "eina_mempool.h" | | #include "eina_mempool.h" | |
| #include "eina_error.h" | | #include "eina_error.h" | |
| #include "eina_log.h" | | #include "eina_log.h" | |
|
| | | #include "eina_inarray.h" | |
| #include "eina_array.h" | | #include "eina_array.h" | |
| #include "eina_binshare.h" | | #include "eina_binshare.h" | |
| #include "eina_stringshare.h" | | #include "eina_stringshare.h" | |
| #include "eina_ustringshare.h" | | #include "eina_ustringshare.h" | |
| #include "eina_magic.h" | | #include "eina_magic.h" | |
| #include "eina_counter.h" | | #include "eina_counter.h" | |
| #include "eina_rbtree.h" | | #include "eina_rbtree.h" | |
| #include "eina_accessor.h" | | #include "eina_accessor.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| #include "eina_benchmark.h" | | #include "eina_benchmark.h" | |
| | | | |
| skipping to change at line 189 | | skipping to change at line 226 | |
| #include "eina_binbuf.h" | | #include "eina_binbuf.h" | |
| #include "eina_ustrbuf.h" | | #include "eina_ustrbuf.h" | |
| #include "eina_unicode.h" | | #include "eina_unicode.h" | |
| #include "eina_quadtree.h" | | #include "eina_quadtree.h" | |
| #include "eina_simple_xml_parser.h" | | #include "eina_simple_xml_parser.h" | |
| #include "eina_lock.h" | | #include "eina_lock.h" | |
| #include "eina_prefix.h" | | #include "eina_prefix.h" | |
| #include "eina_refcount.h" | | #include "eina_refcount.h" | |
| #include "eina_mmap.h" | | #include "eina_mmap.h" | |
| #include "eina_xattr.h" | | #include "eina_xattr.h" | |
|
| | | #include "eina_value.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* EINA_H */ | | #endif /* EINA_H */ | |
| | | | |
End of changes. 12 change blocks. |
| 4 lines changed or deleted | | 52 lines changed or added | |
|
| eina_array.h | | eina_array.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| | | | |
| #include "eina_config.h" | | #include "eina_config.h" | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_error.h" | | #include "eina_error.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| #include "eina_accessor.h" | | #include "eina_accessor.h" | |
| #include "eina_magic.h" | | #include "eina_magic.h" | |
| | | | |
| /** | | /** | |
|
| * @page array_01_example_page Basic array usage | | * @page eina_array_01_example_page Basic array usage | |
| * @dontinclude eina_array_01.c | | * @dontinclude eina_array_01.c | |
| * | | * | |
| * For this example we add stdlib.h, stdio.h and string.h for some | | * For this example we add stdlib.h, stdio.h and string.h for some | |
| * convenience functions. The first thing to do to be able to use an | | * convenience functions. The first thing to do to be able to use an | |
| * @ref Eina_Array is to include Eina.h: | | * @ref Eina_Array is to include Eina.h: | |
| * @skip #include | | * @skip #include | |
| * @until Eina.h | | * @until Eina.h | |
| * | | * | |
| * Here we have a callback that prints the element given to it: | | * Here we have a callback that prints the element given to it: | |
| * @until } | | * @until } | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 96 | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @page eina_array_01_c Basic array usage example | | * @page eina_array_01_c Basic array usage example | |
| * | | * | |
| * @include eina_array_01.c | | * @include eina_array_01.c | |
| * @example eina_array_01.c | | * @example eina_array_01.c | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page array_02_example_page Removing array elements | | * @page eina_array_02_example_page Removing array elements | |
| * @dontinclude eina_array_02.c | | * @dontinclude eina_array_02.c | |
| * | | * | |
| * Just the usual includes: | | * Just the usual includes: | |
| * @skip #include | | * @skip #include | |
| * @until Eina.h | | * @until Eina.h | |
| * | | * | |
| * This the callback we are going to use to decide which strings stay on th
e | | * This the callback we are going to use to decide which strings stay on th
e | |
| * array and which will be removed, we use something simple, but this can b
e as | | * array and which will be removed, we use something simple, but this can b
e as | |
| * complex as you like: | | * complex as you like: | |
| * @until } | | * @until } | |
| | | | |
| skipping to change at line 171 | | skipping to change at line 171 | |
| * in the description of this macro. | | * in the description of this macro. | |
| * | | * | |
| * @warning Functions do not check if the used array is valid or not. It's
up to | | * @warning Functions do not check if the used array is valid or not. It's
up to | |
| * the user to be sure of that. It is designed like that for performance | | * the user to be sure of that. It is designed like that for performance | |
| * reasons. | | * reasons. | |
| * | | * | |
| * The usual features of an array are classic ones: to append an | | * The usual features of an array are classic ones: to append an | |
| * element, use eina_array_push() and to remove the last element, use | | * element, use eina_array_push() and to remove the last element, use | |
| * eina_array_pop(). To retrieve the element at a given position, use | | * eina_array_pop(). To retrieve the element at a given position, use | |
| * eina_array_data_get(). The number of elements can be retrieved with | | * eina_array_data_get(). The number of elements can be retrieved with | |
|
| * eina_array_count_get(). | | * eina_array_count(). | |
| * | | * | |
| * Eina_Array is different from a conventional C array in a number of ways,
most | | * Eina_Array is different from a conventional C array in a number of ways,
most | |
| * importantly they grow and shrink dynamically, this means that if you add
an | | * importantly they grow and shrink dynamically, this means that if you add
an | |
| * element to a full array it grows and that when you remove an element fro
m an | | * element to a full array it grows and that when you remove an element fro
m an | |
| * array it @b may shrink. | | * array it @b may shrink. | |
| * | | * | |
| * When the array needs to grow it allocates memory not just for the elemen
t | | * When the array needs to grow it allocates memory not just for the elemen
t | |
| * currently being added since that would mean allocating memory(which is | | * currently being added since that would mean allocating memory(which is | |
| * computationally expensive) often, instead it grows to be able to hold @p
step | | * computationally expensive) often, instead it grows to be able to hold @p
step | |
| * more elements. Similarly if you remove elements in such a way that that
the | | * more elements. Similarly if you remove elements in such a way that that
the | |
| | | | |
| skipping to change at line 193 | | skipping to change at line 193 | |
| * | | * | |
| * The following image illustrates how an Eina_Array grows: | | * The following image illustrates how an Eina_Array grows: | |
| * | | * | |
| * @image html eina_array-growth.png | | * @image html eina_array-growth.png | |
| * @image latex eina_array-growth.eps width=\textwidth | | * @image latex eina_array-growth.eps width=\textwidth | |
| * | | * | |
| * Eina_Array only stores pointers but it can store data of any type in the
form | | * Eina_Array only stores pointers but it can store data of any type in the
form | |
| * of void pointers. | | * of void pointers. | |
| * | | * | |
| * See here some examples: | | * See here some examples: | |
|
| * @li @ref array_01_example_page | | * @li @ref eina_array_01_example_page | |
| * @li @ref array_02_example_page | | * @li @ref eina_array_02_example_page | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Data_Types_Group Data Types | | * @addtogroup Eina_Data_Types_Group Data Types | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Containers_Group Containers | | * @addtogroup Eina_Containers_Group Containers | |
| | | | |
| skipping to change at line 352 | | skipping to change at line 352 | |
| * | | * | |
| * This function sets the data at the position @p idx in @p | | * This function sets the data at the position @p idx in @p | |
| * array to @p data, this effectively replaces the previously held data, yo
u | | * array to @p data, this effectively replaces the previously held data, yo
u | |
| * must therefore get a pointer to it first if you need to free it. For | | * must therefore get a pointer to it first if you need to free it. For | |
| * performance reasons, there is no check of @p array or @p idx. If it is @
c | | * performance reasons, there is no check of @p array or @p idx. If it is @
c | |
| * NULL or invalid, the program may crash. | | * NULL or invalid, the program may crash. | |
| */ | | */ | |
| static inline void eina_array_data_set(const Eina_Array *array, | | static inline void eina_array_data_set(const Eina_Array *array, | |
| unsigned int idx, | | unsigned int idx, | |
| const void *data) EINA_AR
G_NONNULL(1); | | const void *data) EINA_AR
G_NONNULL(1); | |
|
| static inline unsigned int eina_array_count_get(const Eina_Array *array) EI | | static inline unsigned int eina_array_count_get(const Eina_Array *array) EI | |
| NA_ARG_NONNULL(1); | | NA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | |
| | | static inline unsigned int eina_array_count(const Eina_Array *array) EINA_A | |
| | | RG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Returned a new iterator associated to an array. | | * @brief Returned a new iterator associated to an array. | |
| * | | * | |
| * @param array The array. | | * @param array The array. | |
| * @return A new iterator. | | * @return A new iterator. | |
| * | | * | |
| * This function returns a newly allocated iterator associated to | | * This function returns a newly allocated iterator associated to | |
| * @p array. If @p array is @c NULL or the count member of @p array is | | * @p array. If @p array is @c NULL or the count member of @p array is | |
| * less or equal than 0, this function returns NULL. If the memory can | | * less or equal than 0, this function returns NULL. If the memory can | |
| | | | |
| skipping to change at line 430 | | skipping to change at line 431 | |
| * // array is already filled, | | * // array is already filled, | |
| * // its elements are just duplicated strings, | | * // its elements are just duplicated strings, | |
| * // EINA_ARRAY_ITER_NEXT will be used to free those strings | | * // EINA_ARRAY_ITER_NEXT will be used to free those strings | |
| * | | * | |
| * EINA_ARRAY_ITER_NEXT(array, i, item, iterator) | | * EINA_ARRAY_ITER_NEXT(array, i, item, iterator) | |
| * free(item); | | * free(item); | |
| * @endcode | | * @endcode | |
| */ | | */ | |
| #define EINA_ARRAY_ITER_NEXT(array, index, item, iterator)
\ | | #define EINA_ARRAY_ITER_NEXT(array, index, item, iterator)
\ | |
| for (index = 0, iterator = (array)->data;
\ | | for (index = 0, iterator = (array)->data;
\ | |
|
| (index < eina_array_count_get(array)) && ((item = *((iterator)++)));
\ | | (index < eina_array_count(array)) && ((item = *((iterator)++)));
\ | |
| ++(index)) | | ++(index)) | |
| | | | |
| #include "eina_inline_array.x" | | #include "eina_inline_array.x" | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| | | | |
End of changes. 6 change blocks. |
| 8 lines changed or deleted | | 10 lines changed or added | |
|
| eina_clist.h | | eina_clist.h | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 46 | |
| | | | |
| /** | | /** | |
| * @defgroup Eina_CList_Group Compact List | | * @defgroup Eina_CList_Group Compact List | |
| * | | * | |
| * @{ | | * @{ | |
| * | | * | |
| * @brief Eina_Clist is a compact (inline) list implementation | | * @brief Eina_Clist is a compact (inline) list implementation | |
| * | | * | |
| * Elements of this list are members of the structs stored in the list | | * Elements of this list are members of the structs stored in the list | |
| * | | * | |
|
| * Advantages over @ref Eina_List and @ref Eina_Inlist: | | * Advantages over @ref Eina_List and @ref Eina_Inlist : | |
| * - uses less memory (two machine words per item) | | * - uses less memory (two machine words per item) | |
| * - allows removing items without knowing which list they're in using O(1
) time | | * - allows removing items without knowing which list they're in using O(1
) time | |
| * - no need to keep updating the head pointer as the list is changed | | * - no need to keep updating the head pointer as the list is changed | |
| * | | * | |
| * Disadvantages: | | * Disadvantages: | |
| * - O(N) time to calculate list length | | * - O(N) time to calculate list length | |
| * - requires one list entry in a struct per list (i.e. it's an inlist) | | * - requires one list entry in a struct per list (i.e. it's an inlist) | |
| * - requires a head/tail pointer | | * - requires a head/tail pointer | |
| * - need to know the list head when moving to next or previous pointer | | * - need to know the list head when moving to next or previous pointer | |
| * | | * | |
| | | | |
| skipping to change at line 134 | | skipping to change at line 134 | |
| * Add an element after the specified one. | | * Add an element after the specified one. | |
| * | | * | |
| * @param elem An element in the list | | * @param elem An element in the list | |
| * @param to_add The element to add to the list | | * @param to_add The element to add to the list | |
| * @pre The list head must be initialized once before adding anything. | | * @pre The list head must be initialized once before adding anything. | |
| * @pre The element is not in any list. | | * @pre The element is not in any list. | |
| * | | * | |
| * @note There's no need to initialize an element before adding it to the l
ist. | | * @note There's no need to initialize an element before adding it to the l
ist. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_ad | | static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_ad | |
| d) | | d); | |
| { | | | |
| to_add->next = elem->next; | | | |
| to_add->prev = elem; | | | |
| elem->next->prev = to_add; | | | |
| elem->next = to_add; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Add an element before the specified one. | | * Add an element before the specified one. | |
| * | | * | |
| * @param elem An element in the list | | * @param elem An element in the list | |
| * @param to_add The element to add to the list | | * @param to_add The element to add to the list | |
| * @pre The list head must be initialized once before adding anything. | | * @pre The list head must be initialized once before adding anything. | |
| * @pre The element is not in any list. | | * @pre The element is not in any list. | |
| * | | * | |
| * @note There's no need to initialize an element before adding it to the l
ist. | | * @note There's no need to initialize an element before adding it to the l
ist. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_a | | static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_a | |
| dd) | | dd); | |
| { | | | |
| to_add->next = elem; | | | |
| to_add->prev = elem->prev; | | | |
| elem->prev->next = to_add; | | | |
| elem->prev = to_add; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Add element at the head of the list. | | * Add element at the head of the list. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @param elem An element | | * @param elem An element | |
| * @pre The list head must be initialized once before adding anything. | | * @pre The list head must be initialized once before adding anything. | |
| * @pre The element is not in any list. | | * @pre The element is not in any list. | |
| * | | * | |
| * @note There's no need to initialize an element before adding it to the l
ist. | | * @note There's no need to initialize an element before adding it to the l
ist. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) | | static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem); | |
| { | | | |
| eina_clist_add_after(list, elem); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Add element at the tail of the list. | | * Add element at the tail of the list. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @param elem An element | | * @param elem An element | |
| * @pre The list head must be initialized once before adding anything. | | * @pre The list head must be initialized once before adding anything. | |
| * @pre The element is not in any list. | | * @pre The element is not in any list. | |
| * | | * | |
| * @note There's no need to initialize an element before adding it to the l
ist. | | * @note There's no need to initialize an element before adding it to the l
ist. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) | | static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem); | |
| { | | | |
| eina_clist_add_before(list, elem); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Init an (unlinked) element. | | * Init an (unlinked) element. | |
| * | | * | |
| * Call this function on elements that have not been added to the list | | * Call this function on elements that have not been added to the list | |
| * if you want eina_clist_element_init() to work correctly | | * if you want eina_clist_element_init() to work correctly | |
| * | | * | |
| * @param elem An element | | * @param elem An element | |
| * @pre The element is not in any list. | | * @pre The element is not in any list. | |
| * @post The element is marked as not being in any list | | * @post The element is marked as not being in any list | |
| * | | * | |
| * @note It is not necessary to call this before adding an element to this
list. | | * @note It is not necessary to call this before adding an element to this
list. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_element_init(Eina_Clist *elem) | | static inline void eina_clist_element_init(Eina_Clist *elem); | |
| { | | | |
| elem->next = NULL; | | | |
| elem->prev = NULL; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Check if an element is in a list or not. | | * Check if an element is in a list or not. | |
| * | | * | |
| * @param elem An element | | * @param elem An element | |
| * | | * | |
| * @pre Either eina_clist_element_init() has been called on @a elem, | | * @pre Either eina_clist_element_init() has been called on @a elem, | |
| * it has been added to a list or remove from a list. | | * it has been added to a list or remove from a list. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline int eina_clist_element_is_linked(Eina_Clist *elem) | | static inline int eina_clist_element_is_linked(Eina_Clist *elem); | |
| { | | | |
| return (elem->next != NULL && elem->prev != NULL); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Remove an element from its list. | | * Remove an element from its list. | |
| * | | * | |
| * @param elem An element | | * @param elem An element | |
| * @pre The element is in a list already | | * @pre The element is in a list already | |
| * @post The element is marked as not being in any list | | * @post The element is marked as not being in any list | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_remove(Eina_Clist *elem) | | static inline void eina_clist_remove(Eina_Clist *elem); | |
| { | | | |
| elem->next->prev = elem->prev; | | | |
| elem->prev->next = elem->next; | | | |
| eina_clist_element_init(elem); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Get the next element. | | * Get the next element. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @param elem An element | | * @param elem An element | |
| * @pre @a elem is in @a list | | * @pre @a elem is in @a list | |
| * @return The element after @a elem in @a list or @c NULL if @a elem is l
ast in @a list | | * @return The element after @a elem in @a list or @c NULL if @a elem is l
ast in @a list | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Ein | | static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Ein | |
| a_Clist *elem) | | a_Clist *elem); | |
| { | | | |
| Eina_Clist *ret = elem->next; | | | |
| if (elem->next == list) ret = NULL; | | | |
| return ret; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Get the previous element. | | * Get the previous element. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @param elem An element | | * @param elem An element | |
| * | | * | |
| * @return The element before @a elem or NULL if @a elem is the first in th
e list | | * @return The element before @a elem or NULL if @a elem is the first in th
e list | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Ein | | static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Ein | |
| a_Clist *elem) | | a_Clist *elem); | |
| { | | | |
| Eina_Clist *ret = elem->prev; | | | |
| if (elem->prev == list) ret = NULL; | | | |
| return ret; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Get the first element. | | * Get the first element. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @returns The first element in @a list or NULL if @a list is empty | | * @returns The first element in @a list or NULL if @a list is empty | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline Eina_Clist *eina_clist_head(const Eina_Clist *list) | | static inline Eina_Clist *eina_clist_head(const Eina_Clist *list); | |
| { | | | |
| return eina_clist_next(list, list); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Get the last element. | | * Get the last element. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @returns The last element in @a list or NULL if @a list is empty | | * @returns The last element in @a list or NULL if @a list is empty | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) | | static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list); | |
| { | | | |
| return eina_clist_prev(list, list); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Check if a list is empty. | | * Check if a list is empty. | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @returns non-zero if @a list is empty, zero if it is not | | * @returns non-zero if @a list is empty, zero if it is not | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline int eina_clist_empty(const Eina_Clist *list) | | static inline int eina_clist_empty(const Eina_Clist *list); | |
| { | | | |
| return list->next == list; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Initialize a list | | * Initialize a list | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @pre The list is uninitialized | | * @pre The list is uninitialized | |
| * @post The list contains no items | | * @post The list contains no items | |
| * | | * | |
| * @note Don't call this function on a list with items | | * @note Don't call this function on a list with items | |
| * @note This function must be called. Don't try do | | * @note This function must be called. Don't try do | |
| * initialize the list by zero'ing out the list head. | | * initialize the list by zero'ing out the list head. | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_init(Eina_Clist *list) | | static inline void eina_clist_init(Eina_Clist *list); | |
| { | | | |
| list->next = list->prev = list; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Count the elements of a list | | * Count the elements of a list | |
| * | | * | |
| * @param list The list | | * @param list The list | |
| * @returns The number of items in the list | | * @returns The number of items in the list | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline unsigned int eina_clist_count(const Eina_Clist *list) | | static inline unsigned int eina_clist_count(const Eina_Clist *list); | |
| { | | | |
| unsigned count = 0; | | | |
| const Eina_Clist *ptr; | | | |
| for (ptr = list->next; ptr != list; ptr = ptr->next) count++; | | | |
| return count; | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * Move all elements from src to the tail of dst | | * Move all elements from src to the tail of dst | |
| * | | * | |
| * @param dst List to be appended to | | * @param dst List to be appended to | |
| * @param src List to append | | * @param src List to append | |
| * | | * | |
| * @post @a src is initialized but empty after this operation | | * @post @a src is initialized but empty after this operation | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src) | | static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src); | |
| { | | | |
| if (eina_clist_empty(src)) return; | | | |
| | | | |
| dst->prev->next = src->next; | | | |
| src->next->prev = dst->prev; | | | |
| dst->prev = src->prev; | | | |
| src->prev->next = dst; | | | |
| eina_clist_init(src); | | | |
| } | | | |
| | | | |
| /** | | /** | |
| * move all elements from src to the head of dst | | * move all elements from src to the head of dst | |
| * | | * | |
| * @param dst List to be prepended to | | * @param dst List to be prepended to | |
| * @param src List to prepend | | * @param src List to prepend | |
| * | | * | |
| * @post @a src is initialized but empty after this operation | | * @post @a src is initialized but empty after this operation | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
|
| static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src) | | static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src); | |
| { | | | |
| if (eina_clist_empty(src)) return; | | | |
| | | | |
| dst->next->prev = src->prev; | | | |
| src->prev->next = dst->next; | | | |
| dst->next = src->next; | | | |
| src->next->prev = dst; | | | |
| eina_clist_init(src); | | | |
| } | | | |
| | | | |
| /** | | /** | |
|
| * iterate through the list | | * @def EINA_CLIST_FOR_EACH | |
| | | * @brief Iterate through the list. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| */ | | */ | |
| #define EINA_CLIST_FOR_EACH(cursor,list) \ | | #define EINA_CLIST_FOR_EACH(cursor,list) \ | |
| for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->
next) | | for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->
next) | |
| | | | |
|
| /* iterate through the list, with safety against removal */ | | /** | |
| | | * @def EINA_CLIST_FOR_EACH_SAFE | |
| | | * @brief Iterate through the list, with safety against removal. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param cursor2 The auxiliar pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) \ | | #define EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) \ | |
| for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \ | | for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \ | |
| (cursor) != (list); \ | | (cursor) != (list); \ | |
| (cursor) = (cursor2), (cursor2) = (cursor)->next) | | (cursor) = (cursor2), (cursor2) = (cursor)->next) | |
| | | | |
|
| /* iterate through the list using a list entry */ | | /** | |
| | | * @def EINA_CLIST_FOR_EACH_ENTRY | |
| | | * @brief Iterate through the list using a list entry. | |
| | | * @param elem The element to be used. | |
| | | * @param list The list to be iterated. | |
| | | * @param type The type of the list. | |
| | | * @param field The field of the element. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) \ | | #define EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) \ | |
| for ((elem) = EINA_CLIST_ENTRY((list)->next, type, field); \ | | for ((elem) = EINA_CLIST_ENTRY((list)->next, type, field); \ | |
| &(elem)->field != (list); \ | | &(elem)->field != (list); \ | |
| (elem) = EINA_CLIST_ENTRY((elem)->field.next, type, field)) | | (elem) = EINA_CLIST_ENTRY((elem)->field.next, type, field)) | |
| | | | |
|
| /* iterate through the list using a list entry, with safety against removal | | /** | |
| */ | | * @def EINA_CLIST_FOR_EACH_ENTRY_SAFE | |
| | | * @brief Iterate through the list using a list entry, with safety against | |
| | | removal. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param cursor2 The auxiliar pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| | | * @param type The type of the list. | |
| | | * @param field The field of the element. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
\ | | #define EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
\ | |
| for ((cursor) = EINA_CLIST_ENTRY((list)->next, type, field), \ | | for ((cursor) = EINA_CLIST_ENTRY((list)->next, type, field), \ | |
| (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field); \ | | (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field); \ | |
| &(cursor)->field != (list); \ | | &(cursor)->field != (list); \ | |
| (cursor) = (cursor2), \ | | (cursor) = (cursor2), \ | |
| (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field)) | | (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field)) | |
| | | | |
|
| /* iterate through the list in reverse order */ | | /** | |
| | | * @def EINA_CLIST_FOR_EACH_REV | |
| | | * @brief Iterate through the list in reverse order. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_REV(cursor,list) \ | | #define EINA_CLIST_FOR_EACH_REV(cursor,list) \ | |
| for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->
prev) | | for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->
prev) | |
| | | | |
|
| /* iterate through the list in reverse order, with safety against removal * | | /** | |
| / | | * @def EINA_CLIST_FOR_EACH_SAFE_REV | |
| | | * @brief Iterate through the list in reverse order, with safety against re | |
| | | moval. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param cursor2 The auxiliar pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \ | | #define EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \ | |
| for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \ | | for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \ | |
| (cursor) != (list); \ | | (cursor) != (list); \ | |
| (cursor) = (cursor2), (cursor2) = (cursor)->prev) | | (cursor) = (cursor2), (cursor2) = (cursor)->prev) | |
| | | | |
|
| /* iterate through the list in reverse order using a list entry */ | | /** | |
| | | * @def EINA_CLIST_FOR_EACH_ENTRY_REV | |
| | | * @brief Iterate through the list in reverse order using a list entry. | |
| | | * @param elem The element to be used. | |
| | | * @param list The list to be iterated. | |
| | | * @param type The type of the list. | |
| | | * @param field The field of the element. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \ | | #define EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \ | |
| for ((elem) = EINA_CLIST_ENTRY((list)->prev, type, field); \ | | for ((elem) = EINA_CLIST_ENTRY((list)->prev, type, field); \ | |
| &(elem)->field != (list); \ | | &(elem)->field != (list); \ | |
| (elem) = EINA_CLIST_ENTRY((elem)->field.prev, type, field)) | | (elem) = EINA_CLIST_ENTRY((elem)->field.prev, type, field)) | |
| | | | |
|
| /* iterate through the list in reverse order using a list entry, with safet | | /** | |
| y against removal */ | | * @def EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV | |
| | | * @brief Iterate through the list in reverse order using a list entry, wit | |
| | | h safety against | |
| | | * removal. | |
| | | * @param cursor The pointer to be used during the interation. | |
| | | * @param cursor2 The auxiliar pointer to be used during the interation. | |
| | | * @param list The list to be interated. | |
| | | * @param type The type of the list. | |
| | | * @param field The field of the element. | |
| | | */ | |
| #define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, fie
ld) \ | | #define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, fie
ld) \ | |
| for ((cursor) = EINA_CLIST_ENTRY((list)->prev, type, field), \ | | for ((cursor) = EINA_CLIST_ENTRY((list)->prev, type, field), \ | |
| (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field); \ | | (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field); \ | |
| &(cursor)->field != (list); \ | | &(cursor)->field != (list); \ | |
| (cursor) = (cursor2), \ | | (cursor) = (cursor2), \ | |
| (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field)) | | (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field)) | |
| | | | |
|
| /* macros for statically initialized lists */ | | /** | |
| | | * @def EINA_CLIST_INIT | |
| | | * @brief Macros for statically initialized lists. | |
| | | * @param list The list to be used. | |
| | | */ | |
| #undef EINA_CLIST_INIT | | #undef EINA_CLIST_INIT | |
| #define EINA_CLIST_INIT(list) { &(list), &(list) } | | #define EINA_CLIST_INIT(list) { &(list), &(list) } | |
| | | | |
|
| /* get pointer to object containing list element */ | | /** | |
| | | * @def EINA_CLIST_ENTRY | |
| | | * @brief Get pointer to object containing list element. | |
| | | * @param elem The element to be used. | |
| | | * @param type The type of the element. | |
| | | * @param field The field of the element. | |
| | | */ | |
| #undef EINA_CLIST_ENTRY | | #undef EINA_CLIST_ENTRY | |
| #define EINA_CLIST_ENTRY(elem, type, field) \ | | #define EINA_CLIST_ENTRY(elem, type, field) \ | |
| ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) | | ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) | |
| | | | |
|
| | | #include "eina_inline_clist.x" | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| | | | |
End of changes. 28 change blocks. |
| 110 lines changed or deleted | | 97 lines changed or added | |
|
| eina_file.h | | eina_file.h | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; | | * License along with this library; | |
| * if not, see <http://www.gnu.org/licenses/>. | | * if not, see <http://www.gnu.org/licenses/>. | |
| */ | | */ | |
| | | | |
| #ifndef EINA_FILE_H_ | | #ifndef EINA_FILE_H_ | |
| #define EINA_FILE_H_ | | #define EINA_FILE_H_ | |
| | | | |
| #include <limits.h> | | #include <limits.h> | |
| #include <time.h> | | #include <time.h> | |
|
| | | #include <sys/stat.h> | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_array.h" | | #include "eina_array.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| | | | |
| /** | | /** | |
| * @page eina_file_example_01_page | | * @page eina_file_example_01_page | |
| * @dontinclude eina_file_01.c | | * @dontinclude eina_file_01.c | |
| * | | * | |
| * For brevity includes, variable declarations and initialization was omitt
ed | | * For brevity includes, variable declarations and initialization was omitt
ed | |
| | | | |
| skipping to change at line 93 | | skipping to change at line 94 | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @typedef Eina_File_Direct_Info | | * @typedef Eina_File_Direct_Info | |
| * A typedef to #_Eina_File_Direct_Info. | | * A typedef to #_Eina_File_Direct_Info. | |
| */ | | */ | |
| typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; | | typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; | |
| | | | |
| /** | | /** | |
|
| | | * @typedef Eina_Stat | |
| | | * A typedef to #_Eina_Stat. | |
| | | * @since 1.2 | |
| | | */ | |
| | | typedef struct _Eina_Stat Eina_Stat; | |
| | | | |
| | | /** | |
| * @typedef Eina_File_Dir_List_Cb | | * @typedef Eina_File_Dir_List_Cb | |
| * Type for a callback to be called when iterating over the files of a | | * Type for a callback to be called when iterating over the files of a | |
| * directory. | | * directory. | |
| * @param The file name EXCLUDING the path | | * @param The file name EXCLUDING the path | |
| * @param path The path passed to eina_file_dir_list() | | * @param path The path passed to eina_file_dir_list() | |
| * @param data The data passed to eina_file_dir_list() | | * @param data The data passed to eina_file_dir_list() | |
| */ | | */ | |
| typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, v
oid *data); | | typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, v
oid *data); | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 119 | | skipping to change at line 127 | |
| EINA_FILE_CHR, /**< Character device type (unused on Windows). */ | | EINA_FILE_CHR, /**< Character device type (unused on Windows). */ | |
| EINA_FILE_DIR, /**< Directory type. */ | | EINA_FILE_DIR, /**< Directory type. */ | |
| EINA_FILE_BLK, /**< Block device type (unused on Windows). */ | | EINA_FILE_BLK, /**< Block device type (unused on Windows). */ | |
| EINA_FILE_REG, /**< Regular file type. */ | | EINA_FILE_REG, /**< Regular file type. */ | |
| EINA_FILE_LNK, /**< Symbolic link type. */ | | EINA_FILE_LNK, /**< Symbolic link type. */ | |
| EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */ | | EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */ | |
| EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */ | | EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */ | |
| } Eina_File_Type; | | } Eina_File_Type; | |
| | | | |
| typedef struct _Eina_File Eina_File; | | typedef struct _Eina_File Eina_File; | |
|
| | | /** | |
| | | * @typedef Eina_File_Populate | |
| | | * File access type used in Eina_File_Direct_info. | |
| | | */ | |
| typedef enum { | | typedef enum { | |
| EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memo
ry. */ | | EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memo
ry. */ | |
| EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped
memory. */ | | EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped
memory. */ | |
| EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */ | | EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */ | |
| EINA_FILE_POPULATE /**< Request all the mapped memory. */ | | EINA_FILE_POPULATE /**< Request all the mapped memory. */ | |
| } Eina_File_Populate; | | } Eina_File_Populate; | |
| | | | |
| /* Why do this? Well PATH_MAX may vary from when eina itself is compiled | | /* Why do this? Well PATH_MAX may vary from when eina itself is compiled | |
| * to when the app using eina is compiled. exposing the path buffer below | | * to when the app using eina is compiled. exposing the path buffer below | |
| * can't safely and portably vary based on how/when you compile. it should | | * can't safely and portably vary based on how/when you compile. it should | |
| * always be the same for both eina inside AND for apps outside that use ei
na | | * always be the same for both eina inside AND for apps outside that use ei
na | |
| * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (wit
h | | * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (wit
h | |
| * windows i think being 260), so 8192 should cover almost all cases. there | | * windows i think being 260), so 8192 should cover almost all cases. there | |
| * is a possibility that PATH_MAX could be more than 8192. if anyone spots | | * is a possibility that PATH_MAX could be more than 8192. if anyone spots | |
| * a path_max that is bigger - let us know, but, for now we will assume | | * a path_max that is bigger - let us know, but, for now we will assume | |
| * it never happens */ | | * it never happens */ | |
|
| | | /** | |
| | | * @def EINA_PATH_MAX | |
| | | * @brief The constant defined as the highest value for PATH_MAX. | |
| | | */ | |
| #define EINA_PATH_MAX 8192 | | #define EINA_PATH_MAX 8192 | |
| /** | | /** | |
| * @struct _Eina_File_Direct_Info | | * @struct _Eina_File_Direct_Info | |
| * A structure to store informations of a path. | | * A structure to store informations of a path. | |
| */ | | */ | |
| struct _Eina_File_Direct_Info | | struct _Eina_File_Direct_Info | |
| { | | { | |
| size_t path_length; /**< size of the whole path */ | | size_t path_length; /**< size of the whole path */ | |
| size_t name_length; /**< size of the filename/basename com
ponent */ | | size_t name_length; /**< size of the filename/basename com
ponent */ | |
| size_t name_start; /**< where the filename/basename compon
ent starts */ | | size_t name_start; /**< where the filename/basename compon
ent starts */ | |
| Eina_File_Type type; /**< file type */ | | Eina_File_Type type; /**< file type */ | |
| char path[EINA_PATH_MAX]; /**< the path */ | | char path[EINA_PATH_MAX]; /**< the path */ | |
| }; | | }; | |
| | | | |
| /** | | /** | |
|
| | | * @struct _Eina_Stat | |
| | | * A structure to store informations of a path. | |
| | | * @since 1.2 | |
| | | */ | |
| | | struct _Eina_Stat | |
| | | { | |
| | | unsigned long int dev; | |
| | | unsigned long int ino; | |
| | | unsigned int mode; | |
| | | unsigned int nlink; | |
| | | unsigned int uid; | |
| | | unsigned int gid; | |
| | | unsigned long int rdev; | |
| | | unsigned long int size; | |
| | | unsigned long int blksize; | |
| | | unsigned long int blocks; | |
| | | unsigned long int atime; | |
| | | unsigned long int atimensec; | |
| | | unsigned long int mtime; | |
| | | unsigned long int mtimensec; | |
| | | unsigned long int ctime; | |
| | | unsigned long int ctimensec; | |
| | | }; | |
| | | | |
| | | /** | |
| * @def EINA_FILE_DIR_LIST_CB | | * @def EINA_FILE_DIR_LIST_CB | |
| * @brief cast to an #Eina_File_Dir_List_Cb. | | * @brief cast to an #Eina_File_Dir_List_Cb. | |
| * | | * | |
| * @param function The function to cast. | | * @param function The function to cast. | |
| * | | * | |
| * This macro casts @p function to Eina_File_Dir_List_Cb. | | * This macro casts @p function to Eina_File_Dir_List_Cb. | |
| */ | | */ | |
| #define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) | | #define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 279 | |
| * dir will only be fetched when advancing the iterator, which means there
is | | * dir will only be fetched when advancing the iterator, which means there
is | |
| * cost associated with creating the list and stopping halfway through it. | | * cost associated with creating the list and stopping halfway through it. | |
| * | | * | |
| * @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b> | | * @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b> | |
| * be modified in any way. | | * be modified in any way. | |
| * @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo | | * @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo | |
| * returned is no longer valid. | | * returned is no longer valid. | |
| * | | * | |
| * @note The container for the iterator is of type DIR*. | | * @note The container for the iterator is of type DIR*. | |
| * @note The iterator will walk over '.' and '..' without returning them. | | * @note The iterator will walk over '.' and '..' without returning them. | |
|
| * @note The difference between this function ahd eina_file_direct_ls() is
that | | * @note The difference between this function and eina_file_direct_ls() is
that | |
| * it guarantees the file type information will be correct incurring
a | | * it guarantees the file type information will be correct incurring
a | |
| * possible performance penalty. | | * possible performance penalty. | |
| * | | * | |
| * @see eina_file_direct_ls() | | * @see eina_file_direct_ls() | |
| */ | | */ | |
| EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RES
ULT EINA_ARG_NONNULL(1) EINA_MALLOC; | | EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RES
ULT EINA_ARG_NONNULL(1) EINA_MALLOC; | |
| | | | |
| /** | | /** | |
|
| | | * @brief Use information provided by Eina_Iterator of eina_file_stat_ls or | |
| | | eina_file_direct_ls | |
| | | * to call stat in the most efficient way on your system. | |
| | | * | |
| | | * @param container The container returned by the Eina_Iterator using eina_ | |
| | | iterator_container_get(). | |
| | | * @param info The content of the current Eina_File_Direct_Info provided by | |
| | | the Eina_Iterator | |
| | | * @param buf Where to put the result of the stat | |
| | | * @return On success 0 is returned, On error -1 is returned and errno is s | |
| | | et appropriately. | |
| | | * | |
| | | * This function calls fstatat or stat depending on what your system suppor | |
| | | ts. This makes it efficient and simple | |
| | | * to use on your side without complex detection already done inside Eina o | |
| | | n what the system can do. | |
| | | * | |
| | | * @see eina_file_direct_ls() | |
| | | * @see eina_file_stat_ls() | |
| | | * @since 1.2 | |
| | | */ | |
| | | EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Ein | |
| | | a_Stat *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2, 3); | |
| | | | |
| | | /** | |
| * @brief Get an iterator to list the content of a directory, with direct | | * @brief Get an iterator to list the content of a directory, with direct | |
| * information. | | * information. | |
| * | | * | |
| * @param dir The name of the directory to list | | * @param dir The name of the directory to list | |
| * | | * | |
| * @return Return an Eina_Iterator that will walk over the files and | | * @return Return an Eina_Iterator that will walk over the files and | |
| * directory in the pointed directory. On failure it will | | * directory in the pointed directory. On failure it will | |
| * return NULL. | | * return NULL. | |
| * | | * | |
| * Returns an iterator for Eina_File_Direct_Info, the name of each file in
@p | | * Returns an iterator for Eina_File_Direct_Info, the name of each file in
@p | |
| | | | |
| skipping to change at line 270 | | skipping to change at line 328 | |
| * | | * | |
| * @warning If readdir_r doesn't contain file type information file type wi
ll | | * @warning If readdir_r doesn't contain file type information file type wi
ll | |
| * be DT_UNKNOW. | | * be DT_UNKNOW. | |
| * @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b> | | * @warning The Eina_File_Direct_Info returned by the iterator <b>must not<
/b> | |
| * be modified in any way. | | * be modified in any way. | |
| * @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo | | * @warning When the iterator is advanced or deleted the Eina_File_Direct_I
nfo | |
| * returned is no longer valid. | | * returned is no longer valid. | |
| * | | * | |
| * @note The container for the iterator is of type DIR*. | | * @note The container for the iterator is of type DIR*. | |
| * @note The iterator will walk over '.' and '..' without returning them. | | * @note The iterator will walk over '.' and '..' without returning them. | |
|
| * @note The difference between this function ahd eina_file_stat_ls() is th
at | | * @note The difference between this function and eina_file_stat_ls() is th
at | |
| * it may not get the file type information however it is likely to b
e | | * it may not get the file type information however it is likely to b
e | |
| * faster. | | * faster. | |
| * | | * | |
| * @see eina_file_ls() | | * @see eina_file_ls() | |
| */ | | */ | |
| EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_R
ESULT EINA_ARG_NONNULL(1) EINA_MALLOC; | | EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_R
ESULT EINA_ARG_NONNULL(1) EINA_MALLOC; | |
| | | | |
| /** | | /** | |
| * @brief Sanitize file path. | | * @brief Sanitize file path. | |
| * | | * | |
| | | | |
| skipping to change at line 298 | | skipping to change at line 356 | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI char *eina_file_path_sanitize(const char *path); | | EAPI char *eina_file_path_sanitize(const char *path); | |
| | | | |
| /** | | /** | |
| * @brief Get a read-only handler to a file. | | * @brief Get a read-only handler to a file. | |
| * | | * | |
| * @param name Filename to open | | * @param name Filename to open | |
| * @param shared Requested a shm | | * @param shared Requested a shm | |
|
| | | * @return Eina_File handle to the file | |
| * | | * | |
| * Opens a file in read-only mode. @p name should be an absolute path. An | | * Opens a file in read-only mode. @p name should be an absolute path. An | |
| * Eina_File handle can be shared among multiple instances if @p shared is | | * Eina_File handle can be shared among multiple instances if @p shared is | |
| * EINA_TRUE. | | * EINA_TRUE. | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WAR
N_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; | | EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WAR
N_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; | |
| | | | |
| /** | | /** | |
| * @brief Unref file handler. | | * @brief Unref file handler. | |
| * | | * | |
| * @param file File handler to unref. | | * @param file File handler to unref. | |
| * | | * | |
|
| * Decremente file's refcount and if it reaches zero close it. | | * Decrement file's refcount and if it reaches zero close it. | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI void eina_file_close(Eina_File *file); | | EAPI void eina_file_close(Eina_File *file); | |
| | | | |
| /** | | /** | |
| * @brief Get file size at open time. | | * @brief Get file size at open time. | |
| * | | * | |
| * @param file The file handler to request the size from. | | * @param file The file handler to request the size from. | |
| * @return The length of the file. | | * @return The length of the file. | |
| | | | |
| skipping to change at line 349 | | skipping to change at line 408 | |
| * @brief Get the filename of an open file. | | * @brief Get the filename of an open file. | |
| * | | * | |
| * @param file The file handler to request the name from. | | * @param file The file handler to request the name from. | |
| * @return Stringshared filename of the file. | | * @return Stringshared filename of the file. | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI const char *eina_file_filename_get(Eina_File *file); | | EAPI const char *eina_file_filename_get(Eina_File *file); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Get the eXtended attribute of an open file. | |
| | | * | |
| | | * @param file The file handler to request the eXtended attribute from. | |
| | | * @return an iterator. | |
| | | * | |
| | | * The iterator will list all eXtended attribute name without allocating | |
| | | * them, so you need to copy them yourself if needed. | |
| | | * | |
| | | * @since 1.2 | |
| | | */ | |
| | | EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file); | |
| | | | |
| | | /** | |
| | | * @brief Get the eXtended attribute of an open file. | |
| | | * | |
| | | * @param file The file handler to request the eXtended attribute from. | |
| | | * @return an iterator. | |
| | | * | |
| | | * The iterator will list all eXtended attribute without allocating | |
| | | * them, so you need to copy them yourself if needed. It is returning | |
| | | * Eina_Xattr structure. | |
| | | * | |
| | | * @since 1.2 | |
| | | */ | |
| | | EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file); | |
| | | | |
| | | /** | |
| * @brief Map all the file to a buffer. | | * @brief Map all the file to a buffer. | |
| * | | * | |
| * @param file The file handler to map in memory | | * @param file The file handler to map in memory | |
| * @param rule The rule to apply to the mapped memory | | * @param rule The rule to apply to the mapped memory | |
| * @return A pointer to a buffer that map all the file content. @c NULL if
it fail. | | * @return A pointer to a buffer that map all the file content. @c NULL if
it fail. | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule); | | EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule); | |
| | | | |
| | | | |
| skipping to change at line 386 | | skipping to change at line 472 | |
| * @brief Unref and unmap memory if possible. | | * @brief Unref and unmap memory if possible. | |
| * | | * | |
| * @param file The file handler to unmap memory from. | | * @param file The file handler to unmap memory from. | |
| * @param map Memory map to unref and unmap. | | * @param map Memory map to unref and unmap. | |
| * | | * | |
| * @since 1.1 | | * @since 1.1 | |
| */ | | */ | |
| EAPI void eina_file_map_free(Eina_File *file, void *map); | | EAPI void eina_file_map_free(Eina_File *file, void *map); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Tell if their was an IO error during the life of a mmaped file | |
| | | * | |
| | | * @param file The file handler to the mmaped file. | |
| | | * @param map Memory map to check if an error occurred on it. | |
| | | * @return #EINA_TRUE if there was an IO error, #EINA_FALSE otherwise. | |
| | | * | |
| | | * @since 1.2 | |
| | | */ | |
| | | EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map); | |
| | | | |
| | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| #endif /* EINA_FILE_H_ */ | | #endif /* EINA_FILE_H_ */ | |
| | | | |
End of changes. 12 change blocks. |
| 4 lines changed or deleted | | 108 lines changed or added | |
|
| eina_inline_mempool.x | | eina_inline_mempool.x | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| * Lesser General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; | | * License along with this library; | |
| * if not, see <http://www.gnu.org/licenses/>. | | * if not, see <http://www.gnu.org/licenses/>. | |
| */ | | */ | |
| | | | |
| #ifndef EINA_INLINE_MEMPOOL_X_ | | #ifndef EINA_INLINE_MEMPOOL_X_ | |
| #define EINA_INLINE_MEMPOOL_X_ | | #define EINA_INLINE_MEMPOOL_X_ | |
| | | | |
|
| | | #include <string.h> | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Memory_Pool_Group Memory Pool | | * @addtogroup Eina_Memory_Pool_Group Memory Pool | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /* Memory Pool */ | | /* Memory Pool */ | |
| typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1; | | typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1; | |
| typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2; | | typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2; | |
| | | | |
| | | | |
| skipping to change at line 70 | | skipping to change at line 72 | |
| }; | | }; | |
| | | | |
| struct _Eina_Mempool | | struct _Eina_Mempool | |
| { | | { | |
| Eina_Mempool_Backend_ABI1 backend; | | Eina_Mempool_Backend_ABI1 backend; | |
| void *backend_data; | | void *backend_data; | |
| Eina_Mempool_Backend_ABI2 *backend2; | | Eina_Mempool_Backend_ABI2 *backend2; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
|
| * @brief Re-allocate a amount memory by the given mempool. | | * @brief Re-allocate an amount memory by the given mempool. | |
| * | | * | |
| * @param mp The mempool. | | * @param mp The mempool. | |
| * @param element The element to re-allocate. | | * @param element The element to re-allocate. | |
| * @param size The size in bytes to re-allocate. | | * @param size The size in bytes to re-allocate. | |
| * @return The newly re-allocated data. | | * @return The newly re-allocated data. | |
| * | | * | |
|
| * This function re-allocates @p element with @p size bytes, using the | | * This function re-allocates and returns @p element with @p size bytes usi | |
| * mempool @p mp and returns the allocated data. If not used anymore, | | ng the | |
| * the data must be freed with eina_mempool_free(). No check is done | | * mempool @p mp. If not used anymore, the data must be freed with eina_mem | |
| * on @p mp, so it must be a valid mempool. | | pool_free(). | |
| | | * @warning No checks are done for @p mp. | |
| */ | | */ | |
| static inline void * | | static inline void * | |
| eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) | | eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) | |
| { | | { | |
| return mp->backend.realloc(mp->backend_data, element, size); | | return mp->backend.realloc(mp->backend_data, element, size); | |
| } | | } | |
| | | | |
| /** | | /** | |
|
| * @brief Allocate a amount memory by the given mempool. | | * @brief Allocate memory using the given mempool. | |
| * | | * | |
| * @param mp The mempool. | | * @param mp The mempool. | |
| * @param size The size in bytes to allocate. | | * @param size The size in bytes to allocate. | |
| * @return The newly allocated data. | | * @return The newly allocated data. | |
| * | | * | |
|
| * This function allocates @p size bytes, using the mempool @p mp and | | * This function allocates and returns @p size bytes using the mempool @p m | |
| * returns the allocated data. If not used anymore, the data must be | | p. | |
| * freed with eina_mempool_free(). No check is done on @p mp, so it | | * If not used anymore, the data must be freed with eina_mempool_free(). | |
| * must be a valid mempool. | | * @warning No checks are done for @p mp. | |
| */ | | */ | |
| static inline void * | | static inline void * | |
| eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) | | eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) | |
| { | | { | |
| return mp->backend.alloc(mp->backend_data, size); | | return mp->backend.alloc(mp->backend_data, size); | |
| } | | } | |
| | | | |
| /** | | /** | |
|
| * @brief Free the allocated ressources by the given mempool. | | * @brief Allocate and zero memory using the given mempool. | |
| | | * | |
| | | * @param mp The mempool. | |
| | | * @param size The size in bytes to allocate. | |
| | | * @return The newly allocated data. | |
| | | * | |
| | | * This function allocates, zeroes, and returns @p size bytes using the mem | |
| | | pool @p mp. | |
| | | * If not used anymore, the data must be freed with eina_mempool_free(). | |
| | | * @warning No checks are done for @p mp. | |
| | | * @since 1.2 | |
| | | */ | |
| | | static inline void * | |
| | | eina_mempool_calloc(Eina_Mempool *mp, unsigned int size) | |
| | | { | |
| | | void *r = mp->backend.alloc(mp->backend_data, size); | |
| | | if (!r) return NULL; | |
| | | memset(r, 0, size); | |
| | | return r; | |
| | | } | |
| | | | |
| | | /** | |
| | | * @brief Free resources previously allocated by the given mempool. | |
| * | | * | |
| * @param mp The mempool. | | * @param mp The mempool. | |
| * @param element The data to free. | | * @param element The data to free. | |
| * | | * | |
| * This function frees @p element allocated by @p mp. @p element must | | * This function frees @p element allocated by @p mp. @p element must | |
|
| * have been obtained by eina_mempool_malloc() or | | * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or | |
| * eina_mempool_realloc(). No check is done on @p mp, so it must be a | | * eina_mempool_realloc(). | |
| * valid mempool. | | * @warning No checks are done for @p mp. | |
| */ | | */ | |
| static inline void | | static inline void | |
| eina_mempool_free(Eina_Mempool *mp, void *element) | | eina_mempool_free(Eina_Mempool *mp, void *element) | |
| { | | { | |
|
| | | if (!element) return ; | |
| mp->backend.free(mp->backend_data, element); | | mp->backend.free(mp->backend_data, element); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 8 change blocks. |
| 14 lines changed or deleted | | 40 lines changed or added | |
|
| eina_inlist.h | | eina_inlist.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| | | | |
| #ifndef EINA_INLIST_H_ | | #ifndef EINA_INLIST_H_ | |
| #define EINA_INLIST_H_ | | #define EINA_INLIST_H_ | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| #include "eina_accessor.h" | | #include "eina_accessor.h" | |
| #include <stddef.h> | | #include <stddef.h> | |
| | | | |
| /** | | /** | |
|
| * @page inlist_01_example_page Eina_Inlist basic usage | | * @page eina_inlist_01_example_page Eina_Inlist basic usage | |
| * @dontinclude eina_inlist_01.c | | * @dontinclude eina_inlist_01.c | |
| * | | * | |
| * To see the full source for this example, click here: @ref | | * To see the full source for this example, click here: @ref | |
| * eina_inlist_01_c | | * eina_inlist_01_c | |
| * | | * | |
| * As explained before, inline lists mean its nodes pointers are part of sa
me | | * As explained before, inline lists mean its nodes pointers are part of sa
me | |
| * memory block/blob. This is done by using the macro @ref EINA_INLIST insi
de the | | * memory block/blob. This is done by using the macro @ref EINA_INLIST insi
de the | |
| * data structure that will be used: | | * data structure that will be used: | |
| * | | * | |
| * @skip struct | | * @skip struct | |
| | | | |
| skipping to change at line 114 | | skipping to change at line 114 | |
| * it is the same as the list pointer, since the @ref EINA_INLIST macro was
used | | * it is the same as the list pointer, since the @ref EINA_INLIST macro was
used | |
| * in the beginning of the structure. | | * in the beginning of the structure. | |
| * | | * | |
| * Now to finish this example, lets delete this list: | | * Now to finish this example, lets delete this list: | |
| * | | * | |
| * @skip while | | * @skip while | |
| * @until } | | * @until } | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page inlist_02_example_page Eina_Inlist advanced usage - lists and inli
sts | | * @page eina_inlist_02_example_page Eina_Inlist advanced usage - lists and
inlists | |
| * @dontinclude eina_inlist_02.c | | * @dontinclude eina_inlist_02.c | |
| * | | * | |
| * This example describes the usage of @ref Eina_Inlist mixed with @ref | | * This example describes the usage of @ref Eina_Inlist mixed with @ref | |
| * Eina_List . We create and add elements to an inlist, and the even member
s | | * Eina_List . We create and add elements to an inlist, and the even member
s | |
| * are also added to a normal list. Later we remove the elements divisible
by 3 | | * are also added to a normal list. Later we remove the elements divisible
by 3 | |
| * from this normal list. | | * from this normal list. | |
| * | | * | |
| * The struct that is going to be used is the same used in @ref | | * The struct that is going to be used is the same used in @ref | |
|
| * inlist_01_example_page , since we still need the @ref EINA_INLIST macro
to | | * eina_inlist_01_example_page , since we still need the @ref EINA_INLIST m
acro to | |
| * declare the inlist node info: | | * declare the inlist node info: | |
| * | | * | |
| * @skip struct | | * @skip struct | |
| * @until }; | | * @until }; | |
| * | | * | |
| * The resulting node representing this struct can be exemplified by the | | * The resulting node representing this struct can be exemplified by the | |
| * following picture: | | * following picture: | |
| * | | * | |
| * @image html eina_inlist-node_eg2-my-struct.png | | * @image html eina_inlist-node_eg2-my-struct.png | |
| * @image rtf eina_inlist-node_eg2-my-struct.png | | * @image rtf eina_inlist-node_eg2-my-struct.png | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 187 | |
| * elements, then we free all elements in the inlist (that contains all ele
ments | | * elements, then we free all elements in the inlist (that contains all ele
ments | |
| * allocated until now): | | * allocated until now): | |
| * | | * | |
| * @skip eina_list_free | | * @skip eina_list_free | |
| * @until } | | * @until } | |
| * | | * | |
| * Here is the full source code for this example: @ref eina_inlist_02_c | | * Here is the full source code for this example: @ref eina_inlist_02_c | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page inlist_03_example_page Eina_Inlist advanced usage - multi-inlists | | * @page eina_inlist_03_example_page Eina_Inlist advanced usage - multi-inl
ists | |
| * @dontinclude eina_inlist_03.c | | * @dontinclude eina_inlist_03.c | |
| * | | * | |
| * This example describes the usage of multiple inlists storing the same da
ta. | | * This example describes the usage of multiple inlists storing the same da
ta. | |
| * It means that some data may appear in more than one inlist at the same t
ime. | | * It means that some data may appear in more than one inlist at the same t
ime. | |
| * We will demonstrate this by creating an inlist with 100 numbers, and add
ing | | * We will demonstrate this by creating an inlist with 100 numbers, and add
ing | |
| * the odd numbers to the second inlist, then remove the numbers divisible
by 3 | | * the odd numbers to the second inlist, then remove the numbers divisible
by 3 | |
| * from the second list. | | * from the second list. | |
| * | | * | |
| * To accomplish this, it is necessary to have two inlist pointers in the s
truct | | * To accomplish this, it is necessary to have two inlist pointers in the s
truct | |
| * that is going to be stored. We are using the default inlist member @ref | | * that is going to be stored. We are using the default inlist member @ref | |
| | | | |
| skipping to change at line 318 | | skipping to change at line 318 | |
| * regular lists instead. | | * regular lists instead. | |
| * | | * | |
| * Tip: When using inlists in more than one place (that is, passing them ar
ound | | * Tip: When using inlists in more than one place (that is, passing them ar
ound | |
| * functions or keeping a pointer to them in a structure) it's more correct | | * functions or keeping a pointer to them in a structure) it's more correct | |
| * to keep a pointer to the first container, and not a pointer to the first | | * to keep a pointer to the first container, and not a pointer to the first | |
| * inlist item (mostly they are the same, but that's not always correct). | | * inlist item (mostly they are the same, but that's not always correct). | |
| * This lets the compiler to do type checking and let the programmer know | | * This lets the compiler to do type checking and let the programmer know | |
| * exactly what type this list is. | | * exactly what type this list is. | |
| * | | * | |
| * A simple example demonstrating the basic usage of an inlist can be found | | * A simple example demonstrating the basic usage of an inlist can be found | |
|
| * here: @ref inlist_01_example_page | | * here: @ref eina_inlist_01_example_page | |
| * | | * | |
| * @section inlist_algo Algorithm | | * @section inlist_algo Algorithm | |
| * | | * | |
| * The basic structure can be represented by the following picture: | | * The basic structure can be represented by the following picture: | |
| * | | * | |
| * @image html eina_inlist-node.png | | * @image html eina_inlist-node.png | |
| * @image rtf eina_inlist-node.png | | * @image rtf eina_inlist-node.png | |
| * @image latex eina_inlist-node.eps | | * @image latex eina_inlist-node.eps | |
| * | | * | |
| * One data structure will also have the node information, with three point
ers: | | * One data structure will also have the node information, with three point
ers: | |
| | | | |
| skipping to change at line 361 | | skipping to change at line 361 | |
| * have an inlist node information (prev, next and last pointers) created w
ith | | * have an inlist node information (prev, next and last pointers) created w
ith | |
| * @ref EINA_INLIST during the struct declaration. This allows one to use t
he | | * @ref EINA_INLIST during the struct declaration. This allows one to use t
he | |
| * convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GE
T(), | | * convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GE
T(), | |
| * @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_IN
LIST | | * @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_IN
LIST | |
| * macro declares a struct member with the name @a __inlist, and all the ot
her | | * macro declares a struct member with the name @a __inlist, and all the ot
her | |
| * macros assume that this struct member has this name. | | * macros assume that this struct member has this name. | |
| * | | * | |
| * It may be the case that someone needs to have some inlist nodes added to
a | | * It may be the case that someone needs to have some inlist nodes added to
a | |
| * @ref Eina_List too. If this happens, the inlist nodes can be added to th
e | | * @ref Eina_List too. If this happens, the inlist nodes can be added to th
e | |
| * @ref Eina_List without any problems. This example demonstrates this case
: | | * @ref Eina_List without any problems. This example demonstrates this case
: | |
|
| * @ref inlist_02_example_page | | * @ref eina_inlist_02_example_page | |
| * | | * | |
| * It's also possible to have some data that is part of two different inlis
ts. | | * It's also possible to have some data that is part of two different inlis
ts. | |
| * If this is the case, then it won't be possible to use the convenience ma
cros | | * If this is the case, then it won't be possible to use the convenience ma
cros | |
| * to both of the lists. It will be necessary to create a new set of macros
that | | * to both of the lists. It will be necessary to create a new set of macros
that | |
| * will allow access to the second list node info. An example for this usag
e can | | * will allow access to the second list node info. An example for this usag
e can | |
| * be found here: | | * be found here: | |
|
| * @ref inlist_03_example_page | | * @ref eina_inlist_03_example_page | |
| * | | * | |
| * List of examples: | | * List of examples: | |
|
| * @li @ref inlist_01_example_page | | * @li @ref eina_inlist_01_example_page | |
| * @li @ref inlist_02_example_page | | * @li @ref eina_inlist_02_example_page | |
| * @li @ref inlist_03_example_page | | * @li @ref eina_inlist_03_example_page | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Data_Types_Group Data Types | | * @addtogroup Eina_Data_Types_Group Data Types | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Containers_Group Containers | | * @addtogroup Eina_Containers_Group Containers | |
| | | | |
| skipping to change at line 774 | | skipping to change at line 774 | |
| * return(strcmp(x1->text, x2->text)); | | * return(strcmp(x1->text, x2->text)); | |
| * } | | * } | |
| * extern Eina_Inlist *list; | | * extern Eina_Inlist *list; | |
| * | | * | |
| * list = eina_inlist_sort(list, sort_cb); | | * list = eina_inlist_sort(list, sort_cb); | |
| * @endcode | | * @endcode | |
| */ | | */ | |
| EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func)
; | | EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func)
; | |
| | | | |
| /* This two macros are helpers for the _FOREACH ones, don't use them */ | | /* This two macros are helpers for the _FOREACH ones, don't use them */ | |
|
| | | /** | |
| | | * @def _EINA_INLIST_OFFSET | |
| | | * @param ref The reference to be used. | |
| | | */ | |
| #define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char
*)(ref)) | | #define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char
*)(ref)) | |
| | | | |
| #if !defined(__cplusplus) | | #if !defined(__cplusplus) | |
|
| | | /** | |
| | | * @def _EINA_INLIST_CONTAINER | |
| | | * @param ref The reference to be used. | |
| | | * @param ptr The pointer to be used. | |
| | | */ | |
| #define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \ | | #define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \ | |
| _EINA_INLIST_OFFSET(ref)) | | _EINA_INLIST_OFFSET(ref)) | |
| #else | | #else | |
| /* | | /* | |
| * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's ty
peof | | * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's ty
peof | |
| * operator. | | * operator. | |
| */ | | */ | |
| #define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \ | | #define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \ | |
| _EINA_INLIST_OFFSET(ref)) | | _EINA_INLIST_OFFSET(ref)) | |
| #endif | | #endif | |
| | | | |
|
| | | /** Macro to iterate over an inlist */ | |
| #define EINA_INLIST_FOREACH(list, l) \ | | #define EINA_INLIST_FOREACH(list, l) \ | |
| for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ | | for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ | |
| l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIS
T_GET(l)->next) : NULL)) | | l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIS
T_GET(l)->next) : NULL)) | |
|
| | | /** | |
| | | * @def EINA_INLIST_FOREACH_SAFE | |
| | | * @param list The first list to be used. | |
| | | * @param list2 The second list to be used. | |
| | | * @param l The auxiliar variable to be used. | |
| | | */ | |
| #define EINA_INLIST_FOREACH_SAFE(list, list2, l) \ | | #define EINA_INLIST_FOREACH_SAFE(list, list2, l) \ | |
| for (l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL), list2 = l ? ((
EINA_INLIST_GET(l) ? EINA_INLIST_GET(l)->next : NULL)) : NULL; \ | | for (l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL), list2 = l ? ((
EINA_INLIST_GET(l) ? EINA_INLIST_GET(l)->next : NULL)) : NULL; \ | |
| l; \ | | l; \ | |
| l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next :
NULL) | | l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next :
NULL) | |
|
| | | /** | |
| | | * @def EINA_INLIST_REVERSE_FOREACH | |
| | | * @param list The list to be reversed. | |
| | | * @param l The auxiliar variable to be used. | |
| | | */ | |
| #define EINA_INLIST_REVERSE_FOREACH(list, l)
\ | | #define EINA_INLIST_REVERSE_FOREACH(list, l)
\ | |
| for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL);
\ | | for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL);
\ | |
| l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_IN
LIST_GET(l)->prev) : NULL)) | | l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_IN
LIST_GET(l)->prev) : NULL)) | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| | | | |
End of changes. 13 change blocks. |
| 10 lines changed or deleted | | 31 lines changed or added | |
|
| eina_iterator.h | | eina_iterator.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| | | | |
| #ifndef EINA_ITERATOR_H__ | | #ifndef EINA_ITERATOR_H__ | |
| #define EINA_ITERATOR_H__ | | #define EINA_ITERATOR_H__ | |
| | | | |
| #include "eina_config.h" | | #include "eina_config.h" | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_magic.h" | | #include "eina_magic.h" | |
| | | | |
| /** | | /** | |
|
| * @page eina_iterator_example Eina_Iterator usage | | * @page eina_iterator_example_page Eina_Iterator usage | |
| * @dontinclude eina_iterator_01.c | | * @dontinclude eina_iterator_01.c | |
| * | | * | |
| * As always when using eina we need to include it: | | * As always when using eina we need to include it: | |
| * @skip #include | | * @skip #include | |
| * @until Eina.h | | * @until Eina.h | |
| * | | * | |
| * Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prin
ts | | * Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prin
ts | |
| * some data: | | * some data: | |
| * @until } | | * @until } | |
| * @note Returning EINA_TRUE is important so we don't stop iterating over t
he | | * @note Returning EINA_TRUE is important so we don't stop iterating over t
he | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 51 | |
| * And here a more interesting function, it uses an iterator to print the | | * And here a more interesting function, it uses an iterator to print the | |
| * contents of a container. What's interesting about it is that it doesn't
care | | * contents of a container. What's interesting about it is that it doesn't
care | |
| * the type of container, it works for anything that can provide an iterato
r: | | * the type of container, it works for anything that can provide an iterato
r: | |
| * @until } | | * @until } | |
| * | | * | |
| * And on to our main function were we declare some variables and initializ
e | | * And on to our main function were we declare some variables and initializ
e | |
| * eina, nothing too special: | | * eina, nothing too special: | |
| * @until eina_init | | * @until eina_init | |
| * | | * | |
| * Next we populate both an array and a list with our strings, for more det
ails | | * Next we populate both an array and a list with our strings, for more det
ails | |
|
| * see @ref eina_list_01_example and @ref eina_array_01_example: | | * see @ref eina_list_01_example_page and @ref eina_array_01_example_page : | |
| * @until } | | * @until } | |
| * | | * | |
| * And now we create an array and because the first element of the containe
r | | * And now we create an array and because the first element of the containe
r | |
| * doesn't interest us we skip it: | | * doesn't interest us we skip it: | |
| * @until iterator_next | | * @until iterator_next | |
| * | | * | |
| * Having our iterator now pointing to interesting data we go ahead and pri
nt: | | * Having our iterator now pointing to interesting data we go ahead and pri
nt: | |
| * @until print_eina_container | | * @until print_eina_container | |
| * | | * | |
| * As always once data with a structure we free it, but just because we can
we | | * As always once data with a structure we free it, but just because we can
we | |
| * do it by asking the iterator for it's container, and then of course free
the | | * do it by asking the iterator for it's container, and then of course free
the | |
| * iterator itself: | | * iterator itself: | |
| * @until eina_iterator_free | | * @until eina_iterator_free | |
| * | | * | |
|
| * But so far you're not impressed in @ref eina_array_01_example an array i
s | | * But so far you're not impressed in @ref eina_array_01_example_page an ar
ray is | |
| * also printed, so now we go to the cool stuff and use an iterator to do s
ame | | * also printed, so now we go to the cool stuff and use an iterator to do s
ame | |
| * stuff to a list: | | * stuff to a list: | |
| * @until eina_iterator_free | | * @until eina_iterator_free | |
| * @note The only significant diference to the block above is in the | | * @note The only significant diference to the block above is in the | |
| * function used to create the iterator. | | * function used to create the iterator. | |
| * | | * | |
| * And now we free the list and shut eina down: | | * And now we free the list and shut eina down: | |
| * @until } | | * @until } | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 102 | |
| * iterators in the C++ STL). Iterators only allows sequential access | | * iterators in the C++ STL). Iterators only allows sequential access | |
| * (that is, from an element to the next one). For random access, see | | * (that is, from an element to the next one). For random access, see | |
| * @ref Eina_Accessor_Group. | | * @ref Eina_Accessor_Group. | |
| * | | * | |
| * An iterator is created from container data types, so no creation | | * An iterator is created from container data types, so no creation | |
| * function is available here. An iterator is deleted with | | * function is available here. An iterator is deleted with | |
| * eina_iterator_free(). To get the data and iterate, use | | * eina_iterator_free(). To get the data and iterate, use | |
| * eina_iterator_next(). To call a function on all the elements of a | | * eina_iterator_next(). To call a function on all the elements of a | |
| * container, use eina_iterator_foreach(). | | * container, use eina_iterator_foreach(). | |
| * | | * | |
|
| * Here an @ref eina_iterator_example "example" | | * Here an @ref eina_iterator_example_page "example" | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Content_Access_Group Content Access | | * @addtogroup Eina_Content_Access_Group Content Access | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup Eina_Iterator_Group Iterator Functions | | * @defgroup Eina_Iterator_Group Iterator Functions | |
| | | | |
End of changes. 4 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| eina_list.h | | eina_list.h | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| | | | |
| #include "eina_config.h" | | #include "eina_config.h" | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| #include "eina_accessor.h" | | #include "eina_accessor.h" | |
| #include "eina_magic.h" | | #include "eina_magic.h" | |
| | | | |
| /** | | /** | |
|
| * @page list_01_example_page Adding elements to Eina_List | | * @page eina_list_01_example_page Adding elements to Eina_List | |
| * @dontinclude eina_list_01.c | | * @dontinclude eina_list_01.c | |
| * | | * | |
| * Creating an @ref Eina_List and adding elements to it is very easy and ca
n be | | * Creating an @ref Eina_List and adding elements to it is very easy and ca
n be | |
| * understood from an example: | | * understood from an example: | |
| * First thing is always to include Eina.h, for this example we also | | * First thing is always to include Eina.h, for this example we also | |
| * include stdio.h so we can use printf. | | * include stdio.h so we can use printf. | |
| * @skip #include | | * @skip #include | |
| * @until Eina.h | | * @until Eina.h | |
| * | | * | |
| * Just some boilerplate code, declaring some variable and initializing ein
a. | | * Just some boilerplate code, declaring some variable and initializing ein
a. | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 59 | |
| * @endhtmlonly | | * @endhtmlonly | |
| * @image rtf eina_list_example_01_a.png | | * @image rtf eina_list_example_01_a.png | |
| * @image latex eina_list_example_01_a.eps width=\textwidth | | * @image latex eina_list_example_01_a.eps width=\textwidth | |
| * @until roslin | | * @until roslin | |
| * There are a couple of interesting things happening here, first is that w
e are | | * There are a couple of interesting things happening here, first is that w
e are | |
| * passing a NULL pointer to the first @ref eina_list_append() call, when t
his | | * passing a NULL pointer to the first @ref eina_list_append() call, when t
his | |
| * is done a list is created. The other @b very important detail to notice
is | | * is done a list is created. The other @b very important detail to notice
is | |
| * that the return value is attributed to the @a list variable, this needs
to | | * that the return value is attributed to the @a list variable, this needs
to | |
| * be done every time we use a a function that alters the contents of the l
ist. | | * be done every time we use a a function that alters the contents of the l
ist. | |
| * | | * | |
|
| * Now that we have a list we some elements in it we can look at it's conte
nts. | | * Now that we have a list with some elements in it we can look at it's con
tents. | |
| * @until printf | | * @until printf | |
| * | | * | |
| * There are many ways of accessing elements in the list, including by it's | | * There are many ways of accessing elements in the list, including by it's | |
| * index: | | * index: | |
| * @until nth | | * @until nth | |
| * @note It should be noted that the index starts at 0. | | * @note It should be noted that the index starts at 0. | |
| * | | * | |
| * @ref eina_list_append() is not the only way to add elements to a a list.
A | | * @ref eina_list_append() is not the only way to add elements to a a list.
A | |
| * common requirement is to add an element in a specific position this can
be | | * common requirement is to add an element in a specific position this can
be | |
| * accomplished using @ref eina_list_append_relative() and | | * accomplished using @ref eina_list_append_relative() and | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 102 | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @page eina_list_01_c Adding elements to Eina_List example | | * @page eina_list_01_c Adding elements to Eina_List example | |
| * | | * | |
| * @include eina_list_01.c | | * @include eina_list_01.c | |
| * @example eina_list_01.c | | * @example eina_list_01.c | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page list_02_example_page Sorting Eina_List elements | | * @page eina_list_02_example_page Sorting Eina_List elements | |
| * @dontinclude eina_list_02.c | | * @dontinclude eina_list_02.c | |
| * | | * | |
| * If you don't know how to create lists see | | * If you don't know how to create lists see | |
|
| * @ref list_01_example_page. | | * @ref eina_list_01_example_page. | |
| * | | * | |
| * @skip #include | | * @skip #include | |
| * @until boomer | | * @until boomer | |
| * This is the code we have already seen to create a list. Now if we need t
o | | * This is the code we have already seen to create a list. Now if we need t
o | |
| * search the list we can do it like this: | | * search the list we can do it like this: | |
| * @until return | | * @until return | |
| * | | * | |
| * However if searching the list multiple times it probably is better to so
rt | | * However if searching the list multiple times it probably is better to so
rt | |
| * the list since the sorted_search functions are much faster: | | * the list since the sorted_search functions are much faster: | |
| * @until return | | * @until return | |
| | | | |
| skipping to change at line 154 | | skipping to change at line 154 | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @page eina_list_02_c Sorting Eina_List elements example | | * @page eina_list_02_c Sorting Eina_List elements example | |
| * | | * | |
| * @include eina_list_02.c | | * @include eina_list_02.c | |
| * @example eina_list_02.c | | * @example eina_list_02.c | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page list_03_example_page Reordering Eina_List elments | | * @page eina_list_03_example_page Reordering Eina_List elements | |
| * @dontinclude eina_list_03.c | | * @dontinclude eina_list_03.c | |
| * | | * | |
| * If you don't know how to create lists see | | * If you don't know how to create lists see | |
|
| * @ref list_01_example_page. | | * @ref eina_list_01_example_page. | |
| * | | * | |
| * We start out with code that should be familiar by now: | | * We start out with code that should be familiar by now: | |
| * @skip #include | | * @skip #include | |
| * @until gemenon | | * @until gemenon | |
| * | | * | |
| * You can move elements around in a list using @ref eina_list_move() or us
ing | | * You can move elements around in a list using @ref eina_list_move() or us
ing | |
| * @ref eina_list_promote_list() and @ref eina_list_demote_list() which mov
e a | | * @ref eina_list_promote_list() and @ref eina_list_demote_list() which mov
e a | |
| * list node to the head and end of the list respectevely: | | * list node to the head and end of the list respectevely: | |
| * @until demote | | * @until demote | |
| * | | * | |
| | | | |
| skipping to change at line 193 | | skipping to change at line 193 | |
| * @note Always remember to free your iterators when done using them. | | * @note Always remember to free your iterators when done using them. | |
| * | | * | |
| * And as always release memory and shutdown eina before ending: | | * And as always release memory and shutdown eina before ending: | |
| * @until } | | * @until } | |
| * | | * | |
| * The full source code can be found on the examples folder | | * The full source code can be found on the examples folder | |
| * on the @ref eina_list_03_c "eina_list_03.c" file. | | * on the @ref eina_list_03_c "eina_list_03.c" file. | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page eina_list_03_c Reordering Eina_List elments example | | * @page eina_list_03_c Reordering Eina_List elements example | |
| * | | * | |
| * @include eina_list_03.c | | * @include eina_list_03.c | |
| * @example eina_list_03.c | | * @example eina_list_03.c | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| * @page list_04_example_page Eina_List and memory allocation | | * @page eina_list_04_example_page Eina_List and memory allocation | |
| * @dontinclude eina_list_04.c | | * @dontinclude eina_list_04.c | |
| * | | * | |
| * If you don't know how to create lists see | | * If you don't know how to create lists see | |
|
| * @ref list_01_example_page. In this example we also use | | * @ref eina_list_01_example_page. In this example we also use | |
| * @ref Eina_Stringshare_Group, however it should be possible to understand
the code | | * @ref Eina_Stringshare_Group, however it should be possible to understand
the code | |
| * regardless of previous knowledge about it. | | * regardless of previous knowledge about it. | |
| * | | * | |
| * Here we have the usual list creation code with a twist, now we are using
as | | * Here we have the usual list creation code with a twist, now we are using
as | |
| * data for the list memory that has to be freed later on. | | * data for the list memory that has to be freed later on. | |
| * @skip #include | | * @skip #include | |
| * @until Sharon | | * @until Sharon | |
| * | | * | |
| * This time we are going to iterate over our list in a different way: | | * This time we are going to iterate over our list in a different way: | |
| * @until printf | | * @until printf | |
| | | | |
| skipping to change at line 279 | | skipping to change at line 279 | |
| * @ref eina_list_append_relative, @ref eina_list_remove, | | * @ref eina_list_append_relative, @ref eina_list_remove, | |
| * @ref eina_list_data_find), the @a list versions of these functions opera
te | | * @ref eina_list_data_find), the @a list versions of these functions opera
te | |
| * on @ref Eina_List nodes. | | * on @ref Eina_List nodes. | |
| * | | * | |
| * @warning You must @b always use the pointer to the first element of the
list | | * @warning You must @b always use the pointer to the first element of the
list | |
| * as the list! | | * as the list! | |
| * @warning You must @b never use a pointer to an element in the middle of
the | | * @warning You must @b never use a pointer to an element in the middle of
the | |
| * list as the list! | | * list as the list! | |
| * | | * | |
| * Here are some examples of @ref Eina_List usage: | | * Here are some examples of @ref Eina_List usage: | |
|
| * @li @ref list_01_example_page | | * @li @ref eina_list_01_example_page | |
| * @li @ref list_02_example_page | | * @li @ref eina_list_02_example_page | |
| * @li @ref list_03_example_page | | * @li @ref eina_list_03_example_page | |
| * @li @ref list_04_example_page | | * @li @ref eina_list_04_example_page | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Data_Types_Group Data Types | | * @addtogroup Eina_Data_Types_Group Data Types | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Containers_Group Containers | | * @addtogroup Eina_Containers_Group Containers | |
| | | | |
| skipping to change at line 576 | | skipping to change at line 576 | |
| * include the case where @p data is @c NULL), nothing is done. If | | * include the case where @p data is @c NULL), nothing is done. If | |
| * @p list is @c NULL, @c NULL is returned, otherwise a new list | | * @p list is @c NULL, @c NULL is returned, otherwise a new list | |
| * pointer that should be used in place of the one passed to this | | * pointer that should be used in place of the one passed to this | |
| * function. | | * function. | |
| * | | * | |
| * @warning @p list must be a pointer to the first element of the list. | | * @warning @p list must be a pointer to the first element of the list. | |
| */ | | */ | |
| EAPI Eina_List *eina_list_remove(Eina_List *list, const void *da
ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; | | EAPI Eina_List *eina_list_remove(Eina_List *list, const void *da
ta) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
|
| * @brief Remove the specified data. | | * @brief Remove the specified list node. | |
| * | | * | |
| * @param list The given linked list. | | * @param list The given linked list. | |
| * @param remove_list The list node which is to be removed. | | * @param remove_list The list node which is to be removed. | |
| * @return A list pointer. | | * @return A list pointer. | |
| * | | * | |
| * This function removes the list node @p remove_list from @p list and | | * This function removes the list node @p remove_list from @p list and | |
| * frees the list node structure @p remove_list. If @p list is | | * frees the list node structure @p remove_list. If @p list is | |
| * @c NULL, this function returns @c NULL. If @p remove_list is | | * @c NULL, this function returns @c NULL. If @p remove_list is | |
| * @c NULL, it returns @p list, otherwise, a new list pointer that | | * @c NULL, it returns @p list, otherwise, a new list pointer that | |
| * should be used in place of the one passed to this function. | | * should be used in place of the one passed to this function. | |
| | | | |
| skipping to change at line 864 | | skipping to change at line 864 | |
| * @warning @p list must be a pointer to the first element of the list. | | * @warning @p list must be a pointer to the first element of the list. | |
| * | | * | |
| * @see eina_list_reverse_clone() | | * @see eina_list_reverse_clone() | |
| */ | | */ | |
| EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN
_UNUSED_RESULT; | | EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN
_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Sort a list according to the ordering func will return. | | * @brief Sort a list according to the ordering func will return. | |
| * | | * | |
| * @param list The list handle to sort. | | * @param list The list handle to sort. | |
|
| * @param size The length of the list to sort. | | * @param limit The maximum number of list elements to sort. | |
| * @param func A function pointer that can handle comparing the list data | | * @param func A function pointer that can handle comparing the list data | |
| * nodes. | | * nodes. | |
| * @return the new head of list. | | * @return the new head of list. | |
| * | | * | |
| * This function sorts @p list. @p size if the number of the first | | * This function sorts @p list. @p size if the number of the first | |
|
| * element to sort. If @p size is 0 or greater than the number of | | * element to sort. If @p limit is 0 or greater than the number of | |
| * elements in @p list, all the elements are sorted. @p func is used to | | * elements in @p list, all the elements are sorted. @p func is used to | |
| * compare two elements of @p list. If @p list or @p func are @c NULL, | | * compare two elements of @p list. If @p list or @p func are @c NULL, | |
| * this function returns @c NULL. | | * this function returns @c NULL. | |
| * | | * | |
| * @note @b in-place: this will change the given list, so you should | | * @note @b in-place: this will change the given list, so you should | |
| * now point to the new list head that is returned by this function. | | * now point to the new list head that is returned by this function. | |
| * | | * | |
| * @note worst case is O(n * log2(n)) comparisons (calls to func()), | | * @note worst case is O(n * log2(n)) comparisons (calls to func()), | |
| * O(n) comparisons average case. That means that for 1,000,000 list | | * O(n) comparisons average case. That means that for 1,000,000 list | |
| * elements, sort will usually do 1,000,000 comparisons, but may do up | | * elements, sort will usually do 1,000,000 comparisons, but may do up | |
| | | | |
| skipping to change at line 903 | | skipping to change at line 903 | |
| * | | * | |
| * return(strcmp(txt, txt2)); | | * return(strcmp(txt, txt2)); | |
| * } | | * } | |
| * extern Eina_List *list; | | * extern Eina_List *list; | |
| * | | * | |
| * list = eina_list_sort(list, eina_list_count(list), sort_cb); | | * list = eina_list_sort(list, eina_list_count(list), sort_cb); | |
| * @endcode | | * @endcode | |
| * | | * | |
| * @warning @p list must be a pointer to the first element of the list. | | * @warning @p list must be a pointer to the first element of the list. | |
| */ | | */ | |
|
| EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int siz
e, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; | | EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int lim
it, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Merge two list. | | * @brief Merge two list. | |
| * | | * | |
| * @param left Head list to merge. | | * @param left Head list to merge. | |
| * @param right Tail list to merge. | | * @param right Tail list to merge. | |
| * @return A new merged list. | | * @return A new merged list. | |
| * | | * | |
|
| * This function puts right at the end of left and return the head. | | * This function puts right at the end of left and returns the head. | |
| * | | * | |
|
| * Both left and right does not exist anymore after the merge. | | * Both left and right do not exist anymore after the merge. | |
| * | | * | |
| * @note merge cost is O(n), being @b n the size of the smallest | | * @note merge cost is O(n), being @b n the size of the smallest | |
| * list. This is due the need to fix accounting of that segment, | | * list. This is due the need to fix accounting of that segment, | |
| * making count and last access O(1). | | * making count and last access O(1). | |
| * | | * | |
| * @warning @p list must be a pointer to the first element of the list. | | * @warning @p list must be a pointer to the first element of the list. | |
| */ | | */ | |
| EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *righ
t) EINA_WARN_UNUSED_RESULT; | | EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *righ
t) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 937 | | skipping to change at line 937 | |
| * @param left First list to merge. | | * @param left First list to merge. | |
| * @param right Second list to merge. | | * @param right Second list to merge. | |
| * @param func A function pointer that can handle comparing the list data | | * @param func A function pointer that can handle comparing the list data | |
| * nodes. | | * nodes. | |
| * @return A new sorted list. | | * @return A new sorted list. | |
| * | | * | |
| * This function compares the head of @p left and @p right, and choose the | | * This function compares the head of @p left and @p right, and choose the | |
| * smallest one to be head of the returned list. It will continue this proc
ess | | * smallest one to be head of the returned list. It will continue this proc
ess | |
| * for all entry of both list. | | * for all entry of both list. | |
| * | | * | |
|
| * Both left and right does not exist anymore after the merge. | | * Both left and right do not exist anymore after the merge. | |
| * If @p func is NULL, it will return NULL. | | * If @p func is NULL, it will return NULL. | |
| * | | * | |
| * Example: | | * Example: | |
| * @code | | * @code | |
| * int | | * int | |
| * sort_cb(void *d1, void *d2) | | * sort_cb(void *d1, void *d2) | |
| * { | | * { | |
| * const char *txt = NULL; | | * const char *txt = NULL; | |
| * const char *txt2 = NULL; | | * const char *txt2 = NULL; | |
| * | | * | |
| | | | |
End of changes. 17 change blocks. |
| 20 lines changed or deleted | | 20 lines changed or added | |
|
| eina_lock.h | | eina_lock.h | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 59 | |
| # include "eina_inline_lock_win32.x" | | # include "eina_inline_lock_win32.x" | |
| # else | | # else | |
| # include "eina_inline_lock_posix.x" | | # include "eina_inline_lock_posix.x" | |
| # endif | | # endif | |
| #else | | #else | |
| # include "eina_inline_lock_void.x" | | # include "eina_inline_lock_void.x" | |
| #endif | | #endif | |
| | | | |
| EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP; | | EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP; | |
| | | | |
|
| | | /** @relates static Eina_Bool eina_lock_new(_Eina_Lock *mutex) */ | |
| static inline Eina_Bool eina_lock_new(Eina_Lock *mutex); | | static inline Eina_Bool eina_lock_new(Eina_Lock *mutex); | |
|
| | | /** @relates static void eina_lock_free(_Eina_Lock *mutex) */ | |
| static inline void eina_lock_free(Eina_Lock *mutex); | | static inline void eina_lock_free(Eina_Lock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_lock_take(_Eina_Lock *mutex) */ | |
| static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex); | | static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_lock_take_try(_Eina_Lock *mutex)
*/ | |
| static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex); | | static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_lock_release(_Eina_Lock *mutex) *
/ | |
| static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex); | | static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex); | |
|
| | | /** @relates static void eina_lock_debug(const _Eina_Lock *mutex) */ | |
| static inline void eina_lock_debug(const Eina_Lock *mutex); | | static inline void eina_lock_debug(const Eina_Lock *mutex); | |
| | | | |
|
| | | /** @relates static Eina_Bool eina_condition_new(_Eina_Condition *cond, _Ei
na_Lock *mutex) */ | |
| static inline Eina_Bool eina_condition_new(Eina_Condition *cond, Eina_Lock
*mutex); | | static inline Eina_Bool eina_condition_new(Eina_Condition *cond, Eina_Lock
*mutex); | |
|
| | | /** @relates static void eina_condition_free(_Eina_Condition *cond) */ | |
| static inline void eina_condition_free(Eina_Condition *cond); | | static inline void eina_condition_free(Eina_Condition *cond); | |
|
| | | /** @relates static Eina_Bool eina_condition_wait(_Eina_Condition *cond) */ | |
| static inline Eina_Bool eina_condition_wait(Eina_Condition *cond); | | static inline Eina_Bool eina_condition_wait(Eina_Condition *cond); | |
|
| | | /** @relates static Eina_Bool eina_condition_timedwait(_Eina_Condition *con
d, double t) */ | |
| static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, doub
le t); | | static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, doub
le t); | |
|
| | | /** @relates static Eina_Bool eina_condition_broadcast(_Eina_Condition *con
d) */ | |
| static inline Eina_Bool eina_condition_broadcast(Eina_Condition *cond); | | static inline Eina_Bool eina_condition_broadcast(Eina_Condition *cond); | |
|
| | | /** @relates static Eina_Bool eina_condition_signal(_Eina_Condition *cond)
*/ | |
| static inline Eina_Bool eina_condition_signal(Eina_Condition *cond); | | static inline Eina_Bool eina_condition_signal(Eina_Condition *cond); | |
| | | | |
|
| | | /** @relates static Eina_Bool eina_rwlock_new(_Eina_RWLock *mutex) */ | |
| static inline Eina_Bool eina_rwlock_new(Eina_RWLock *mutex); | | static inline Eina_Bool eina_rwlock_new(Eina_RWLock *mutex); | |
|
| | | /** @relates static void eina_rwlock_free(_Eina_RWLock *mutex) */ | |
| static inline void eina_rwlock_free(Eina_RWLock *mutex); | | static inline void eina_rwlock_free(Eina_RWLock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_rwlock_take_read(_Eina_RWLock *mu
tex) */ | |
| static inline Eina_Lock_Result eina_rwlock_take_read(Eina_RWLock *mutex); | | static inline Eina_Lock_Result eina_rwlock_take_read(Eina_RWLock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_rwlock_take_write(_Eina_RWLock *m
utex) */ | |
| static inline Eina_Lock_Result eina_rwlock_take_write(Eina_RWLock *mutex); | | static inline Eina_Lock_Result eina_rwlock_take_write(Eina_RWLock *mutex); | |
|
| | | /** @relates static Eina_Lock_Result eina_rwlock_release(_Eina_RWLock *mute
x) */ | |
| static inline Eina_Lock_Result eina_rwlock_release(Eina_RWLock *mutex); | | static inline Eina_Lock_Result eina_rwlock_release(Eina_RWLock *mutex); | |
| | | | |
|
| | | /** @relates static Eina_Bool eina_tls_new(pthread_key_t *key) */ | |
| static inline Eina_Bool eina_tls_new(Eina_TLS *key); | | static inline Eina_Bool eina_tls_new(Eina_TLS *key); | |
|
| | | /** @relates static void eina_tls_free(pthread_key_t key) */ | |
| static inline void eina_tls_free(Eina_TLS key); | | static inline void eina_tls_free(Eina_TLS key); | |
|
| | | /** @relates static void eina_tls_get(pthread_key_t key) */ | |
| static inline void *eina_tls_get(Eina_TLS key); | | static inline void *eina_tls_get(Eina_TLS key); | |
|
| | | /** @relates static Eina_Bool eina_tls_set(pthread_key_t key, const void *d
ata) */ | |
| static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); | | static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); | |
|
| | | /** @relates static Eina_Bool eina_semaphore_new(sem_t *sem, int count_init | |
| | | ) */ | |
| | | static inline Eina_Bool eina_semaphore_new(Eina_Semaphore *sem, int count_i | |
| | | nit); | |
| | | /** @relates static Eina_Bool eina_semaphore_free(sem_t *sem) */ | |
| | | static inline Eina_Bool eina_semaphore_free(Eina_Semaphore *sem); | |
| | | /** @relates static Eina_Bool eina_semaphore_lock(sem_t *sem) */ | |
| | | static inline Eina_Bool eina_semaphore_lock(Eina_Semaphore *sem); | |
| | | /** @relates static Eina_Bool eina_semaphore_release(sem_t *sem, int count_ | |
| | | release) */ | |
| | | static inline Eina_Bool eina_semaphore_release(Eina_Semaphore *sem, int cou | |
| | | nt_release); | |
| | | | |
| #ifdef EINA_HAVE_DEBUG_THREADS | | #ifdef EINA_HAVE_DEBUG_THREADS | |
| # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ | | # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ | |
| do { \ | | do { \ | |
| if (EINA_UNLIKELY(!eina_main_loop_is())) \ | | if (EINA_UNLIKELY(!eina_main_loop_is())) \ | |
| {
\ | | {
\ | |
| eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ | | eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ | |
| EINA_LOG_ERR("You are calling %s from outside" \ | | EINA_LOG_ERR("You are calling %s from outside" \ | |
| "of the main loop threads in %s at line %i", \ | | "of the main loop threads in %s at line %i", \ | |
| __FUNCTION__, \ | | __FUNCTION__, \ | |
| | | | |
| skipping to change at line 112 | | skipping to change at line 141 | |
| eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ | | eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ | |
| EINA_LOG_ERR("You are calling %s from outside" \ | | EINA_LOG_ERR("You are calling %s from outside" \ | |
| "of the main loop threads in %s at line %i", \ | | "of the main loop threads in %s at line %i", \ | |
| __FUNCTION__, \ | | __FUNCTION__, \ | |
| __FILE__, \ | | __FILE__, \ | |
| __LINE__); \ | | __LINE__); \ | |
| return ; \ | | return ; \ | |
| }
\ | | }
\ | |
| } while (0) | | } while (0) | |
| #else | | #else | |
|
| | | /** | |
| | | * @def EINA_MAIN_LOOP_CHECK_RETURN_VAL | |
| | | * @brief The macro doesn't do anything unless EINA_HAVE_DEBUG_THREADS is d | |
| | | efined. | |
| | | * @param val The value to be returned. | |
| | | */ | |
| # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) | | # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) | |
|
| | | /** | |
| | | * @def EINA_MAIN_LOOP_CHECK_RETURN | |
| | | * @brief The macro doesn't do anything unless EINA_HAVE_DEBUG_THREADS is d | |
| | | efined. | |
| | | */ | |
| # define EINA_MAIN_LOOP_CHECK_RETURN | | # define EINA_MAIN_LOOP_CHECK_RETURN | |
| #endif | | #endif | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
End of changes. 24 change blocks. |
| 0 lines changed or deleted | | 44 lines changed or added | |
|
| eina_log.h | | eina_log.h | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; | | * License along with this library; | |
| * if not, see <http://www.gnu.org/licenses/>. | | * if not, see <http://www.gnu.org/licenses/>. | |
| */ | | */ | |
| | | | |
| #ifndef EINA_LOG_H_ | | #ifndef EINA_LOG_H_ | |
| #define EINA_LOG_H_ | | #define EINA_LOG_H_ | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <stdarg.h> | | #include <stdarg.h> | |
|
| | | #include <sys/types.h> | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| | | | |
| #define EINA_COLOR_LIGHTRED "\033[31;1m" | | #define EINA_COLOR_LIGHTRED "\033[31;1m" | |
| #define EINA_COLOR_RED "\033[31m" | | #define EINA_COLOR_RED "\033[31m" | |
| #define EINA_COLOR_LIGHTBLUE "\033[34;1m" | | #define EINA_COLOR_LIGHTBLUE "\033[34;1m" | |
| #define EINA_COLOR_BLUE "\033[34m" | | #define EINA_COLOR_BLUE "\033[34m" | |
| #define EINA_COLOR_GREEN "\033[32;1m" | | #define EINA_COLOR_GREEN "\033[32;1m" | |
| #define EINA_COLOR_YELLOW "\033[33;1m" | | #define EINA_COLOR_YELLOW "\033[33;1m" | |
| #define EINA_COLOR_ORANGE "\033[0;33m" | | #define EINA_COLOR_ORANGE "\033[0;33m" | |
| | | | |
| skipping to change at line 299 | | skipping to change at line 300 | |
| * @note if @c EINA_LOG_LEVEL_MAXIMUM is defined, then messages larger | | * @note if @c EINA_LOG_LEVEL_MAXIMUM is defined, then messages larger | |
| * than this value will be ignored regardless of current domain | | * than this value will be ignored regardless of current domain | |
| * level, the eina_log_print() is not even called! Most | | * level, the eina_log_print() is not even called! Most | |
| * compilers will just detect the two integers make the branch | | * compilers will just detect the two integers make the branch | |
| * impossible and remove the branch and function call all | | * impossible and remove the branch and function call all | |
| * together. Take this as optimization tip and possible remove | | * together. Take this as optimization tip and possible remove | |
| * debug messages from binaries to be deployed, saving on hot | | * debug messages from binaries to be deployed, saving on hot | |
| * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public | | * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public | |
| * header files. | | * header files. | |
| */ | | */ | |
|
| #ifdef EINA_LOG_LEVEL_MAXIMUM | | #ifdef EINA_ENABLE_LOG | |
| #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | | # ifdef EINA_LOG_LEVEL_MAXIMUM | |
| do { \ | | # define EINA_LOG(DOM, LEVEL, fmt, ...) | |
| if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ | | \ | |
| eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ | | do { \ | |
| fmt, ## __VA_ARGS__); } \ | | if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ | |
| } while (0) | | eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ | |
| #else | | fmt, ## __VA_ARGS__); } \ | |
| #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | | } while (0) | |
| eina_log_print(DOM, \ | | # else | |
| LEVEL, \ | | # define EINA_LOG(DOM, LEVEL, fmt, ...) \ | |
| __FILE__, \ | | eina_log_print(DOM, \ | |
| __FUNCTION__, \ | | LEVEL, \ | |
| __LINE__, \ | | __FILE__, \ | |
| fmt, \ | | __FUNCTION__, \ | |
| | | __LINE__, \ | |
| | | fmt, \ | |
| ## __VA_ARGS__) | | ## __VA_ARGS__) | |
|
| | | # endif | |
| | | #else | |
| | | #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | |
| | | do { (void) DOM; (void) LEVEL; (void) fmt; } while (0) | |
| #endif | | #endif | |
| | | | |
| /** | | /** | |
| * @def EINA_LOG_DOM_CRIT(DOM, fmt, ...) | | * @def EINA_LOG_DOM_CRIT(DOM, fmt, ...) | |
| * Logs a message with level CRITICAL on the specified domain and format. | | * Logs a message with level CRITICAL on the specified domain and format. | |
| */ | | */ | |
| #define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \ | | #define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \ | |
| EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__) | | EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__) | |
| | | | |
| /** | | /** | |
| | | | |
End of changes. 3 change blocks. |
| 15 lines changed or deleted | | 22 lines changed or added | |
|
| eina_module.h | | eina_module.h | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 53 | |
| * POSIX, but enhance its usage by defining some good practices. | | * POSIX, but enhance its usage by defining some good practices. | |
| * | | * | |
| * Modules are created with eina_module_new() and later loaded with | | * Modules are created with eina_module_new() and later loaded with | |
| * eina_module_load(). Loads are reference counted and there must be | | * eina_module_load(). Loads are reference counted and there must be | |
| * the same number of eina_module_unload() in order to have it to call | | * the same number of eina_module_unload() in order to have it to call | |
| * dlclose(). This makes simple to have different users for the same | | * dlclose(). This makes simple to have different users for the same | |
| * module. | | * module. | |
| * | | * | |
| * The loaded shared objects may have two visible functions that will | | * The loaded shared objects may have two visible functions that will | |
| * be called and might provide initialization and shutdown | | * be called and might provide initialization and shutdown | |
|
| * proceedures. The symbols are @c __eina_module_init and | | * procedures. The symbols are @c __eina_module_init and | |
| * @c __eina_module_shutdown and will be defined by the macros | | * @c __eina_module_shutdown and will be defined by the macros | |
| * EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN(). | | * EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN(). | |
| * | | * | |
| * There are some helpers to automatically create modules based on | | * There are some helpers to automatically create modules based on | |
| * directory listing. See eina_module_arch_list_get(), | | * directory listing. See eina_module_arch_list_get(), | |
| * eina_module_list_get() and eina_module_find(). | | * eina_module_list_get() and eina_module_find(). | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 125 | | skipping to change at line 125 | |
| /** | | /** | |
| * @var EINA_ERROR_MODULE_INIT_FAILED | | * @var EINA_ERROR_MODULE_INIT_FAILED | |
| * Error identifier corresponding to a failure during the initialisation of
a module. | | * Error identifier corresponding to a failure during the initialisation of
a module. | |
| */ | | */ | |
| extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED; | | extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED; | |
| | | | |
| /** | | /** | |
| * @brief Return a new module. | | * @brief Return a new module. | |
| * | | * | |
| * @param file The name of the file module to load. | | * @param file The name of the file module to load. | |
|
| * | | * @return A new module. If @p file is @c NULL, the function | |
| * This function returns a new module. If @p file is @c NULL, the | | * returns @c NULL, otherwise, it allocates an Eina_Module, stores | |
| * function returns @c NULL, otherwise, it allocates an Eina_Module, | | * a duplicate string of @p file, sets its reference to @c 0 and | |
| * stores a duplicate string of @p file, sets its reference to @c 0 | | * its handle to @c NULL. | |
| * and its handle to @c NULL. | | | |
| * | | * | |
| * When the new module is not needed anymore, use eina_module_free() | | * When the new module is not needed anymore, use eina_module_free() | |
| * to free the allocated memory. | | * to free the allocated memory. | |
| * | | * | |
| * @see eina_module_load | | * @see eina_module_load | |
| */ | | */ | |
| EAPI Eina_Module * | | EAPI Eina_Module * | |
| eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA
_ARG_NONNULL(1); | | eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA
_ARG_NONNULL(1); | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 166 | | skipping to change at line 165 | |
| * @param module The module to load. | | * @param module The module to load. | |
| * @return EINA_TRUE on success, EINA_FALSE otherwise. | | * @return EINA_TRUE on success, EINA_FALSE otherwise. | |
| * | | * | |
| * This function load the shared file object passed in | | * This function load the shared file object passed in | |
| * eina_module_new(). If it is a internal Eina module (like the | | * eina_module_new(). If it is a internal Eina module (like the | |
| * mempools), it also initialize it. It the shared file object can not | | * mempools), it also initialize it. It the shared file object can not | |
| * be loaded, the error #EINA_ERROR_WRONG_MODULE is set and | | * be loaded, the error #EINA_ERROR_WRONG_MODULE is set and | |
| * #EINA_FALSE is returned. If it is a internal Eina module and the | | * #EINA_FALSE is returned. If it is a internal Eina module and the | |
| * module can not be initialized, the error | | * module can not be initialized, the error | |
| * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is | | * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is | |
|
| * returned. If the module has already been loaded, it's refeence | | * returned. If the module has already been loaded, it's reference | |
| * counter is increased by one and #EINA_TRUE is returned. If @p module is | | * counter is increased by one and #EINA_TRUE is returned. If @p module is | |
| * @c NULL, the function returns immediately #EINA_FALSE. | | * @c NULL, the function returns immediately #EINA_FALSE. | |
| * | | * | |
|
| * When the symbols of the shared file objetcts are not needed | | * When the symbols of the shared file objects are not needed | |
| * anymore, call eina_module_unload() to unload the module. | | * anymore, call eina_module_unload() to unload the module. | |
| */ | | */ | |
| EAPI Eina_Bool | | EAPI Eina_Bool | |
| eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1); | | eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1); | |
| | | | |
| /** | | /** | |
| * @brief Unload a module. | | * @brief Unload a module. | |
| * | | * | |
| * @param module The module to load. | | * @param module The module to load. | |
| * @return EINA_TRUE on success, EINA_FALSE otherwise. | | * @return EINA_TRUE on success, EINA_FALSE otherwise. | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 193 | |
| * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the | | * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the | |
| * shared object file is closed and if it is a internal Eina module, it | | * shared object file is closed and if it is a internal Eina module, it | |
| * is shutted down just before. In that case, #EINA_TRUE is | | * is shutted down just before. In that case, #EINA_TRUE is | |
| * returned. In all case, the reference counter is decreased. If @p module | | * returned. In all case, the reference counter is decreased. If @p module | |
| * is @c NULL, the function returns immediately #EINA_FALSE. | | * is @c NULL, the function returns immediately #EINA_FALSE. | |
| */ | | */ | |
| EAPI Eina_Bool | | EAPI Eina_Bool | |
| eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1); | | eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1); | |
| | | | |
| /** | | /** | |
|
| * @brief Retrive the data associated to a symbol. | | * @brief Retrieve the data associated to a symbol. | |
| * | | * | |
| * @param module The module. | | * @param module The module. | |
| * @param symbol The symbol. | | * @param symbol The symbol. | |
| * @return The data associated to the symbol, or @c NULL on failure. | | * @return The data associated to the symbol, or @c NULL on failure. | |
| * | | * | |
| * This function returns the data associated to @p symbol of @p module. @p | | * This function returns the data associated to @p symbol of @p module. @p | |
| * module must have been loaded before with eina_module_load(). If @p modul
e | | * module must have been loaded before with eina_module_load(). If @p modul
e | |
| * is @c NULL, or if it has not been correctly loaded before, the | | * is @c NULL, or if it has not been correctly loaded before, the | |
| * function returns immediately @c NULL. | | * function returns immediately @c NULL. | |
| */ | | */ | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 238 | |
| * This function returns the path built by concatenating the path of | | * This function returns the path built by concatenating the path of | |
| * the library containing the symbol @p symbol and @p sub_dir. @p sub_dir | | * the library containing the symbol @p symbol and @p sub_dir. @p sub_dir | |
| * can be @c NULL. The returned path must be freed when not used | | * can be @c NULL. The returned path must be freed when not used | |
| * anymore. If the symbol is not found, or dl_addr() is not supported, | | * anymore. If the symbol is not found, or dl_addr() is not supported, | |
| * or allocation fails, this function returns @c NULL. | | * or allocation fails, this function returns @c NULL. | |
| */ | | */ | |
| EAPI char * | | EAPI char * | |
| eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_
PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); | | eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_
PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); | |
| | | | |
| /** | | /** | |
|
| * @brief Return the path built from the value of an environment varialbe a
nd a | | * @brief Return the path built from the value of an environment variable a
nd a | |
| * given sub directory. | | * given sub directory. | |
| * | | * | |
| * @param env The environment variable to expand. | | * @param env The environment variable to expand. | |
| * @param sub_dir The subdirectory to append. | | * @param sub_dir The subdirectory to append. | |
| * @return The built path on success, @c NULL otherwise. | | * @return The built path on success, @c NULL otherwise. | |
| * | | * | |
| * This function returns the path built by concatenating the value of | | * This function returns the path built by concatenating the value of | |
| * the environment variable named @p env and @p sub_dir. @p sub_dir | | * the environment variable named @p env and @p sub_dir. @p sub_dir | |
| * can be @c NULL. The returned path must be freed when not used | | * can be @c NULL. The returned path must be freed when not used | |
| * anymore. If the symbol is not found, or @p env does not exist, or | | * anymore. If the symbol is not found, or @p env does not exist, or | |
| | | | |
End of changes. 6 change blocks. |
| 10 lines changed or deleted | | 9 lines changed or added | |
|
| eina_prefix.h | | eina_prefix.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| * @param envprefix This is the prefix to any environment variables that ma
y override prefix detection and give the exact location of the software | | * @param envprefix This is the prefix to any environment variables that ma
y override prefix detection and give the exact location of the software | |
| * @param sharedir This is the directory inside the standard share or data
dir where the software will store data files | | * @param sharedir This is the directory inside the standard share or data
dir where the software will store data files | |
| * @param magicsharefile This is a magic file to check existence of to dete
rmine the prefix find was correct, and it must be located in the data dir u
nder the share dir provided above, or NULL if the check is not to be done | | * @param magicsharefile This is a magic file to check existence of to dete
rmine the prefix find was correct, and it must be located in the data dir u
nder the share dir provided above, or NULL if the check is not to be done | |
| * @param pkg_bin This is the compile-time binary install dir | | * @param pkg_bin This is the compile-time binary install dir | |
| * @param pkg_lib This is the compile-time library install dir | | * @param pkg_lib This is the compile-time library install dir | |
| * @param pkg_data This is the compile-time share/data install dir | | * @param pkg_data This is the compile-time share/data install dir | |
| * @param pkg_locale This is the compile-time locale install dir | | * @param pkg_locale This is the compile-time locale install dir | |
| * @return The prefix handle, or NULL on failure | | * @return The prefix handle, or NULL on failure | |
| * | | * | |
| * Applications and libraries are most often not just single executables no
r | | * Applications and libraries are most often not just single executables no
r | |
|
| * single shared library binares, but also come with extra modules they | | * single shared library binaries, but also come with extra modules they | |
| * have to load, extra binary utilities they need to run, or have data file
s | | * have to load, extra binary utilities they need to run, or have data file
s | |
|
| * they need to load. A very primitve application ASSUMES a fixed install | | * they need to load. A very primitive application ASSUMES a fixed install | |
| * location at compile-time, but this disallows the ability to re-locate | | * location at compile-time, but this disallows the ability to re-locate | |
| * the application (or library) somewhere else after compilation (if you ru
n | | * the application (or library) somewhere else after compilation (if you ru
n | |
| * out of space on a given disk, partition etc. for example), or necessitat
e | | * out of space on a given disk, partition etc. for example), or necessitat
e | |
| * the need for having to maintain environment variables for every piece of | | * the need for having to maintain environment variables for every piece of | |
| * software to let it know its location, or have to use large sets of | | * software to let it know its location, or have to use large sets of | |
| * symlinks pointing from the compiled location to the new one. | | * symlinks pointing from the compiled location to the new one. | |
| * | | * | |
| * Being re-locatable at runtime allows much easier distribution and | | * Being re-locatable at runtime allows much easier distribution and | |
| * installation into places like the users own home directory, instead of | | * installation into places like the users own home directory, instead of | |
| * on a system partition, if the developer wishes for easier distribution | | * on a system partition, if the developer wishes for easier distribution | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 109 | |
| * so detection can know if it worked or not. | | * so detection can know if it worked or not. | |
| * | | * | |
| * The @p pkg_bin, @p pkg_lib, @p pkg_data and @p pkg_locale are compile-ti
me | | * The @p pkg_bin, @p pkg_lib, @p pkg_data and @p pkg_locale are compile-ti
me | |
| * strings (the kind standard autoconf/automake define) to be passed in | | * strings (the kind standard autoconf/automake define) to be passed in | |
| * so there can be a fallback to compiled-in defaults as well as use them | | * so there can be a fallback to compiled-in defaults as well as use them | |
| * to determine actual names of directories like libdirs maybe changing to | | * to determine actual names of directories like libdirs maybe changing to | |
| * be lib32 or lib64 instead of lib etc. | | * be lib32 or lib64 instead of lib etc. | |
| * | | * | |
| * Compile the following defining at compile time your prefixes like (examp
le): | | * Compile the following defining at compile time your prefixes like (examp
le): | |
| * | | * | |
|
| * gcc appname.c -o appname \ | | * gcc appname.c -o appname | |
| * -DPACKAGE_BIN_DIR=/usr/local/bin \ | | * -DPACKAGE_BIN_DIR=\\"/usr/local/bin\" | |
| * -DPACKAGE_LIB_DIR=/usr/local/lib \ | | * -DPACKAGE_LIB_DIR=\\"/usr/local/lib\" | |
| * -DPACKAGE_DATA_DIR=/usr/local/share/appname \ | | * -DPACKAGE_DATA_DIR=\\"/usr/local/share/appname\" | |
| * -DLOCALE_DIR=/usr/local/share/locale | | * -DLOCALE_DIR=\\"/usr/local/share/locale\" | |
| | | * `pkg-config --cflags --libs eina` | |
| * | | * | |
| * (of course add appropriate compile flags to linking etc. etc. and note t
hat | | * (of course add appropriate compile flags to linking etc. etc. and note t
hat | |
| * locale dir is optional. if you don't need it provide data dir as the | | * locale dir is optional. if you don't need it provide data dir as the | |
| * locale dir. also note that the magicsharefile is optional for testing an
d | | * locale dir. also note that the magicsharefile is optional for testing an
d | |
| * ensuring that the prefix check is correct. this file must be installed | | * ensuring that the prefix check is correct. this file must be installed | |
| * in the application data dir (eg /usr/local/share/appname) and be referre
d | | * in the application data dir (eg /usr/local/share/appname) and be referre
d | |
| * to using a unix-style relative path from that dir, eg directory/filename
.png) | | * to using a unix-style relative path from that dir, eg directory/filename
.png) | |
| * | | * | |
| * @code | | * @code | |
|
| | | * #include <Eina.h> | |
| | | * | |
| * static Eina_Prefix *pfx = NULL; | | * static Eina_Prefix *pfx = NULL; | |
| * | | * | |
|
| * int main(argc, char **argv) | | * int main(int argc, char **argv) | |
| * { | | * { | |
|
| | | * eina_init(); | |
| | | * | |
| * pfx = eina_prefix_new(argv[0], main, "APPNAME", "appname", NULL, | | * pfx = eina_prefix_new(argv[0], main, "APPNAME", "appname", NULL, | |
| * PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, | | * PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, | |
| * PACKAGE_DATA_DIR, LOCALE_DIR); | | * PACKAGE_DATA_DIR, LOCALE_DIR); | |
| * if (!pfx) printf("ERROR: Critical error in finding prefix\n"); | | * if (!pfx) printf("ERROR: Critical error in finding prefix\n"); | |
| * printf("install prefix is: %s\n", eina_prefix_get(pfx)); | | * printf("install prefix is: %s\n", eina_prefix_get(pfx)); | |
| * printf("binaries are in: %s\n", eina_prefix_bin_get(pfx)); | | * printf("binaries are in: %s\n", eina_prefix_bin_get(pfx)); | |
| * printf("libraries are in: %s\n", eina_prefix_lib_get(pfx)); | | * printf("libraries are in: %s\n", eina_prefix_lib_get(pfx)); | |
| * printf("data files are in: %s\n", eina_prefix_data_get(pfx)); | | * printf("data files are in: %s\n", eina_prefix_data_get(pfx)); | |
| * eina_prefix_free(pfx); | | * eina_prefix_free(pfx); | |
|
| | | * | |
| | | * eina_shutdown(); | |
| * } | | * } | |
| * @endcode | | * @endcode | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI Eina_Prefix * | | EAPI Eina_Prefix * | |
| eina_prefix_new(const char *argv0, void *symbol, const char *envprefix, | | eina_prefix_new(const char *argv0, void *symbol, const char *envprefix, | |
| const char *sharedir, const char *magicsharefile, | | const char *sharedir, const char *magicsharefile, | |
| const char *pkg_bin, const char *pkg_lib, | | const char *pkg_bin, const char *pkg_lib, | |
| const char *pkg_data, const char *pkg_locale); | | const char *pkg_data, const char *pkg_locale); | |
| | | | |
| skipping to change at line 164 | | skipping to change at line 171 | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI void | | EAPI void | |
| eina_prefix_free(Eina_Prefix *pfx); | | eina_prefix_free(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @brief Get the prefix base directory | | * @brief Get the prefix base directory | |
| * | | * | |
| * @param pfx The prefix object | | * @param pfx The prefix object | |
|
| * | | * @return The base prefix (eg "/usr/local", "/usr", "/opt/appname" or | |
| * This returns the base prefix (eg "/usr/local", "/usr", "/opt/appname" or | | | |
| * "/home/user/myapps/appname" etc.) that the software resides in at runtim
e. | | * "/home/user/myapps/appname" etc.) that the software resides in at runtim
e. | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI const char * | | EAPI const char * | |
| eina_prefix_get(Eina_Prefix *pfx); | | eina_prefix_get(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @brief Get the binary installation directory | | * @brief Get the binary installation directory | |
| * | | * | |
| * @param pfx The prefix object | | * @param pfx The prefix object | |
|
| * | | * @return The location of installed binaries (eg "/usr/local/bin", | |
| * This returns the location of installed binaries (eg "/usr/local/bin", | | | |
| * "/usr/bin", "/opt/appname/bin", "/home/user/myapps/appname/bin" etc.). | | * "/usr/bin", "/opt/appname/bin", "/home/user/myapps/appname/bin" etc.). | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI const char * | | EAPI const char * | |
| eina_prefix_bin_get(Eina_Prefix *pfx); | | eina_prefix_bin_get(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @brief Get the library installation directory | | * @brief Get the library installation directory | |
| * | | * | |
| * @param pfx The prefix object | | * @param pfx The prefix object | |
|
| * | | * @return The location of installed binaries (eg "/usr/local/lib", | |
| * This returns the location of installed binaries (eg "/usr/local/lib", | | | |
| * "/usr/lib32", "/opt/appname/lib64", "/home/user/myapps/appname/lib" etc.
). | | * "/usr/lib32", "/opt/appname/lib64", "/home/user/myapps/appname/lib" etc.
). | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI const char * | | EAPI const char * | |
| eina_prefix_lib_get(Eina_Prefix *pfx); | | eina_prefix_lib_get(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @brief Get the data installation directory | | * @brief Get the data installation directory | |
| * | | * | |
| * @param pfx The prefix object | | * @param pfx The prefix object | |
|
| * | | * @return The location of installed binaries (eg "/usr/local/share/appname | |
| * This returns the location of installed binaries (eg "/usr/local/share/ap | | ", | |
| pname", | | | |
| * "/usr/share/appname", "/opt/appname/share/appname", "/home/user/myapps/a
ppname/share/appname" etc.). | | * "/usr/share/appname", "/opt/appname/share/appname", "/home/user/myapps/a
ppname/share/appname" etc.). | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI const char * | | EAPI const char * | |
| eina_prefix_data_get(Eina_Prefix *pfx); | | eina_prefix_data_get(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @brief Get the locale installation directory | | * @brief Get the locale installation directory | |
| * | | * | |
| * @param pfx The prefix object | | * @param pfx The prefix object | |
|
| * | | * @return The location of installed binaries (eg "/usr/local/share/locale" | |
| * This returns the location of installed binaries (eg "/usr/local/share/lo | | , | |
| cale", | | | |
| * "/usr/share/locale", "/opt/appname/share/locale", "/home/user/myapps/app
name/share/locale" etc.). | | * "/usr/share/locale", "/opt/appname/share/locale", "/home/user/myapps/app
name/share/locale" etc.). | |
| * | | * | |
| * @since 1.1.0 | | * @since 1.1.0 | |
| */ | | */ | |
| EAPI const char * | | EAPI const char * | |
| eina_prefix_locale_get(Eina_Prefix *pfx); | | eina_prefix_locale_get(Eina_Prefix *pfx); | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
End of changes. 12 change blocks. |
| 20 lines changed or deleted | | 22 lines changed or added | |
|
| eina_safety_checks.h | | eina_safety_checks.h | |
| | | | |
| skipping to change at line 213 | | skipping to change at line 213 | |
| eina_error_set(EINA_ERROR_SAFETY_FAILED);
\ | | eina_error_set(EINA_ERROR_SAFETY_FAILED);
\ | |
| EINA_LOG_ERR("%s", "safety check failed: " # exp " is false");
\ | | EINA_LOG_ERR("%s", "safety check failed: " # exp " is false");
\ | |
| goto label;
\ | | goto label;
\ | |
| }
\ | | }
\ | |
| }
\ | | }
\ | |
| while (0) | | while (0) | |
| | | | |
| #ifdef EINA_ARG_NONNULL | | #ifdef EINA_ARG_NONNULL | |
| /* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */ | | /* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */ | |
| #undef EINA_ARG_NONNULL | | #undef EINA_ARG_NONNULL | |
|
| #define EINA_ARG_NONNULL(idx, ...) | | #define EINA_ARG_NONNULL(...) | |
| #endif | | #endif | |
| | | | |
| #else /* no safety checks */ | | #else /* no safety checks */ | |
| | | | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_NULL_RETURN | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | */ | |
| #define EINA_SAFETY_ON_NULL_RETURN(exp) \ | | #define EINA_SAFETY_ON_NULL_RETURN(exp) \ | |
| do { (void)(!(exp)); } while (0) | | do { (void)(!(exp)); } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_NULL_RETURN_VAL | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param val The value to be returned. | |
| | | */ | |
| #define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ | | #define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ | |
| do { if (0 && !(exp)) { (void)val; } } while (0) | | do { if (0 && !(exp)) { (void)val; } } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_NULL_GOTO | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param label The label to jump to. | |
| | | */ | |
| #define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ | | #define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ | |
| do { if (0 && (exp) == NULL) { goto label; } } while (0) | | do { if (0 && (exp) == NULL) { goto label; } } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_TRUE_RETURN | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | */ | |
| #define EINA_SAFETY_ON_TRUE_RETURN(exp) \ | | #define EINA_SAFETY_ON_TRUE_RETURN(exp) \ | |
| do { (void)(exp); } while (0) | | do { (void)(exp); } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_TRUE_RETURN_VAL | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param val The value to be returned. | |
| | | */ | |
| #define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ | | #define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ | |
| do { if (0 && (exp)) { (void)val; } } while (0) | | do { if (0 && (exp)) { (void)val; } } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_TRUE_GOTO | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param label The label to jump to. | |
| | | */ | |
| #define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ | | #define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ | |
| do { if (0 && (exp)) { goto label; } } while (0) | | do { if (0 && (exp)) { goto label; } } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_FALSE_RETURN | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | */ | |
| #define EINA_SAFETY_ON_FALSE_RETURN(exp) \ | | #define EINA_SAFETY_ON_FALSE_RETURN(exp) \ | |
| do { (void)(!(exp)); } while (0) | | do { (void)(!(exp)); } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_FALSE_RETURN_VAL | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param val The value to be returned. | |
| | | */ | |
| #define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ | | #define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ | |
| do { if (0 && !(exp)) { (void)val; } } while (0) | | do { if (0 && !(exp)) { (void)val; } } while (0) | |
|
| | | /** | |
| | | * @def EINA_SAFETY_ON_FALSE_GOTO | |
| | | * @brief The macro doesn't do anything unless EINA_SAFETY_CHECKS is define | |
| | | d. | |
| | | * @param exp The expression to be evaluated. | |
| | | * @param label The label to jump to. | |
| | | */ | |
| #define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ | | #define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ | |
| do { if (0 && !(exp)) { goto label; } } while (0) | | do { if (0 && !(exp)) { goto label; } } while (0) | |
| | | | |
| #endif /* safety checks macros */ | | #endif /* safety checks macros */ | |
| #endif /* EINA_SAFETY_CHECKS_H_ */ | | #endif /* EINA_SAFETY_CHECKS_H_ */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| | | | |
End of changes. 10 change blocks. |
| 9 lines changed or deleted | | 61 lines changed or added | |
|
| eina_simple_xml_parser.h | | eina_simple_xml_parser.h | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| #ifndef EINA_SIMPLE_XML_H_ | | #ifndef EINA_SIMPLE_XML_H_ | |
| #define EINA_SIMPLE_XML_H_ | | #define EINA_SIMPLE_XML_H_ | |
| | | | |
| #include "eina_config.h" | | #include "eina_config.h" | |
| | | | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_magic.h" | | #include "eina_magic.h" | |
| #include "eina_inlist.h" | | #include "eina_inlist.h" | |
| | | | |
| /** | | /** | |
|
| | | * @page eina_simple_xml_parser_example_01_page | |
| | | * @dontinclude eina_simple_xml_parser_01.c | |
| | | * | |
| | | * We are going to parse an XML sample file and print the data to stdout. | |
| | | * | |
| | | * Like all examples we start by including Eina: | |
| | | * @skipline #include | |
| | | * | |
| | | * We declare 2 booleans to keep track of tags: | |
| | | * @skipline tag_login | |
| | | * @skipline tag_message | |
| | | * | |
| | | * Here we declare some variables and initialize eina: | |
| | | * @until eina_init | |
| | | * | |
| | | * We fill buffer with the XML data from chat.xml: | |
| | | * @until fread | |
| | | * | |
| | | * We will use an Eina_Array to store the data: | |
| | | * @skipline array | |
| | | * | |
| | | * Here we call eina_simple_xml_parse(). We pass the buffer with data, its | |
| | | size, | |
| | | * we ask to strip leading and trailing whitespace, we give the callback | |
| | | * function and the array to store the formatted data: | |
| | | * @until _xml_tag_cb | |
| | | * | |
| | | * This will loop over the array and print the data using _print callback: | |
| | | * @skipline foreach | |
| | | * | |
| | | * This is the main XML parser callback, it will check for known tags and g | |
| | | et | |
| | | * the corresponding values: | |
| | | * @skip static | |
| | | * @until str | |
| | | * | |
| | | * We first check for opening tag: | |
| | | * @skipline type | |
| | | * | |
| | | * If we know the tag should have attributes, then we find them using | |
| | | * eina_simple_xml_tag_attributes_find() and give them to another parsing | |
| | | * function using eina_simple_xml_attributes_parse(): | |
| | | * @until _xml_attr_cb | |
| | | * | |
| | | * We check for other known tags: | |
| | | * @until tag_message | |
| | | * | |
| | | * We then check data for corresponding tag: | |
| | | * @until EINA_FALSE | |
| | | * | |
| | | * We are doing the formatting in same time and put all the \<post\> childr | |
| | | en | |
| | | * in str. | |
| | | * @until EINA_FALSE | |
| | | * | |
| | | * Finally, we store our string in the array: | |
| | | * @skipline push | |
| | | * | |
| | | * This is the callback to parse the attributes, we check for key name and | |
| | | keep | |
| | | * the value: | |
| | | * @skip static | |
| | | * @until snprintf | |
| | | * | |
| | | * This is the function that simply print items of the array: | |
| | | * @until EINA_TRUE | |
| | | * | |
| | | * You can see the full source code | |
| | | * @ref eina_simple_xml_parser_example_01 "here". | |
| | | */ | |
| | | | |
| | | /** | |
| | | * @page eina_simple_xml_parser_example_01 | |
| | | * @include eina_simple_xml_parser_01.c | |
| | | * @example eina_simple_xml_parser_01.c | |
| | | */ | |
| | | | |
| | | /** | |
| * @defgroup Eina_Simple_XML_Group Simple_XML | | * @defgroup Eina_Simple_XML_Group Simple_XML | |
| * | | * | |
| * Simplistic relaxed SAX-like XML parser. | | * Simplistic relaxed SAX-like XML parser. | |
| * | | * | |
| * This parser is far from being compliant with XML standard, but will | | * This parser is far from being compliant with XML standard, but will | |
| * do for most XMLs out there. If you know that your format is simple | | * do for most XMLs out there. If you know that your format is simple | |
| * and will not vary in future with strange corner cases, then you can | | * and will not vary in future with strange corner cases, then you can | |
| * use it safely. | | * use it safely. | |
| * | | * | |
| * The parser is SAX like, that is, it will tokenize contents and call | | * The parser is SAX like, that is, it will tokenize contents and call | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 125 | |
| * during this parser work and it's not recursive, so you can use it | | * during this parser work and it's not recursive, so you can use it | |
| * with a very large document without worries. | | * with a very large document without worries. | |
| * | | * | |
| * It will not validate the document anyhow, neither it will create a | | * It will not validate the document anyhow, neither it will create a | |
| * tree hierarchy. That's up to you. | | * tree hierarchy. That's up to you. | |
| * | | * | |
| * Accordingly to XML, open tags may contain attributes. This parser | | * Accordingly to XML, open tags may contain attributes. This parser | |
| * will not tokenize this. If you want you can use | | * will not tokenize this. If you want you can use | |
| * eina_simple_xml_tag_attributes_find() and then | | * eina_simple_xml_tag_attributes_find() and then | |
| * eina_simple_xml_attributes_parse(). | | * eina_simple_xml_attributes_parse(). | |
|
| | | * | |
| | | * For more information, see | |
| | | * @ref eina_simple_xml_parser_example_01_page "this example". | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @addtogroup Eina_Tools_Group Tools | | * @addtogroup Eina_Tools_Group Tools | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup Eina_Simple_XML_Group Simple_XML | | * @defgroup Eina_Simple_XML_Group Simple_XML | |
| | | | |
| skipping to change at line 119 | | skipping to change at line 196 | |
| Eina_Inlist *attributes; | | Eina_Inlist *attributes; | |
| const char *name; | | const char *name; | |
| }; | | }; | |
| | | | |
| struct _Eina_Simple_XML_Node_Data | | struct _Eina_Simple_XML_Node_Data | |
| { | | { | |
| Eina_Simple_XML_Node base; | | Eina_Simple_XML_Node base; | |
| size_t length; | | size_t length; | |
| char data[]; | | char data[]; | |
| }; | | }; | |
|
| | | /** | |
| | | * @typedef _Eina_Simple_XML_Type | |
| | | * a simple XML type. | |
| | | */ | |
| typedef enum _Eina_Simple_XML_Type | | typedef enum _Eina_Simple_XML_Type | |
| { | | { | |
|
| EINA_SIMPLE_XML_OPEN = 0, /* <tag attribute="value"> */ | | EINA_SIMPLE_XML_OPEN = 0, /*!< \<tag attribute="value"\> */ | |
| EINA_SIMPLE_XML_OPEN_EMPTY, /* <tag attribute="value" /> */ | | EINA_SIMPLE_XML_OPEN_EMPTY, /*!< \<tag attribute="value" /\> */ | |
| EINA_SIMPLE_XML_CLOSE, /* </tag> */ | | EINA_SIMPLE_XML_CLOSE, /*!< \</tag\> */ | |
| EINA_SIMPLE_XML_DATA, /* tag text data */ | | EINA_SIMPLE_XML_DATA, /*!< tag text data */ | |
| EINA_SIMPLE_XML_CDATA, /* <![CDATA[something]]> */ | | EINA_SIMPLE_XML_CDATA, /*!< \<![CDATA[something]]\> */ | |
| EINA_SIMPLE_XML_ERROR, /* error contents */ | | EINA_SIMPLE_XML_ERROR, /*!< error contents */ | |
| EINA_SIMPLE_XML_PROCESSING, /* <?xml ... ?> <?php .. ?> */ | | EINA_SIMPLE_XML_PROCESSING, /*!< \<?xml ... ?\> \<?php .. ?\> */ | |
| EINA_SIMPLE_XML_DOCTYPE, /* <!DOCTYPE html */ | | EINA_SIMPLE_XML_DOCTYPE, /*!< \<!DOCTYPE html */ | |
| EINA_SIMPLE_XML_COMMENT, /* <!-- something --> */ | | EINA_SIMPLE_XML_COMMENT, /*!< \<!-- something --\> */ | |
| EINA_SIMPLE_XML_IGNORED /* whatever is ignored by parser, like whitespace | | EINA_SIMPLE_XML_IGNORED /*!< whatever is ignored by parser, like whitespa | |
| */ | | ce */ | |
| } Eina_Simple_XML_Type; | | } Eina_Simple_XML_Type; | |
| | | | |
| typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type ty
pe, const char *content, unsigned offset, unsigned length); | | typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type ty
pe, const char *content, unsigned offset, unsigned length); | |
| typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *k
ey, const char *value); | | typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *k
ey, const char *value); | |
| | | | |
| /** | | /** | |
| * Parse a section of XML string text | | * Parse a section of XML string text | |
| * | | * | |
| * @param buf the input string. May not contain \0 terminator. | | * @param buf the input string. May not contain \0 terminator. | |
| * @param buflen the input string size. | | * @param buflen the input string size. | |
| | | | |
End of changes. 4 change blocks. |
| 12 lines changed or deleted | | 96 lines changed or added | |
|
| eina_stringshare.h | | eina_stringshare.h | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 129 | |
| * circumstances where you could have multiple copies of a structure that | | * circumstances where you could have multiple copies of a structure that | |
| * allocates the string. So rather than duplicating and freeing these | | * allocates the string. So rather than duplicating and freeing these | |
| * strings, you request a read-only pointer to an existing string and | | * strings, you request a read-only pointer to an existing string and | |
| * only incur the overhead of a hash lookup. | | * only incur the overhead of a hash lookup. | |
| * | | * | |
| * It sounds like micro-optimizing, but profiling has shown this can have | | * It sounds like micro-optimizing, but profiling has shown this can have | |
| * a significant impact as you scale the number of copies up. It improves | | * a significant impact as you scale the number of copies up. It improves | |
| * string creation/destruction speed, reduces memory use and decreases | | * string creation/destruction speed, reduces memory use and decreases | |
| * memory fragmentation, so a win all-around. | | * memory fragmentation, so a win all-around. | |
| * | | * | |
|
| | | * Using eina stringshares usually boils down to: | |
| | | * @code | |
| | | * const char *str = eina_stringshare_add("My string"); | |
| | | * ... | |
| | | * //Use str | |
| | | * ... | |
| | | * eina_stringshare_del(str); | |
| | | * @endcode | |
| | | * @note It's very important to note that string shares are @b @c const, | |
| | | * changing them will result in undefined behavior. | |
| | | * @note eina_stringshare_del() @b doesn't guarantee the string share will | |
| | | be | |
| | | * freed, it releases a reference to it, but if other references to it stil | |
| | | l | |
| | | * exist the string share will live until those are released. | |
| | | * | |
| * The following diagram gives an idea of what happens as you create string
s | | * The following diagram gives an idea of what happens as you create string
s | |
| * with eina_stringshare_add(): | | * with eina_stringshare_add(): | |
| * | | * | |
| * @image html eina_stringshare.png | | * @image html eina_stringshare.png | |
| * @image latex eina_stringshare.eps height=\textheight | | * @image latex eina_stringshare.eps height=\textheight | |
| * | | * | |
| * For more information, see @ref eina_stringshare_example_01_page | | * For more information, see @ref eina_stringshare_example_01_page | |
| * "this example". | | * "this example". | |
| */ | | */ | |
| | | | |
| | | | |
| skipping to change at line 152 | | skipping to change at line 166 | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup Eina_Stringshare_Group Stringshare | | * @defgroup Eina_Stringshare_Group Stringshare | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| | | * @typedef Eina_Stringshare | |
| | | * | |
| | | * Interchangeable with "const char *" but still a good visual hint for the | |
| | | * purpose. Maybe in the far far future we'll even add strict type checking | |
| | | . | |
| | | * | |
| | | * @since 1.2.0 | |
| | | */ | |
| | | typedef const char Eina_Stringshare; | |
| | | | |
| | | /** | |
| * @brief Retrieve an instance of a string for use in a program. | | * @brief Retrieve an instance of a string for use in a program. | |
| * | | * | |
| * @param str The string to retrieve an instance of. | | * @param str The string to retrieve an instance of. | |
| * @param slen The string size (<= strlen(str)). | | * @param slen The string size (<= strlen(str)). | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| * This function retrieves an instance of @p str. If @p str is | | * This function retrieves an instance of @p str. If @p str is | |
| * @c NULL, then @c NULL is returned. If @p str is already stored, it | | * @c NULL, then @c NULL is returned. If @p str is already stored, it | |
| * is just returned and its reference counter is increased. Otherwise | | * is just returned and its reference counter is increased. Otherwise | |
| * a duplicated string of @p str is returned. | | * a duplicated string of @p str is returned. | |
| * | | * | |
| * This function does not check string size, but uses the | | * This function does not check string size, but uses the | |
| * exact given size. This can be used to share_common part of a larger | | * exact given size. This can be used to share_common part of a larger | |
| * buffer or substring. | | * buffer or substring. | |
| * | | * | |
| * @see eina_share_common_add() | | * @see eina_share_common_add() | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_add_length(const char *str, unsign
ed int slen) EINA_WARN_UNUSED_RESULT; | | EAPI Eina_Stringshare *eina_stringshare_add_length(const char *str, unsign
ed int slen) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Retrieve an instance of a string for use in a program. | | * @brief Retrieve an instance of a string for use in a program. | |
| * | | * | |
| * @param str The NULL terminated string to retrieve an instance of. | | * @param str The NULL terminated string to retrieve an instance of. | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| * This function retrieves an instance of @p str. If @p str is | | * This function retrieves an instance of @p str. If @p str is | |
| * @c NULL, then @c NULL is returned. If @p str is already stored, it | | * @c NULL, then @c NULL is returned. If @p str is already stored, it | |
| * is just returned and its reference counter is increased. Otherwise | | * is just returned and its reference counter is increased. Otherwise | |
| * a duplicated string of @p str is returned. | | * a duplicated string of @p str is returned. | |
| * | | * | |
| * The string @p str must be NULL terminated ('@\0') and its full | | * The string @p str must be NULL terminated ('@\0') and its full | |
| * length will be used. To use part of the string or non-null | | * length will be used. To use part of the string or non-null | |
| * terminated, use eina_stringshare_add_length() instead. | | * terminated, use eina_stringshare_add_length() instead. | |
| * | | * | |
| * @see eina_stringshare_add_length() | | * @see eina_stringshare_add_length() | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNU
SED_RESULT; | | EAPI Eina_Stringshare *eina_stringshare_add(const char *str) EINA_WARN_UNU
SED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Retrieve an instance of a string for use in a program | | * @brief Retrieve an instance of a string for use in a program | |
| * from a format string. | | * from a format string. | |
| * | | * | |
| * @param fmt The NULL terminated format string to retrieve an instance o
f. | | * @param fmt The NULL terminated format string to retrieve an instance o
f. | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| * This function retrieves an instance of @p fmt. If @p fmt is | | * This function retrieves an instance of @p fmt. If @p fmt is | |
| * @c NULL, then @c NULL is returned. If @p fmt is already stored, it | | * @c NULL, then @c NULL is returned. If @p fmt is already stored, it | |
| * is just returned and its reference counter is increased. Otherwise | | * is just returned and its reference counter is increased. Otherwise | |
| * a duplicated string is returned. | | * a duplicated string is returned. | |
| * | | * | |
| * The format string @p fmt must be NULL terminated ('@\0') and its full | | * The format string @p fmt must be NULL terminated ('@\0') and its full | |
| * length will be used. To use part of the format string or non-null | | * length will be used. To use part of the format string or non-null | |
| * terminated, use eina_stringshare_nprintf() instead. | | * terminated, use eina_stringshare_nprintf() instead. | |
| * | | * | |
| * @see eina_stringshare_nprintf() | | * @see eina_stringshare_nprintf() | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_
WARN_UNUSED_RESULT EINA_PRINTF(1, 2); | | EAPI Eina_Stringshare *eina_stringshare_printf(const char *fmt, ...) EINA_
WARN_UNUSED_RESULT EINA_PRINTF(1, 2); | |
| | | | |
| /** | | /** | |
| * @brief Retrieve an instance of a string for use in a program | | * @brief Retrieve an instance of a string for use in a program | |
| * from a format string. | | * from a format string. | |
| * | | * | |
| * @param fmt The NULL terminated format string to retrieve an instance o
f. | | * @param fmt The NULL terminated format string to retrieve an instance o
f. | |
| * @param args The va_args for @p fmt | | * @param args The va_args for @p fmt | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| | | | |
| skipping to change at line 233 | | skipping to change at line 257 | |
| * @c NULL, then @c NULL is returned. If @p fmt with @p args is already sto
red, it | | * @c NULL, then @c NULL is returned. If @p fmt with @p args is already sto
red, it | |
| * is just returned and its reference counter is increased. Otherwise | | * is just returned and its reference counter is increased. Otherwise | |
| * a duplicated string is returned. | | * a duplicated string is returned. | |
| * | | * | |
| * The format string @p fmt must be NULL terminated ('@\0') and its full | | * The format string @p fmt must be NULL terminated ('@\0') and its full | |
| * length will be used. To use part of the format string or non-null | | * length will be used. To use part of the format string or non-null | |
| * terminated, use eina_stringshare_nprintf() instead. | | * terminated, use eina_stringshare_nprintf() instead. | |
| * | | * | |
| * @see eina_stringshare_nprintf() | | * @see eina_stringshare_nprintf() | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list a
rgs) EINA_WARN_UNUSED_RESULT; | | EAPI Eina_Stringshare *eina_stringshare_vprintf(const char *fmt, va_list a
rgs) EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Retrieve an instance of a string for use in a program | | * @brief Retrieve an instance of a string for use in a program | |
| * from a format string with size limitation. | | * from a format string with size limitation. | |
| * @param len The length of the format string to use | | * @param len The length of the format string to use | |
| * @param fmt The format string to retrieve an instance of. | | * @param fmt The format string to retrieve an instance of. | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| * This function retrieves an instance of @p fmt limited by @p len. If @p f
mt is | | * This function retrieves an instance of @p fmt limited by @p len. If @p f
mt is | |
| * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting str
ing | | * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting str
ing | |
| * is already stored, it is returned and its reference counter is increased
. | | * is already stored, it is returned and its reference counter is increased
. | |
| * Otherwise a duplicated string is returned. | | * Otherwise a duplicated string is returned. | |
| * | | * | |
| * @p len length of the format string will be used. To use the | | * @p len length of the format string will be used. To use the | |
| * entire format string, use eina_stringshare_printf() instead. | | * entire format string, use eina_stringshare_printf() instead. | |
| * | | * | |
| * @see eina_stringshare_printf() | | * @see eina_stringshare_printf() | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_nprintf(unsigned int len, const ch
ar *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); | | EAPI Eina_Stringshare *eina_stringshare_nprintf(unsigned int len, const ch
ar *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); | |
| | | | |
| /** | | /** | |
| * Increment references of the given shared string. | | * Increment references of the given shared string. | |
| * | | * | |
| * @param str The shared string. | | * @param str The shared string. | |
| * @return A pointer to an instance of the string on success. | | * @return A pointer to an instance of the string on success. | |
| * @c NULL on failure. | | * @c NULL on failure. | |
| * | | * | |
| * This is similar to eina_share_common_add(), but it's faster since it wil
l | | * This is similar to eina_share_common_add(), but it's faster since it wil
l | |
| * avoid lookups if possible, but on the down side it requires the paramete
r | | * avoid lookups if possible, but on the down side it requires the paramete
r | |
| * to be shared string. In other words, it must be the return of a previous | | * to be shared string. In other words, it must be the return of a previous | |
| * call to one of the stringshare functions. | | * call to one of the stringshare functions. | |
| * | | * | |
| * There is no unref since this is the work of eina_share_common_del(). | | * There is no unref since this is the work of eina_share_common_del(). | |
| */ | | */ | |
|
| EAPI const char *eina_stringshare_ref(const char *str); | | EAPI Eina_Stringshare *eina_stringshare_ref(Eina_Stringshare *str); | |
| | | | |
| /** | | /** | |
| * @brief Note that the given string has lost an instance. | | * @brief Note that the given string has lost an instance. | |
| * | | * | |
| * @param str string The given string. | | * @param str string The given string. | |
| * | | * | |
| * This function decreases the reference counter associated to @p str | | * This function decreases the reference counter associated to @p str | |
| * if it exists. If that counter reaches 0, the memory associated to | | * if it exists. If that counter reaches 0, the memory associated to | |
| * @p str is freed. If @p str is NULL, the function returns | | * @p str is freed. If @p str is NULL, the function returns | |
| * immediately. | | * immediately. | |
| * | | * | |
| * Note that if the given pointer is not shared or NULL, bad things | | * Note that if the given pointer is not shared or NULL, bad things | |
| * will happen, likely a segmentation fault. | | * will happen, likely a segmentation fault. | |
| */ | | */ | |
|
| EAPI void eina_stringshare_del(const char *str); | | EAPI void eina_stringshare_del(Eina_Stringshare *str); | |
| | | | |
| /** | | /** | |
| * @brief Note that the given string @b must be shared. | | * @brief Note that the given string @b must be shared. | |
| * | | * | |
| * @param str the shared string to know the length. It is safe to | | * @param str the shared string to know the length. It is safe to | |
| * give NULL, in that case -1 is returned. | | * give NULL, in that case -1 is returned. | |
| * @return The length of a shared string. | | * @return The length of a shared string. | |
| * | | * | |
| * This function is a cheap way to known the length of a shared | | * This function is a cheap way to known the length of a shared | |
| * string. Note that if the given pointer is not shared, bad | | * string. Note that if the given pointer is not shared, bad | |
| * things will happen, likely a segmentation fault. If in doubt, try | | * things will happen, likely a segmentation fault. If in doubt, try | |
| * strlen(). | | * strlen(). | |
| */ | | */ | |
|
| EAPI int eina_stringshare_strlen(const char *str) EINA_PURE
EINA_WARN_UNUSED_RESULT; | | EAPI int eina_stringshare_strlen(Eina_Stringshare *str) EINA
_PURE EINA_WARN_UNUSED_RESULT; | |
| | | | |
| /** | | /** | |
| * @brief Dump the contents of the share_common. | | * @brief Dump the contents of the share_common. | |
| * | | * | |
| * This function dumps all strings in the share_common to stdout with a | | * This function dumps all strings in the share_common to stdout with a | |
| * DDD: prefix per line and a memory usage summary. | | * DDD: prefix per line and a memory usage summary. | |
| */ | | */ | |
| EAPI void eina_stringshare_dump(void); | | EAPI void eina_stringshare_dump(void); | |
| | | | |
|
| static inline Eina_Bool eina_stringshare_replace(const char **p_str, const | | static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, | |
| char *news) EINA_ARG_NONNULL(1); | | const char *news) EINA_ARG_NONNULL(1); | |
| static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, | | static inline Eina_Bool eina_stringshare_replace_length(Eina_Stringshare ** | |
| const char *news, unsigned int slen) EINA_ARG_NONNULL(1); | | p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1); | |
| | | | |
| #include "eina_inline_stringshare.x" | | #include "eina_inline_stringshare.x" | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
End of changes. 11 change blocks. |
| 12 lines changed or deleted | | 39 lines changed or added | |
|
| eina_tiler.h | | eina_tiler.h | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| #include "eina_types.h" | | #include "eina_types.h" | |
| #include "eina_iterator.h" | | #include "eina_iterator.h" | |
| #include "eina_rectangle.h" | | #include "eina_rectangle.h" | |
| | | | |
| /** | | /** | |
| * @page eina_tiler_example_01 | | * @page eina_tiler_example_01 | |
| * @dontinclude eina_tiler_01.c | | * @dontinclude eina_tiler_01.c | |
| * | | * | |
| * This is an example that illustrates how Eina_Tiler works for a given set
of | | * This is an example that illustrates how Eina_Tiler works for a given set
of | |
| * rectangles. The rectangles must be given in the command line in the form
: | | * rectangles. The rectangles must be given in the command line in the form
: | |
|
| * <width>x<height>+<x offset>+<y offset> | | * \<width\>x\<height\>+\<x offset\>+\<y offset\> | |
| * The example will show two panels, the first(input) will show the given | | * The example will show two panels, the first(input) will show the given | |
| * rectangles(in different colors) and in the seconds(output) it will show
the | | * rectangles(in different colors) and in the seconds(output) it will show
the | |
| * rectangles given by the tiler. The rectangles will be added one by one e
very | | * rectangles given by the tiler. The rectangles will be added one by one e
very | |
| * two seconds. A lot of the example deals with actually painting the recta
ngles | | * two seconds. A lot of the example deals with actually painting the recta
ngles | |
| * so we'll skip over quite a bit of code, but you can see all of it in @re
f | | * so we'll skip over quite a bit of code, but you can see all of it in @re
f | |
| * eina_tiler_01.c "eina_tiler_01.c". | | * eina_tiler_01.c "eina_tiler_01.c". | |
| * | | * | |
| * The first thing of note in our example is the creation of the tiler: | | * The first thing of note in our example is the creation of the tiler: | |
| * @skipline eina_tiler_new | | * @skipline eina_tiler_new | |
| * @note @p maxw and @p maxh are calculated such that the tiler's size will | | * @note @p maxw and @p maxh are calculated such that the tiler's size will | |
| | | | |
| skipping to change at line 121 | | skipping to change at line 121 | |
| * @see eina_tiler_new() | | * @see eina_tiler_new() | |
| * @see eina_tiler_rect_add() | | * @see eina_tiler_rect_add() | |
| * @see eina_tiler_iterator_new() | | * @see eina_tiler_iterator_new() | |
| * | | * | |
| * @warning There are no guarantees that this will be the most efficient wa
y to | | * @warning There are no guarantees that this will be the most efficient wa
y to | |
| * re-render for any particular case. | | * re-render for any particular case. | |
| * | | * | |
| * @section grid_slicer Grid Slicer | | * @section grid_slicer Grid Slicer | |
| * | | * | |
| * Grid slicer and Eina_Tiler are usually used together, that is however @b
not | | * Grid slicer and Eina_Tiler are usually used together, that is however @b
not | |
|
| * nescessary, they can be used independently. Grid slicer provides an easy | | * necessary, they can be used independently. Grid slicer provides an easy | |
| API | | API | |
| * to divide an area in tiles which is usefull in certain applications to d | | * to divide an area in tiles which is useful in certain applications to di | |
| ivide | | vide | |
| * the area that will be rendered into tiles. It's customary to, then creat
e one | | * the area that will be rendered into tiles. It's customary to, then creat
e one | |
| * Eina_Tiler for each tile. | | * Eina_Tiler for each tile. | |
| * | | * | |
| * The following is pseudo-code showing a very simplified use of grid slice
r | | * The following is pseudo-code showing a very simplified use of grid slice
r | |
| * together with Eina_Tiler: | | * together with Eina_Tiler: | |
| * @code | | * @code | |
| * itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVA
S_HEIGHT, TILE_WIDTH, TILE_HEIGHT); | | * itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVA
S_HEIGHT, TILE_WIDTH, TILE_HEIGHT); | |
| * EINA_ITERATOR_FOREACH(itr, grid_info) | | * EINA_ITERATOR_FOREACH(itr, grid_info) | |
| * { | | * { | |
| * tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w); | | * tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w); | |
| | | | |
| skipping to change at line 213 | | skipping to change at line 213 | |
| * @warning @p w and @p h @b must be greater than zero, otherwise tile size | | * @warning @p w and @p h @b must be greater than zero, otherwise tile size | |
| * won't be changed. | | * won't be changed. | |
| * @warning Tile size is not used! | | * @warning Tile size is not used! | |
| */ | | */ | |
| EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int
h); | | EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int
h); | |
| /** | | /** | |
| * @brief Adds a rectangle to a tiler. | | * @brief Adds a rectangle to a tiler. | |
| * | | * | |
| * @param t The tiler in which to add a container. | | * @param t The tiler in which to add a container. | |
| * @param r The rectangle to be added. | | * @param r The rectangle to be added. | |
|
| | | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | |
| * | | * | |
| * @see eina_tiler_rect_del() | | * @see eina_tiler_rect_del() | |
| */ | | */ | |
| EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Recta
ngle *r); | | EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Recta
ngle *r); | |
| /** | | /** | |
| * @brief Removes a rectangle from a tiler. | | * @brief Removes a rectangle from a tiler. | |
| * | | * | |
| * @param t The tiler in which to add a container. | | * @param t The tiler in which to add a container. | |
| * @param r The rectangle to be removed. | | * @param r The rectangle to be removed. | |
| * | | * | |
| | | | |
| skipping to change at line 259 | | skipping to change at line 260 | |
| * @param h height. | | * @param h height. | |
| * @param tile_w tile width. | | * @param tile_w tile width. | |
| * @param tile_h tile height. | | * @param tile_h tile height. | |
| * @return A pointer to the Eina_Iterator. @c NULL on failure. | | * @return A pointer to the Eina_Iterator. @c NULL on failure. | |
| * | | * | |
| * The region defined by @a x, @a y, @a w, @a h will be divided in to a gri
d of | | * The region defined by @a x, @a y, @a w, @a h will be divided in to a gri
d of | |
| * tiles of width @a tile_w and height @p tile_h, the returned iterator wil
l | | * tiles of width @a tile_w and height @p tile_h, the returned iterator wil
l | |
| * iterate over every tile in the grid having as its data a | | * iterate over every tile in the grid having as its data a | |
| * #Eina_Tile_Grid_Info. | | * #Eina_Tile_Grid_Info. | |
| * | | * | |
|
| * @note This is a convinience function, iterating over the returned iterat
or is | | * @note This is a convenience function, iterating over the returned iterat
or is | |
| * equivalent to calling eina_tile_grid_slicer_setup() and calling | | * equivalent to calling eina_tile_grid_slicer_setup() and calling | |
| * eina_tile_grid_slicer_next() untill it returns EINA_FALSE. | | * eina_tile_grid_slicer_next() untill it returns EINA_FALSE. | |
| */ | | */ | |
| EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, in
t w, int h, int tile_w, int tile_h); | | EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, in
t w, int h, int tile_w, int tile_h); | |
| /** | | /** | |
| * @brief Iterates over the tiles set by eina_tile_grid_slicer_setup(). | | * @brief Iterates over the tiles set by eina_tile_grid_slicer_setup(). | |
| * | | * | |
| * @param slc Pointer to an Eina_Tile_Grid_Slicer struct. | | * @param slc Pointer to an Eina_Tile_Grid_Slicer struct. | |
| * @param rect Pointer to a struct Eina_Tile_Grid_Info *. | | * @param rect Pointer to a struct Eina_Tile_Grid_Info *. | |
| * @return @c EINA_TRUE if the current rect is valid. | | * @return @c EINA_TRUE if the current rect is valid. | |
| | | | |
End of changes. 4 change blocks. |
| 6 lines changed or deleted | | 7 lines changed or added | |
|
| eina_types.h | | eina_types.h | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| # define EAPI __declspec(dllimport) | | # define EAPI __declspec(dllimport) | |
| # endif /* ! EFL_EINA_BUILD */ | | # endif /* ! EFL_EINA_BUILD */ | |
| #else | | #else | |
| # ifdef __GNUC__ | | # ifdef __GNUC__ | |
| # if __GNUC__ >= 4 | | # if __GNUC__ >= 4 | |
| # define EAPI __attribute__ ((visibility("default"))) | | # define EAPI __attribute__ ((visibility("default"))) | |
| # else | | # else | |
| # define EAPI | | # define EAPI | |
| # endif | | # endif | |
| # else | | # else | |
|
| | | /** | |
| | | * @def EAPI | |
| | | * @brief Used to export functions(by changing visibility). | |
| | | */ | |
| # define EAPI | | # define EAPI | |
| # endif | | # endif | |
| #endif | | #endif | |
| | | | |
| #include "eina_config.h" | | #include "eina_config.h" | |
| | | | |
| #ifdef EINA_WARN_UNUSED_RESULT | | #ifdef EINA_WARN_UNUSED_RESULT | |
| # undef EINA_WARN_UNUSED_RESULT | | # undef EINA_WARN_UNUSED_RESULT | |
| #endif | | #endif | |
| #ifdef EINA_ARG_NONNULL | | #ifdef EINA_ARG_NONNULL | |
| | | | |
| skipping to change at line 101 | | skipping to change at line 105 | |
| #endif | | #endif | |
| #ifdef EINA_UNLIKELY | | #ifdef EINA_UNLIKELY | |
| # undef EINA_UNLIKELY | | # undef EINA_UNLIKELY | |
| #endif | | #endif | |
| #ifdef EINA_LIKELY | | #ifdef EINA_LIKELY | |
| # undef EINA_LIKELY | | # undef EINA_LIKELY | |
| #endif | | #endif | |
| | | | |
| #ifdef __GNUC__ | | #ifdef __GNUC__ | |
| # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) | | # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) | |
|
| # define EINA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) | | # define EINA_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) | |
| # else | | # else | |
| # define EINA_WARN_UNUSED_RESULT | | # define EINA_WARN_UNUSED_RESULT | |
| # endif | | # endif | |
| | | | |
| # if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && _
_GNUC_MINOR__ >= 3)) | | # if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && _
_GNUC_MINOR__ >= 3)) | |
|
| # define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_A
RGS__))) | | # define EINA_ARG_NONNULL(...) __attribute__ ((__nonnull__(__VA_ARGS__))) | |
| # else | | # else | |
|
| # define EINA_ARG_NONNULL(idx, ...) | | # define EINA_ARG_NONNULL(...) | |
| # endif | | # endif | |
| | | | |
| # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | | # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | |
| # define EINA_DEPRECATED __attribute__ ((__deprecated__)) | | # define EINA_DEPRECATED __attribute__ ((__deprecated__)) | |
| # else | | # else | |
| # define EINA_DEPRECATED | | # define EINA_DEPRECATED | |
| # endif | | # endif | |
| | | | |
| # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | |
|
| # define EINA_MALLOC __attribute__ ((malloc)) | | # define EINA_MALLOC __attribute__ ((__malloc__)) | |
| # define EINA_PURE __attribute__ ((pure)) | | # define EINA_PURE __attribute__ ((__pure__)) | |
| # else | | # else | |
| # define EINA_MALLOC | | # define EINA_MALLOC | |
| # define EINA_PURE | | # define EINA_PURE | |
| # endif | | # endif | |
| | | | |
| # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) | | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) | |
|
| # define EINA_PRINTF(fmt, arg) __attribute__((format (printf, fmt, arg))) | | # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3) | |
| # define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg))) | | # define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__gnu_printf__, | |
| # define EINA_FORMAT(fmt) __attribute__((format_arg(fmt))) | | fmt, arg))) | |
| # define EINA_CONST __attribute__((const)) | | # else | |
| # define EINA_NOINSTRUMENT __attribute__((no_instrument_function)) | | # define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__printf__, fmt | |
| | | , arg))) | |
| | | # endif | |
| | | # define EINA_SCANF(fmt, arg) __attribute__((__format__ (__scanf__, fmt, | |
| | | arg))) | |
| | | # define EINA_FORMAT(fmt) __attribute__((__format_arg__(fmt))) | |
| | | # define EINA_CONST __attribute__((__const__)) | |
| | | # define EINA_NOINSTRUMENT __attribute__((__no_instrument_function__)) | |
| # define EINA_UNLIKELY(exp) __builtin_expect((exp), 0) | | # define EINA_UNLIKELY(exp) __builtin_expect((exp), 0) | |
| # define EINA_LIKELY(exp) __builtin_expect((exp), 1) | | # define EINA_LIKELY(exp) __builtin_expect((exp), 1) | |
| # else | | # else | |
| # define EINA_PRINTF(fmt, arg) | | # define EINA_PRINTF(fmt, arg) | |
| # define EINA_SCANF(fmt, arg) | | # define EINA_SCANF(fmt, arg) | |
| # define EINA_FORMAT(fmt) | | # define EINA_FORMAT(fmt) | |
| # define EINA_CONST | | # define EINA_CONST | |
| # define EINA_NOINSTRUMENT | | # define EINA_NOINSTRUMENT | |
| # define EINA_UNLIKELY(exp) exp | | # define EINA_UNLIKELY(exp) exp | |
| # define EINA_LIKELY(exp) exp | | # define EINA_LIKELY(exp) exp | |
| # endif | | # endif | |
| | | | |
| #elif defined(_WIN32) | | #elif defined(_WIN32) | |
| # define EINA_WARN_UNUSED_RESULT | | # define EINA_WARN_UNUSED_RESULT | |
|
| # define EINA_ARG_NONNULL(idx, ...) | | # define EINA_ARG_NONNULL(...) | |
| # if defined(_MSC_VER) && _MSC_VER >= 1300 | | # if defined(_MSC_VER) && _MSC_VER >= 1300 | |
| # define EINA_DEPRECATED __declspec(deprecated) | | # define EINA_DEPRECATED __declspec(deprecated) | |
| # else | | # else | |
| # define EINA_DEPRECATED | | # define EINA_DEPRECATED | |
| # endif | | # endif | |
| # define EINA_MALLOC | | # define EINA_MALLOC | |
| # define EINA_PURE | | # define EINA_PURE | |
| # define EINA_PRINTF(fmt, arg) | | # define EINA_PRINTF(fmt, arg) | |
| # define EINA_SCANF(fmt, arg) | | # define EINA_SCANF(fmt, arg) | |
| # define EINA_FORMAT(fmt) | | # define EINA_FORMAT(fmt) | |
| | | | |
| skipping to change at line 197 | | skipping to change at line 205 | |
| /** | | /** | |
| * @def EINA_WARN_UNUSED_RESULT | | * @def EINA_WARN_UNUSED_RESULT | |
| * Used to warn when the returned value of the function is not used. | | * Used to warn when the returned value of the function is not used. | |
| */ | | */ | |
| # define EINA_WARN_UNUSED_RESULT | | # define EINA_WARN_UNUSED_RESULT | |
| | | | |
| /** | | /** | |
| * @def EINA_ARG_NONNULL | | * @def EINA_ARG_NONNULL | |
| * Used to warn when the specified arguments of the function are @c NULL. | | * Used to warn when the specified arguments of the function are @c NULL. | |
| */ | | */ | |
|
| # define EINA_ARG_NONNULL(idx, ...) | | # define EINA_ARG_NONNULL(...) | |
| | | | |
| /** | | /** | |
| * @def EINA_DEPRECATED | | * @def EINA_DEPRECATED | |
| * Used to warn when the function is considered as deprecated. | | * Used to warn when the function is considered as deprecated. | |
| */ | | */ | |
| # define EINA_DEPRECATED | | # define EINA_DEPRECATED | |
|
| | | /** | |
| | | * @def EINA_MALLOC | |
| | | * @brief EINA_MALLOC is used to tell the compiler that a function may be t | |
| | | reated | |
| | | * as if any non-NULL pointer it returns cannot alias any other pointer val | |
| | | id when | |
| | | * the function returns and that the memory has undefined content. | |
| | | */ | |
| # define EINA_MALLOC | | # define EINA_MALLOC | |
|
| | | /** | |
| | | * @def EINA_PURE | |
| | | * @brief EINA_PURE is used to tell the compiler this functions has no effe | |
| | | cts | |
| | | * except the return value and their return value depends only on the param | |
| | | eters | |
| | | * and/or global variables. | |
| | | */ | |
| # define EINA_PURE | | # define EINA_PURE | |
|
| | | /** | |
| | | * @def EINA_PRINTF | |
| | | * @param fmt The format to be used. | |
| | | * @param arg The argument to be used. | |
| | | */ | |
| # define EINA_PRINTF(fmt, arg) | | # define EINA_PRINTF(fmt, arg) | |
|
| | | /** | |
| | | * @def EINA_SCANF | |
| | | * @param fmt The format to be used. | |
| | | * @param arg The argument to be used. | |
| | | */ | |
| # define EINA_SCANF(fmt, arg) | | # define EINA_SCANF(fmt, arg) | |
|
| | | /** | |
| | | * @def EINA_FORMAT | |
| | | * @param fmt The format to be used. | |
| | | */ | |
| # define EINA_FORMAT(fmt) | | # define EINA_FORMAT(fmt) | |
|
| | | /** | |
| | | * @def EINA_CONST | |
| | | * @brief Attribute from gcc to prevent the function to read/modify any glo | |
| | | bal memory. | |
| | | */ | |
| # define EINA_CONST | | # define EINA_CONST | |
|
| | | /** | |
| | | * @def EINA_NOINSTRUMENT | |
| | | * @brief Attribute from gcc to disable instrumentation for a specific func | |
| | | tion. | |
| | | */ | |
| # define EINA_NOINSTRUMENT | | # define EINA_NOINSTRUMENT | |
|
| | | /** | |
| | | * @def EINA_UNLIKELY | |
| | | * @param exp The expression to be used. | |
| | | */ | |
| # define EINA_UNLIKELY(exp) exp | | # define EINA_UNLIKELY(exp) exp | |
|
| | | /** | |
| | | * @def EINA_LIKELY | |
| | | * @param exp The expression to be used. | |
| | | */ | |
| # define EINA_LIKELY(exp) exp | | # define EINA_LIKELY(exp) exp | |
| #endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */ | | #endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */ | |
| | | | |
| /** | | /** | |
| * @typedef Eina_Bool | | * @typedef Eina_Bool | |
| * Type to mimic a boolean. | | * Type to mimic a boolean. | |
| * | | * | |
| * @note it differs from stdbool.h as this is defined as an unsigned | | * @note it differs from stdbool.h as this is defined as an unsigned | |
| * char to make it usable by bitfields (Eina_Bool name:1) and | | * char to make it usable by bitfields (Eina_Bool name:1) and | |
| * also take as few bytes as possible. | | * also take as few bytes as possible. | |
| | | | |
| skipping to change at line 279 | | skipping to change at line 329 | |
| */ | | */ | |
| typedef void (*Eina_Free_Cb)(void *data); | | typedef void (*Eina_Free_Cb)(void *data); | |
| | | | |
| /** | | /** | |
| * @def EINA_FREE_CB | | * @def EINA_FREE_CB | |
| * Macro to cast to Eina_Free_Cb. | | * Macro to cast to Eina_Free_Cb. | |
| */ | | */ | |
| #define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function) | | #define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function) | |
| | | | |
| /** | | /** | |
|
| | | * @def EINA_C_ARRAY_LENGTH | |
| | | * Macro to return the array length of a standard c array. | |
| | | * For example: | |
| | | * int foo[] = { 0, 1, 2, 3 }; | |
| | | * would return 4 and not 4 * sizeof(int). | |
| | | * @since 1.2.0 | |
| | | */ | |
| | | #define EINA_C_ARRAY_LENGTH(arr) (sizeof(arr) / sizeof((arr)[0])) | |
| | | | |
| | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| #endif /* EINA_TYPES_H_ */ | | #endif /* EINA_TYPES_H_ */ | |
| | | | |
End of changes. 18 change blocks. |
| 12 lines changed or deleted | | 81 lines changed or added | |
|