From 07274513e984f0b5544586c74508ccd16e7dcafa Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 17:29:19 +1000 Subject: Remove EFL, since it's been released now. --- libraries/eina/src/include/Eina.h | 233 -- libraries/eina/src/include/Makefile.am | 94 - libraries/eina/src/include/Makefile.in | 570 ---- libraries/eina/src/include/eina_accessor.h | 340 -- libraries/eina/src/include/eina_array.h | 450 --- libraries/eina/src/include/eina_benchmark.h | 453 --- libraries/eina/src/include/eina_binbuf.h | 235 -- libraries/eina/src/include/eina_binshare.h | 193 -- libraries/eina/src/include/eina_clist.h | 378 --- libraries/eina/src/include/eina_config.h | 86 - libraries/eina/src/include/eina_config.h.in | 86 - libraries/eina/src/include/eina_convert.h | 374 --- libraries/eina/src/include/eina_counter.h | 213 -- libraries/eina/src/include/eina_cpu.h | 39 - libraries/eina/src/include/eina_error.h | 198 -- libraries/eina/src/include/eina_file.h | 483 --- libraries/eina/src/include/eina_fp.h | 111 - libraries/eina/src/include/eina_hamster.h | 58 - libraries/eina/src/include/eina_hash.h | 1040 ------ libraries/eina/src/include/eina_inarray.h | 710 ---- libraries/eina/src/include/eina_inline_array.x | 184 - libraries/eina/src/include/eina_inline_clist.x | 135 - libraries/eina/src/include/eina_inline_f16p16.x | 83 - libraries/eina/src/include/eina_inline_f32p32.x | 110 - libraries/eina/src/include/eina_inline_f8p24.x | 82 - libraries/eina/src/include/eina_inline_fp.x | 153 - libraries/eina/src/include/eina_inline_hash.x | 151 - libraries/eina/src/include/eina_inline_list.x | 67 - .../eina/src/include/eina_inline_lock_posix.x | 556 --- libraries/eina/src/include/eina_inline_lock_void.x | 273 -- .../eina/src/include/eina_inline_lock_win32.x | 550 --- .../eina/src/include/eina_inline_lock_wince.x | 212 -- libraries/eina/src/include/eina_inline_log.x | 197 -- libraries/eina/src/include/eina_inline_mempool.x | 148 - libraries/eina/src/include/eina_inline_rbtree.x | 50 - libraries/eina/src/include/eina_inline_rectangle.x | 254 -- libraries/eina/src/include/eina_inline_str.x | 76 - .../eina/src/include/eina_inline_stringshare.x | 91 - libraries/eina/src/include/eina_inline_tiler.x | 151 - libraries/eina/src/include/eina_inline_trash.x | 90 - .../eina/src/include/eina_inline_ustringshare.x | 93 - libraries/eina/src/include/eina_inline_value.x | 1790 ---------- libraries/eina/src/include/eina_inlist.h | 814 ----- libraries/eina/src/include/eina_iterator.h | 337 -- libraries/eina/src/include/eina_lalloc.h | 60 - libraries/eina/src/include/eina_list.h | 1631 --------- libraries/eina/src/include/eina_lock.h | 129 - libraries/eina/src/include/eina_log.h | 903 ----- libraries/eina/src/include/eina_magic.h | 330 -- libraries/eina/src/include/eina_main.h | 165 - libraries/eina/src/include/eina_matrixsparse.h | 399 --- libraries/eina/src/include/eina_mempool.h | 123 - libraries/eina/src/include/eina_mmap.h | 59 - libraries/eina/src/include/eina_model.h | 3105 ----------------- libraries/eina/src/include/eina_module.h | 350 -- libraries/eina/src/include/eina_prefix.h | 228 -- libraries/eina/src/include/eina_quadtree.h | 53 - libraries/eina/src/include/eina_rbtree.h | 271 -- libraries/eina/src/include/eina_rectangle.h | 239 -- libraries/eina/src/include/eina_refcount.h | 76 - libraries/eina/src/include/eina_safety_checks.h | 254 -- libraries/eina/src/include/eina_sched.h | 39 - .../eina/src/include/eina_simple_xml_parser.h | 390 --- libraries/eina/src/include/eina_str.h | 325 -- libraries/eina/src/include/eina_strbuf.h | 623 ---- libraries/eina/src/include/eina_stringshare.h | 345 -- libraries/eina/src/include/eina_tiler.h | 310 -- libraries/eina/src/include/eina_trash.h | 100 - libraries/eina/src/include/eina_types.h | 300 -- libraries/eina/src/include/eina_unicode.h | 186 -- libraries/eina/src/include/eina_ustrbuf.h | 464 --- libraries/eina/src/include/eina_ustringshare.h | 200 -- libraries/eina/src/include/eina_value.h | 3533 -------------------- libraries/eina/src/include/eina_xattr.h | 215 -- 74 files changed, 28396 deletions(-) delete mode 100644 libraries/eina/src/include/Eina.h delete mode 100644 libraries/eina/src/include/Makefile.am delete mode 100644 libraries/eina/src/include/Makefile.in delete mode 100644 libraries/eina/src/include/eina_accessor.h delete mode 100644 libraries/eina/src/include/eina_array.h delete mode 100644 libraries/eina/src/include/eina_benchmark.h delete mode 100644 libraries/eina/src/include/eina_binbuf.h delete mode 100644 libraries/eina/src/include/eina_binshare.h delete mode 100644 libraries/eina/src/include/eina_clist.h delete mode 100644 libraries/eina/src/include/eina_config.h delete mode 100644 libraries/eina/src/include/eina_config.h.in delete mode 100644 libraries/eina/src/include/eina_convert.h delete mode 100644 libraries/eina/src/include/eina_counter.h delete mode 100644 libraries/eina/src/include/eina_cpu.h delete mode 100644 libraries/eina/src/include/eina_error.h delete mode 100644 libraries/eina/src/include/eina_file.h delete mode 100644 libraries/eina/src/include/eina_fp.h delete mode 100644 libraries/eina/src/include/eina_hamster.h delete mode 100644 libraries/eina/src/include/eina_hash.h delete mode 100644 libraries/eina/src/include/eina_inarray.h delete mode 100644 libraries/eina/src/include/eina_inline_array.x delete mode 100644 libraries/eina/src/include/eina_inline_clist.x delete mode 100644 libraries/eina/src/include/eina_inline_f16p16.x delete mode 100644 libraries/eina/src/include/eina_inline_f32p32.x delete mode 100644 libraries/eina/src/include/eina_inline_f8p24.x delete mode 100644 libraries/eina/src/include/eina_inline_fp.x delete mode 100644 libraries/eina/src/include/eina_inline_hash.x delete mode 100644 libraries/eina/src/include/eina_inline_list.x delete mode 100644 libraries/eina/src/include/eina_inline_lock_posix.x delete mode 100644 libraries/eina/src/include/eina_inline_lock_void.x delete mode 100644 libraries/eina/src/include/eina_inline_lock_win32.x delete mode 100644 libraries/eina/src/include/eina_inline_lock_wince.x delete mode 100644 libraries/eina/src/include/eina_inline_log.x delete mode 100644 libraries/eina/src/include/eina_inline_mempool.x delete mode 100644 libraries/eina/src/include/eina_inline_rbtree.x delete mode 100644 libraries/eina/src/include/eina_inline_rectangle.x delete mode 100644 libraries/eina/src/include/eina_inline_str.x delete mode 100644 libraries/eina/src/include/eina_inline_stringshare.x delete mode 100644 libraries/eina/src/include/eina_inline_tiler.x delete mode 100644 libraries/eina/src/include/eina_inline_trash.x delete mode 100644 libraries/eina/src/include/eina_inline_ustringshare.x delete mode 100644 libraries/eina/src/include/eina_inline_value.x delete mode 100644 libraries/eina/src/include/eina_inlist.h delete mode 100644 libraries/eina/src/include/eina_iterator.h delete mode 100644 libraries/eina/src/include/eina_lalloc.h delete mode 100644 libraries/eina/src/include/eina_list.h delete mode 100644 libraries/eina/src/include/eina_lock.h delete mode 100644 libraries/eina/src/include/eina_log.h delete mode 100644 libraries/eina/src/include/eina_magic.h delete mode 100644 libraries/eina/src/include/eina_main.h delete mode 100644 libraries/eina/src/include/eina_matrixsparse.h delete mode 100644 libraries/eina/src/include/eina_mempool.h delete mode 100644 libraries/eina/src/include/eina_mmap.h delete mode 100644 libraries/eina/src/include/eina_model.h delete mode 100644 libraries/eina/src/include/eina_module.h delete mode 100644 libraries/eina/src/include/eina_prefix.h delete mode 100644 libraries/eina/src/include/eina_quadtree.h delete mode 100644 libraries/eina/src/include/eina_rbtree.h delete mode 100644 libraries/eina/src/include/eina_rectangle.h delete mode 100644 libraries/eina/src/include/eina_refcount.h delete mode 100644 libraries/eina/src/include/eina_safety_checks.h delete mode 100644 libraries/eina/src/include/eina_sched.h delete mode 100644 libraries/eina/src/include/eina_simple_xml_parser.h delete mode 100644 libraries/eina/src/include/eina_str.h delete mode 100644 libraries/eina/src/include/eina_strbuf.h delete mode 100644 libraries/eina/src/include/eina_stringshare.h delete mode 100644 libraries/eina/src/include/eina_tiler.h delete mode 100644 libraries/eina/src/include/eina_trash.h delete mode 100644 libraries/eina/src/include/eina_types.h delete mode 100644 libraries/eina/src/include/eina_unicode.h delete mode 100644 libraries/eina/src/include/eina_ustrbuf.h delete mode 100644 libraries/eina/src/include/eina_ustringshare.h delete mode 100644 libraries/eina/src/include/eina_value.h delete mode 100644 libraries/eina/src/include/eina_xattr.h (limited to 'libraries/eina/src/include') diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h deleted file mode 100644 index d99b129..0000000 --- a/libraries/eina/src/include/Eina.h +++ /dev/null @@ -1,233 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008-2012 Enlightenment Developers: - * Albin "Lutin" Tonnerre - * Alexandre "diaxen" Becoulet - * Andre Dieb - * Arnaud de Turckheim "quarium" - * Carsten Haitzler - * Cedric Bail - * Corey "atmos" Donohoe - * Fabiano FidĂȘncio - * Gustavo Chaves - * Gustavo Sverzut Barbieri - * Jorge Luis "turran" Zapata - * Peter "pfritz" Wehrfritz - * Raphael Kubo da Costa - * Tilman Sauerbeck - * Vincent "caro" Torri - * Tom Hacohen - * Jonas M. Gastal - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_H_ -#define EINA_H_ - -/** - * @file - * @brief Eina Utility library - * - * These routines are used for Eina. - */ - -/** - * @mainpage Eina - * - * @version 1.1 - * @date 2008-2012 - * - * @section eina_intro_sec Introduction - * - * The Eina library is a library that implements an API for data types - * in an efficient way. It also provides some useful tools like - * opening shared libraries, errors management, type conversion, - * time accounting and memory pool. - * - * This library is cross-platform and can be compiled and used on - * Linux, BSD, Opensolaris and Windows (XP and CE). - * - * 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_Hash_Group standard hash of @c void* data. - * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. - * @li @ref Eina_CList_Group Compact List. - * @li @ref Eina_List_Group standard list of @c void* data. - * @li @ref Eina_Iterator_Group Iterator functions. - * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. - * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user type. - * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or append strings to a buffer. - * @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 regions. - * @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): - * @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_Counter_Group measures number of calls and their time. - * @li @ref Eina_Error_Group error identifiers. - * @li @ref Eina_File_Group simple file list and path split. - * @li @ref Eina_Lalloc_Group simple lazy allocator. - * @li @ref Eina_Log_Group full-featured logging system. - * @li @ref Eina_Magic_Group provides runtime type checking. - * @li @ref Eina_Memory_Pool_Group abstraction for various memory allocators. - * @li @ref Eina_Module_Group lists, loads and share modules using Eina_Module standard. - * @li @ref Eina_Rectangle_Group rectangle structure and standard manipulation methods. - * @li @ref Eina_Safety_Checks_Group extra checks that will report unexpected conditions and can be disabled at compile time. - * @li @ref Eina_String_Group a set of functions that manages C strings. - * - * Please see the @ref authors page for contact details. - * - * @defgroup Eina_Data_Types_Group Data Types - * - * Eina provide easy to use and optimized data types and structures. - * - * - * @defgroup Eina_Containers_Group Containers - * - * Containers are data types that hold data and allow iteration over - * their elements with an @ref Eina_Iterator_Group, or eventually an - * @ref Eina_Accessor_Group. - * - * The containers in eina are designed with performance in mind, one consequence - * of this is that they @b don't check the validity of data structures given 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 with - * minimal overhead; - * @li inline arrays use very little memory and don't cause fragmentation and - * 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 acceptable. - * @warning These are general considerations, every situation is different, - * don't follow these recommendations blindly. - * - * @defgroup Eina_Tools_Group Tools - * - * Eina tools aims to help application development, providing ways to - * make it safer, log errors, manage memory more efficiently and more. - * - */ - -/** - * - * @page authors Authors - * - * @author Albin "Lutin" Tonnerre - * @author Alexandre "diaxen" Becoulet - * @author Andre Dieb - * @author Arnaud de Turckheim "quarium" - * @author Carsten Haitzler - * @author Cedric Bail - * @author Corey "atmos" Donohoe - * @author Vincent "caro" Torri - * @author Fabiano FidĂȘncio - * @author Gustavo Chaves - * @author Gustavo Sverzut Barbieri - * @author Jorge Luis "turran" Zapata - * @author Tilman Sauerbeck - * @author Peter "pfritz" Wehrfritz - * @author Raphael Kubo da Costa - * @author Tom Hacohen - * @author Brett Nash - * @author Sebastian Dransfeld - * @author Myungjae Lee - * @author Youness Alaoui - * @author Boris "billiob" Faure - * @author Sung W. Park - * @author Guillaume Friloux - * - * Please contact to get in - * contact with the developers and maintainers. - * - */ - -#ifdef _WIN32 -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include "eina_config.h" -#include "eina_types.h" -#include "eina_main.h" -#include "eina_fp.h" -#include "eina_rectangle.h" -#include "eina_clist.h" -#include "eina_inlist.h" -#include "eina_file.h" -#include "eina_list.h" -#include "eina_hash.h" -#include "eina_trash.h" -#include "eina_lalloc.h" -#include "eina_module.h" -#include "eina_mempool.h" -#include "eina_error.h" -#include "eina_log.h" -#include "eina_inarray.h" -#include "eina_array.h" -#include "eina_binshare.h" -#include "eina_stringshare.h" -#include "eina_ustringshare.h" -#include "eina_magic.h" -#include "eina_counter.h" -#include "eina_rbtree.h" -#include "eina_accessor.h" -#include "eina_iterator.h" -#include "eina_benchmark.h" -#include "eina_convert.h" -#include "eina_cpu.h" -#include "eina_sched.h" -#include "eina_tiler.h" -#include "eina_hamster.h" -#include "eina_matrixsparse.h" -#include "eina_str.h" -#include "eina_strbuf.h" -#include "eina_binbuf.h" -#include "eina_ustrbuf.h" -#include "eina_unicode.h" -#include "eina_quadtree.h" -#include "eina_simple_xml_parser.h" -#include "eina_lock.h" -#include "eina_prefix.h" -#include "eina_refcount.h" -#include "eina_mmap.h" -#include "eina_xattr.h" -#include "eina_value.h" -#include "eina_model.h" - -#ifdef __cplusplus -} -#endif - -#endif /* EINA_H */ diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am deleted file mode 100644 index 31ef71e..0000000 --- a/libraries/eina/src/include/Makefile.am +++ /dev/null @@ -1,94 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in - -EINAHEADERS = \ -eina_safety_checks.h \ -eina_error.h \ -eina_log.h \ -eina_inline_log.x \ -eina_fp.h \ -eina_inline_f32p32.x \ -eina_inline_f16p16.x \ -eina_inline_f8p24.x \ -eina_inline_fp.x \ -eina_hash.h \ -eina_inline_hash.x \ -eina_lalloc.h \ -eina_clist.h \ -eina_inline_clist.x \ -eina_inarray.h \ -eina_inlist.h \ -eina_list.h \ -eina_file.h \ -eina_mempool.h \ -eina_module.h \ -eina_rectangle.h \ -eina_types.h \ -eina_array.h \ -eina_counter.h \ -eina_inline_array.x \ -eina_magic.h \ -eina_stringshare.h \ -eina_binshare.h \ -eina_binbuf.h \ -eina_ustringshare.h \ -eina_inline_stringshare.x \ -eina_inline_ustringshare.x \ -eina_inline_list.x \ -eina_accessor.h \ -eina_convert.h \ -eina_rbtree.h \ -eina_benchmark.h \ -eina_inline_rbtree.x \ -eina_inline_mempool.x \ -eina_inline_rectangle.x \ -eina_inline_trash.x \ -eina_trash.h \ -eina_iterator.h \ -eina_main.h \ -eina_cpu.h \ -eina_sched.h \ -eina_tiler.h \ -eina_hamster.h \ -eina_matrixsparse.h \ -eina_inline_tiler.x \ -eina_str.h \ -eina_inline_str.x \ -eina_strbuf.h \ -eina_ustrbuf.h \ -eina_unicode.h \ -eina_quadtree.h \ -eina_simple_xml_parser.h \ -eina_lock.h \ -eina_prefix.h \ -eina_refcount.h \ -eina_mmap.h \ -eina_xattr.h \ -eina_value.h \ -eina_inline_value.x \ -eina_model.h - -# Will be back for developper after 1.1. -# eina_object.h - -if EINA_HAVE_THREADS -if EINA_HAVE_WINCE -EINAHEADERS += eina_inline_lock_wince.x -else -if EINA_HAVE_WIN32 -EINAHEADERS += eina_inline_lock_win32.x -else -EINAHEADERS += eina_inline_lock_posix.x -endif -endif -else -EINAHEADERS += eina_inline_lock_void.x -endif - -installed_mainheaderdir = $(includedir)/eina-@VMAJ@ -dist_installed_mainheader_DATA = Eina.h eina_config.h - -installed_headersdir = $(includedir)/eina-@VMAJ@/eina -dist_installed_headers_DATA = $(EINAHEADERS) - -EXTRA_DIST = \ -eina_config.h.in diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in deleted file mode 100644 index 7e819b8..0000000 --- a/libraries/eina/src/include/Makefile.in +++ /dev/null @@ -1,570 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ - -# Will be back for developper after 1.1. -# eina_object.h -@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WINCE_TRUE@am__append_1 = eina_inline_lock_wince.x -@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_TRUE@@EINA_HAVE_WINCE_FALSE@am__append_2 = eina_inline_lock_win32.x -@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_FALSE@@EINA_HAVE_WINCE_FALSE@am__append_3 = eina_inline_lock_posix.x -@EINA_HAVE_THREADS_FALSE@am__append_4 = eina_inline_lock_void.x -subdir = src/include -DIST_COMMON = $(am__dist_installed_headers_DATA_DIST) \ - $(dist_installed_mainheader_DATA) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/eina_config.h.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/eina/eina_bench.m4 \ - $(top_srcdir)/m4/eina/eina_check.m4 \ - $(top_srcdir)/m4/common/efl_attribute.m4 \ - $(top_srcdir)/m4/common/efl_benchmark.m4 \ - $(top_srcdir)/m4/common/efl_compiler_flag.m4 \ - $(top_srcdir)/m4/common/efl_coverage.m4 \ - $(top_srcdir)/m4/common/efl_cpu.m4 \ - $(top_srcdir)/m4/common/efl_doxygen.m4 \ - $(top_srcdir)/m4/common/efl_examples.m4 \ - $(top_srcdir)/m4/common/efl_fnmatch.m4 \ - $(top_srcdir)/m4/common/efl_path_max.m4 \ - $(top_srcdir)/m4/common/efl_tests.m4 \ - $(top_srcdir)/m4/common/efl_threads.m4 \ - $(top_srcdir)/m4/common/efl_voltron.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = eina_config.h -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \ - eina_error.h eina_log.h eina_inline_log.x eina_fp.h \ - eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \ - eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \ - eina_clist.h eina_inline_clist.x eina_inarray.h eina_inlist.h \ - eina_list.h eina_file.h eina_mempool.h eina_module.h \ - eina_rectangle.h eina_types.h eina_array.h eina_counter.h \ - eina_inline_array.x eina_magic.h eina_stringshare.h \ - eina_binshare.h eina_binbuf.h eina_ustringshare.h \ - eina_inline_stringshare.x eina_inline_ustringshare.x \ - eina_inline_list.x eina_accessor.h eina_convert.h \ - eina_rbtree.h eina_benchmark.h eina_inline_rbtree.x \ - eina_inline_mempool.x eina_inline_rectangle.x \ - eina_inline_trash.x eina_trash.h eina_iterator.h eina_main.h \ - eina_cpu.h eina_sched.h eina_tiler.h eina_hamster.h \ - eina_matrixsparse.h eina_inline_tiler.x eina_str.h \ - eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \ - eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \ - eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \ - eina_value.h eina_inline_value.x eina_model.h \ - eina_inline_lock_wince.x eina_inline_lock_win32.x \ - eina_inline_lock_posix.x eina_inline_lock_void.x -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(installed_headersdir)" \ - "$(DESTDIR)$(installed_mainheaderdir)" -DATA = $(dist_installed_headers_DATA) \ - $(dist_installed_mainheader_DATA) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AS = @AS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CHECK_CFLAGS = @CHECK_CFLAGS@ -CHECK_LIBS = @CHECK_LIBS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@ -ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@ -EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ -EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ -EFL_EINA_BUILD = @EFL_EINA_BUILD@ -EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@ -EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@ -EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@ -EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@ -EGREP = @EGREP@ -EINA_CFLAGS = @EINA_CFLAGS@ -EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ -EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@ -EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ -EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@ -EINA_CONFIGURE_HAVE_EXOTIC = @EINA_CONFIGURE_HAVE_EXOTIC@ -EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ -EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ -EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ -EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@ -EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@ -EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@ -EINA_LIBS = @EINA_LIBS@ -EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@ -EMEMOA_CFLAGS = @EMEMOA_CFLAGS@ -EMEMOA_LIBS = @EMEMOA_LIBS@ -ESCAPE_CFLAGS = @ESCAPE_CFLAGS@ -ESCAPE_LIBS = @ESCAPE_LIBS@ -EVIL_CFLAGS = @EVIL_CFLAGS@ -EVIL_LIBS = @EVIL_LIBS@ -EXEEXT = @EXEEXT@ -EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ -EXOTIC_LIBS = @EXOTIC_LIBS@ -FGREP = @FGREP@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_LIBS = @GLIB_LIBS@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -MODULE_ARCH = @MODULE_ARCH@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ -VALGRIND_LIBS = @VALGRIND_LIBS@ -VERSION = @VERSION@ -VMAJ = @VMAJ@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -dlopen_libs = @dlopen_libs@ -docdir = @docdir@ -dvidir = @dvidir@ -efl_doxygen = @efl_doxygen@ -efl_have_doxygen = @efl_have_doxygen@ -exec_prefix = @exec_prefix@ -have_lcov = @have_lcov@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -iconv_libs = @iconv_libs@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -lt_enable_auto_import = @lt_enable_auto_import@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgconfig_requires_private = @pkgconfig_requires_private@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -release_info = @release_info@ -requirement_eina = @requirement_eina@ -rt_libs = @rt_libs@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -version_info = @version_info@ -MAINTAINERCLEANFILES = Makefile.in -EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \ - eina_inline_log.x eina_fp.h eina_inline_f32p32.x \ - eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \ - eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \ - eina_inline_clist.x eina_inarray.h eina_inlist.h eina_list.h \ - eina_file.h eina_mempool.h eina_module.h eina_rectangle.h \ - eina_types.h eina_array.h eina_counter.h eina_inline_array.x \ - eina_magic.h eina_stringshare.h eina_binshare.h eina_binbuf.h \ - eina_ustringshare.h eina_inline_stringshare.x \ - eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ - eina_convert.h eina_rbtree.h eina_benchmark.h \ - eina_inline_rbtree.x eina_inline_mempool.x \ - eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \ - eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \ - eina_tiler.h eina_hamster.h eina_matrixsparse.h \ - eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ - eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ - eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ - eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \ - eina_inline_value.x eina_model.h $(am__append_1) \ - $(am__append_2) $(am__append_3) $(am__append_4) -installed_mainheaderdir = $(includedir)/eina-@VMAJ@ -dist_installed_mainheader_DATA = Eina.h eina_config.h -installed_headersdir = $(includedir)/eina-@VMAJ@/eina -dist_installed_headers_DATA = $(EINAHEADERS) -EXTRA_DIST = \ -eina_config.h.in - -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/include/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/include/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -eina_config.h: $(top_builddir)/config.status $(srcdir)/eina_config.h.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-dist_installed_headersDATA: $(dist_installed_headers_DATA) - @$(NORMAL_INSTALL) - test -z "$(installed_headersdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_headersdir)" - @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_headersdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_headersdir)" || exit $$?; \ - done - -uninstall-dist_installed_headersDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(installed_headersdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(installed_headersdir)" && rm -f $$files -install-dist_installed_mainheaderDATA: $(dist_installed_mainheader_DATA) - @$(NORMAL_INSTALL) - test -z "$(installed_mainheaderdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_mainheaderdir)" - @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_mainheaderdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_mainheaderdir)" || exit $$?; \ - done - -uninstall-dist_installed_mainheaderDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(installed_mainheaderdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(installed_mainheaderdir)" && rm -f $$files -tags: TAGS -TAGS: - -ctags: CTAGS -CTAGS: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(DATA) -installdirs: - for dir in "$(DESTDIR)$(installed_headersdir)" "$(DESTDIR)$(installed_mainheaderdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-dist_installed_headersDATA \ - install-dist_installed_mainheaderDATA - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-dist_installed_headersDATA \ - uninstall-dist_installed_mainheaderDATA - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - distclean distclean-generic distclean-libtool distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am \ - install-dist_installed_headersDATA \ - install-dist_installed_mainheaderDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - uninstall uninstall-am uninstall-dist_installed_headersDATA \ - uninstall-dist_installed_mainheaderDATA - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libraries/eina/src/include/eina_accessor.h b/libraries/eina/src/include/eina_accessor.h deleted file mode 100644 index cae7a5c..0000000 --- a/libraries/eina/src/include/eina_accessor.h +++ /dev/null @@ -1,340 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_ACCESSOR_H__ -#define EINA_ACCESSOR_H__ - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_magic.h" - -/** - * @page eina_accessor_example_01_page Eina_Accessor usage - * @dontinclude eina_accessor_01.c - * - * We start by including necessary headers, declaring variables and - * initializing eina: - * @skip #include - * @until eina_init - * - * Next we populate our array and list: - * @until } - * - * Now that we have two containers populated we can actually start the example - * and create an accessor: - * @until accessor_new - * - * Once having the accessor we can use it to access certain elements in the - * container: - * @until } - * @note Unlike iterators accessors allow us non-linear access, which allows us - * to print only the odd elements in the container. - * - * As with every other resource we allocate we need to free the accessor(and the - * array): - * @until array_free - * - * Now we create another accessor, this time for the list: - * @until accessor_new - * - * And now the interesting bit, we use the same code we used above to print - * parts of the array to print parts of the list: - * @until } - * - * And to free the list we use a gimmick, instead of freeing @a list, we ask the - * accessor for it's container and free that: - * @until list_free - * - * Finally we shut eina down and leave: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_accessor_01_c "eina_accessor_01.c" file. - */ - -/** - * @page eina_accessor_01_c Eina_Accessor usage example - * - * @include eina_accessor_01.c - * @example eina_accessor_01.c - */ - -/** - * @addtogroup Eina_Accessor_Group Accessor Functions - * - * @brief These functions manage accessor on containers. - * - * These functions allow to access elements of a container in a - * generic way, without knowing which container is used (a bit like - * iterators in the C++ STL). Accessors allows random access (that is, any - * element in the container). For sequential access, see - * @ref Eina_Iterator_Group. - * - * An accessor is created from container data types, so no creation - * function is available here. An accessor is deleted with - * eina_accessor_free(). To get the data of an element at a given - * position, use eina_accessor_data_get(). To call a function on - * chosen elements of a container, use eina_accessor_over(). - * - * See an example @ref eina_accessor_example_01_page "here". - */ - -/** - * @addtogroup Eina_Content_Access_Group Content Access - * - * @{ - */ - -/** - * @defgroup Eina_Accessor_Group Accessor Functions - * - * @{ - */ - -/** - * @typedef Eina_Accessor - * Abstract type for accessors. - */ -typedef struct _Eina_Accessor Eina_Accessor; - -/** - * @typedef Eina_Accessor_Get_At_Callback - * Type for a callback that returns the data of a container as the given index. - */ -typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it, - unsigned int idx, - void **data); - -/** - * @typedef Eina_Accessor_Get_Container_Callback - * Type for a callback that returns the container. - */ -typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it); - -/** - * @typedef Eina_Accessor_Free_Callback - * Type for a callback that frees the container. - */ -typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it); - -/** - * @typedef Eina_Accessor_Lock_Callback - * Type for a callback that lock the container. - */ -typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it); - -/** - * @struct _Eina_Accessor - * Type to provide random access to data structures. - */ -struct _Eina_Accessor -{ -#define EINA_ACCESSOR_VERSION 1 - int version; /**< Version of the Accessor API. */ - - Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT; /**< Callback called when a data element is requested. */ - Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */ - Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */ - - Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */ - Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */ - -#define EINA_MAGIC_ACCESSOR 0x98761232 - EINA_MAGIC -}; - -/** - * @def FUNC_ACCESSOR_GET_AT(Function) - * Helper macro to cast @p Function to a Eina_Accessor_Get_At_Callback. - */ -#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function) - -/** - * @def FUNC_ACCESSOR_GET_CONTAINER(Function) - * Helper macro to cast @p Function to a Eina_Accessor_Get_Container_Callback. - */ -#define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function) - -/** - * @def FUNC_ACCESSOR_FREE(Function) - * Helper macro to cast @p Function to a Eina_Accessor_Free_Callback. - */ -#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function) - -/** - * @def FUNC_ACCESSOR_LOCK(Function) - * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback. - */ -#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function) - - -/** - * @brief Free an accessor. - * - * @param accessor The accessor to free. - * - * This function frees @p accessor if it is not @c NULL; - */ -EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve the data of an accessor at a given position. - * - * @param accessor The accessor. - * @param position The position of the element. - * @param data The pointer that stores the data to retrieve. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function retrieves the data of the element pointed by - * @p accessor at the porition @p position, and stores it in - * @p data. If @p accessor is @c NULL or if an error occurred, - * #EINA_FALSE is returned, otherwise EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor, - unsigned int position, - void **data) EINA_ARG_NONNULL(1); - -/** - * @brief Return the container of an accessor. - * - * @param accessor The accessor. - * @return The container which created the accessor. - * - * This function returns the container which created @p accessor. If - * @p accessor is @c NULL, this function returns @c NULL. - */ -EAPI void *eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE; - -/** - * @brief Iterate over the container and execute a callback on chosen elements. - * - * @param accessor The accessor. - * @param cb The callback called on the chosen elements. - * @param start The position of the first element. - * @param end The position of the last element. - * @param fdata The data passed to the callback. - * - * This function iterates over the elements pointed by @p accessor, - * starting from the element at position @p start and ending to the - * element at position @p end. For Each element, the callback - * @p cb is called with the data @p fdata. If @p accessor is @c NULL - * or if @p start is greter or equal than @p end, the function returns - * immediately. - */ -EAPI void eina_accessor_over(Eina_Accessor *accessor, - Eina_Each_Cb cb, - unsigned int start, - unsigned int end, - const void *fdata) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Lock the container of the accessor. - * - * @param accessor The accessor. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * If the container of the @p accessor permits it, it will be locked. When a - * container is locked calling eina_accessor_over() on it will return - * immediately. If @p accessor is @c NULL or if a problem occurred, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. If the container isn't - * lockable, it will return EINA_TRUE. - * - * @warning None of the existing eina data structures are lockable. - */ -EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); - -/** - * @brief Unlock the container of the accessor. - * - * @param accessor The accessor. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * If the container of the @p accessor permits it and was previously - * locked, it will be unlocked. If @p accessor is @c NULL or if a - * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE - * is returned. If the container is not lockable, it will return - * EINA_TRUE. - * - * @warning None of the existing eina data structures are lockable. - */ -EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1); - -/** - * @def EINA_ACCESSOR_FOREACH - * @brief Macro to iterate over all elements easily. - * - * @param accessor The accessor to use. - * @param counter A counter used by eina_accessor_data_get() when - * iterating over the container. - * @param data Where to store * data, must be a pointer support getting - * its address since * eina_accessor_data_get() requires a pointer to - * pointer! - * - * This macro allows a convenient way to loop over all elements in an - * accessor, very similar to EINA_LIST_FOREACH(). - * - * This macro can be used for freeing the data of a list, like in the - * following example. It has the same goal as the one documented in - * EINA_LIST_FOREACH(), but using accessors: - * - * @code - * Eina_List *list; - * Eina_Accessor *accessor; - * unsigned int i; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings - * - * accessor = eina_list_accessor_new(list); - * EINA_ACCESSOR_FOREACH(accessor, i, data) - * free(data); - * eina_accessor_free(accessor); - * eina_list_free(list); - * @endcode - * - * @note if the datatype provides both iterators and accessors prefer - * to use iterators to iterate over, as they're likely to be more - * optimized for such task. - * - * @note this example is not optimal algorithm to release a list since - * it will walk the list twice, but it serves as an example. For - * optimized version use EINA_LIST_FREE() - * - * @warning unless explicitly stated in functions returning accessors, - * do not modify the accessed object while you walk it, in this - * example using lists, do not remove list nodes or you might - * crash! This is not a limitiation of accessors themselves, - * rather in the accessors implementations to keep them as simple - * and fast as possible. - */ -#define EINA_ACCESSOR_FOREACH(accessor, counter, data) \ - for ((counter) = 0; \ - eina_accessor_data_get((accessor), (counter), (void **)(void *)&(data)); \ - (counter)++) - -/** - * @} - */ - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h deleted file mode 100644 index 4ab3b50..0000000 --- a/libraries/eina/src/include/eina_array.h +++ /dev/null @@ -1,450 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_ARRAY_H_ -#define EINA_ARRAY_H_ - -#include - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_error.h" -#include "eina_iterator.h" -#include "eina_accessor.h" -#include "eina_magic.h" - - -/** - * @page eina_array_01_example_page Basic array usage - * @dontinclude eina_array_01.c - * - * 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 - * @ref Eina_Array is to include Eina.h: - * @skip #include - * @until Eina.h - * - * Here we have a callback that prints the element given to it: - * @until } - * - * Now we create our entry point and declare some variables, nothing especial: - * @until unsigned - * - * Before we can start using any array function we need to initialize eina: - * @until eina_init - * - * So now to actually creating our array. The only interesting thing here is the - * argument given to the eina_array_new() function, this argument sets how fast - * the array grows. - * @until array_new - * - * If you know before hand how big the array will need to be you should set the - * step to that. In our case we can set it to the number of string we have and - * since we didn't do that in the eina_array_new() we can do it now: - * @until array_step_set - * - * Now let us populate our array with some strings: - * @until push - * @note Notice we use strdup, so we will have to free that memory later on. - * - * Now lets check the size of the array: - * @until printf - * - * And now we call a function on every member of our array to print it: - * @until foreach - * - * One of the strenghts of @ref Eina_Array over @ref Eina_List is that it has - * very fast random access to elements, so this is very efficient: - * @until printf - * - * And now we free up the memory allocated with the strdup()s: - * @until free - * - * And the array memory itself: - * @until array_free - * - * And finally shutdown eina and exit: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_array_01_c "eina_array_01.c" file. - */ - -/** - * @page eina_array_01_c Basic array usage example - * - * @include eina_array_01.c - * @example eina_array_01.c - */ - -/** - * @page eina_array_02_example_page Removing array elements - * @dontinclude eina_array_02.c - * - * Just the usual includes: - * @skip #include - * @until Eina.h - * - * This the callback we are going to use to decide which strings stay on the - * array and which will be removed, we use something simple, but this can be as - * complex as you like: - * @until } - * - * This is the same code we used before to populate the list with the slight - * difference of not using strdup: - * @until array_push - * - * So we have added all our elements to the array, but it turns out that is not - * the elements we wanted, so let's empty the array and add the correct strings: - * @until array_push - * - * It seems we made a little mistake in one of our strings so we need to replace - * it, here is how: - * @until data_set - * - * Now that there is a populated array we can remove elements from it easily: - * @until array_remove - * - * And check that the elements were actually removed: - * @until printf - * - * Since this time we didn't use strdup we don't need to free each string: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_array_02_c "eina_array_02.c" file. - */ - -/** - * @page eina_array_02_c Basic array usage example - * - * @include eina_array_02.c - * @example eina_array_02.c - */ - -/** - * @addtogroup Eina_Array_Group Array - * - * @brief These functions provide array management. - * - * The Array data type in Eina is designed to have very fast access to - * its data (compared to the Eina @ref Eina_List_Group). On the other hand, - * data can be added or removed only at the end of the array. To insert - * data at any place, the Eina @ref Eina_List_Group is the correct container - * to use. - * - * To use the array data type, eina_init() must be called before any - * other array functions. When no more eina array functions are used, - * eina_shutdown() must be called to free all the resources. - * - * An array must be created with eina_array_new(). It allocates all - * the necessary data for an array. When not needed anymore, an array - * is freed with eina_array_free(). This function does not free any - * allocated memory used to store the data of each element. For that, - * just iterate over the array to free them. A convenient way to do - * that is by using #EINA_ARRAY_ITER_NEXT. An example of code is given - * in the description of this macro. - * - * @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 - * reasons. - * - * The usual features of an array are classic ones: to append an - * 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_data_get(). The number of elements can be retrieved with - * eina_array_count(). - * - * 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 - * element to a full array it grows and that when you remove an element from an - * array it @b may shrink. - * - * When the array needs to grow it allocates memory not just for the element - * currently being added since that would mean allocating memory(which is - * 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 - * array is left holding its capacity - @p step elements it will shrink. - * - * The following image illustrates how an Eina_Array grows: - * - * @image html eina_array-growth.png - * @image latex eina_array-growth.eps width=\textwidth - * - * Eina_Array only stores pointers but it can store data of any type in the form - * of void pointers. - * - * See here some examples: - * @li @ref eina_array_01_example_page - * @li @ref eina_array_02_example_page - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Array_Group Array - * - * @{ - */ - -/** - * @typedef Eina_Array - * Type for a generic vector. - */ -typedef struct _Eina_Array Eina_Array; - -/** - * @typedef Eina_Array_Iterator - * Type for an iterator on arrays, used with #EINA_ARRAY_ITER_NEXT. - */ -typedef void **Eina_Array_Iterator; - -/** - * @struct _Eina_Array - * Type for an array of data. - */ -struct _Eina_Array -{ -#define EINA_ARRAY_VERSION 1 - int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */ - - void **data; /**< Pointer to a vector of pointer to payload */ - unsigned int total; /**< Total number of slots in the vector */ - unsigned int count; /**< Number of active slots in the vector */ - unsigned int step; /**< How much must we grow the vector when it is full */ - EINA_MAGIC -}; - - -/** - * @brief Create a new array. - * - * @param step The count of pointers to add when increasing the array size. - * @return @c NULL on failure, non @c NULL otherwise. - * - * This function creates a new array. When adding an element, the array - * allocates @p step elements. When that buffer is full, then adding - * another element will increase the buffer by @p step elements again. - * - * This function return a valid array on success, or @c NULL if memory - * allocation fails. In that case, the error is set to - * #EINA_ERROR_OUT_OF_MEMORY. - */ -EAPI Eina_Array *eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free an array. - * - * @param array The array to free. - * - * This function frees @p array. It calls first eina_array_flush() then - * free the memory of the pointer. It does not free the memory - * allocated for the elements of @p array. To free them, use - * #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check - * of @p array. - */ -EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @brief Set the step of an array. - * - * @param array The array. - * @param sizeof_eina_array Should be the value returned by sizeof(Eina_Array). - * @param step The count of pointers to add when increasing the array size. - * - * This function sets the step of @p array to @p step. For performance - * reasons, there is no check of @p array. If it is @c NULL or - * invalid, the program may crash. - * - * @warning This function can @b only be called on uninitialized arrays. - */ -EAPI void eina_array_step_set(Eina_Array *array, - unsigned int sizeof_eina_array, - unsigned int step) EINA_ARG_NONNULL(1); -/** - * @brief Clean an array. - * - * @param array The array to clean. - * - * This function sets the count member of @p array to 0, however it doesn't free - * any space. This is particularly useful if you need to empty the array and - * add lots of elements quickly. For performance reasons, there is no check of - * @p array. If it is @c NULL or invalid, the program may crash. - */ -static inline void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @brief Flush an array. - * - * @param array The array to flush. - * - * This function sets the count and total members of @p array to 0, - * frees and set to NULL its data member. For performance reasons, - * there is no check of @p array. If it is @c NULL or invalid, the - * program may crash. - */ -EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @brief Rebuild an array by specifying the data to keep. - * - * @param array The array. - * @param keep The functions which selects the data to keep. - * @param gdata The data to pass to the function keep. - * @return #EINA_TRUE on success, #EINA_FALSE oterwise. - * - * This function rebuilds @p array be specifying the elements to keep with the - * function @p keep. No empty/invalid fields are left in the array. @p gdata is - * an additional data to pass to @p keep. For performance reasons, there is no - * check of @p array. If it is @c NULL or invalid, the program may crash. - * - * If it wasn't able to remove items due to an allocation failure, it will - * return #EINA_FALSE and the error is set to #EINA_ERROR_OUT_OF_MEMORY. - */ -EAPI Eina_Bool eina_array_remove(Eina_Array * array, - Eina_Bool (*keep)(void *data, void *gdata), - void *gdata) EINA_ARG_NONNULL(1, 2); -static inline Eina_Bool eina_array_push(Eina_Array *array, - const void *data) EINA_ARG_NONNULL(1, 2); -static inline void *eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1); -static inline void *eina_array_data_get(const Eina_Array *array, - unsigned int idx) EINA_ARG_NONNULL(1); -/** - * @brief Set the data at a given position in an array. - * - * @param array The array. - * @param idx The potition of the data to set. - * @param data The data to set. - * - * This function sets the data at the position @p idx in @p - * array to @p data, this effectively replaces the previously held data, you - * 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 - * NULL or invalid, the program may crash. -*/ -static inline void eina_array_data_set(const Eina_Array *array, - unsigned int idx, - const void *data) EINA_ARG_NONNULL(1); -static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new iterator associated to an array. - * - * @param array The array. - * @return A new iterator. - * - * 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 - * less or equal than 0, this function returns NULL. If the memory can - * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is - * set. Otherwise, a valid iterator is returned. - */ -EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new accessor associated to an array. - * - * @param array The array. - * @return A new accessor. - * - * This function returns a newly allocated accessor associated to - * @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 - * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is - * set. Otherwise, a valid accessor is returned. - */ -EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -/** - * @brief Provide a safe way to iterate over an array - * - * @param array The array to iterate over. - * @param cb The callback to call for each item. - * @param fdata The user data to pass to the callback. - * @return EINA_TRUE if it successfully iterate all items of the array. - * - * This function provide a safe way to iterate over an array. @p cb should - * return EINA_TRUE as long as you want the function to continue iterating, - * by returning EINA_FALSE it will stop and return EINA_FALSE as a result. - */ -static inline Eina_Bool eina_array_foreach(Eina_Array *array, - Eina_Each_Cb cb, - void *fdata); -/** - * @def EINA_ARRAY_ITER_NEXT - * @brief Macro to iterate over an array easily. - * - * @param array The array to iterate over. - * @param index The integer number that is increased while itareting. - * @param item The data - * @param iterator The iterator - * - * This macro allows the iteration over @p array in an easy way. It - * iterates from the first element to the last one. @p index is an - * integer that increases from 0 to the number of elements. @p item is - * the data of each element of @p array, so it is a pointer to a type - * chosen by the user. @p iterator is of type #Eina_Array_Iterator. - * - * This macro can be used for freeing the data of an array, like in - * the following example: - * - * @code - * Eina_Array *array; - * char *item; - * Eina_Array_Iterator iterator; - * unsigned int i; - * - * // array is already filled, - * // its elements are just duplicated strings, - * // EINA_ARRAY_ITER_NEXT will be used to free those strings - * - * EINA_ARRAY_ITER_NEXT(array, i, item, iterator) - * free(item); - * @endcode - */ -#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \ - for (index = 0, iterator = (array)->data; \ - (index < eina_array_count(array)) && ((item = *((iterator)++))); \ - ++(index)) - -#include "eina_inline_array.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_benchmark.h b/libraries/eina/src/include/eina_benchmark.h deleted file mode 100644 index 9e96d64..0000000 --- a/libraries/eina/src/include/eina_benchmark.h +++ /dev/null @@ -1,453 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_BENCHMARK_H_ -#define EINA_BENCHMARK_H_ - -#include "eina_array.h" - - - -/** - * @page tutorial_benchmark_page Benchmark Tutorial - * - * The Benchmark module allows you to write easily benchmarks - * framework in a project for timing critical part and detect slow - * parts of code. In addition it automatically creates data files of - * these benchmark, as well as a gnuplot file which can display the - * comparison curves of the benchmarks. - * - * @section tutorial_benchmark_basic_usage Basic Usage - * - * To create a basic benchmark, you have to follow these steps: - * - * @li Create a new bechmark - * @li Write the functions that wraps the the functions you want to - * bechmark. - * @li Register these wrappers functions. - * @li Run the benchmark. - * @li Free the memory. - * - * Here is a basic example of bechmark which creates two functions - * that will be run. These functions just print a message. - * - * @code - * #include - * #include - * - * #include - * - * static - * void work1(int request) - * { - * printf ("work1 in progress... Request: %d\n", request); - * } - * - * static - * void work2(int request) - * { - * printf ("work2 in progress... Request: %d\n", request); - * } - * - * int main() - * { - * Eina_Benchmark *test; - * Eina_Array *ea; - * - * if (!eina_init()) - * return EXIT_FAILURE; - * - * test = eina_benchmark_new("test", "run"); - * if (!test) - * goto shutdown_eina; - * - * eina_benchmark_register(test, "work-1", EINA_BENCHMARK(work1), 200, 300, 10); - * eina_benchmark_register(test, "work-2", EINA_BENCHMARK(work2), 100, 150, 5); - * - * ea = eina_benchmark_run(test); - * - * eina_benchmark_free(test); - * eina_shutdown(); - * - * return EXIT_SUCCESS; - * - * shutdown_eina: - * eina_shutdown(); - * - * return EXIT_FAILURE; - * } - * @endcode - * - * As "test", "run" are passed to eina_benchmark_new() and as the tests - * "work-1" and "work-2" are registered, the data files - * bench_test_run.work-1.data and bench_test_run.work-2.data will be - * created after the eina_benchmark_run() call. They contain four - * columns. The file bench_test_run.work-1.data contains for example: - * - * @code - * # specimen experiment time starting time ending time - * 200 23632 2852446 2876078 - * 210 6924 2883046 2889970 - * 220 6467 2895962 2902429 - * 230 6508 2908271 2914779 - * 240 6278 2920610 2926888 - * 250 6342 2932830 2939172 - * 260 6252 2944954 2951206 - * 270 6463 2956978 2963441 - * 280 6347 2969548 2975895 - * 290 6457 2981702 2988159 - * @endcode - * - * The first column (specimen) is the integer passed to the work1() - * function when the test is run. The second column (experiment time) - * is the time, in nanosecond, that work1() takes. The third and - * fourth columnd are self-explicit. - * - * You can see that the integer passed work1() starts from 200 and - * finishes at 290, with a step of 10. These values are computed withe - * last 3 values passed to eina_benchmark_register(). See the document - * of that function for the detailed behavior. - * - * The gnuplot file will be named bench_test_run.gnuplot. Just run: - * - * @code - * gnuplot bench_test_run.gnuplot - * @endcode - * - * to create the graphic of the comparison curves. The image file is - * named output_test_run.png. - * - * @section tutorial_benchmark_advanced_usage More Advanced Usage - * - * In this section, several test will be created and run. The idea is - * exactly the same than in the previous section, but with some basic - * automatic way to run all the benchmarks. The following code - * benchmarks some Eina converts functions, and some Eina containers - * types: - * - * @code - * #include - * #include - * #include - * - * #include - * - * static void bench_convert(Eina_Benchmark *bench); - * static void bench_container(Eina_Benchmark *bench); - * - * typedef struct _Benchmark_Case Benchmark_Case; - * - * struct _Benchmark_Case - * { - * const char *bench_case; - * void (*build)(Eina_Benchmark *bench); - * }; - * - * static const Benchmark_Case benchmarks[] = { - * { "Bench 1", bench_convert }, - * { "Bench 2", bench_container }, - * { NULL, NULL } - * }; - * - * static - * void convert1(int request) - * { - * char tmp[128]; - * int i; - * - * srand(time(NULL)); - * - * for (i = 0; i < request; ++i) - * eina_convert_itoa(rand(), tmp); - * } - * - * static - * void convert2(int request) - * { - * char tmp[128]; - * int i; - * - * srand(time(NULL)); - * - * for (i = 0; i < request; ++i) - * eina_convert_xtoa(rand(), tmp); - * } - * - * static void - * bench_convert(Eina_Benchmark *bench) - * { - * eina_benchmark_register(bench, "convert-1", EINA_BENCHMARK(convert1), 200, 400, 10); - * eina_benchmark_register(bench, "convert-2", EINA_BENCHMARK(convert2), 200, 400, 10); - * } - * - * static - * void array(int request) - * { - * Eina_Array *array; - * Eina_Array_Iterator it; - * int *data; - * int i; - * - * srand(time(NULL)); - * - * array = eina_array_new(64); - * - * for (i = 0; i < request; ++i) - * { - * data = (int *)malloc(sizeof(int)); - * if (!data) continue; - * *data = rand(); - * eina_array_push(array, data); - * } - * - * EINA_ARRAY_ITER_NEXT(array, i, data, it) - * free(data); - * - * eina_array_free(array); - * } - * - * static - * void list(int request) - * { - * Eina_List *l = NULL; - * int *data; - * int i; - * - * srand(time(NULL)); - * - * for (i = 0; i < request; ++i) - * { - * data = (int *)malloc(sizeof(int)); - * if (!data) continue; - * *data = rand(); - * l = eina_list_prepend(l, data); - * } - * - * while (l) - * { - * free(eina_list_data_get(l)); - * l = eina_list_remove_list(l, l); - * } - * } - * - * static void - * bench_container(Eina_Benchmark *bench) - * { - * eina_benchmark_register(bench, "array", EINA_BENCHMARK(array), 200, 300, 10); - * eina_benchmark_register(bench, "list", EINA_BENCHMARK(list), 200, 300, 10); - * } - * - * int main() - * { - * Eina_Benchmark *test; - * Eina_Array *ea; - * unsigned int i; - * - * if (!eina_init()) - * return EXIT_FAILURE; - * - * for (i = 0; benchmarks[i].bench_case != NULL; ++i) - * { - * test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark example"); - * if (!test) - * continue; - * - * benchmarks[i].build(test); - * - * ea = eina_benchmark_run(test); - * - * eina_benchmark_free(test); - * } - * - * eina_shutdown(); - * - * return EXIT_SUCCESS; - * } - * @endcode - * - * gnuplot can be used to see how are performed the convert functions - * together, as well as how are performed the containers. So it is now - * easy to see that the hexadecimal convert function is faster than - * the decimal one, and that arrays are faster than lists. - * - * You can improve all that by executing automatically gnuplot in your - * program, or integrate the Eina benchmark framework in an autotooled - * project. See that - * page - * for more informations. - * - */ - - -/** - * @addtogroup Eina_Benchmark_Group Benchmark - * - * These functions allow you to add benchmark framework in a project - * for timing critical part and detect slow parts of code. It is used - * in Eina to compare the time used by eina, glib, evas and ecore data - * types. - * - * To use the benchmark module, Eina must be initialized with - * eina_init() and later shut down with eina_shutdown(). A benchmark - * is created with eina_benchmark_new() and freed with - * eina_benchmark_free(). - * - * eina_benchmark_register() adds a test to a benchmark. That test can - * be run a certain amount of times. Adding more than one test to be - * executed allows the comparison between several parts of a program, - * or different implementations. - * - * eina_benchmark_run() runs all the tests registered with - * eina_benchmark_register(). The amount of time of each test is - * written in a gnuplot file. - * - * For more information, you can look at the @ref tutorial_benchmark_page. - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Benchmark_Group Benchmark - * - * @{ - */ - -/** - * @typedef Eina_Benchmark - * Type for a benchmark. - */ -typedef struct _Eina_Benchmark Eina_Benchmark; - -/** - * @typedef Eina_Benchmark_Specimens - * Type for a test function to be called when running a benchmark. - */ -typedef void (*Eina_Benchmark_Specimens)(int request); - -/** - * @def EINA_BENCHMARK - * @brief cast to an #Eina_Benchmark_Specimens. - * - * @param function The function to cast. - * - * This macro casts @p function to Eina_Benchmark_Specimens. - */ -#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function) - - -/** - * @brief Create a new array. - * - * @param name The name of the benchmark. - * @param run The name of the run. - * @return @c NULL on failure, non @c NULL otherwise. - * - * This function creates a new benchmark. @p name and @p run are used - * to name the gnuplot file that eina_benchmark_run() will create. - * - * This function return a valid benchmark on success, or @c NULL if - * memory allocation fails. In that case, the error is set to - * #EINA_ERROR_OUT_OF_MEMORY. - * - * When the new module is not needed anymore, use - * eina_benchmark_free() to free the allocated memory. - */ -EAPI Eina_Benchmark *eina_benchmark_new(const char *name, - const char *run); - -/** - * @brief Free a benchmark object. - * - * @param bench The benchmark to free. - * - * This function removes all the benchmark tests that have been - * registered and frees @p bench. If @p bench is @c NULL, this - * function returns immediately. - */ -EAPI void eina_benchmark_free(Eina_Benchmark *bench); - -/** - * @brief Add a test to a benchmark. - * - * @param bench The benchmark. - * @param name The name of the test. - * @param bench_cb The test function to be called. - * @param count_start The start data to be passed to @p bench_cb. - * @param count_end The end data to be passed to @p bench_cb. - * @param count_step The step data to be passed to @p bench_cb. - * @return #EINA_FALSE on failure, #EINA_TRUE otherwise. - * - * This function adds the test named @p name to @p benchmark. @p - * bench_cb is the function called when the test is executed. That - * test can be executed a certain amount of time. @p count_start, @p count_end and - * @p count_step define a loop with a step increment. The integer that is - * increasing by @p count_step from @p count_start to @p count_end is passed to @p - * bench_cb when eina_benchmark_run() is called. - * - * If @p bench is @c NULL, this function returns imediatly. If the - * allocation of the memory of the test to add fails, the error is set - * to #EINA_ERROR_OUT_OF_MEMORY. This function returns #EINA_FALSE - * on failure, #EINA_TRUE otherwise. - */ -EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench, - const char *name, - Eina_Benchmark_Specimens bench_cb, - int count_start, - int count_end, - int count_step); - -/** - * @brief Run the benchmark tests that have been registered. - * - * @param bench The benchmark. - * @return The list of names of the test files. - * - * This function runs all the tests that as been registered with - * eina_benchmark_register() and save the result in a gnuplot - * file. The name of the file has the following format: - * - * @code - * bench_[name]_[run]%s.gnuplot - * @endcode - * - * where [name] and [run] are the values passed to - * eina_benchmark_new(). - * - * Each registered test is executed and timed. The time is written to - * the gnuplot file. The number of times each test is executed is - * controlled by the parameters passed to eina_benchmark_register(). - * - * If @p bench is @c NULL, this functions returns @c NULL - * immediately. Otherwise, it returns the list of the names of each - * test. - */ -EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_BENCHMARK_H_ */ diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h deleted file mode 100644 index 7c3524b..0000000 --- a/libraries/eina/src/include/eina_binbuf.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef EINA_BINBUF_H -#define EINA_BINBUF_H - -#include -#include - -#include "eina_types.h" - -/** - * @addtogroup Eina_Binary_Buffer_Group Binary Buffer - * - * @brief These functions provide string buffers management. - * - * The Binary Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_Binary_Buffer_Group Binary Buffer - * - * @{ - */ - -/** - * @typedef Eina_Binbuf - * Type for a string buffer. - */ -typedef struct _Eina_Strbuf Eina_Binbuf; - -/** - * @brief Create a new string buffer. - * - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_binbuf_free(). - * - * @see eina_binbuf_free() - * @see eina_binbuf_append() - * @see eina_binbuf_string_get() - */ -EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_binbuf_string_steal . The passed string must be malloced. - * - * @param str the string to manage - * @param length the length of the string. - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_binbuf_free(). - * - * @see eina_binbuf_manage_new() - * @since 1.2.0 - */ -EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free a string buffer. - * - * @param buf The string buffer to free. - * - * This function frees the memory of @p buf. @p buf must have been - * created by eina_binbuf_new(). - */ -EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Reset a string buffer. - * - * @param buf The string buffer to reset. - * - * This function reset @p buf: the buffer len is set to 0, and the - * string is set to '\\0'. No memory is free'd. - */ -EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Append a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_binbuf_append() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_binbuf_append() - * @see eina_binbuf_append_n() - */ -EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char *str, size_t length) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to append to. - * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf. If it can not insert it, - * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_ARG_NONNULL(1); - -/** - * @brief Insert a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param length The exact length to use. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_binbuf_insert() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_binbuf_insert() - * @see eina_binbuf_insert_n() - */ -EAPI Eina_Bool eina_binbuf_insert_length(Eina_Binbuf *buf, const unsigned char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to insert to. - * @param c The char to insert. - * @param pos The position to insert the char. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf at position @p pos. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t pos) EINA_ARG_NONNULL(1); - -/** - * @brief Remove a slice of the given string buffer. - * - * @param buf The string buffer to remove a slice. - * @param start The initial (inclusive) slice position to start - * removing, in bytes. - * @param end The final (non-inclusive) slice position to finish - * removing, in bytes. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function removes a slice of @p buf, starting at @p start - * (inclusive) and ending at @p end (non-inclusive). Both values are - * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. - */ - -EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve a pointer to the contents of a string buffer - * - * @param buf The string buffer. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. The returned - * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_binbuf_append() or similar will - * make that pointer invalid. - * - * @see eina_binbuf_string_steal() - */ -EAPI const unsigned char *eina_binbuf_string_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Steal the contents of a string buffer. - * - * @param buf The string buffer to steal. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. @p buf is - * then initialized and does not own the returned string anymore. The - * caller must release the memory of the returned string by calling - * free(). - * - * @see eina_binbuf_string_get() - */ -EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Free the contents of a string buffer but not the buffer. - * - * @param buf The string buffer to free the string of. - * - * This function frees the string contained in @p buf without freeing - * @p buf. - */ -EAPI void eina_binbuf_string_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve the length of the string buffer content. - * - * @param buf The string buffer. - * @return The current length of the string, in bytes. - * - * This function returns the length of @p buf. - */ -EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRBUF_H */ diff --git a/libraries/eina/src/include/eina_binshare.h b/libraries/eina/src/include/eina_binshare.h deleted file mode 100644 index 55b17a6..0000000 --- a/libraries/eina/src/include/eina_binshare.h +++ /dev/null @@ -1,193 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright (C) 2008 Peter Wehrfritz - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies of the Software and its Copyright notices. In addition publicly - * documented acknowledgment must be given that this software has been used if no - * source code of this software is made available publicly. This includes - * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing - * documents or any documentation provided with any product containing this - * software. This License does not apply to any software that links to the - * libraries provided by this software (statically or dynamically), but only to - * the software provided. - * - * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice - * and it's intent. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef EINA_BINSHARE_H_ -#define EINA_BINSHARE_H_ - -#include "eina_types.h" - -/** - * @page tutorial_binshare_page Binary Share Tutorial - * - * Should call eina_binshare_init() before usage and eina_binshare_shutdown() after. - * to be written... - * - */ - -/** - * @addtogroup Eina_Binshare_Group Binary Share - * - * These functions allow you to store one copy of an object, and use it - * throughout your program. - * - * This is a method to reduce the number of duplicated objects kept in - * memory. - * - * For more information, you can look at the @ref tutorial_binshare_page. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_Binshare_Group Binary Share - * - * @{ - */ - - -/** - * @brief Retrieve an instance of an object for use in a program. - * - * @param obj The binary object to retrieve an instance of. - * @param olen The byte size - * @return A pointer to an instance of the object on success. - * @c NULL on failure. - * - * This function retrieves an instance of @p obj. If @p obj is - * @c NULL, then @c NULL is returned. If @p obj is already stored, it - * is just returned and its reference counter is increased. Otherwise - * it is added to the objects to be searched and a duplicated object - * of @p obj is returned. - * - * This function does not check object size, but uses the - * exact given size. This can be used to share part of a larger - * object or subobject. - * - * @see eina_binshare_add() - */ -EAPI const void *eina_binshare_add_length(const void *obj, - unsigned int olen) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * Increment references of the given shared object. - * - * @param obj The shared object. - * @return A pointer to an instance of the object on success. - * @c NULL on failure. - * - * This is similar to eina_share_common_add(), but it's faster since it will - * avoid lookups if possible, but on the down side it requires the parameter - * to be shared before, in other words, it must be the return of a previous - * eina_binshare_add(). - * - * There is no unref since this is the work of eina_binshare_del(). - */ -EAPI const void *eina_binshare_ref(const void *obj); - -/** - * @brief Note that the given object has lost an instance. - * - * @param obj object The given object. - * - * This function decreases the reference counter associated to @p obj - * if it exists. If that counter reaches 0, the memory associated to - * @p obj is freed. If @p obj is NULL, the function returns - * immediately. - * - * Note that if the given pointer is not shared or NULL, bad things - * will happen, likely a segmentation fault. - */ -EAPI void eina_binshare_del(const void *obj); - -/** - * @brief Note that the given object @b must be shared. - * - * @param obj the shared object to know the length. It is safe to - * give NULL, in that case -1 is returned. - * @return The length of the shared object. - * - * This function is a cheap way to known the length of a shared - * object. Note that if the given pointer is not shared, bad - * things will happen, likely a segmentation fault. If in doubt, try - * strlen(). - */ -EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Dump the contents of the share_common. - * - * This function dumps all objects in the share_common to stdout with a - * DDD: prefix per line and a memory usage summary. - */ -EAPI void eina_binshare_dump(void); - -/** - * @brief Retrieve an instance of a blob for use in a program. - * - * @param ptr The binary blob to retrieve an instance of. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * This macro retrieves an instance of @p obj. If @p obj is - * @c NULL, then @c NULL is returned. If @p obj is already stored, it - * is just returned and its reference counter is increased. Otherwise - * it is added to the blobs to be searched and a duplicated blob - * of @p obj is returned. - * - * This macro essentially calls eina_binshare_add_length with ptr and sizeof(*ptr) - * as the parameters. It's useful for pointers to structures. - * - * @see eina_stringshare_add_length() - */ -#define eina_binshare_add(ptr) eina_binshare_add_length(ptr, sizeof(*ptr)) - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRINGSHARE_H_ */ diff --git a/libraries/eina/src/include/eina_clist.h b/libraries/eina/src/include/eina_clist.h deleted file mode 100644 index 096a4b7..0000000 --- a/libraries/eina/src/include/eina_clist.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Linked lists support - * - * Copyright (C) 2002 Alexandre Julliard - * Copyright (C) 2011 Mike McCormack (adapted for Eina) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __EINA_CLIST_H__ -#define __EINA_CLIST_H__ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_CList_Group Compact List - * - * @{ - * - * @brief Eina_Clist is a compact (inline) list implementation - * - * Elements of this list are members of the structs stored in the list - * - * Advantages over @ref Eina_List and @ref Eina_Inlist: - * - uses less memory (two machine words per item) - * - 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 - * - * Disadvantages: - * - O(N) time to calculate list length - * - requires one list entry in a struct per list (i.e. it's an inlist) - * - requires a head/tail pointer - * - need to know the list head when moving to next or previous pointer - * - * @note There's no NULL at the end of the list, the last item points to the head. - * - * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init - * - * Define a list like so: - * - * @code - * struct gadget - * { - * struct Eina_Clist entry; <-- doesn't have to be the first item in the struct - * int a, b; - * }; - * - * static Eina_Clist global_gadgets = EINA_CLIST_INIT( global_gadgets ); - * @endcode - * - * or - * - * @code - * struct some_global_thing - * { - * Eina_Clist gadgets; - * }; - * - * eina_clist_init( &some_global_thing->gadgets ); - * @endcode - * - * Manipulate it like this: - * - * @code - * eina_clist_add_head( &global_gadgets, &new_gadget->entry ); - * eina_clist_remove( &new_gadget->entry ); - * eina_clist_add_after( &some_random_gadget->entry, &new_gadget->entry ); - * @endcode - * - * And to iterate over it: - * - * @code - * struct gadget *gadget; - * EINA_CLIST_FOR_EACH_ENTRY( gadget, &global_gadgets, struct gadget, entry ) - * { - * ... - * } - * @endcode - * - */ - -/** - * @typedef Eina_Clist - * This is the list head and the list entry. - * @since 1.1.0 - */ -typedef struct _Eina_Clist Eina_Clist; - -/** - * @struct _Eina_Clist - * Compact list type - * @note This structure is used as both the list head and the list entry. - * @since 1.1.0 - */ -struct _Eina_Clist -{ - Eina_Clist *next; - Eina_Clist *prev; -}; - -/** - * Add an element after the specified one. - * - * @param elem An element in 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 element is not in any list. - * - * @note There's no need to initialize an element before adding it to the list. - * @since 1.1.0 - */ -static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add); - -/** - * Add an element before the specified one. - * - * @param elem An element in 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 element is not in any list. - * - * @note There's no need to initialize an element before adding it to the list. - * @since 1.1.0 - */ -static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add); - -/** - * Add element at the head of the list. - * - * @param list The list - * @param elem An element - * @pre The list head must be initialized once before adding anything. - * @pre The element is not in any list. - * - * @note There's no need to initialize an element before adding it to the list. - * @since 1.1.0 - */ -static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem); - -/** - * Add element at the tail of the list. - * - * @param list The list - * @param elem An element - * @pre The list head must be initialized once before adding anything. - * @pre The element is not in any list. - * - * @note There's no need to initialize an element before adding it to the list. - * @since 1.1.0 - */ -static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem); - -/** - * Init an (unlinked) element. - * - * Call this function on elements that have not been added to the list - * if you want eina_clist_element_init() to work correctly - * - * @param elem An element - * @pre The element is not 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. - * @since 1.1.0 - */ -static inline void eina_clist_element_init(Eina_Clist *elem); - -/** - * Check if an element is in a list or not. - * - * @param elem An element - * - * @pre Either eina_clist_element_init() has been called on @a elem, - * it has been added to a list or remove from a list. - * @since 1.1.0 - */ -static inline int eina_clist_element_is_linked(Eina_Clist *elem); - -/** - * Remove an element from its list. - * - * @param elem An element - * @pre The element is in a list already - * @post The element is marked as not being in any list - * @since 1.1.0 - */ -static inline void eina_clist_remove(Eina_Clist *elem); - -/** - * Get the next element. - * - * @param list The list - * @param elem An element - * @pre @a elem is in @a list - * @return The element after @a elem in @a list or @c NULL if @a elem is last in @a list - * @since 1.1.0 - */ -static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem); - -/** - * Get the previous element. - * - * @param list The list - * @param elem An element - * - * @return The element before @a elem or NULL if @a elem is the first in the list - * @since 1.1.0 - */ -static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem); - -/** - * Get the first element. - * - * @param list The list - * @returns The first element in @a list or NULL if @a list is empty - * @since 1.1.0 - */ -static inline Eina_Clist *eina_clist_head(const Eina_Clist *list); - -/** - * Get the last element. - * - * @param list The list - * @returns The last element in @a list or NULL if @a list is empty - * @since 1.1.0 - */ -static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list); - -/** - * Check if a list is empty. - * - * @param list The list - * @returns non-zero if @a list is empty, zero if it is not - * @since 1.1.0 - */ -static inline int eina_clist_empty(const Eina_Clist *list); - -/** - * Initialize a list - * - * @param list The list - * @pre The list is uninitialized - * @post The list contains no items - * - * @note Don't call this function on a list with items - * @note This function must be called. Don't try do - * initialize the list by zero'ing out the list head. - * @since 1.1.0 - */ -static inline void eina_clist_init(Eina_Clist *list); - -/** - * Count the elements of a list - * - * @param list The list - * @returns The number of items in the list - * @since 1.1.0 - */ -static inline unsigned int eina_clist_count(const Eina_Clist *list); - -/** - * Move all elements from src to the tail of dst - * - * @param dst List to be appended to - * @param src List to append - * - * @post @a src is initialized but empty after this operation - * @since 1.1.0 - */ -static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src); - -/** - * move all elements from src to the head of dst - * - * @param dst List to be prepended to - * @param src List to prepend - * - * @post @a src is initialized but empty after this operation - * @since 1.1.0 - */ -static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src); - -/** - * iterate through the list - */ -#define EINA_CLIST_FOR_EACH(cursor,list) \ - for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next) - -/* iterate through the list, with safety against removal */ -#define EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) \ - for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \ - (cursor) != (list); \ - (cursor) = (cursor2), (cursor2) = (cursor)->next) - -/* iterate through the list using a list entry */ -#define EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) \ - for ((elem) = EINA_CLIST_ENTRY((list)->next, type, field); \ - &(elem)->field != (list); \ - (elem) = EINA_CLIST_ENTRY((elem)->field.next, type, field)) - -/* iterate through the list using a list entry, with safety against removal */ -#define EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field) \ - for ((cursor) = EINA_CLIST_ENTRY((list)->next, type, field), \ - (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field); \ - &(cursor)->field != (list); \ - (cursor) = (cursor2), \ - (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field)) - -/* iterate through the list in reverse order */ -#define EINA_CLIST_FOR_EACH_REV(cursor,list) \ - for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev) - -/* iterate through the list in reverse order, with safety against removal */ -#define EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \ - for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \ - (cursor) != (list); \ - (cursor) = (cursor2), (cursor2) = (cursor)->prev) - -/* iterate through the list in reverse order using a list entry */ -#define EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \ - for ((elem) = EINA_CLIST_ENTRY((list)->prev, type, field); \ - &(elem)->field != (list); \ - (elem) = EINA_CLIST_ENTRY((elem)->field.prev, type, field)) - -/* iterate through the list in reverse order using a list entry, with safety against removal */ -#define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field) \ - for ((cursor) = EINA_CLIST_ENTRY((list)->prev, type, field), \ - (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field); \ - &(cursor)->field != (list); \ - (cursor) = (cursor2), \ - (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field)) - -/* macros for statically initialized lists */ -#undef EINA_CLIST_INIT -#define EINA_CLIST_INIT(list) { &(list), &(list) } - -/* get pointer to object containing list element */ -#undef EINA_CLIST_ENTRY -#define EINA_CLIST_ENTRY(elem, type, field) \ - ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) - -#include "eina_inline_clist.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* __EINA_CLIST_H__ */ diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h deleted file mode 100644 index b1108b6..0000000 --- a/libraries/eina/src/include/eina_config.h +++ /dev/null @@ -1,86 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_CONFIG_H_ -#define EINA_CONFIG_H_ - -#ifdef EINA_HAVE_EXOTIC_H -# undef EINA_HAVE_EXOTIC_H -#endif - - -#ifdef EINA_HAVE_EXOTIC -# include -#endif - -#ifdef EINA_MAGIC_DEBUG -# undef EINA_MAGIC_DEBUG -#endif -#define EINA_MAGIC_DEBUG - -#ifdef EINA_DEFAULT_MEMPOOL -# undef EINA_DEFAULT_MEMPOOL -#endif - - -#ifdef EINA_SAFETY_CHECKS -# undef EINA_SAFETY_CHECKS -#endif -#define EINA_SAFETY_CHECKS - -#ifdef EINA_HAVE_INTTYPES_H -# undef EINA_HAVE_INTTYPES_H -#endif -#define EINA_HAVE_INTTYPES_H - -#ifdef EINA_HAVE_STDINT_H -# undef EINA_HAVE_STDINT_H -#endif -#define EINA_HAVE_STDINT_H - -#ifdef EINA_HAVE_THREADS -# undef EINA_HAVE_THREADS -#endif -#define EINA_HAVE_THREADS - -#ifdef EINA_HAVE_DEBUG_THREADS -# undef EINA_HAVE_DEBUG_THREADS -#endif - - -#ifdef EINA_SIZEOF_WCHAR_T -# undef EINA_SIZEOF_WCHAR_T -#endif -#define EINA_SIZEOF_WCHAR_T 4 - -#ifdef EINA_HAVE_ON_OFF_THREADS -# undef EINA_HAVE_ON_OFF_THREADS -#endif - - -#ifdef EINA_CONFIGURE_HAVE_DIRENT_H -# undef EINA_CONFIGURE_HAVE_DIRENT_H -#endif -#define EINA_HAVE_DIRENT_H - -#ifdef EINA_CONFIGURE_ENABLE_LOG -# undef EINA_CONFIGURE_ENABLE_LOG -#endif -#define EINA_ENABLE_LOG - -#endif /* EINA_CONFIG_H_ */ diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in deleted file mode 100644 index 937d208..0000000 --- a/libraries/eina/src/include/eina_config.h.in +++ /dev/null @@ -1,86 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_CONFIG_H_ -#define EINA_CONFIG_H_ - -#ifdef EINA_HAVE_EXOTIC_H -# undef EINA_HAVE_EXOTIC_H -#endif -@EINA_CONFIGURE_HAVE_EXOTIC@ - -#ifdef EINA_HAVE_EXOTIC -# include -#endif - -#ifdef EINA_MAGIC_DEBUG -# undef EINA_MAGIC_DEBUG -#endif -@EINA_CONFIGURE_MAGIC_DEBUG@ - -#ifdef EINA_DEFAULT_MEMPOOL -# undef EINA_DEFAULT_MEMPOOL -#endif -@EINA_CONFIGURE_DEFAULT_MEMPOOL@ - -#ifdef EINA_SAFETY_CHECKS -# undef EINA_SAFETY_CHECKS -#endif -@EINA_CONFIGURE_SAFETY_CHECKS@ - -#ifdef EINA_HAVE_INTTYPES_H -# undef EINA_HAVE_INTTYPES_H -#endif -@EINA_CONFIGURE_HAVE_INTTYPES_H@ - -#ifdef EINA_HAVE_STDINT_H -# undef EINA_HAVE_STDINT_H -#endif -@EINA_CONFIGURE_HAVE_STDINT_H@ - -#ifdef EINA_HAVE_THREADS -# undef EINA_HAVE_THREADS -#endif -@EINA_CONFIGURE_HAVE_THREADS@ - -#ifdef EINA_HAVE_DEBUG_THREADS -# undef EINA_HAVE_DEBUG_THREADS -#endif -@EINA_CONFIGURE_HAVE_DEBUG_THREADS@ - -#ifdef EINA_SIZEOF_WCHAR_T -# undef EINA_SIZEOF_WCHAR_T -#endif -#define EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@ - -#ifdef EINA_HAVE_ON_OFF_THREADS -# undef EINA_HAVE_ON_OFF_THREADS -#endif -@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ - -#ifdef EINA_CONFIGURE_HAVE_DIRENT_H -# undef EINA_CONFIGURE_HAVE_DIRENT_H -#endif -@EINA_CONFIGURE_HAVE_DIRENT_H@ - -#ifdef EINA_CONFIGURE_ENABLE_LOG -# undef EINA_CONFIGURE_ENABLE_LOG -#endif -@EINA_CONFIGURE_ENABLE_LOG@ - -#endif /* EINA_CONFIG_H_ */ diff --git a/libraries/eina/src/include/eina_convert.h b/libraries/eina/src/include/eina_convert.h deleted file mode 100644 index af839e2..0000000 --- a/libraries/eina/src/include/eina_convert.h +++ /dev/null @@ -1,374 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric BAIL, Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_CONVERT_H_ -#define EINA_CONVERT_H_ - -#include "eina_types.h" -#include "eina_error.h" - -#include "eina_fp.h" - - -/** - * @addtogroup Eina_Convert_Group Convert - * - * These functions allow you to convert integer or real numbers to - * string or conversely. - * - * To use these functions, you have to call eina_init() - * first, and eina_shutdown() when eina is not used anymore. - * - * @section Eina_Convert_From_Integer_To_Sring Conversion from integer to string - * - * To convert an integer to a string in the decimal base, - * eina_convert_itoa() should be used. If the hexadecimal base is - * wanted, eina_convert_xtoa() should be used. They all need a bufffer - * sufficiently large to store all the cyphers. - * - * Here is an example of use: - * - * @code - * #include - * #include - * - * #include - * - * int main(void) - * { - * char tmp[128]; - * - * if (!eina_init()) - * { - * printf ("Error during the initialization of eina.\n"); - * return EXIT_FAILURE; - * } - * - * eina_convert_itoa(45, tmp); - * printf("value: %s\n", tmp); - * eina_convert_xtoa(0xA1, tmp); - * printf("value: %s\n", tmp); - * - * eina_shutdown(); - * - * return EXIT_SUCCESS; - * } - * @endcode - * - * Compile this code with the following command: - * - * @code - * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina` - * @endcode - * - * @note - * The alphabetical cyphers are in lower case. - * - * @section Eina_Convert_Double Conversion double / string - * - * To convert a double to a string, eina_convert_dtoa() should be - * used. Like with the integer functions, a buffer must be used. The - * resulting string ghas the following format (which is the result - * obtained with snprintf() and the @%a modifier): - * - * @code - * [-]0xh.hhhhhp[+-]e - * @endcode - * - * To convert a string to a double, eina_convert_atod() should be - * used. The format of the string must be as above. Then, the double - * has the following mantiss and exponent: - * - * @code - * mantiss : [-]hhhhhh - * exponent : 2^([+-]e - 4 * n) - * @endcode - * - * with n being number of cypers after the point in the string - * format. To obtain the double number from the mantiss and exponent, - * use ldexp(). - * - * Here is an example of use: - * - * @code - * #include - * #include - * #include - * - * #include - * - * int main(void) - * { - * char tmp[128]; - * long long int m = 0; - * long int e = 0; - * double r; - * - * if (!eina_init()) - * { - * printf ("Error during the initialization of eina.\n"); - * return EXIT_FAILURE; - * } - * - * printf("initial value : 40.56\n"); - * eina_convert_dtoa(40.56, tmp); - * printf("result dtoa : %s\n", tmp); - - * eina_convert_atod(tmp, 128, &m, &e); - * r = ldexp((double)m, e); - * printf("result atod : %f\n", r); - * - * eina_shutdown(); - * - * return EXIT_SUCCESS; - * } - * @endcode - * - * Compile this code with the following command: - * - * @code - * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina` -lm - * @endcode - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Convert_Group Convert - * - * @{ - */ - -/** - * @var EINA_ERROR_CONVERT_P_NOT_FOUND - * Error identifier corresponding to string not containing 'p'. - */ - -EAPI extern Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND; - -/** - * @var EINA_ERROR_CONVERT_0X_NOT_FOUND - * Error identifier corresponding to string not containing '0x'. - */ -EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND; - -/** - * @var EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH - * Error identifier corresponding to length of the string being too small. - */ -EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH; - -/** - * @brief Convert an integer number to a string in decimal base. - * - * @param n The integer to convert. - * @param s The buffer to store the converted integer. - * @return The length of the string, including the nul terminated - * character. - * - * This function converts @p n to a nul terminated string. The - * converted string is in decimal base. As no check is done, @p s must - * be a buffer that is sufficiently large to store the integer. - * - * The returned value is the length of the string, including the nul - * terminated character. - */ -EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2); - -/** - * @brief Convert an integer number to a string in hexadecimal base. - * - * @param n The integer to convert. - * @param s The buffer to store the converted integer. - * @return The length of the string, including the nul terminated - * character. - * - * This function converts @p n to a nul terminated string. The - * converted string is in hexadecimal base and the alphabetical - * cyphers are in lower case. As no check is done, @p s must be a - * buffer that is sufficiently large to store the integer. - * - * The returned value is the length of the string, including the nul - * terminated character. - */ -EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2); - - -/** - * @brief Convert a double to a string. - * - * @param d The double to convert. - * @param des The destination buffer to store the converted double. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function converts the double @p d to a string. The string is - * stored in the buffer pointed by @p des and must be sufficiently - * large to contain the converted double. The returned string is nul - * terminated and has the following format: - * - * @code - * [-]0xh.hhhhhp[+-]e - * @endcode - * - * where the h are the hexadecimal cyphers of the mantiss and e the - * exponent (a decimal number). - * - * The returned value is the length of the string, including the nul - * character. - */ -EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2); - -/** - * @brief Convert a string to a double. - * - * @param src The string to convert. - * @param length The length of the string. - * @param m The mantisse. - * @param e The exponent. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function converts the string @p s of length @p length that - * represent a double in hexadecimal base to a double. It is used to - * replace the use of snprintf() with the \%a modifier, which is - * missing on some platform (like Windows (tm) or OpenBSD). - * - * The string must have the following format: - * - * @code - * [-]0xh.hhhhhp[+-]e - * @endcode - * - * where the h are the hexadecimal cyphers of the mantiss and e the - * exponent (a decimal number). If n is the number of cypers after the - * point, the returned mantiss and exponents are: - * - * @code - * mantiss : [-]hhhhhh - * exponent : 2^([+-]e - 4 * n) - * @endcode - * - * The mantiss and exponent are stored in the buffers pointed - * respectively by @p m and @p e. - * - * If the string is invalid, the error is set to: - * - * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found, - * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found, - * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not - * correct. - * - * In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_convert_atod(const char *src, - int length, - long long *m, - long *e) EINA_ARG_NONNULL(1, 3, 4); - - -/** - * @brief Convert a 32.32 fixed point number to a string. - * - * @param fp The fixed point number to convert. - * @param des The destination buffer to store the converted fixed point number. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function converts the 32.32 fixed point number @p fp to a - * string. The string is stored in the buffer pointed by @p des and - * must be sufficiently large to contain the converted fixed point - * number. The returned string is terminated and has the following - * format: - * - * @code - * [-]0xh.hhhhhp[+-]e - * @endcode - * - * where the h are the hexadecimal cyphers of the mantiss and e the - * exponent (a decimal number). - * - * The returned value is the length of the string, including the nul - * character. - * - * @note The code is the same than eina_convert_dtoa() except that it - * implements the frexp() function for fixed point numbers and does - * some optimisations. - */ -EAPI int eina_convert_fptoa(Eina_F32p32 fp, - char *des) EINA_ARG_NONNULL(2); - -/** - * @brief Convert a string to a 32.32 fixed point number. - * - * @param src The string to convert. - * @param length The length of the string. - * @param fp The fixed point number. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function converts the string @p src of length @p length that - * represent a double in hexadecimal base to a 32.32 fixed point - * number stored in @p fp. The function always tries to convert the - * string with eina_convert_atod(). - * - * The string must have the following format: - * - * @code - * [-]0xh.hhhhhp[+-]e - * @endcode - * - * where the h are the hexadecimal cyphers of the mantiss and e the - * exponent (a decimal number). If n is the number of cypers after the - * point, the returned mantiss and exponents are: - * - * @code - * mantiss : [-]hhhhhh - * exponent : 2^([+-]e - 4 * n) - * @endcode - * - * The mantiss and exponent are stored in the buffers pointed - * respectively by @p m and @p e. - * - * If the string is invalid, the error is set to: - * - * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found, - * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found, - * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not - * correct. - * - * In those cases, or if @p fp is @c NULL, #EINA_FALSE is returned, - * otherwise @p fp is computed and #EINA_TRUE is returned. - * - * @note The code uses eina_convert_atod() and do the correct bit - * shift to compute the fixed point number. - */ -EAPI Eina_Bool eina_convert_atofp(const char *src, - int length, - Eina_F32p32 *fp) EINA_ARG_NONNULL(1, 3); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_CONVERT_H_ */ diff --git a/libraries/eina/src/include/eina_counter.h b/libraries/eina/src/include/eina_counter.h deleted file mode 100644 index 26bee06..0000000 --- a/libraries/eina/src/include/eina_counter.h +++ /dev/null @@ -1,213 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_COUNTER_H_ -#define EINA_COUNTER_H_ - -#include "eina_types.h" - -/** - * @addtogroup Eina_Counter_Group Counter - * - * @brief These functions allow you to get the time spent in a part of a code. - * - * Before using the counter system, Eina must be initialized with - * eina_init() and later shut down with eina_shutdown(). The create a - * counter, use eina_counter_new(). To free it, use - * eina_counter_free(). - * - * To time a part of a code, call eina_counter_start() just before it, - * and eina_counter_stop() just after it. Each time you start to time - * a code, a clock is added to a list. You can give a number of that - * clock with the second argument of eina_counter_stop(). To send all - * the registered clocks to a stream (like stdout, ofr a file), use - * eina_counter_dump(). - * - * Here is a straightforward example: - * - * @code - * #include - * #include - * - * #include - * - * void test_malloc(void) - * { - * int i; - * - * for (i = 0; i < 100000; ++i) - * { - * void *buf; - * - * buf = malloc(100); - * free(buf); - * } - * } - * - * int main(void) - * { - * Eina_Counter *counter; - * - * if (!eina_init()) - * { - * printf("Error during the initialization of eina\n"); - * return EXIT_FAILURE; - * } - * - * counter = eina_counter_new("malloc"); - * - * eina_counter_start(counter); - * test_malloc(); - * eina_counter_stop(counter, 1); - * - * char* result = eina_counter_dump(counter); - * printf("%s", result); - * free(result); - * - * eina_counter_free(counter); - * eina_shutdown(); - * - * return EXIT_SUCCESS; - * } - * @endcode - * - * Compile this code with the following commant: - * - * @verbatim - * gcc -Wall -o test_eina_counter test_eina.c `pkg-config --cflags --libs eina` - * @endverbatim - * - * The result should be something like that: - * - * @verbatim - * \# specimen experiment time starting time ending time - * 1 9794125 783816 10577941 - * @endverbatim - * - * Note that the displayed time is in nanosecond. - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Counter_Group Counter - * - * @{ - */ - -/** - * @typedef Eina_Counter - * Counter type. - */ -typedef struct _Eina_Counter Eina_Counter; - - -/** - * @brief Return a counter. - * - * @param name The name of the counter. - * @return A newly allocated counter. - * - * This function returns a new counter. It is characterized by @p - * name. If @p name is @c NULL, the function returns @c NULL - * immediately. If memory allocation fails, @c NULL is returned and the - * error is set to #EINA_ERROR_OUT_OF_MEMORY. - * - * Whe the new counter is not needed anymore, use eina_counter_free() to - * free the allocated memory. - */ -EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Delete a counter. - * - * @param counter The counter to delete. - * - * This function remove the clock of @p counter from the used clocks - * (see eina_counter_start()) and frees the memory allocated for - * @p counter. If @p counter is @c NULL, the function returns - * immediately. - */ -EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1); - -/** - * @brief Start the time count. - * - * @param counter The counter. - * - * This function specifies that the part of the code beginning just - * after its call is being to be timed, using @p counter. If - * @p counter is @c NULL, this function returns immediately. - * - * This function adds the clock associated to @p counter in a list. If - * the memory needed by that clock can not be allocated, the function - * returns and the error is set to #EINA_ERROR_OUT_OF_MEMORY. - * - * To stop the timing, eina_counter_stop() must be called with the - * same counter. - */ -EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1); - -/** - * @brief Stop the time count. - * - * @param counter The counter. - * @param specimen The number of the test. - * - * This function stop the timing that has been started with - * eina_counter_start(). @p counter must be the same than the one used - * with eina_counter_start(). @p specimen is the number of the - * test. If @p counter or its associated clock are @c NULL, or if the - * time can't be retrieved the function exits. - */ -EAPI void eina_counter_stop(Eina_Counter *counter, - int specimen) EINA_ARG_NONNULL(1); - -/** - * @brief Dump the result of all clocks of a counter to a stream. - * - * @return A string with a summary of the test. - * @param counter The counter. - * - * This function returns an malloc'd string containing the dump of - * all the valid clocks of @p counter. - * If @p counter @c NULL, the functions exits - * immediately. Otherwise, the output is formattted like that: - * - * @verbatim - * \# specimen experiment time starting time ending time - * 1 208 120000 120208 - * @endverbatim - * - * The unit of time is the nanosecond. - */ -EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_COUNTER_H_ */ diff --git a/libraries/eina/src/include/eina_cpu.h b/libraries/eina/src/include/eina_cpu.h deleted file mode 100644 index ac32e1d..0000000 --- a/libraries/eina/src/include/eina_cpu.h +++ /dev/null @@ -1,39 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_CPU_H_ -#define EINA_CPU_H_ - -#include "eina_types.h" - -typedef enum _Eina_Cpu_Features -{ - EINA_CPU_MMX = 0x00000001, - EINA_CPU_SSE = 0x00000002, - EINA_CPU_SSE2 = 0x00000004, - EINA_CPU_SSE3 = 0x00000008, - /* TODO 3DNow! */ - EINA_CPU_ALTIVEC = 0x00000010, - EINA_CPU_VIS = 0x00000020, - EINA_CPU_NEON = 0x00000040, -} Eina_Cpu_Features; - -EAPI Eina_Cpu_Features eina_cpu_features_get(void); -EAPI int eina_cpu_count(void); - -#endif /* EINA_CPU_H_ */ diff --git a/libraries/eina/src/include/eina_error.h b/libraries/eina/src/include/eina_error.h deleted file mode 100644 index dd87edf..0000000 --- a/libraries/eina/src/include/eina_error.h +++ /dev/null @@ -1,198 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_ERROR_H_ -#define EINA_ERROR_H_ - -#include - -#include "eina_types.h" - - -/** - * @page tutorial_error_page Error Tutorial - * - * @section tutorial_error_registering_msg Registering messages - * - * The error module can provide a system that mimics the errno system - * of the C standard library. It consists in 2 parts: - * - * @li a way of registering new messages with - * eina_error_msg_register() and eina_error_msg_get(), - * @li a way of setting / getting last error message with - * eina_error_set() / eina_error_get(). - * - * So one has to fisrt register all the error messages that a program - * or a lib should manage. Then, when an error can occur, use - * eina_error_set(), and when errors are managed, use - * eina_error_get(). If eina_error_set() is used to set an error, do - * not forget to call before eina_error_set(), to remove previous set - * errors. - * - * Here is an example of use: - * - * @include eina_error_01.c - * - * Of course, instead of printf(), eina_log_print() can be used to - * have beautiful error messages. - */ - -/** - * @addtogroup Eina_Error_Group Error - * - * @brief These functions provide error management for projects. - * - * The Eina error module provides a way to manage errors in a simple but - * powerful way in libraries and modules. It is also used in Eina itself. - * Similar to libC's @c errno and strerror() facilities, this is extensible and - * recommended for other libraries and applications. - * - * A simple example of how to use this can be seen @ref tutorial_error_page - * "here". - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Error_Group Error - * - * @{ - */ - -/** - * @typedef Eina_Error - * Error type. - */ -typedef int Eina_Error; - -/** - * @var EINA_ERROR_OUT_OF_MEMORY - * Error identifier corresponding to a lack of memory. - */ - -EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY; - -/** - * @brief Register a new error type. - * - * @param msg The description of the error. It will be duplicated using - * eina_stringshare_add(). - * @return The unique number identifier for this error. - * - * This function stores in a list the error message described by - * @p msg. The returned value is a unique identifier greater or equal - * than 1. The description can be retrieve later by passing to - * eina_error_msg_get() the returned value. - * - * @see eina_error_msg_static_register() - */ -EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Register a new error type, statically allocated message. - * - * @param msg The description of the error. This string will not be - * duplicated and thus the given pointer should live during - * usage of eina_error. - * @return The unique number identifier for this error. - * - * This function stores in a list the error message described by - * @p msg. The returned value is a unique identifier greater or equal - * than 1. The description can be retrieve later by passing to - * eina_error_msg_get() the returned value. - * - * @see eina_error_msg_register() - */ -EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Change the message of an already registered message - * - * @param error The Eina_Error to change the message of - * @param msg The description of the error. This string will be - * duplicated only if the error was registered with @ref eina_error_msg_register - * otherwise it must remain intact for the duration. - * @return EINA_TRUE if successful, EINA_FALSE on error - * - * This function modifies the message associated with @p error and changes - * it to @p msg. If the error was previously registered by @ref eina_error_msg_static_register - * then the string will not be duplicated, otherwise the previous message - * will be unrefed and @p msg copied. - * - * @see eina_error_msg_register() - */ -EAPI Eina_Bool eina_error_msg_modify(Eina_Error error, - const char *msg) EINA_ARG_NONNULL(2); - -/** - * @brief Return the last set error. - * - * @return The last error. - * - * This function returns the last error set by eina_error_set(). The - * description of the message is returned by eina_error_msg_get(). - */ -EAPI Eina_Error eina_error_get(void); - -/** - * @brief Set the last error. - * - * @param err The error identifier. - * - * This function sets the last error identifier. The last error can be - * retrieved with eina_error_get(). - * - * @note This is also used to clear previous errors, in that case @p err should - * be @c 0. - */ -EAPI void eina_error_set(Eina_Error err); - -/** - * @brief Return the description of the given an error number. - * - * @param error The error number. - * @return The description of the error. - * - * This function returns the description of an error that has been - * registered with eina_error_msg_register(). If an incorrect error is - * given, then @c NULL is returned. - */ -EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE; - -/** - * @brief Find the #Eina_Error corresponding to a message string - * @param msg The error message string to match (NOT @c NULL) - * @return The #Eina_Error matching @p msg, or 0 on failure - * This function attempts to match @p msg with its corresponding #Eina_Error value. - * If no such value is found, 0 is returned. - */ -EAPI Eina_Error eina_error_find(const char *msg) EINA_ARG_NONNULL(1) EINA_PURE; - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_ERROR_H_ */ diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h deleted file mode 100644 index 1af22af..0000000 --- a/libraries/eina/src/include/eina_file.h +++ /dev/null @@ -1,483 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * 2011 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_FILE_H_ -#define EINA_FILE_H_ - -#include -#include -#include - -#include "eina_types.h" -#include "eina_array.h" -#include "eina_iterator.h" - - -/** - * @page eina_file_example_01_page - * @dontinclude eina_file_01.c - * - * For brevity includes, variable declarations and initialization was omitted - * from this page, however the full source code can be seen @ref - * eina_file_example_01 "here". - * - * Here we have a simple callback to print the name of a file and the path that - * contains it: - * @skip static - * @until } - * - * We can use this callback in the following call: - * @skipline eina_file_dir_list - * - * The above was a way to print the files in a directory, but it is not the only - * one: - * @until iterator_free - * - * And now two ways to get more information than just file names: - * @until iterator_free - * @until iterator_free - * - * The above ways of getting files on a list may produce the same output, but - * they have an important difference, eina_file_direct_ls() will @b not call - * stat, this means that on some systems it might not have file type - * information. On the other hand it might be faster than eina_file_stat_ls(). - */ -/** - * @page eina_file_example_01 - * @include eina_file_01.c - * @example eina_file_01.c - */ -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ -/** - * @addtogroup Eina_File_Group File - * - * @brief Functions to handle files and directories. - * - * This functions make it easier to do a number o file and directory operations - * such as getting the list of files in a directory, spliting paths and finding - * out file size and type. - * - * @warning All functions in this group are @b blocking which means they make - * take a long time to return, use them carefully. - * - * See an example @ref eina_file_example_01_page "here". - * - * @{ - */ - -/** - * @typedef Eina_File_Direct_Info - * A typedef to #_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 - * Type for a callback to be called when iterating over the files of a - * directory. - * @param The file name EXCLUDING the path - * @param path The path 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, void *data); - -/** - * @typedef Eina_File_Type - * file type in Eina_File_Direct_Info. - */ -typedef enum { - EINA_FILE_UNKNOWN, /**< Unknown file type. */ - EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */ - EINA_FILE_CHR, /**< Character device type (unused on Windows). */ - EINA_FILE_DIR, /**< Directory type. */ - EINA_FILE_BLK, /**< Block device type (unused on Windows). */ - EINA_FILE_REG, /**< Regular file type. */ - EINA_FILE_LNK, /**< Symbolic link type. */ - EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */ - EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */ -} Eina_File_Type; - -typedef struct _Eina_File Eina_File; - -typedef enum { - EINA_FILE_RANDOM, /**< Advise random 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_POPULATE /**< Request all the mapped memory. */ -} Eina_File_Populate; - -/* 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 - * 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 eina - * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (with - * 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 - * a path_max that is bigger - let us know, but, for now we will assume - * it never happens */ -#define EINA_PATH_MAX 8192 -/** - * @struct _Eina_File_Direct_Info - * A structure to store informations of a path. - */ -struct _Eina_File_Direct_Info -{ - size_t path_length; /**< size of the whole path */ - size_t name_length; /**< size of the filename/basename component */ - size_t name_start; /**< where the filename/basename component starts */ - Eina_File_Type type; /**< file type */ - 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 - * @brief cast to an #Eina_File_Dir_List_Cb. - * - * @param function The function to cast. - * - * This macro casts @p function to Eina_File_Dir_List_Cb. - */ -#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) - - -/** - * @brief List all files on the directory calling the function for every file found. - * - * @param dir The directory name. - * @param recursive Iterate recursively in the directory. - * @param cb The callback to be called. - * @param data The data to pass to the callback. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function calls @p cb for each file that is in @p dir. To have @p cb - * called on files that are in subdirectories of @p dir @p recursive should be - * EINA_TRUE. In other words if @p recursive is EINA_FALSE, only direct children - * of @p dir will be operated on, if @p recursive is EINA_TRUE the entire tree - * of files that is below @p dir will be operated on. - * - * If @p cb or @p dir are @c NULL, or if @p dir is a string of size 0, - * or if @p dir can not be opened, this function returns #EINA_FALSE - * immediately. otherwise, it returns #EINA_TRUE. - */ -EAPI Eina_Bool eina_file_dir_list(const char *dir, - Eina_Bool recursive, - Eina_File_Dir_List_Cb cb, - void *data) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Split a path according to the delimiter of the filesystem. - * - * @param path The path to split. - * @return An array of the parts of the path to split. - * - * This function splits @p path according to the delimiter of the used - * filesystem. If @p path is @c NULL or if the array can not be - * created, @c NULL is returned, otherwise, an array with each part of @p path - * is returned. - */ -EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * @brief Get an iterator to list the content of a directory. - * - * @param dir The name of the directory to list - * @return Return an Eina_Iterator that will walk over the files and directories - * in @p dir. On failure it will return NULL. - * - * Returns an iterator for shared strings, the name of each file in @p dir will - * only be fetched when advancing the iterator, which means there is very little - * cost associated with creating the list and stopping halfway through it. - * - * @warning The iterator will hand the user a stringshared value with the full - * path. The user must free the string using eina_stringshare_del() on it. - * - * @note The container for the iterator is of type DIR*. - * @note The iterator will walk over '.' and '..' without returning them. - * - * @see eina_file_direct_ls() - */ -EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * @brief Get an iterator to list the content of a directory, with direct - * information. - * - * @param dir The name of the directory to list - * - * @return Return an Eina_Iterator that will walk over the files and - * directory in the pointed directory. On failure it will - * return NULL. - * - * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p - * dir will only be fetched when advancing the iterator, which means there is - * cost associated with creating the list and stopping halfway through it. - * - * @warning The Eina_File_Direct_Info returned by the iterator must not - * be modified in any way. - * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info - * returned is no longer valid. - * - * @note The container for the iterator is of type DIR*. - * @note The iterator will walk over '.' and '..' without returning them. - * @note The difference between this function ahd eina_file_direct_ls() is that - * it guarantees the file type information will be correct incurring a - * possible performance penalty. - * - * @see eina_file_direct_ls() - */ -EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT 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 set appropriately. - * - * This function calls fstatat or stat depending on what your system supports. This makes it efficient and simple - * to use on your side without complex detection already done inside Eina on 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, Eina_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 - * information. - * - * @param dir The name of the directory to list - * - * @return Return an Eina_Iterator that will walk over the files and - * directory in the pointed directory. On failure it will - * return NULL. - * - * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p - * dir will only be fetched when advancing the iterator, which means there is - * cost associated with creating the list and stopping halfway through it. - * - * @warning If readdir_r doesn't contain file type information file type will - * be DT_UNKNOW. - * @warning The Eina_File_Direct_Info returned by the iterator must not - * be modified in any way. - * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info - * returned is no longer valid. - * - * @note The container for the iterator is of type DIR*. - * @note The iterator will walk over '.' and '..' without returning them. - * @note The difference between this function ahd eina_file_stat_ls() is that - * it may not get the file type information however it is likely to be - * faster. - * - * @see eina_file_ls() - */ -EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * @brief Sanitize file path. - * - * @param path The path to sanitize - * - * @return an allocated string with the sanitized path. - * - * This function take care of adding the current working directory if it's a - * relative path and also remove all '..' and '//' reference in the original - * path. - * - * @since 1.1 - */ -EAPI char *eina_file_path_sanitize(const char *path); - -/** - * @brief Get a read-only handler to a file. - * - * @param name Filename to open - * @param shared Requested a shm - * - * 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_TRUE. - * - * @since 1.1 - */ -EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * @brief Unref file handler. - * - * @param file File handler to unref. - * - * Decremente file's refcount and if it reaches zero close it. - * - * @since 1.1 - */ -EAPI void eina_file_close(Eina_File *file); - -/** - * @brief Get file size at open time. - * - * @param file The file handler to request the size from. - * @return The length of the file. - * - * @since 1.1 - */ -EAPI size_t eina_file_size_get(Eina_File *file); - -/** - * @brief Get the last modification time of an open file. - * - * @param file The file handler to request the modification time from. - * @return The last modification time. - * - * @since 1.1 - */ -EAPI time_t eina_file_mtime_get(Eina_File *file); - -/** - * @brief Get the filename of an open file. - * - * @param file The file handler to request the name from. - * @return Stringshared filename of the file. - * - * @since 1.1 - */ -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. - * - * @param file The file handler to map in 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. - * - * @since 1.1 - */ -EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule); - -/** - * @brief Map a part of the file. - * - * @param file The file handler to map in memory - * @param rule The rule to apply to the mapped memory - * @param offset The offset inside the file - * @param length The length of the memory to map - * @return A valid pointer to the system memory with @p length valid byte in it. And @c NULL if not inside the file or anything else goes wrong. - * - * This does handle refcounting so it will share map that target the same memory area. - * - * @since 1.1 - */ -EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule, - unsigned long int offset, unsigned long int length); - -/** - * @brief Unref and unmap memory if possible. - * - * @param file The file handler to unmap memory from. - * @param map Memory map to unref and unmap. - * - * @since 1.1 - */ -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 occured on it. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_FILE_H_ */ diff --git a/libraries/eina/src/include/eina_fp.h b/libraries/eina/src/include/eina_fp.h deleted file mode 100644 index c73dc16..0000000 --- a/libraries/eina/src/include/eina_fp.h +++ /dev/null @@ -1,111 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_FP_H_ -# define EINA_FP_H_ - -#include "eina_types.h" - -#ifdef _MSC_VER -typedef unsigned __int64 uint64_t; -typedef signed __int64 int64_t; -typedef signed int int32_t; -#else -# include -#endif - -#define EINA_F32P32_PI 0x00000003243f6a89 - -typedef int64_t Eina_F32p32; -typedef int32_t Eina_F16p16; -typedef int32_t Eina_F8p24; - -static inline Eina_F32p32 eina_f32p32_int_from(int32_t v); -static inline int32_t eina_f32p32_int_to(Eina_F32p32 v); -static inline Eina_F32p32 eina_f32p32_double_from(double v); -static inline double eina_f32p32_double_to(Eina_F32p32 v); - -static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, - Eina_F32p32 b); -static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, - Eina_F32p32 b); -static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, - Eina_F32p32 b); -static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a, - int b); -static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, - Eina_F32p32 b); -static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a); -static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v); - -// dont use llabs - issues if not on 64bit -#define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a)) - -EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a); -EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a); - -static inline Eina_F16p16 eina_f16p16_int_from(int32_t v); -static inline int32_t eina_f16p16_int_to(Eina_F16p16 v); -static inline Eina_F16p16 eina_f16p16_float_from(float v); -static inline float eina_f16p16_float_to(Eina_F16p16 v); - -static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, - Eina_F16p16 b); -static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, - Eina_F16p16 b); -static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, - Eina_F16p16 b); -static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a, - int b); -static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, - Eina_F16p16 b); -static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a); -static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v); - -static inline Eina_F8p24 eina_f8p24_int_from(int32_t v); -static inline int32_t eina_f8p24_int_to(Eina_F8p24 v); -static inline Eina_F8p24 eina_f8p24_float_from(float v); -static inline float eina_f8p24_float_to(Eina_F8p24 v); - -static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, - Eina_F8p24 b); -static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, - Eina_F8p24 b); -static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, - Eina_F8p24 b); -static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a, - int b); -static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, - Eina_F8p24 b); -static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a); -static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v); - -static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a); -static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a); -static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a); -static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a); -static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a); -static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a); - -#include "eina_inline_f32p32.x" -#include "eina_inline_f16p16.x" -#include "eina_inline_f8p24.x" -#include "eina_inline_fp.x" - -#endif diff --git a/libraries/eina/src/include/eina_hamster.h b/libraries/eina/src/include/eina_hamster.h deleted file mode 100644 index bea759d..0000000 --- a/libraries/eina/src/include/eina_hamster.h +++ /dev/null @@ -1,58 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_HAMSTER_H_ -#define EINA_HAMSTER_H_ - -/** - * @addtogroup Eina_Hamster_Group Hamster - * - * @brief These functions provide hamster calls. - * - * @{ - */ - -/** - * @addtogroup Eina_Core_Group Core - * - * @{ - */ - -/** - * @defgroup Eina_Hamster_Group Hamster - */ - - -/** - * @brief Get the hamster count. - * - * @return The number of available hamsters. - * - * This function returns how many hamsters you have. - */ -EAPI int eina_hamster_count(void); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_HAMSTER_H_ */ diff --git a/libraries/eina/src/include/eina_hash.h b/libraries/eina/src/include/eina_hash.h deleted file mode 100644 index 57316b2..0000000 --- a/libraries/eina/src/include/eina_hash.h +++ /dev/null @@ -1,1040 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Gustavo Sverzut Barbieri, - * Vincent Torri, Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_HASH_H_ -#define EINA_HASH_H_ - -#include "eina_types.h" -#include "eina_iterator.h" - -/** - * @page hash_01_example_page Eina_Hash in action - * @dontinclude eina_hash_01.c - * - * We are going to store some tuples into our table, that will map each @a name - * to a @a number. The cost to access a given number from the name should be - * very small, even with many entries in our table. This is the initial data: - * @skip _Phone_Entry - * @until // _start_entries - * - * Before starting to play with the hash, let's write a callback that will be - * used to free the elements from it. Since we are just storing strduped - * strings, we just need to free them: - * - * @skip static - * @until } - * - * We also need a callback to iterate over the elements of the list later, so - * we are defining it now: - * - * @skip Eina_Bool - * @until } - * - * Now let's create our @ref Eina_Hash using @ref - * eina_hash_string_superfast_new : - * - * @skip eina_init - * @until phone_book - * - * Now we add the keys and data to the hash using @ref eina_hash_add . This - * means that the key is copied inside the table, together with the pointer to - * the data (phone numbers). - * - * @skip for - * @until } - * - * Some basic manipulations with the hash, like finding a value given a key, - * deleting an entry, modifying an entry are exemplified in the following lines. - * Notice that the @ref eina_hash_modify function returns the old value stored - * in that entry, and it needs to be freed, while the @ref eina_hash_del - * function already calls our free callback: - * - * @skip Look for - * @until free( - * - * The @ref eina_hash_set function can be used to set a key-value entry to the - * table if it doesn't exist, or to modify an existent entry. It returns the old - * entry if it was already set, and NULL otherwise. But since it will - * return NULL on error too, we need to check if an error has occurred: - * - * @skip Modify - * @until printf("\n"); - * - * There are different ways of iterate over the entries of a hash. Here we show - * two of them: using @ref eina_hash_foreach and @ref Eina_Iterator . - * - * @skip List of phones - * @until eina_iterator_free(it); - * - * It's also possible to change the key for a specific entry, without having to - * remove the entry from the table and adding it again: - * - * @skipline eina_hash_move - * - * We can remove all the elements from the table without free the table itself: - * - * @skip Empty the phone book - * @until eina_hash_population - * - * Or free the the entire table with its content: - * - * @skipline eina_hash_free - * - * - * The full code for this example can be seen here: @ref eina_hash_01_c - */ - -/** - * @page eina_hash_01_c Hash table in action - * - * @include eina_hash_01.c - * @example eina_hash_01.c - */ - -/** - * @page hash_02_example_page Different types of tables - * - * This example shows two more types of hash tables that can be created using - * @ref Eina_Hash . For more types, consult the reference documentation of @ref - * eina_hash_new. - * @include eina_hash_02.c - * @example eina_hash_02.c - */ - -/** - * @example eina_hash_03.c - * Same example as @ref hash_01_example_page but using a "string small" hash - * table instead of "string superfast". - */ - -/** - * @example eina_hash_04.c - * Same example as @ref hash_01_example_page but using a "string djb2" hash - * table instead of "string superfast". - */ - -/** - * @example eina_hash_05.c - * Same example as @ref hash_01_example_page but using a "int32" hash - * table instead of "string superfast". - */ - -/** - * @example eina_hash_06.c - * Same example as @ref hash_01_example_page but using a "int64" hash - * table instead of "string superfast". - */ - -/** - * @example eina_hash_07.c - * Same example as @ref hash_01_example_page but using a "pointer" hash - * table instead of "string superfast". - */ - -/** - * @example eina_hash_08.c - * This example shows the the usage of eina_hash_add(), eina_hash_add_by_hash(), - * eina_hash_direct_add_by_hash(), eina_hash_del(), eina_hash_del_by_key_hash(), - * eina_hash_del_by_key(), eina_hash_del_by_data(), eina_hash_find_by_hash() and - * eina_hash_modify_by_hash(). - */ - -/** - * @addtogroup Eina_Hash_Group Hash Table - * - * @brief Hash table management. Useful for mapping keys to values. - * - * The hash table is useful for when one wants to implement a table that maps - * keys (usually strings) to data, and have relatively fast access time. The - * performance is proportional to the load factor of the table (number of - * elements / number of buckets). See @ref hashtable_algo for implementation - * details. - * - * Different implementations exists depending on what kind of key will be used - * to access the data: strings, integers, pointers, stringshared or your own. - * - * Eina hash tables can copy the keys when using eina_hash_add() or not when - * using eina_hash_direct_add(). - * - * @section hashtable_algo Algorithm - * - * The Eina_Hash is implemented using an array of N "buckets", where each - * bucket is a pointer to a structure that is the head of a red-black tree. The - * array can then be indexed by the [hash_of_element mod N]. The - * hash_of_element is calculated using the hashing function, passed as - * parameter to the @ref eina_hash_new function. N is the number of buckets - * (array positions), and is calculated based on the buckets_power_size - * (argument of @ref eina_hash_new too). The following picture ilustrates the - * basic idea: - * - * @htmlonly - * - * @endhtmlonly - * @image latex 01_hash-table.eps - * - * Adding an element to the hash table is made of: - * @li calculating the hash for that key (using the specified hash function); - * @li calculate the array position [hash mod N]; - * @li add the element to the rbtree on that position. - * - * The two first steps have constant time, proportional to the hash function - * being used. Adding the key to the rbtree will be proportional on the number - * of keys on that bucket. - * - * The average cost of lookup depends on the number of keys per - * bucket (load factor) of the table, if the distribution of keys is - * sufficiently uniform. - * - * @section hashtable_perf Performance - * - * As said before, the performance depends on the load factor. So trying to keep - * the load factor as small as possible will improve the hash table performance. But - * increasing the buckets_power_size will also increase the memory consumption. - * The default hash table creation functions already have a good number of - * buckets, enough for most cases. Particularly for strings, if just a few keys - * (less than 30) will be added to the hash table, @ref - * eina_hash_string_small_new should be used, since it will reduce the memory - * consumption for the buckets, and you still won't have many collisions. - * However, @ref eina_hash_string_small_new still uses the same hash calculation - * function that @ref eina_hash_string_superfast_new, which is more complex than - * @ref eina_hash_string_djb2_new. The latter has a faster hash computation - * function, but that will imply on a not so good distribution. But if just a - * few keys are being added, this is not a problem, it will still have not many - * collisions and be faster to calculate the hash than in a hash created with - * @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new. - * - * A simple comparison between them would be: - * - * @li @c djb2 - faster hash function - 256 buckets (higher memory consumption) - * @li @c string_small - slower hash function but less collisions - 32 buckets - * (lower memory consumption) - * @li @c string_superfast - slower hash function but less collisions - 256 buckets - * (higher memory consumption) - * - * Basically for a very small number of keys (10 or less), @c djb2 should be - * used, or @c string_small if you have a restriction on memory usage. And for a - * higher number of keys, @c string_superfast should be always preferred. - * - * If just stringshared keys are being added, use @ref - * eina_hash_stringshared_new. If a lot of keys will be added to the hash table - * (e.g. more than 1000), then it's better to increase the buckets_power_size. - * See @ref eina_hash_new for more details. - * - * When adding a new key to a hash table, use @ref eina_hash_add or @ref - * eina_hash_direct_add (the latter if this key is already stored elsewhere). If - * the key may be already inside the hash table, instead of checking with - * @ref eina_hash_find and then doing @ref eina_hash_add, one can use just @ref - * eina_hash_set (this will change the data pointed by this key if it was - * already present in the table). - * - * @section hashtable_tutorial Tutorial - * - * These examples show many Eina_Hash functions in action: - *
    - *
  • @ref hash_01_example_page - *
  • @ref hash_02_example_page - *
  • Different types of hash in use: - *
      - *
    • @ref eina_hash_03.c "string small" - *
    • @ref eina_hash_04.c "string djb2" - *
    • @ref eina_hash_05.c "int32" - *
    • @ref eina_hash_06.c "int64" - *
    • @ref eina_hash_07.c "pointer" - *
    - *
  • @ref eina_hash_08.c "Different add and delete functions" - *
- */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Hash_Group Hash Table - * - * @{ - */ - -/** - * @typedef Eina_Hash - * Type for a generic hash table. - */ -typedef struct _Eina_Hash Eina_Hash; - -typedef struct _Eina_Hash_Tuple Eina_Hash_Tuple; - -struct _Eina_Hash_Tuple -{ - const void *key; /**< The key */ - void *data; /**< The data associated to the key */ - unsigned int key_length; /**< The length of the key */ -}; - -typedef unsigned int (*Eina_Key_Length)(const void *key); -#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function) -typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, const void *key2, int key2_length); -#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function) -typedef int (*Eina_Key_Hash)(const void *key, int key_length); -#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function) -typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata); - - -/** - * @brief Create a new hash table. - * - * @param key_length_cb The function called when getting the size of the key. - * @param key_cmp_cb The function called when comparing the keys. - * @param key_hash_cb The function called when getting the values. - * @param data_free_cb The function called on each value when the hash table is - * freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @param buckets_power_size The size of the buckets. - * @return The new hash table. - * - * This function creates a new hash table using user-defined callbacks - * to manage the hash table. On failure, @c NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. If @p key_cmp_cb or @p key_hash_cb - * are @c NULL, @c NULL is returned. If @p buckets_power_size is - * smaller or equal than 2, or if it is greater or equal than 17, - * @c NULL is returned. - * - * The number of buckets created will be 2 ^ @p buckets_power_size. This means - * that if @p buckets_power_size is 5, there will be created 32 buckets. for a - * @p buckets_power_size of 8, there will be 256 buckets. - * - * Pre-defined functions are available to create a hash table. See - * eina_hash_string_djb2_new(), eina_hash_string_superfast_new(), - * eina_hash_string_small_new(), eina_hash_int32_new(), - * eina_hash_int64_new(), eina_hash_pointer_new() and - * eina_hash_stringshared_new(). - */ -EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb, - Eina_Key_Cmp key_cmp_cb, - Eina_Key_Hash key_hash_cb, - Eina_Free_Cb data_free_cb, - int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3); - -/** - * @brief Redefine the callback that clean the data of a hash - * - * @param hash The given hash table - * @param data_free_cb The function called on each value when the hash - * table is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @since 1.1 - * See @ref eina_hash_new. - */ -EAPI void eina_hash_free_cb_set(Eina_Hash *hash, Eina_Free_Cb data_free_cb) EINA_ARG_NONNULL(1); - -/** - * @brief Create a new hash table using the djb2 algorithm. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table using the djb2 algorithm for - * table management and strcmp() to compare the keys. Values can then - * be looked up with pointers other than the original key pointer that - * was used to add values. On failure, this function returns @c NULL. - */ -EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table for use with strings. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table using the superfast algorithm - * for table management and strcmp() to compare the keys. Values can - * then be looked up with pointers other than the original key pointer - * that was used to add values. On failure, this function returns - * @c NULL. - */ -EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table for use with strings with small bucket size. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table using the superfast algorithm - * for table management and strcmp() to compare the keys, but with a - * smaller bucket size (compared to eina_hash_string_superfast_new()) - * which will minimize the memory used by the returned hash - * table. Values can then be looked up with pointers other than the - * original key pointer that was used to add values. On failure, this - * function returns @c NULL. - */ -EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table for use with 32bit integers. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table where keys are 32bit integers. - * When adding or looking up in the hash table, pointers to 32bit integers - * must be passed. They can be addresses on the stack if you let the - * eina_hash copy the key. Values can then - * be looked up with pointers other than the original key pointer that was - * used to add values. This method is not suitable to match string keys as - * it would only match the first character. - * On failure, this function returns @c NULL. - */ -EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table for use with 64bit integers. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table where keys are 64bit integers. - * When adding or looking up in the hash table, pointers to 64bit integers - * must be passed. They can be addresses on the stack. Values can then - * be looked up with pointers other than the original key pointer that was - * used to add values. This method is not suitable to match string keys as - * it would only match the first character. - * On failure, this function returns @c NULL. - */ -EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table for use with pointers. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table using the int64/int32 algorithm for - * table management and dereferenced pointers to compare the - * keys. Values can then be looked up with pointers other than the - * original key pointer that was used to add values. This method may - * appear to be able to match string keys, actually it only matches - * the first character. On failure, this function returns @c NULL. - */ -EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Create a new hash table optimized for stringshared values. - * - * @param data_free_cb The function called on each value when the hash table - * is freed, or when an item is deleted from it. @c NULL can be passed as - * callback. - * @return The new hash table. - * - * This function creates a new hash table optimized for stringshared - * values. Values CAN NOT be looked up with pointers not - * equal to the original key pointer that was used to add a value. On failure, - * this function returns @c NULL. - * - * Excerpt of code that will NOT work with this type of hash: - * - * @code - * extern Eina_Hash *hash; - * extern const char *value; - * const char *a = eina_stringshare_add("key"); - * - * eina_hash_add(hash, a, value); - * eina_hash_find(hash, "key") - * @endcode - */ -EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb); - -/** - * @brief Add an entry to the given hash table. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key A unique key. Cannot be @c NULL. - * @param data Data to associate with the string given by @p key. Cannot be @c - * NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function adds @p key to @p hash. @p key is - * expected to be unique within the hash table. Key uniqueness varies - * depending on the type of @p hash: a stringshared @ref Eina_Hash - * need to have unique pointers (which implies unique strings). - * All other string hash types require the strings - * themselves to be unique. Pointer, int32 and int64 hashes need to have these - * values as unique. Failure to use sufficient uniqueness will - * result in unexpected results when inserting data pointers accessed - * with eina_hash_find(), and removed with eina_hash_del(). Key - * strings are case sensitive. If an error occurs, eina_error_get() - * should be used to determine if an allocation error occurred during - * this function. This function returns #EINA_FALSE if an error - * occurred, #EINA_TRUE otherwise. - */ -EAPI Eina_Bool eina_hash_add(Eina_Hash *hash, - const void *key, - const void *data) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Add an entry to the given hash table without duplicating the string - * key. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key A unique key. Cannot be @c NULL. - * @param data Data to associate with the string given by @p key. Cannot be @c - * NULL - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function adds @p key to @p hash. @p key is - * expected to be unique within the hash table. Key uniqueness varies - * depending on the type of @p hash: a stringshared @ref Eina_Hash - * need have unique pointers (which implies unique strings). - * All other string hash types require the strings - * themselves to be unique. Pointer, int32 and int64 hashes need to have these - * values as unique. Failure to use sufficient uniqueness will - * result in unexpected results when inserting data pointers accessed - * with eina_hash_find(), and removed with eina_hash_del(). This - * function does not make a copy of @p key, so it must be a string - * constant or stored elsewhere ( in the object being added). Key - * strings are case sensitive. If an error occurs, eina_error_get() - * should be used to determine if an allocation error occurred during - * this function. This function returns #EINA_FALSE if an error - * occurred, #EINA_TRUE otherwise. - */ -EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash, - const void *key, - const void *data) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Remove the entry identified by a key or a data from the given - * hash table. - * - * @param hash The given hash table. - * @param key The key. - * @param data The data pointer to remove if the key is @c NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function removes the entry identified by @p key or @p data - * from @p hash. If a free function was given to the - * callback on creation, it will be called for the data being - * deleted. If @p hash is @c NULL, the functions returns immediately - * #EINA_FALSE. If @p key is @c NULL, then @p data is used to find the a - * match to remove, otherwise @p key is used and @p data is not - * required and can be @c NULL. This function returns #EINA_FALSE if - * an error occurred, #EINA_TRUE otherwise. - * - * @note if you know you already have the key, use - * eina_hash_del_by_key() or eina_hash_del_by_key_hash(). If you - * know you don't have the key, use eina_hash_del_by_data() - * directly. - */ -EAPI Eina_Bool eina_hash_del(Eina_Hash *hash, - const void *key, - const void *data) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve a specific entry in the given hash table. - * - * @param hash The given hash table. - * @param key The key of the entry to find. - * @return The data pointer for the stored entry on success, @c NULL - * otherwise. - * - * This function retrieves the entry associated to @p key in - * @p hash. If @p hash is @c NULL, this function returns immediately - * @c NULL. This function returns the data pointer on success, @c NULL - * otherwise. - */ -EAPI void *eina_hash_find(const Eina_Hash *hash, - const void *key) EINA_ARG_NONNULL(2); - -/** - * @brief Modify the entry pointer at the specified key and return the old - * entry. - * @param hash The given hash table. - * @param key The key of the entry to modify. - * @param data The data to replace the old entry. - * @return The data pointer for the old stored entry on success, or - * @c NULL otherwise. - * - * This function modifies the data of @p key with @p data in @p - * hash. If no entry is found, nothing is added to @p hash. On success - * this function returns the old entry, otherwise it returns @c NULL. - */ -EAPI void *eina_hash_modify(Eina_Hash *hash, - const void *key, - const void *data) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Modify the entry pointer at the specified key and return the - * old entry or add the entry if not found. - * - * @param hash The given hash table. - * @param key The key of the entry to modify. - * @param data The data to replace the old entry - * @return The data pointer for the old stored entry, or @c NULL - * otherwise. - * - * This function modifies the data of @p key with @p data in @p - * hash. If no entry is found, @p data is added to @p hash with the - * key @p key. On success this function returns the old entry, - * otherwise it returns @c NULL. To check for errors, use - * eina_error_get(). - */ -EAPI void *eina_hash_set(Eina_Hash *hash, - const void *key, - const void *data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Change the key associated with a data without triggering the - * free callback. - * - * @param hash The given hash table. - * @param old_key The current key associated with the data - * @param new_key The new key to associate data with - * @return EINA_FALSE in any case but success, EINA_TRUE on success. - * - * This function allows for the move of data from one key to another, - * but does not call the Eina_Free_Cb associated with the hash table - * when destroying the old key. - */ -EAPI Eina_Bool eina_hash_move(Eina_Hash *hash, - const void *old_key, - const void *new_key) EINA_ARG_NONNULL(1, 2, 3); - -/** - * Free the given hash table resources. - * - * @param hash The hash table to be freed. - * - * This function frees up all the memory allocated to storing @p hash, - * and call the free callback if it has been passed to the hash table - * at creation time. If no free callback has been passed, any entries - * in the table that the program has no more pointers for elsewhere - * may now be lost, so this should only be called if the program has - * already freed any allocated data in the hash table or has the - * pointers for data in the table stored elsewhere as well. If @p hash - * is @c NULL, the function returns immediately. - * - * Example: - * @code - * extern Eina_Hash *hash; - * - * eina_hash_free(hash); - * hash = NULL; - * @endcode - */ -EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1); - -/** - * Free the given hash table buckets resources. - * - * @param hash The hash table whose buckets have to be freed. - * - * This function frees up all the memory allocated to storing the - * buckets of @p hash, and calls the free callback on all hash table - * buckets if it has been passed to the hash table at creation time, - * then frees the buckets. If no free callback has been passed, no - * buckets value will be freed. If @p hash is @c NULL, the function - * returns immediately. - */ -EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1); - -/** - * @brief Returns the number of entries in the given hash table. - * - * @param hash The given hash table. - * @return The number of entries in the hash table. - * - * This function returns the number of entries in @p hash, or 0 on - * error. If @p hash is @c NULL, 0 is returned. - */ -EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1); - -/** - * @brief Add an entry to the given hash table. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key A unique key. Cannot be @c NULL. - * @param key_length The length of the key. - * @param key_hash The hash that will always match key. - * @param data The data to associate with the string given by the key. Cannot be - * @c NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function adds @p key to @p hash. @p hash, @p key and @p data - * cannot be @c NULL, in that case #EINA_FALSE is returned. @p key is - * expected to be a unique within the hash table. Otherwise, - * one cannot be sure which inserted data pointer will be accessed - * with @ref eina_hash_find, and removed with @ref eina_hash_del. Do - * not forget to count '\\0' for string when setting the value of - * @p key_length. @p key_hash is expected to always match - * @p key. Otherwise, one cannot be sure to find it again with @ref - * eina_hash_find_by_hash. Key strings are case sensitive. If an error - * occurs, eina_error_get() should be used to determine if an - * allocation error occurred during this function. This function - * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * @see eina_hash_add() - */ -EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash, - const void *key, - int key_length, - int key_hash, - const void *data) EINA_ARG_NONNULL(1, 2, 5); - -/** - * @brief Add an entry to the given hash table and do not duplicate the string - * key. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key A unique key. Cannot be @c NULL. - * @param key_length Should be the length of @p key (don't forget to count - * '\\0' for string). - * @param key_hash The hash that will always match key. - * @param data Data to associate with the string given by @p key. Cannot be @c - * NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function adds @p key to @p hash. @p hash, @p key and @p data - * can be @c NULL, in that case #EINA_FALSE is returned. @p key is - * expected to be unique within the hash table. Otherwise, - * one cannot be sure which inserted data pointer will be accessed - * with @ref eina_hash_find, and removed with @ref eina_hash_del. This - * function does not make a copy of @p key so it must be a string - * constant or stored elsewhere (in the object being added). Do - * not forget to count '\\0' for string when setting the value of - * @p key_length. @p key_hash is expected to always match - * @p key. Otherwise, one cannot be sure to find it again with @ref - * eina_hash_find_by_hash. Key strings are case sensitive. If an error - * occurs, eina_error_get() should be used to determine if an - * allocation error occurred during this function. This function - * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * @see eina_hash_direct_add() - */ -EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash, - const void *key, - int key_length, - int key_hash, - const void *data) EINA_ARG_NONNULL(1, 2, 5); - -/** - * @brief Remove the entry identified by a key and a key hash from the given - * hash table. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key The key. Cannot be @c NULL. - * @param key_length The length of the key. - * @param key_hash The hash that always match the key. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function removes the entry identified by @p key and - * @p key_hash from @p hash. If a free function was given to the - * callback on creation, it will be called for the data being - * deleted. Do not forget to count '\\0' for string when setting the - * value of @p key_length. If @p hash or @p key are @c NULL, the - * functions returns immediately #EINA_FALSE. This function returns - * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * @note if you don't have the key_hash, use eina_hash_del_by_key() instead. - * @note if you don't have the key, use eina_hash_del_by_data() instead. - */ -EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash, - const void *key, - int key_length, - int key_hash) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Remove the entry identified by a key from the given hash table. - * - * This version will calculate key length and hash by using functions - * provided to hash creation function. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key The key. Cannot be @c NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function removes the entry identified by @p key from @p - * hash. The key length and hash will be calculated automatically by - * using functiond provided to has creation function. If a free - * function was given to the callback on creation, it will be called - * for the data being deleted. If @p hash or @p key are @c NULL, the - * functions returns immediately #EINA_FALSE. This function returns - * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * @note if you already have the key_hash, use eina_hash_del_by_key_hash() - * instead. - * @note if you don't have the key, use eina_hash_del_by_data() instead. - */ -EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash, - const void *key) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Remove the entry identified by a data from the given hash table. - * - * This version is slow since there is no quick access to nodes based on data. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param data The data value to search and remove. Cannot be @c NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * thing goes fine. - * - * This function removes the entry identified by @p data from @p - * hash. If a free function was given to the callback on creation, it - * will be called for the data being deleted. If @p hash or @p data - * are @c NULL, the functions returns immediately #EINA_FALSE. This - * function returns #EINA_FALSE if an error occurred, #EINA_TRUE - * otherwise. - * - * @note if you already have the key, use eina_hash_del_by_key() or - * eina_hash_del_by_key_hash() instead. - */ -EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash, - const void *data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Remove the entry identified by a key and a key hash or a - * data from the given hash table. - * - * If @p key is @c NULL, then @p data is used to find a match to - * remove. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key The key. - * @param key_length The length of the key. - * @param key_hash The hash that always match the key. - * @param data The data pointer to remove if the key is @c NULL. - * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * This function removes the entry identified by @p key and - * @p key_hash, or @p data, from @p hash. If a free function was given to - * the callback on creation, it will be called for the data being - * deleted. If @p hash is @c NULL, the functions returns immediately - * #EINA_FALSE. If @p key is @c NULL, then @p key_length and @p key_hash - * are ignored and @p data is used to find a match to remove, - * otherwise @p key and @p key_hash are used and @p data is not - * required and can be @c NULL. Do not forget to count '\\0' for - * string when setting the value of @p key_length. This function - * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise. - * - * @note if you know you already have the key, use eina_hash_del_by_key_hash(), - * if you know you don't have the key, use eina_hash_del_by_data() - * directly. - */ -EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash, - const void *key, - int key_length, - int key_hash, - const void *data) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve a specific entry in the given hash table. - * - * @param hash The given hash table. Cannot be @c NULL. - * @param key The key of the entry to find. - * @param key_length The length of the key. - * @param key_hash The hash that always match the key - * @return The data pointer for the stored entry on success, @c NULL - * otherwise. - * - * This function retrieves the entry associated to @p key of length - * @p key_length in @p hash. @p key_hash is the hash that always match - * @p key. It is ignored if @p key is @c NULL. Do not forget to count - * '\\0' for string when setting the value of @p key_length. If - * @p hash is @c NULL, this function returns immediately @c NULL. This - * function returns the data pointer on success, @c NULL otherwise. - */ -EAPI void *eina_hash_find_by_hash(const Eina_Hash *hash, - const void *key, - int key_length, - int key_hash) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Modify the entry pointer at the specified key and returns - * the old entry. - * - * @param hash The given hash table. - * @param key The key of the entry to modify. - * @param key_length Should be the length of @p key (don't forget to count - * '\\0' for string). - * @param key_hash The hash that always match the key. Ignored if @p key is - * @c NULL. - * @param data The data to replace the old entry, if it exists. - * @return The data pointer for the old stored entry, or @c NULL if not - * found. If an existing entry is not found, nothing is added to the - * hash. - */ -EAPI void *eina_hash_modify_by_hash(Eina_Hash *hash, - const void *key, - int key_length, - int key_hash, - const void *data) EINA_ARG_NONNULL(1, 2, 5); - -/** - * @brief Returned a new iterator associated to hash keys. - * - * @param hash The hash. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * hash. If @p hash is not populated, this function still returns a - * valid iterator that will always return false on - * eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the hash structure changes then the iterator becomes - * invalid! That is, if you add or remove items this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new iterator associated to hash data. - * - * @param hash The hash. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to - * @p hash. If @p hash is not populated, this function still returns a - * valid iterator that will always return false on - * eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, @c NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the hash structure changes then the iterator becomes - * invalid. That is, if you add or remove items this iterator behavior - * is undefined and your program may crash. - */ -EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new iterator associated to hash keys and data. - * - * @param hash The hash. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * hash. If @p hash is not populated, this function still returns a - * valid iterator that will always return false on - * eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @note iterator data will provide values as Eina_Hash_Tuple that should not - * be modified! - * - * @warning if the hash structure changes then the iterator becomes - * invalid! That is, if you add or remove items this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Call a function on every member stored in the hash table - * - * @param hash The hash table whose members will be walked - * @param func The function to call on each parameter - * @param fdata The data pointer to pass to the function being called - * - * This function goes through every entry in the hash table @p hash and calls - * the function @p func on each member. The function should @b not modify the - * hash table contents if it returns 1. @b If the hash table contents are - * modified by this function or the function wishes to stop processing it must - * return 0, otherwise return 1 to keep processing. - * - * Example: - * @code - * extern Eina_Hash *hash; - * - * Eina_Bool hash_fn(const Eina_Hash *hash, const void *key, - * void *data, void *fdata) - * { - * printf("Func data: %s, Hash entry: %s / %p\n", - * fdata, (const char *)key, data); - * return 1; - * } - * - * int main(int argc, char **argv) - * { - * char *hash_fn_data; - * - * hash_fn_data = strdup("Hello World"); - * eina_hash_foreach(hash, hash_fn, hash_fn_data); - * free(hash_fn_data); - * } - * @endcode - */ -EAPI void eina_hash_foreach(const Eina_Hash *hash, - Eina_Hash_Foreach func, - const void *fdata) EINA_ARG_NONNULL(1, 2); -/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */ -EAPI int eina_hash_superfast(const char *key, - int len) EINA_ARG_NONNULL(1); -/* Hash function first reported by dan bernstein many years ago in comp.lang.c */ -static inline int eina_hash_djb2(const char *key, - int len) EINA_ARG_NONNULL(1); -static inline int eina_hash_djb2_len(const char *key, - int *plen) EINA_ARG_NONNULL(1, 2); -/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */ -static inline int eina_hash_int32(const unsigned int *pkey, - int len) EINA_ARG_NONNULL(1); -static inline int eina_hash_int64(const unsigned long int *pkey, - int len) EINA_ARG_NONNULL(1); -/* http://sites.google.com/site/murmurhash/ */ -static inline int eina_hash_murmur3(const char *key, - int len) EINA_ARG_NONNULL(1); -#include "eina_inline_hash.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /*EINA_HASH_H_*/ diff --git a/libraries/eina/src/include/eina_inarray.h b/libraries/eina/src/include/eina_inarray.h deleted file mode 100644 index 079f1e3..0000000 --- a/libraries/eina/src/include/eina_inarray.h +++ /dev/null @@ -1,710 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2012 ProFUSION embedded systems - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INARRAY_H_ -#define EINA_INARRAY_H_ - -#include "eina_types.h" -#include "eina_iterator.h" -#include "eina_accessor.h" - -/** - * @page eina_inarray_example_01 Eina inline array usage - * @dontinclude eina_inarray_01.c - * - * This example will create an inline array of chars, add some elements, print - * it, re-purpose the array to store ints, add some elements and print that. - * - * We'll start with a function to compare ints we need this because the '>' - * operator is not a function and can't be used where Eina_Compare_Cb is needed. - * @skip int - * @until } - * - * And then move on to the code we actually care about, starting with variable - * declarations and eina initialization: - * @until eina_init - * - * Creating an inline array is very simple, we just need to know what type we - * want to store: - * @until inarray_new - * @note The second parameter(the step) is left at zero which means that eina - * will choose an appropriate value, this should @b only be changed if it's - * known, beforehand, how many elements the array will have. - * - * Once we have an array we can start adding elements to it. Because the - * insertion function expect a memory address we have to put the value we want - * to store in a variable(this should be no problem since in real world usage - * that's usually where the value will be anyways): - * @until append - * @note Because the inline array copies the value given to it we can later - * change @c ch, which we do, without affecting the contents of the array. - * - * So let's add some more elements: - * @until append - * @until append - * @until append - * - * We will then iterate over our array and print every position of it. The thing - * to note here is not so much the values which will be the expected 'a', 'b', - * 'c' and 'd', but rather the memory address of these values, they are - * sequential: - * @until printf - * @until printf - * - * We'll now use our array to store ints, so we need to first erase every member - * currently on the array: - * @until _flush - * - * And then to be able to store a different type on the same array we use the - * eina_array_setup() function, which is just like the eina_inarray_new() - * function except it receives already allocated memory. This time we're going - * to ask eina to use a step of size 4 because that's how many elements we'll be - * putting on the array: - * @until _setup - * @note Strictly speaking the reason to call eina_inarray_setup() is not - * because we're storing different type, but rather because our types have - * different sizes. Eina inline arrays don't actually know anything about types, - * they only deal in blocks of memory of a given size. - * @note Since eina_array_setup() receives already allocated memory you can(and - * it is in fact good practice) use inline arrays not declared as pointers: - * @code - * Eina_Inarray arr; - * eina_inarray_setup(&arr, sizeof(int), 4); - * @endcode - * - * And now to add our integer values to the array: - * @until append - * @until append - * @until append - * - * Just to change things up a bit we've left out the 99 value, but will still - * add it in such a way to keep the array ordered. There are many ways to do - * this, we could use eina_inarray_insert_at(), or we could change the value - * of the last member using eina_inarray_replace_at() and then append the values - * in the right order, but for no particular reason we're going to use - * eina_inarray_insert_sorted() instead: - * @until insert_sorted - * - * We then print the size of our array, and the array itself, much like last - * time the values are not surprising, and neither should it be that the memory - * addresses are contiguous: - * @until printf - * @until printf - * - * Once done we free our array and shutdown eina: - * @until } - * - * The source for this example: @ref eina_inarray_01_c - */ - -/** - * @page eina_inarray_01_c eina_inarray_01.c - * @include eina_inarray_01.c - * @example eina_inarray_01.c - */ - -/** - * @page eina_inarray_example_02 Eina inline array of strings - * @dontinclude eina_inarray_02.c - * - * This example will create an inline array of strings, add some elements and - * then print them. This example is based on @ref eina_array_01_example_page and - * @ref eina_inarray_example_01. - * - * We start with some variable declarations and eina initialization: - * @skip int - * @until eina_init - * - * We then create the array much like we did on @ref eina_inarray_example_01: - * @until inarray_new - * - * The point were this example significantly differs from the first eina inline - * array example. We'll not be adding the strings themselves to the array since - * their size varies, we'll store pointer to the strings instead. We therefore - * use @c char** to populate our inline array: - * @until } - * - * The source for this example: @ref eina_inarray_02_c - */ - -/** - * @page eina_inarray_02_c eina_inarray_02.c - * @include eina_inarray_02.c - * @example eina_inarray_02.c - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @since 1.2 - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Inline_Array_Group Inline Array - * - * Inline array is a container that stores the data itself not pointers to data, - * this means there is no memory fragmentation, also for small data types(such - * as char, short, int, etc.) it's more memory efficient. - * - * Usage of the inline array is very similar to that of other - * @ref Eina_Containers_Group, like all arrays adding elements to the beginning - * of the array is a lot more costly than appending, so those operations should - * be minimized. - * - * Examples: - * @li @ref eina_inarray_example_01 - * @li @ref eina_inarray_example_02 - * - * @{ - */ - - -/** - * @typedef Eina_Inarray - * Inlined array type. - * - * @since 1.2 - */ -typedef struct _Eina_Inarray Eina_Inarray; - -/** - * Inline array structure, use #Eina_Inarray typedef instead. - * - * Do not modify these fields directly, use eina_inarray_setup() or - * eina_inarray_new() instead. - * - * @since 1.2 - */ -struct _Eina_Inarray -{ - unsigned int member_size; /**< byte size of each entry in members */ - unsigned int len; /**< number of elements used in members */ - unsigned int max; /**< number of elements allocated in members */ - unsigned int step; /**< amount to grow number of members allocated */ - void *members; /**< actual array of elements */ - EINA_MAGIC -}; - -/** - * @brief Create new inline array. - * - * @param member_size size of each member in the array. - * @param step when resizing the array, do this using the following - * extra amount. - * @return The new inline array table or @c NULL on failure. - * - * Create a new array where members are inlined in a sequence. Each - * member has @a member_size bytes. - * - * If the @a step is 0, then a safe default is chosen. - * - * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is - * set. If @a member_size is zero, then @c NULL is returned. - * - * @see eina_inarray_free() - * - * @since 1.2 - */ -EAPI Eina_Inarray *eina_inarray_new(unsigned int member_size, - unsigned int step) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free array and its members. - * @param array array object - * - * @see eina_inarray_flush() - * - * @since 1.2 - */ -EAPI void eina_inarray_free(Eina_Inarray *array) EINA_ARG_NONNULL(1); - -/** - * @brief Initialize inline array. - * @param array array object to initialize. - * @param member_size size of each member in the array. - * @param step when resizing the array, do this using the following - * extra amount. - * - * Initialize array. If the @a step is 0, then a safe default is - * chosen. - * - * This is useful for arrays inlined into other structures or - * allocated at stack. - * - * @see eina_inarray_flush() - * - * @since 1.2 - */ -EAPI void eina_inarray_setup(Eina_Inarray *array, - unsigned int member_size, - unsigned int step) EINA_ARG_NONNULL(1); - -/** - * @brief Remove every member from array. - * @param array array object - * - * @since 1.2 - */ -EAPI void eina_inarray_flush(Eina_Inarray *array) EINA_ARG_NONNULL(1); - -/** - * @brief Copy the data as the last member of the array. - * @param array array object - * @param data data to be copied at the end - * @return the index of the new member or -1 on errors. - * - * Copies the given pointer contents at the end of the array. The - * pointer is not referenced, instead it's contents is copied to the - * members array using the previously defined @c member_size. - * - * @see eina_inarray_insert_at(). - * - * @since 1.2 - */ -EAPI int eina_inarray_append(Eina_Inarray *array, - const void *data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Copy the data to array at position found by comparison function - * @param array array object - * @param data data to be copied - * @param compare compare function - * @return the index of the new member or -1 on errors. - * - * Copies the given pointer contents at the array position defined by - * given @a compare function. The pointer is not referenced, instead - * it's contents is copied to the members array using the previously - * defined @c member_size. - * - * The data given to @a compare function are the pointer to member - * memory itself, do no change it. - * - * @see eina_inarray_insert_sorted() - * @see eina_inarray_insert_at() - * @see eina_inarray_append() - * - * @since 1.2 - */ -EAPI int eina_inarray_insert(Eina_Inarray *array, - const void *data, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Copy the data to array at position found by comparison function - * @param array array object - * @param data data to be copied - * @param compare compare function - * @return the index of the new member or -1 on errors. - * - * Copies the given pointer contents at the array position defined by - * given @a compare function. The pointer is not referenced, instead - * it's contents is copied to the members array using the previously - * defined @c member_size. - * - * The data given to @a compare function are the pointer to member - * memory itself, do no change it. - * - * This variation will optimize insertion position assuming the array - * is already sorted by doing binary search. - * - * @see eina_inarray_sort() - * - * @since 1.2 - */ -EAPI int eina_inarray_insert_sorted(Eina_Inarray *array, - const void *data, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Find data and remove matching member - * @param array array object - * @param data data to be found and removed - * @return the index of the removed member or -1 on errors. - * - * Find data in the array and remove it. Data may be an existing - * member of array (then optimized) or the contents will be matched - * using memcmp(). - * - * @see eina_inarray_pop() - * @see eina_inarray_remove_at() - * - * @since 1.2 - */ -EAPI int eina_inarray_remove(Eina_Inarray *array, - const void *data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Removes the last member of the array - * @param array array object - * @return the index of the removed member or -1 on errors. - * - * @since 1.2 - */ -EAPI int eina_inarray_pop(Eina_Inarray *array) EINA_ARG_NONNULL(1); - -/** - * @brief Get the member at given position - * @param array array object - * @param position member position - * @return pointer to current member memory. - * - * Gets the member given its position in the array. It is a pointer to - * its current memory, then it can be invalidated with functions that - * changes the array such as eina_inarray_append(), - * eina_inarray_insert_at() or eina_inarray_remove_at() or variants. - * - * See also eina_inarray_lookup() and eina_inarray_lookup_sorted(). - * - * @since 1.2 - */ -EAPI void *eina_inarray_nth(const Eina_Inarray *array, - unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Copy the data at given position in the array - * @param array array object - * @param position where to insert the member - * @param data data to be copied at position - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * Copies the given pointer contents at the given @a position in the - * array. The pointer is not referenced, instead it's contents is - * copied to the members array using the previously defined - * @c member_size. - * - * All the members from @a position to the end of the array are - * shifted to the end. - * - * If @a position is equal to the end of the array (equals to - * eina_inarray_count()), then the member is appended. - * - * If @a position is bigger than the array length, it will fail. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_inarray_insert_at(Eina_Inarray *array, - unsigned int position, - const void *data) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Opens a space at given position, returning its pointer. - * @param array array object - * @param position where to insert first member (open/allocate space) - * @param member_count how many times member_size bytes will be allocated. - * @return pointer to first member memory allocated or @c NULL on errors. - * - * This is similar to eina_inarray_insert_at(), but useful if the - * members contents are still unknown or unallocated. It will make - * room for the required number of items and return the pointer to the - * first item, similar to malloc(member_count * member_size), with the - * guarantee all memory is within members array. - * - * The new member memory is undefined, it's not automatically zeroed. - * - * All the members from @a position to the end of the array are - * shifted to the end. - * - * If @a position is equal to the end of the array (equals to - * eina_inarray_count()), then the member is appended. - * - * If @a position is bigger than the array length, it will fail. - * - * @since 1.2 - */ -EAPI void *eina_inarray_alloc_at(Eina_Inarray *array, - unsigned int position, - unsigned int member_count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Copy the data over the given position. - * @param array array object - * @param position where to replace the member - * @param data data to be copied at position - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * Copies the given pointer contents at the given @a position in the - * array. The pointer is not referenced, instead it's contents is - * copied to the members array using the previously defined - * @c member_size. - * - * If @a position does not exist, it will fail. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_inarray_replace_at(Eina_Inarray *array, - unsigned int position, - const void *data) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Remove member at given position - * @param array array object - * @param position position to be removed - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * The member is removed from array and any members after it are moved - * towards the array head. - * - * See also eina_inarray_pop() and eina_inarray_remove(). - * - * @since 1.2 - */ -EAPI Eina_Bool eina_inarray_remove_at(Eina_Inarray *array, - unsigned int position) EINA_ARG_NONNULL(1); - -/** - * @brief Reverse members in the array. - * @param array array object - * - * If you do not want to change the array, just walk its elements - * backwards, then use EINA_INARRAY_REVERSE_FOREACH() macro. - * - * @see EINA_INARRAY_REVERSE_FOREACH() - * - * @since 1.2 - */ -EAPI void eina_inarray_reverse(Eina_Inarray *array) EINA_ARG_NONNULL(1); - -/** - * @brief Applies quick sort to array - * @param array array object - * @param compare compare function - * - * Applies quick sort to the @a array. - * - * The data given to @a compare function are the pointer to member - * memory itself, do no change it. - * - * @see eina_inarray_insert_sorted() - * - * @since 1.2 - */ -EAPI void eina_inarray_sort(Eina_Inarray *array, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Search member (linear walk) - * @param array array object - * @param data member to search using @a compare function. - * @param compare compare function - * @return the member index or -1 if not found. - * - * Walks array linearly looking for given data as compared by - * @a compare function. - * - * The data given to @a compare function are the pointer to member - * memory itself, do no change it. - * - * See also eina_inarray_lookup_sorted(). - * - * @since 1.2 - */ -EAPI int eina_inarray_search(const Eina_Inarray *array, - const void *data, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Search member (binary search walk) - * @param array array object - * @param data member to search using @a compare function. - * @param compare compare function - * @return the member index or -1 if not found. - * - * Uses binary search for given data as compared by @a compare function. - * - * The data given to @a compare function are the pointer to member - * memory itself, do no change it. - * - * @since 1.2 - */ -EAPI int eina_inarray_search_sorted(const Eina_Inarray *array, - const void *data, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Call function for each array member - * @param array array object - * @param function callback function - * @param user_data user data given to callback @a function - * @return #EINA_TRUE if it successfully iterate all items of the array. - * - * Call @a function for every given data in @a array. - * - * Safe way to iterate over an array. @p function should return - * #EINA_TRUE as long as you want the function to continue iterating, - * by returning #EINA_FALSE it will stop and return #EINA_FALSE as a - * result. - * - * The data given to @a function are the pointer to member memory - * itself. - * - * @see EINA_INARRAY_FOREACH() - * - * @since 1.2 - */ -EAPI Eina_Bool eina_inarray_foreach(const Eina_Inarray *array, - Eina_Each_Cb function, - const void *user_data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Remove all members that matched. - * @param array array object - * @param match match function - * @param user_data user data given to callback @a match. - * @return number of removed entries or -1 on error. - * - * Remove all entries in the @a array where @a match function - * returns #EINA_TRUE. - * - * @since 1.2 - */ -EAPI int eina_inarray_foreach_remove(Eina_Inarray *array, - Eina_Each_Cb match, - const void *user_data) EINA_ARG_NONNULL(1, 2); - -/** - * @brief number of members in array. - * @param array array object - * @return number of members in array. - * - * @since 1.2 - */ -EAPI unsigned int eina_inarray_count(const Eina_Inarray *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new iterator associated to an array. - * @param array array object - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to - * @p array. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the array structure changes then the iterator becomes - * invalid! That is, if you add or remove members this - * iterator behavior is undefined and your program may crash! - * - * @since 1.2 - */ -EAPI Eina_Iterator *eina_inarray_iterator_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Returned a new reversed iterator associated to an array. - * @param array array object - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to - * @p array. - * - * Unlike eina_inarray_iterator_new(), this will walk the array backwards. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the array structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - * - * @since 1.2 - */ -EAPI Eina_Iterator *eina_inarray_iterator_reversed_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Returned a new accessor associated to an array. - * @param array array object - * @return A new accessor. - * - * This function returns a newly allocated accessor associated to - * @p array. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid accessor is - * returned. - * - * @since 1.2 - */ -EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @def EINA_INARRAY_FOREACH - * @brief walks array linearly from head to tail - * @param array array object - * @param itr the iterator pointer - * - * @a itr must be a pointer with sizeof(itr*) == array->member_size. - * - * @warning This is fast as it does direct pointer access, but it will - * not check for @c NULL pointers or invalid array object! - * See eina_inarray_foreach() to do that. - * - * @warning Do not modify array as you walk it! If that is desired, - * then use eina_inarray_foreach_remove() - * - * @since 1.2 - */ -#define EINA_INARRAY_FOREACH(array, itr) \ - for ((itr) = (array)->members; \ - (itr) < (((typeof(*itr)*)(array)->members) + (array)->len); \ - (itr)++) - -/** - * @def EINA_INARRAY_REVERSE_FOREACH - * @brief walks array linearly from tail to head - * @param array array object - * @param itr the iterator pointer - * - * @a itr must be a pointer with sizeof(itr*) == array->member_size. - * - * @warning This is fast as it does direct pointer access, but it will - * not check for @c NULL pointers or invalid array object! - * - * @warning Do not modify array as you walk it! If that is desired, - * then use eina_inarray_foreach_remove() - * - * @since 1.2 - */ -#define EINA_INARRAY_REVERSE_FOREACH(array, itr) \ - for ((itr) = ((((typeof(*(itr))*)(array)->members) + (array)->len) - 1); \ - (((itr) >= (typeof(*(itr))*)(array)->members) \ - && ((array)->members != NULL)); \ - (itr)--) - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /*EINA_INARRAY_H_*/ diff --git a/libraries/eina/src/include/eina_inline_array.x b/libraries/eina/src/include/eina_inline_array.x deleted file mode 100644 index a635ee2..0000000 --- a/libraries/eina/src/include/eina_inline_array.x +++ /dev/null @@ -1,184 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_ARRAY_X_ -#define EINA_INLINE_ARRAY_X_ - -#include - -#include - -/** - * @cond LOCAL - */ - -EAPI Eina_Bool eina_array_grow(Eina_Array *array); - -/** - * @endcond - */ - -/** - * @addtogroup Eina_Array_Group Array - * - * @brief These functions provide array management. - * - * @{ - */ - -/** - * @brief Append a data to an array. - * - * @param array The array. - * @param data The data to add. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function appends @p data to @p array. For performance - * reasons, there is no check of @p array. If it is @c NULL or - * invalid, the program may crash. If @p data is @c NULL, or if an - * allocation is necessary and fails, #EINA_FALSE is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, #EINA_TRUE is - * returned. - */ - -static inline Eina_Bool -eina_array_push(Eina_Array *array, const void *data) -{ - if (!data) return EINA_FALSE; - - if (EINA_UNLIKELY((array->count + 1) > array->total)) - if (!eina_array_grow(array)) - return EINA_FALSE; - - array->data[array->count++] = (void*) data; - - return EINA_TRUE; -} - -/** - * @brief Remove the last data of an array. - * - * @param array The array. - * @return The retrieved data. - * - * This function removes the last data of @p array, decreases the count - * of @p array and returns the data. For performance reasons, there - * is no check of @p array. If it is @c NULL or invalid, the program - * may crash. If the count member is less or equal than 0, @c NULL is - * returned. - */ -static inline void * -eina_array_pop(Eina_Array *array) -{ - void *ret = NULL; - - if (array->count <= 0) - goto on_empty; - - ret = array->data[--array->count]; - - on_empty: - return ret; -} - -/** - * @brief Return the data at a given position in an array. - * - * @param array The array. - * @param idx The potition of the data to retrieve. - * @return The retrieved data. - * - * This function returns the data at the position @p idx in @p - * array. For performance reasons, there is no check of @p array or @p - * idx. If it is @c NULL or invalid, the program may crash. - */ -static inline void * -eina_array_data_get(const Eina_Array *array, unsigned int idx) -{ - return array->data[idx]; -} - -static inline void -eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data) -{ - array->data[idx] = (void*) data; -} - -/** - * @brief Return the number of elements in an array. - * - * @param array The array. - * @return The number of elements. - * - * This function returns the number of elements in @p array. For - * performance reasons, there is no check of @p array. If it is - * @c NULL or invalid, the program may crash. - * - * @deprecated use eina_array_count() - */ -static inline unsigned int -eina_array_count_get(const Eina_Array *array) -{ - return array->count; -} - -/** - * @brief Return the number of elements in an array. - * - * @param array The array. - * @return The number of elements. - * - * This function returns the number of elements in @p array. For - * performance reasons, there is no check of @p array. If it is - * @c NULL or invalid, the program may crash. - */ -static inline unsigned int -eina_array_count(const Eina_Array *array) -{ - return array->count; -} - -static inline Eina_Bool -eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata) -{ - void *data; - Eina_Array_Iterator iterator; - unsigned int i; - Eina_Bool ret = EINA_TRUE; - - EINA_ARRAY_ITER_NEXT(array, i, data, iterator) - if (cb(array, data, fdata) != EINA_TRUE) - { - ret = EINA_FALSE; - break; - } - - return ret; -} - -static inline void -eina_array_clean(Eina_Array *array) -{ - array->count = 0; -} - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_inline_clist.x b/libraries/eina/src/include/eina_inline_clist.x deleted file mode 100644 index 66223fe..0000000 --- a/libraries/eina/src/include/eina_inline_clist.x +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Linked lists support - * - * Copyright (C) 2002 Alexandre Julliard - * Copyright (C) 2011 Mike McCormack (adapted for Eina) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __EINA_CLIST_INLINE_H__ -#define __EINA_CLIST_INLINE_H__ - -#include - -static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add) -{ - to_add->next = elem->next; - to_add->prev = elem; - elem->next->prev = to_add; - elem->next = to_add; -} - -static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add) -{ - to_add->next = elem; - to_add->prev = elem->prev; - elem->prev->next = to_add; - elem->prev = to_add; -} - -static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) -{ - eina_clist_add_after(list, elem); -} - -static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) -{ - eina_clist_add_before(list, elem); -} - -static inline void eina_clist_element_init(Eina_Clist *elem) -{ - elem->next = NULL; - elem->prev = NULL; -} - -static inline int eina_clist_element_is_linked(Eina_Clist *elem) -{ - return (elem->next != NULL && elem->prev != NULL); -} - -static inline void eina_clist_remove(Eina_Clist *elem) -{ - elem->next->prev = elem->prev; - elem->prev->next = elem->next; - eina_clist_element_init(elem); -} - -static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem) -{ - Eina_Clist *ret = elem->next; - if (elem->next == list) ret = NULL; - return ret; -} - -static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem) -{ - Eina_Clist *ret = elem->prev; - if (elem->prev == list) ret = NULL; - return ret; -} - -static inline Eina_Clist *eina_clist_head(const Eina_Clist *list) -{ - return eina_clist_next(list, list); -} - -static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) -{ - return eina_clist_prev(list, list); -} - -static inline int eina_clist_empty(const Eina_Clist *list) -{ - return list->next == list; -} - -static inline void eina_clist_init(Eina_Clist *list) -{ - list->next = list->prev = 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; -} - -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); -} - -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); -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_f16p16.x b/libraries/eina/src/include/eina_inline_f16p16.x deleted file mode 100644 index e16d188..0000000 --- a/libraries/eina/src/include/eina_inline_f16p16.x +++ /dev/null @@ -1,83 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_F16P16_X_ -#define EINA_INLINE_F16P16_X_ - -static inline Eina_F16p16 -eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b) -{ - return a + b; -} - -static inline Eina_F16p16 -eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b) -{ - return a - b; -} - -static inline Eina_F16p16 -eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b) -{ - return (Eina_F16p16)(((int64_t)a * (int64_t)b) >> 16); -} - -static inline Eina_F16p16 -eina_f16p16_scale(Eina_F16p16 a, int b) -{ - return a * b; -} - -static inline Eina_F16p16 -eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b) -{ - return (Eina_F16p16) ((((int64_t) a) << 16) / (int64_t) b); -} - -static inline Eina_F16p16 -eina_f16p16_sqrt(Eina_F16p16 a) -{ - unsigned int root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (15 + (16 >> 1)); /* Load loop counter */ - do { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - - return root; -} - -static inline unsigned int -eina_f16p16_fracc_get(Eina_F16p16 v) -{ - return (v & 0xffff); -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_f32p32.x b/libraries/eina/src/include/eina_inline_f32p32.x deleted file mode 100644 index 73480de..0000000 --- a/libraries/eina/src/include/eina_inline_f32p32.x +++ /dev/null @@ -1,110 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2009 Jorge Luis Zapata Muga, Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_F32P32_X_ -# define EINA_INLINE_F32P32_X_ - -#include - -static inline Eina_F32p32 -eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b) -{ - return a + b; -} - -static inline Eina_F32p32 -eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b) -{ - return a - b; -} - -static inline Eina_F32p32 -eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b) -{ - /* Prevent overflow and do '(a * b) >> 32' */ - /* Basically do: Eina_F16p16 * Eina_F16p16 = Eina_F32p32 */ - Eina_F32p32 up; - Eina_F32p32 down; - Eina_F32p32 result; - uint64_t as, bs; - Eina_F32p32 sign; - - sign = a ^ b; - as = eina_fp32p32_llabs(a); - bs = eina_fp32p32_llabs(b); - - up = (as >> 16) * (bs >> 16); - down = (as & 0xFFFF) * (bs & 0xFFFF); - - result = up + (down >> 32); - - return sign < 0 ? - result : result; -} - -static inline Eina_F32p32 -eina_f32p32_scale(Eina_F32p32 a, int b) -{ - return a * b; -} - -static inline Eina_F32p32 -eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b) -{ - Eina_F32p32 sign; - Eina_F32p32 result; - - sign = a ^ b; - - if (b == 0) - return sign < 0 ? (Eina_F32p32) 0x8000000000000000ull : (Eina_F32p32) 0x7FFFFFFFFFFFFFFFull; - - result = (eina_f32p32_mul(eina_fp32p32_llabs(a), (((uint64_t) 1 << 62) / ((uint64_t)(eina_fp32p32_llabs(b)) >> 2)))); - - return sign < 0 ? - result : result; -} - -static inline Eina_F32p32 -eina_f32p32_sqrt(Eina_F32p32 a) -{ - uint64_t root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (31 + (32 >> 1)); /* Load loop counter */ - do { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - - return root; -} - -static inline unsigned int -eina_f32p32_fracc_get(Eina_F32p32 v) -{ - return (unsigned int)v; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_f8p24.x b/libraries/eina/src/include/eina_inline_f8p24.x deleted file mode 100644 index f80bf61..0000000 --- a/libraries/eina/src/include/eina_inline_f8p24.x +++ /dev/null @@ -1,82 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_F8P24_X_ -#define EINA_INLINE_F8P24_X_ - -static inline Eina_F8p24 -eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b) -{ - return a + b; -} - -static inline Eina_F8p24 -eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b) -{ - return a - b; -} - -static inline Eina_F8p24 -eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b) -{ - return (Eina_F8p24)(((int64_t) a * (int64_t) b) >> 24); -} - -static inline Eina_F8p24 -eina_f8p24_scale(Eina_F8p24 a, int b) -{ - return a * b; -} - -static inline Eina_F8p24 -eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b) -{ - return (Eina_F8p24) ((((int64_t) a) << 24) / (int64_t) b); -} - -static inline Eina_F8p24 -eina_f8p24_sqrt(Eina_F8p24 a) -{ - unsigned int root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (23 + (24 >> 1)); /* Load loop counter */ - do { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - return (root); -} - -static inline unsigned int -eina_f8p24_fracc_get(Eina_F8p24 v) -{ - return (v & 0xffffff); -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_fp.x b/libraries/eina/src/include/eina_inline_fp.x deleted file mode 100644 index de44123..0000000 --- a/libraries/eina/src/include/eina_inline_fp.x +++ /dev/null @@ -1,153 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_FP_X_ -# define EINA_INLINE_FP_X_ - -static inline Eina_F32p32 -eina_f32p32_int_from(int32_t v) -{ - return (Eina_F32p32)(v) << 32; -} - -static inline int32_t -eina_f32p32_int_to(Eina_F32p32 v) -{ - return (int32_t)(v >> 32); -} - -static inline Eina_F32p32 -eina_f32p32_double_from(double v) -{ - Eina_F32p32 r; - r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5)); - return r; -} - -static inline double -eina_f32p32_double_to(Eina_F32p32 v) -{ - double r; - r = v / 4294967296.0; - return r; -} - - - -static inline Eina_F16p16 -eina_f16p16_int_from(int32_t v) -{ - return v << 16; -} - -static inline int32_t -eina_f16p16_int_to(Eina_F16p16 v) -{ - return v >> 16; -} - -static inline Eina_F16p16 -eina_f16p16_float_from(float v) -{ - Eina_F16p16 r; - - r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f)); - return r; -} - -static inline float -eina_f16p16_float_to(Eina_F16p16 v) -{ - float r; - - r = v / 65536.0f; - return r; -} - - - -static inline Eina_F8p24 -eina_f8p24_int_from(int32_t v) -{ - return v << 24; -} - -static inline int32_t -eina_f8p24_int_to(Eina_F8p24 v) -{ - return v >> 24; -} - -static inline Eina_F8p24 -eina_f8p24_float_from(float v) -{ - Eina_F8p24 r; - - r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f)); - return r; -} - -static inline float -eina_f8p24_float_to(Eina_F8p24 v) -{ - float r; - - r = v / 16777216.0f; - return r; -} - - - -static inline Eina_F32p32 -eina_f16p16_to_f32p32(Eina_F16p16 a) -{ - return ((Eina_F32p32) a) << 16; -} - -static inline Eina_F32p32 -eina_f8p24_to_f32p32(Eina_F8p24 a) -{ - return ((Eina_F32p32) a) << 8; -} - -static inline Eina_F16p16 -eina_f32p32_to_f16p16(Eina_F32p32 a) -{ - return (Eina_F16p16) (a >> 16); -} - -static inline Eina_F16p16 -eina_f8p24_to_f16p16(Eina_F8p24 a) -{ - return (Eina_F16p16) (a >> 8); -} - -static inline Eina_F8p24 -eina_f32p32_to_f8p24(Eina_F32p32 a) -{ - return (Eina_F8p24) (a >> 8); -} - -static inline Eina_F8p24 -eina_f16p16_to_f8p24(Eina_F16p16 a) -{ - return (Eina_F8p24) (a << 8); -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_hash.x b/libraries/eina/src/include/eina_inline_hash.x deleted file mode 100644 index be20e8f..0000000 --- a/libraries/eina/src/include/eina_inline_hash.x +++ /dev/null @@ -1,151 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_HASH_X_ -#define EINA_INLINE_HASH_X_ - -/* - djb2 hash algorithm was first reported by dan bernstein, and was the old - default hash function for evas. - */ -static inline int -eina_hash_djb2(const char *key, int len) -{ - unsigned int hash_num = 5381; - const unsigned char *ptr; - - if (!key) return 0; - for (ptr = (unsigned char *)key; len; ptr++, len--) - hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ - - return (int)hash_num; -} - -static inline int -eina_hash_djb2_len(const char *key, int *plen) -{ - unsigned int hash_num = 5381; - int len = 0; - const unsigned char *ptr; - - if (!key) return 0; - - for (ptr = (unsigned char *)key; *ptr; ptr++, len++) - hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ - - *plen = len + 1; - - return (int)hash_num; -} - -static inline int -eina_hash_int32(const unsigned int *pkey, int len) -{ - unsigned int key = *pkey; - - (void) len; - - key = ~key + (key << 15); - key ^= key >> 12; - key += key << 2; - key ^= key >> 4; - key *= 2057; - key ^= key >> 16; - return key; -} - -static inline int -eina_hash_int64(const unsigned long int *pkey, int len) -{ - unsigned long int key = *pkey; - - (void) len; - - key = ~key + (key << 18); - key ^= key >> 31; - key *= 21; - key ^= key >> 11; - key += key << 6; - key ^= key >> 22; - return (int) key; -} - -static inline unsigned int _rotl32(unsigned int x, char r) -{ - return (x << r) | (x >> (32 - r)); -} - -static inline unsigned int _fmix32(unsigned int h) -{ - h ^= h >> 16; - h *= 0x85ebca6b; - h ^= h >> 13; - h *= 0xc2b2ae35; - h ^= h >> 16; - - return h; -} - -static inline int -eina_hash_murmur3(const char *key, int len) -{ - const unsigned char * data = (const unsigned char*)key; - const int nblocks = len / 4; - unsigned int h1 = 0, k1; - unsigned int c1 = 0xcc9e2d51; - unsigned int c2 = 0x1b873593; - const unsigned int * blocks = (const unsigned int *)(data + nblocks*4); - int i; - const unsigned char *tail; - - for(i = -nblocks; i; i++) - { - k1 = blocks[i]; - - k1 *= c1; - k1 = _rotl32(k1, 15); - k1 *= c2; - - h1 ^= k1; - h1 = _rotl32(h1, 13); - h1 = h1*5+0xe6546b64; - } - - tail = (const unsigned char*)(data + nblocks*4); - - k1 = 0; - - switch(len & 3) - { - case 3: - k1 ^= tail[2] << 16; - case 2: - k1 ^= tail[1] << 8; - case 1: - k1 ^= tail[0]; - k1 *= c1; - k1 = _rotl32(k1, 16); - k1 *= c2; - h1 ^= k1; - } - - h1 ^= len; - - return _fmix32(h1); -} -#endif diff --git a/libraries/eina/src/include/eina_inline_list.x b/libraries/eina/src/include/eina_inline_list.x deleted file mode 100644 index 3397a1b..0000000 --- a/libraries/eina/src/include/eina_inline_list.x +++ /dev/null @@ -1,67 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LIST_INLINE_H_ -#define EINA_LIST_INLINE_H_ - -static inline Eina_List * -eina_list_last(const Eina_List *list) -{ - if (!list) return NULL; - return list->accounting->last; -} - -static inline Eina_List * -eina_list_next(const Eina_List *list) -{ - if (!list) return NULL; - return list->next; -} - -static inline Eina_List * -eina_list_prev(const Eina_List *list) -{ - if (!list) return NULL; - return list->prev; -} - -static inline void * -eina_list_data_get(const Eina_List *list) -{ - if (!list) return NULL; - return list->data; -} - -static inline void * -eina_list_data_set(Eina_List *list, const void *data) -{ - void *tmp; - if (!list) return NULL; - tmp = list->data; - list->data = (void*) data; - return tmp; -} - -static inline unsigned int -eina_list_count(const Eina_List *list) -{ - if (!list) return 0; - return list->accounting->count; -} - -#endif /* EINA_LIST_INLINE_H_ */ diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x deleted file mode 100644 index 64e049a..0000000 --- a/libraries/eina/src/include/eina_inline_lock_posix.x +++ /dev/null @@ -1,556 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_LOCK_POSIX_X_ -#define EINA_INLINE_LOCK_POSIX_X_ - -#ifdef EINA_UNUSED -# undef EINA_UNUSED -#endif -#ifdef __GNUC__ -# define EINA_UNUSED __attribute__((unused)) -#else -# define EINA_UNUSED -#endif - -#include -#ifndef __USE_UNIX98 -# define __USE_UNIX98 -# include -# undef __USE_UNIX98 -#else -# include -#endif - -#include - -#include -#include - -#ifdef EINA_HAVE_DEBUG_THREADS -#include -#include -#include -#include -#define EINA_LOCK_DEBUG_BT_NUM 64 -typedef void (*Eina_Lock_Bt_Func) (); - -#include "eina_inlist.h" -#endif - -typedef struct _Eina_Lock Eina_Lock; -typedef struct _Eina_RWLock Eina_RWLock; -typedef struct _Eina_Condition Eina_Condition; -typedef pthread_key_t Eina_TLS; -typedef sem_t Eina_Semaphore; - -struct _Eina_Lock -{ -#ifdef EINA_HAVE_DEBUG_THREADS - EINA_INLIST; -#endif - pthread_mutex_t mutex; -#ifdef EINA_HAVE_DEBUG_THREADS - pthread_t lock_thread_id; - Eina_Lock_Bt_Func lock_bt[EINA_LOCK_DEBUG_BT_NUM]; - int lock_bt_num; - Eina_Bool locked : 1; -#endif -}; - -struct _Eina_Condition -{ - Eina_Lock *lock; - pthread_cond_t condition; -}; - -struct _Eina_RWLock -{ - pthread_rwlock_t mutex; -#ifdef EINA_HAVE_DEBUG_THREADS - pthread_t lock_thread_wid; -#endif -}; - -EAPI extern Eina_Bool _eina_threads_activated; - -#ifdef EINA_HAVE_DEBUG_THREADS -EAPI extern int _eina_threads_debug; -EAPI extern pthread_t _eina_main_loop; -EAPI extern pthread_mutex_t _eina_tracking_lock; -EAPI extern Eina_Inlist *_eina_tracking; -#endif - -static inline void -eina_lock_debug(const Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - printf("lock %p, locked: %i, by %i\n", - mutex, (int)mutex->locked, (int)mutex->lock_thread_id); - backtrace_symbols_fd((void **)mutex->lock_bt, mutex->lock_bt_num, 1); -#else - (void) mutex; -#endif -} - -static inline Eina_Bool -eina_lock_new(Eina_Lock *mutex) -{ - pthread_mutexattr_t attr; - -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - if (pthread_mutexattr_init(&attr) != 0) - return EINA_FALSE; - /* NOTE: PTHREAD_MUTEX_RECURSIVE is not allowed at all, you will break on/off - feature for sure with that change. */ -#ifdef EINA_HAVE_DEBUG_THREADS - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) - return EINA_FALSE; - memset(mutex, 0, sizeof(Eina_Lock)); -#endif - if (pthread_mutex_init(&(mutex->mutex), &attr) != 0) - return EINA_FALSE; - - pthread_mutexattr_destroy(&attr); - - return EINA_TRUE; -} - -static inline void -eina_lock_free(Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - pthread_mutex_destroy(&(mutex->mutex)); -#ifdef EINA_HAVE_DEBUG_THREADS - memset(mutex, 0, sizeof(Eina_Lock)); -#endif -} - -static inline Eina_Lock_Result -eina_lock_take(Eina_Lock *mutex) -{ - Eina_Lock_Result ret = EINA_LOCK_FAIL; - int ok; - -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - -#ifdef EINA_HAVE_DEBUG_THREADS - if (_eina_threads_debug) - { - struct timeval t0, t1; - int dt; - - gettimeofday(&t0, NULL); - ok = pthread_mutex_lock(&(mutex->mutex)); - gettimeofday(&t1, NULL); - - dt = (t1.tv_sec - t0.tv_sec) * 1000000; - if (t1.tv_usec > t0.tv_usec) - dt += (t1.tv_usec - t0.tv_usec); - else - dt -= t0.tv_usec - t1.tv_usec; - dt /= 1000; - - if (dt > _eina_threads_debug) abort(); - } - else - { -#endif - ok = pthread_mutex_lock(&(mutex->mutex)); -#ifdef EINA_HAVE_DEBUG_THREADS - } -#endif - - if (ok == 0) ret = EINA_LOCK_SUCCEED; - else if (ok == EDEADLK) - { - printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex); - eina_lock_debug(mutex); - ret = EINA_LOCK_DEADLOCK; // magic -#ifdef EINA_HAVE_DEBUG_THREADS - if (_eina_threads_debug) abort(); -#endif - } - -#ifdef EINA_HAVE_DEBUG_THREADS - mutex->locked = 1; - mutex->lock_thread_id = pthread_self(); - mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM); - - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_append(_eina_tracking, - EINA_INLIST_GET(mutex)); - pthread_mutex_unlock(&_eina_tracking_lock); -#endif - - return ret; -} - -static inline Eina_Lock_Result -eina_lock_take_try(Eina_Lock *mutex) -{ - Eina_Lock_Result ret = EINA_LOCK_FAIL; - int ok; - -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - ok = pthread_mutex_trylock(&(mutex->mutex)); - if (ok == 0) ret = EINA_LOCK_SUCCEED; - else if (ok == EDEADLK) - { - printf("ERROR ERROR: DEADLOCK on trylock %p\n", mutex); - ret = EINA_LOCK_DEADLOCK; // magic - } -#ifdef EINA_HAVE_DEBUG_THREADS - if (ret == EINA_LOCK_SUCCEED) - { - mutex->locked = 1; - mutex->lock_thread_id = pthread_self(); - mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM); - - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_append(_eina_tracking, - EINA_INLIST_GET(mutex)); - pthread_mutex_unlock(&_eina_tracking_lock); - } -#endif - return ret; -} - -static inline Eina_Lock_Result -eina_lock_release(Eina_Lock *mutex) -{ - Eina_Lock_Result ret; - -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - -#ifdef EINA_HAVE_DEBUG_THREADS - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_remove(_eina_tracking, - EINA_INLIST_GET(mutex)); - pthread_mutex_unlock(&_eina_tracking_lock); - - mutex->locked = 0; - mutex->lock_thread_id = 0; - memset(mutex->lock_bt, 0, EINA_LOCK_DEBUG_BT_NUM * sizeof(Eina_Lock_Bt_Func)); - mutex->lock_bt_num = 0; -#endif - ret = (pthread_mutex_unlock(&(mutex->mutex)) == 0) ? - EINA_LOCK_SUCCEED : EINA_LOCK_FAIL; - return ret; -} - -static inline Eina_Bool -eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - assert(mutex != NULL); - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); - memset(cond, 0, sizeof (Eina_Condition)); -#endif - - cond->lock = mutex; - if (pthread_cond_init(&cond->condition, NULL) != 0) - { -#ifdef EINA_HAVE_DEBUG_THREADS - if (errno == EBUSY) - printf("eina_condition_new on already initialized Eina_Condition\n"); -#endif - return EINA_FALSE; - } - - return EINA_TRUE; -} - -static inline void -eina_condition_free(Eina_Condition *cond) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - pthread_cond_destroy(&(cond->condition)); -#ifdef EINA_HAVE_DEBUG_THREADS - memset(cond, 0, sizeof (Eina_Condition)); -#endif -} - -static inline Eina_Bool -eina_condition_wait(Eina_Condition *cond) -{ - Eina_Bool r; - -#ifdef EINA_HAVE_DEBUG_THREADS - assert(_eina_threads_activated); - assert(cond->lock != NULL); - - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_remove(_eina_tracking, - EINA_INLIST_GET(cond->lock)); - pthread_mutex_unlock(&_eina_tracking_lock); -#endif - - r = pthread_cond_wait(&(cond->condition), - &(cond->lock->mutex)) == 0 ? EINA_TRUE : EINA_FALSE; - -#ifdef EINA_HAVE_DEBUG_THREADS - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_append(_eina_tracking, - EINA_INLIST_GET(cond->lock)); - pthread_mutex_unlock(&_eina_tracking_lock); -#endif - - return r; -} - -static inline Eina_Bool -eina_condition_timedwait(Eina_Condition *cond, double t) -{ - struct timespec tv; - Eina_Bool r; - -#ifdef EINA_HAVE_DEBUG_THREADS - assert(_eina_threads_activated); - assert(cond->lock != NULL); - - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_remove(_eina_tracking, - EINA_INLIST_GET(cond->lock)); - pthread_mutex_unlock(&_eina_tracking_lock); -#endif - - tv.tv_sec = t; - tv.tv_nsec = (t - (double) tv.tv_sec) * 1000000000; - - r = pthread_cond_timedwait(&(cond->condition), - &(cond->lock->mutex), - &tv) == 0 ? - EINA_TRUE : EINA_FALSE; - -#ifdef EINA_HAVE_DEBUG_THREADS - pthread_mutex_lock(&_eina_tracking_lock); - _eina_tracking = eina_inlist_append(_eina_tracking, - EINA_INLIST_GET(cond->lock)); - pthread_mutex_unlock(&_eina_tracking_lock); -#endif - - return r; -} - -static inline Eina_Bool -eina_condition_broadcast(Eina_Condition *cond) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - assert(cond->lock != NULL); -#endif - - return pthread_cond_broadcast(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE; -} - -static inline Eina_Bool -eina_condition_signal(Eina_Condition *cond) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - assert(cond->lock != NULL); -#endif - - return pthread_cond_signal(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE; -} - -static inline Eina_Bool -eina_rwlock_new(Eina_RWLock *mutex) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - if (pthread_rwlock_init(&(mutex->mutex), NULL) != 0) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline void -eina_rwlock_free(Eina_RWLock *mutex) -{ -#ifdef EINA_HAVE_DEBUG_THREADS - if (!_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - - pthread_rwlock_destroy(&(mutex->mutex)); -} - -static inline Eina_Lock_Result -eina_rwlock_take_read(Eina_RWLock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - - if (pthread_rwlock_rdlock(&(mutex->mutex)) != 0) - return EINA_LOCK_FAIL; - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_take_write(Eina_RWLock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - - if (pthread_rwlock_wrlock(&(mutex->mutex)) != 0) - return EINA_LOCK_FAIL; - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_release(Eina_RWLock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) - { -#ifdef EINA_HAVE_DEBUG_THREADS - assert(pthread_equal(_eina_main_loop, pthread_self())); -#endif - return EINA_LOCK_SUCCEED; - } -#endif - - if (pthread_rwlock_unlock(&(mutex->mutex)) != 0) - return EINA_LOCK_FAIL; - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Bool -eina_tls_new(Eina_TLS *key) -{ - if (pthread_key_create(key, NULL) != 0) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline void -eina_tls_free(Eina_TLS key) -{ - pthread_key_delete(key); -} - -static inline void * -eina_tls_get(Eina_TLS key) -{ - return pthread_getspecific(key); -} - -static inline Eina_Bool -eina_tls_set(Eina_TLS key, const void *data) -{ - if (pthread_setspecific(key, data) != 0) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_new(Eina_Semaphore *sem, int count_init) -{ - if (!sem || (count_init <= 0)) - return EINA_FALSE; - - return (sem_init(sem, count_init, 1) == 0) ? EINA_TRUE : EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_free(Eina_Semaphore *sem) -{ - if (!sem) - return EINA_FALSE; - - return (sem_destroy(sem) == 0) ? EINA_TRUE : EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_lock(Eina_Semaphore *sem) -{ - if (!sem) - return EINA_FALSE; - - return (sem_wait(sem) == 0) ? EINA_TRUE : EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_release(Eina_Semaphore *sem, int count_release EINA_UNUSED) -{ - if (!sem) - return EINA_FALSE; - - return (sem_post(sem) == 0) ? EINA_TRUE : EINA_FALSE; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_lock_void.x b/libraries/eina/src/include/eina_inline_lock_void.x deleted file mode 100644 index 2f5209f..0000000 --- a/libraries/eina/src/include/eina_inline_lock_void.x +++ /dev/null @@ -1,273 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_LOCK_VOID_X_ -#define EINA_INLINE_LOCK_VOID_X_ - -#ifdef EINA_UNUSED -# undef EINA_UNUSED -#endif -#ifdef __GNUC__ -# define EINA_UNUSED __attribute__((unused)) -#else -# define EINA_UNUSED -#endif - -/** - * @addtogroup Eina_Lock_Group Lock - * - * @brief These functions provide Mutual Exclusion objects management. - * - * @note On Windows XP, critical sections are used, while on Windows - * CE, standard Mutex objects are used. - * - * @{ - */ - -/** - * @typedef Eina_Lock - * Abtract type for a mutual exclusive object. - */ -typedef void *Eina_Lock; -typedef void *Eina_RWLock; -typedef void *Eina_Condition; -typedef void *Eina_TLS; -typedef void *Eina_Semaphore; - -/** - * @brief Create a new #Eina_Lock. - * - * @param mutex A pointer to the lock object. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function creates a new #Eina_Lock object and stores it in the - * @p mutex buffer. On success, this function returns #EINA_TRUE and - * #EINA_FALSE otherwise. To free the resources allocated by this - * function, use eina_lock_free(). For performance reasons, no check - * is done on @p mutex. - */ -static inline Eina_Bool -eina_lock_new(Eina_Lock *mutex EINA_UNUSED) -{ - return EINA_TRUE; -} - -/** - * @brief Free the ressources of the given lock object. - * - * @param mutex The lock object to free. - * - * This function frees the resources of @p mutex allocated by - * eina_lock_new(). For performance reasons, no check is done on - * @p mutex. - */ -static inline void -eina_lock_free(Eina_Lock *mutex EINA_UNUSED) -{ -} - -/** - * @brief Lock the given mutual exclusion object. - * - * @param mutex The lock object to lock. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function locks @p mutex. @p mutex must have been created by - * eina_lock_new(). On success, this function returns #EINA_TRUE and - * #EINA_FALSE otherwise. For performance reasons, no check is done on - * @p mutex. - */ -static inline Eina_Lock_Result -eina_lock_take(Eina_Lock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -/** - * @brief Try to lock the given mutual exclusion object. - * - * @param mutex The lock object to try to lock. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function tries to lock @p mutex. @p mutex must have been created by - * eina_lock_new(). If @p mutex can be locked, this function returns - * #EINA_TRUE; if @p mutex can not be locked, or is already locked, it - * returns #EINA_FALSE. This function does not block and returns - * immediately. For performance reasons, no check is done on - * @p mutex. - * - * @note On Windows CE, this function is actually eina_lock_take(). - */ -static inline Eina_Lock_Result -eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -/** - * @brief Unlock the given mutual exclusion object. - * - * @param mutex The lock object to unlock. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function unlocks @p mutex. @p mutex must have been created by - * eina_lock_new(). On success, this function returns #EINA_TRUE and - * #EINA_FALSE otherwise. For performance reasons, no check is done on - * @p mutex. - */ -static inline Eina_Lock_Result -eina_lock_release(Eina_Lock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline void -eina_lock_debug(const Eina_Lock *mutex EINA_UNUSED) -{ -} - -static inline Eina_Bool -eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline void -eina_condition_free(Eina_Condition *cond EINA_UNUSED) -{ -} - -static inline Eina_Bool -eina_condition_wait(Eina_Condition *cond EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_condition_signal(Eina_Condition *cond EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline void -eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED) -{ -} - -static inline Eina_Lock_Result -eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED) -{ - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Bool -eina_tls_new(Eina_TLS *key EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline void -eina_tls_free(Eina_TLS key EINA_UNUSED) -{ -} - -static inline void * -eina_tls_get(Eina_TLS key EINA_UNUSED) -{ - return NULL; -} - -static inline Eina_Bool -eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED, - int count_init EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED) -{ - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED, - int count_release EINA_UNUSED) -{ - return EINA_TRUE; -} - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x deleted file mode 100644 index 1988724..0000000 --- a/libraries/eina/src/include/eina_inline_lock_win32.x +++ /dev/null @@ -1,550 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_LOCK_WIN32_X_ -#define EINA_INLINE_LOCK_WIN32_X_ - -#include - -typedef CRITICAL_SECTION Eina_Lock; -typedef struct _Eina_Condition Eina_Condition; -typedef struct _Eina_RWLock Eina_RWLock; -typedef DWORD Eina_TLS; -typedef HANDLE Eina_Semaphore; - -#if _WIN32_WINNT >= 0x0600 -struct _Eina_Condition -{ - CRITICAL_SECTION *mutex; - CONDITION_VARIABLE condition; -}; - -struct _Eina_RWLock -{ - SRWLOCK mutex; - - Eina_Bool is_read_mode : 1; -}; -#else -struct _Eina_Condition -{ - int waiters_count; - CRITICAL_SECTION waiters_count_lock; - CRITICAL_SECTION *mutex; - HANDLE semaphore; - HANDLE waiters_done; - Eina_Bool was_broadcast; -}; - -struct _Eina_RWLock -{ - LONG readers_count; - LONG writers_count; - int readers; - int writers; - - Eina_Lock mutex; - Eina_Condition cond_read; - Eina_Condition cond_write; -}; -#endif - - -EAPI extern Eina_Bool _eina_threads_activated; - - -static inline Eina_Bool -eina_lock_new(Eina_Lock *mutex) -{ - InitializeCriticalSection(mutex); - - return EINA_TRUE; -} - -static inline void -eina_lock_free(Eina_Lock *mutex) -{ - DeleteCriticalSection(mutex); -} - -static inline Eina_Lock_Result -eina_lock_take(Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) return EINA_LOCK_SUCCEED; -#endif - - EnterCriticalSection(mutex); - - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_lock_take_try(Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) return EINA_LOCK_SUCCEED; -#endif - - return TryEnterCriticalSection(mutex) == 0 ? EINA_LOCK_FAIL : EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_lock_release(Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) return EINA_LOCK_SUCCEED; -#endif - - LeaveCriticalSection(mutex); - - return EINA_LOCK_SUCCEED; -} - -static inline void -eina_lock_debug(const Eina_Lock *mutex) -{ - (void)mutex; -} - -static inline Eina_Bool -eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex) -{ - cond->mutex = mutex; -#if _WIN32_WINNT >= 0x0600 - InitializeConditionVariable(&cond->condition); -#else - cond->waiters_count = 0; - cond->was_broadcast = EINA_FALSE; - cond->semaphore = CreateSemaphore(NULL, // no security - 0, // initially 0 - 0x7fffffff, // max count - NULL); // unnamed - if (!cond->semaphore) - return EINA_FALSE; - - InitializeCriticalSection(&cond->waiters_count_lock); - - cond->waiters_done = CreateEvent(NULL, // no security - FALSE, // auto-reset - FALSE, // non-signaled initially - NULL); // unnamed - if (!cond->waiters_done) - { - CloseHandle(cond->semaphore); - return EINA_FALSE; - } -#endif - - return EINA_TRUE; -} - -static inline void -eina_condition_free(Eina_Condition *cond) -{ -#if _WIN32_WINNT >= 0x0600 - /* Nothing to do */ - (void)cond; -#else - CloseHandle(cond->waiters_done); - DeleteCriticalSection(&cond->waiters_count_lock); - CloseHandle(cond->semaphore); -#endif -} - -static inline Eina_Bool -_eina_condition_internal_timedwait(Eina_Condition *cond, DWORD t) -{ -#if _WIN32_WINNT >= 0x0600 - SleepConditionVariableCS(&cond->condition, cond->mutex, t); -#else - DWORD ret; - Eina_Bool last_waiter; - - /* Avoid race conditions. */ - EnterCriticalSection(&cond->waiters_count_lock); - cond->waiters_count++; - LeaveCriticalSection(&cond->waiters_count_lock); - - /* - * This call atomically releases the mutex and waits on the - * semaphore until or - * are called by another thread. - */ - ret = SignalObjectAndWait(cond->mutex, cond->semaphore, t, FALSE); - if (ret == WAIT_FAILED) - return EINA_FALSE; - - /* Reacquire lock to avoid race conditions. */ - EnterCriticalSection(&cond->waiters_count_lock); - - /* We're no longer waiting... */ - cond->waiters_count--; - - /* Check to see if we're the last waiter after . */ - last_waiter = (cond->was_broadcast) && (cond->waiters_count == 0); - - LeaveCriticalSection(&cond->waiters_count_lock); - - /* - * If we're the last waiter thread during this particular broadcast - * then let all the other threads proceed. - */ - if (last_waiter) - { - /* - * This call atomically signals the event and waits until - * it can acquire the . This is required to ensure fairness. - */ - ret = SignalObjectAndWait(cond->waiters_done, cond->mutex, t, FALSE); - if (ret == WAIT_FAILED) - return EINA_FALSE; - } - else - { - /* - * Always regain the external mutex since that's the guarantee we - * give to our callers. - */ - ret = WaitForSingleObject(cond->mutex, t); - if (ret == WAIT_FAILED) - return EINA_FALSE; - } -#endif - - return EINA_TRUE; -} - -static inline Eina_Bool -eina_condition_timedwait(Eina_Condition *cond, double val) -{ - return _eina_condition_internal_timedwait(cond, (DWORD)(val * 1000)); -} - -static inline Eina_Bool -eina_condition_wait(Eina_Condition *cond) -{ - return _eina_condition_internal_timedwait(cond, INFINITE); -} - -static inline Eina_Bool -eina_condition_broadcast(Eina_Condition *cond) -{ -#if _WIN32_WINNT >= 0x0600 - WakeAllConditionVariable(&cond->condition); - return EINA_TRUE; -#else - Eina_Bool have_waiters; - - /* - * This is needed to ensure that and are - * consistent relative to each other. - */ - EnterCriticalSection(&cond->waiters_count_lock); - have_waiters = EINA_FALSE; - - if (cond->waiters_count > 0) - { - /* - * We are broadcasting, even if there is just one waiter... - * Record that we are broadcasting, which helps optimize - * for the non-broadcast case. - */ - cond->was_broadcast = EINA_TRUE; - have_waiters = EINA_TRUE; - } - - if (have_waiters) - { - DWORD ret; - - /* Wake up all the waiters atomically. */ - ret = ReleaseSemaphore(cond->semaphore, cond->waiters_count, 0); - LeaveCriticalSection(&cond->waiters_count_lock); - if (!ret) return EINA_FALSE; - - /* - * Wait for all the awakened threads to acquire the counting - * semaphore. - */ - ret = WaitForSingleObject(cond->waiters_done, INFINITE); - if (ret == WAIT_FAILED) - return EINA_FALSE; - /* - * This assignment is okay, even without the held - * because no other waiter threads can wake up to access it. - */ - cond->was_broadcast = EINA_FALSE; - } - else - LeaveCriticalSection(&cond->waiters_count_lock); - - return EINA_TRUE; -#endif -} - -static inline Eina_Bool -eina_condition_signal(Eina_Condition *cond) -{ -#if _WIN32_WINNT >= 0x0600 - WakeConditionVariable(&cond->condition); -#else - Eina_Bool have_waiters; - - EnterCriticalSection(&cond->waiters_count_lock); - have_waiters = (cond->waiters_count > 0); - LeaveCriticalSection(&cond->waiters_count_lock); - - /* If there aren't any waiters, then this is a no-op. */ - if (have_waiters) - { - if (!ReleaseSemaphore(cond->semaphore, 1, 0)) - return EINA_FALSE; - } -#endif - - return EINA_TRUE; -} - -static inline Eina_Bool -eina_rwlock_new(Eina_RWLock *mutex) -{ -#if _WIN32_WINNT >= 0x0600 - InitializeSRWLock(&mutex->mutex); - return EINA_TRUE; -#else - if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE; - if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex))) - goto on_error1; - if (!eina_condition_new(&(mutex->cond_write), &(mutex->mutex))) - goto on_error2; - - mutex->readers_count = 0; - mutex->writers_count = 0; - mutex->readers = 0; - mutex->writers = 0; - - return EINA_TRUE; - - on_error2: - eina_condition_free(&(mutex->cond_read)); - on_error1: - eina_lock_free(&(mutex->mutex)); - return EINA_FALSE; -#endif -} - -static inline void -eina_rwlock_free(Eina_RWLock *mutex) -{ -#if _WIN32_WINNT >= 0x0600 - (void)mutex; -#else - eina_condition_free(&(mutex->cond_read)); - eina_condition_free(&(mutex->cond_write)); - eina_lock_free(&(mutex->mutex)); -#endif -} - -static inline Eina_Lock_Result -eina_rwlock_take_read(Eina_RWLock *mutex) -{ -#if _WIN32_WINNT >= 0x0600 - AcquireSRWLockShared(&mutex->mutex); - mutex->is_read_mode = EINA_TRUE; -#else - DWORD res = 0; - - if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) - return EINA_LOCK_FAIL; - - if (mutex->writers) - { - mutex->readers_count++; - while (mutex->writers) - { - EnterCriticalSection(&mutex->cond_write.waiters_count_lock); - mutex->cond_read.waiters_count++; - LeaveCriticalSection(&mutex->cond_write.waiters_count_lock); - res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE); - if (res != WAIT_OBJECT_0) break; - } - mutex->readers_count--; - } - if (res == 0) - mutex->readers++; - eina_lock_release(&(mutex->mutex)); -#endif - - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_take_write(Eina_RWLock *mutex) -{ -#if _WIN32_WINNT >= 0x0600 - AcquireSRWLockExclusive(&mutex->mutex); - mutex->is_read_mode = EINA_FALSE; -#else - DWORD res = 0; - - if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) - return EINA_LOCK_FAIL; - - if (mutex->writers || mutex->readers > 0) - { - mutex->writers_count++; - while (mutex->writers || mutex->readers > 0) - { - EnterCriticalSection(&mutex->cond_write.waiters_count_lock); - mutex->cond_read.waiters_count++; - LeaveCriticalSection(&mutex->cond_write.waiters_count_lock); - res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE); - if (res != WAIT_OBJECT_0) break; - } - mutex->writers_count--; - } - if (res == 0) mutex->writers = 1; - eina_lock_release(&(mutex->mutex)); -#endif - - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_rwlock_release(Eina_RWLock *mutex) -{ -#if _WIN32_WINNT >= 0x0600 - if (mutex->is_read_mode) - ReleaseSRWLockShared(&mutex->mutex); - else - ReleaseSRWLockExclusive(&mutex->mutex); -#else - if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) - return EINA_LOCK_FAIL; - - if (mutex->writers) - { - mutex->writers = 0; - if (mutex->readers_count == 1) - { - EnterCriticalSection(&mutex->cond_read.waiters_count_lock); - if (mutex->cond_read.waiters_count > 0) - ReleaseSemaphore(mutex->cond_read.semaphore, 1, 0); - LeaveCriticalSection(&mutex->cond_read.waiters_count_lock); - } - else if (mutex->readers_count > 0) - eina_condition_broadcast(&(mutex->cond_read)); - else if (mutex->writers_count > 0) - { - EnterCriticalSection (&mutex->cond_write.waiters_count_lock); - if (mutex->cond_write.waiters_count > 0) - ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0); - LeaveCriticalSection (&mutex->cond_write.waiters_count_lock); - } - } - else if (mutex->readers > 0) - { - mutex->readers--; - if (mutex->readers == 0 && mutex->writers_count > 0) - { - EnterCriticalSection (&mutex->cond_write.waiters_count_lock); - if (mutex->cond_write.waiters_count > 0) - ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0); - LeaveCriticalSection (&mutex->cond_write.waiters_count_lock); - } - } - eina_lock_release(&(mutex->mutex)); -#endif - - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Bool -eina_tls_new(Eina_TLS *key) -{ - if ((*key = TlsAlloc()) == TLS_OUT_OF_INDEXES) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline void -eina_tls_free(Eina_TLS key) -{ - TlsFree(key); -} - -static inline void * -eina_tls_get(Eina_TLS key) -{ - return (void*)TlsGetValue(key); -} - -static inline Eina_Bool -eina_tls_set(Eina_TLS key, const void *data) -{ - if (TlsSetValue(key, (LPVOID)data) == 0) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_new(Eina_Semaphore *sem, int count_init) -{ - if (!sem || (count_init <= 0)) - return EINA_FALSE; - - *sem = CreateSemaphore(NULL, count_init, 32767, NULL); - if (!*sem) - return EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_free(Eina_Semaphore *sem) -{ - if (!sem) - return EINA_FALSE; - - CloseHandle(*sem); -} - -static inline Eina_Bool -eina_semaphore_lock(Eina_Semaphore *sem) -{ - DWORD res; - - if (!sem) - return EINA_FALSE; - - res = WaitForSingleObject(*sem, 0L); - if (res == WAIT_OBJECT_0) - return EINA_TRUE; - - return EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_release(Eina_Semaphore *sem, int count_release) -{ - if (!sem) - return EINA_FALSE; - - return ReleaseSemaphore(*sem, count_release, NULL) ? EINA_TRUE : EINA_FALSE; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x deleted file mode 100644 index 1af1aac..0000000 --- a/libraries/eina/src/include/eina_inline_lock_wince.x +++ /dev/null @@ -1,212 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_LOCK_WIN32_X_ -#define EINA_INLINE_LOCK_WIN32_X_ - -#ifdef EINA_UNUSED -# undef EINA_UNUSED -#endif -#ifdef __GNUC__ -# define EINA_UNUSED __attribute__((unused)) -#else -# define EINA_UNUSED -#endif - -#include - -EAPI extern Eina_Bool _threads_activated; - -typedef HANDLE Eina_Lock; -typedef Eina_Lock Eina_RWLock; -typedef DWORD Eina_TLS; -typedef void * Eina_Semaphore; - -static inline Eina_Bool -eina_lock_new(Eina_Lock *mutex) -{ - Eina_Lock m; - - m = CreateMutex(NULL, FALSE, NULL); - if (m) *mutex = m; - return (m != NULL); -} - -static inline void -eina_lock_free(Eina_Lock *mutex) -{ - CloseHandle(*mutex); -} - -static inline Eina_Lock_Result -eina_lock_take(Eina_Lock *mutex) -{ - DWORD res; - -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) return EINA_LOCK_FAIL; -#endif - - res = WaitForSingleObject(*mutex, INFINITE); - if ((res == WAIT_ABANDONED) || (res == WAIT_FAILED)) - return EINA_LOCK_FAIL; - - return EINA_LOCK_SUCCEED; -} - -static inline Eina_Lock_Result -eina_lock_take_try(Eina_Lock *mutex) -{ - return eina_lock_take(*mutex); -} - -static inline Eina_Lock_Result -eina_lock_release(Eina_Lock *mutex) -{ -#ifdef EINA_HAVE_ON_OFF_THREADS - if (!_eina_threads_activated) return ; -#endif - - return ReleaseMutex(*mutex) ? EINA_LOCK_SUCCEED : EINA_LOCK_FAIL; -} - -static inline void -eina_lock_debug(const Eina_Lock *mutex) -{ -} - -static inline Eina_Bool -eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex) -{ - return EINA_FALSE; -} - -static inline void -eina_condition_free(Eina_Condition *cond) -{ -} - -static inline Eina_Bool -eina_condition_wait(Eina_Condition *cond) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_condition_timedwait(Eina_Condition *cond, double t) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_condition_broadcast(Eina_Condition *cond) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_condition_signal(Eina_Condition *cond) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_rwlock_new(Eina_RWLock *mutex) -{ - return eina_lock_new(mutex); -} - -static inline void -eina_rwlock_free(Eina_RWLock *mutex) -{ - return eina_lock_free(mutex); -} - -static inline Eina_Lock_Result -eina_rwlock_take_read(Eina_RWLock *mutex) -{ - return eina_lock_take(mutex); -} - -static inline Eina_Lock_Result -eina_rwlock_take_write(Eina_RWLock *mutex) -{ - return eina_lock_take(mutex); -} - -static inline Eina_Lock_Result -eina_rwlock_release(Eina_RWLock *mutex) -{ - return eina_lock_release(mutex); -} - -static inline Eina_Bool -eina_tls_new(Eina_TLS *key) -{ - if (TlsAlloc() == TLS_OUT_OF_INDEXES) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline void -eina_tls_free(Eina_TLS key) -{ - TlsFree(key); -} - -static inline void * -eina_tls_get(Eina_TLS key) -{ - return (void*)TlsGetValue(key); -} - -static inline Eina_Bool -eina_tls_set(Eina_TLS key, const void *data) -{ - if (TlsSetValue(key, (LPVOID)data) == 0) - return EINA_FALSE; - return EINA_TRUE; -} - -static inline Eina_Bool -eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED, - int count_init EINA_UNUSED) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED) -{ - return EINA_FALSE; -} - -static inline Eina_Bool -eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED, - int count_release EINA_UNUSED) -{ - return EINA_FALSE; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_log.x b/libraries/eina/src/include/eina_inline_log.x deleted file mode 100644 index 53d8afb..0000000 --- a/libraries/eina/src/include/eina_inline_log.x +++ /dev/null @@ -1,197 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LOG_INLINE_H_ -#define EINA_LOG_INLINE_H_ - -/** - * @addtogroup Eina_Log_Group Log - * - * @{ - */ - -/** - * Checks whenever the given level should be printed out. - * - * This is useful to enable certain blocks of code just when given - * level is to be used. - * - * @code - * #include - * - * void my_func(void *data) - * { - * if (eina_log_level_check(EINA_LOG_LEVEL_WARN)) - * expensive_debugging_code(data); - * - * my_func_code(data); - * } - * @endcode - * - * @return #EINA_TRUE if level is equal or smaller than the current global - * logging level. - */ -static inline Eina_Bool -eina_log_level_check(int level) -{ - return eina_log_level_get() >= level; -} - -/** - * Checks whenever the given level should be printed out. - * - * This is useful to enable certain blocks of code just when given - * level is to be used. - * - * @code - * #include - * - * extern int _my_log_dom; - * - * void my_func(void *data) - * { - * if (eina_log_domain_level_check(_my_log_dom, EINA_LOG_LEVEL_WARN)) - * expensive_debugging_code(data); - * - * my_func_code(data); - * } - * @endcode - * - * @return #EINA_TRUE if level is equal or smaller than the current - * domain logging level. - */ -static inline Eina_Bool -eina_log_domain_level_check(int domain, int level) -{ - int dom_level = eina_log_domain_registered_level_get(domain); - if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN)) - return EINA_FALSE; - return dom_level >= level; -} - -/** - * Function to format the level as a 3 character (+1 null byte) string. - * - * This function converts the given level to a known string name (CRI, - * ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any - * case the last byte will contain a trailing null byte. - * - * If extreme level values are used (greater than 999 and smaller than - * -99), then the value will just consider the less significant - * part. This is so uncommon that users should handle this in their - * code. - * - * @param level what level value to use. - * @param name where to write the actual value. - * - * @return pointer to @p name. - */ -static inline const char * -eina_log_level_name_get(int level, char name[4]) -{ -#define BCPY(A, B, C) \ - do { name[0] = A; name[1] = B; name[2] = C; } while (0) - - if (EINA_UNLIKELY(level < 0)) - { - name[0] = '-'; - name[1] = '0' + (-level / 10) % 10; - name[2] = '0' + (-level % 10); - } - else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS)) - { - name[0] = '0' + (level / 100) % 10; - name[1] = '0' + (level / 10) % 10; - name[2] = '0' + level % 10; - } - else if (level == 0) - BCPY('C', 'R', 'I'); - else if (level == 1) - BCPY('E', 'R', 'R'); - else if (level == 2) - BCPY('W', 'R', 'N'); - else if (level == 3) - BCPY('I', 'N', 'F'); - else if (level == 4) - BCPY('D', 'B', 'G'); - else - BCPY('?', '?', '?'); - - name[3] = '\0'; - - return name; -} - -/** - * Function to get recommended color value for level. - * - * This function will not check if colors are enabled or not before - * returning the level color. If you desire such check, use - * eina_log_level_color_if_enabled_get(). - * - * @param level what level value to use. - * - * @return pointer to null byte terminated ANSI color string to be - * used in virtual terminals supporting VT100 color codes. - * - * @see eina_log_level_color_if_enabled_get() - */ -static inline const char * -eina_log_level_color_get(int level) -{ - if (level <= 0) - return EINA_COLOR_LIGHTRED; - else if (level == 1) - return EINA_COLOR_RED; - else if (level == 2) - return EINA_COLOR_YELLOW; - else if (level == 3) - return EINA_COLOR_GREEN; - else if (level == 4) - return EINA_COLOR_LIGHTBLUE; - else - return EINA_COLOR_BLUE; -} - -/** - * Function to get recommended color value for level, if colors are - * enabled. - * - * This function will check if colors are enabled or not before - * returning the level color. If colors are disabled, then empty - * string is returned. - * - * @param level what level value to use. - * - * @return pointer to null byte terminated ANSI color string to be - * used in virtual terminals supporting VT100 color codes. If - * colors are disabled, the empty string is returned. - */ -static inline const char * -eina_log_level_color_if_enabled_get(int level) -{ - if (eina_log_color_disable_get()) - return ""; - return eina_log_level_color_get(level); -} - -/** - * @} - */ - -#endif /* EINA_LOG_INLINE_H_ */ diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x deleted file mode 100644 index 729a669..0000000 --- a/libraries/eina/src/include/eina_inline_mempool.x +++ /dev/null @@ -1,148 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_MEMPOOL_X_ -#define EINA_INLINE_MEMPOOL_X_ - -#include - -/** - * @addtogroup Eina_Memory_Pool_Group Memory Pool - * - * @{ - */ - -/* Memory Pool */ -typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1; -typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2; - -struct _Eina_Mempool_Backend -{ - const char *name; - void *(*init)(const char *context, const char *options, va_list args); - void (*free)(void *data, void *element); - void *(*alloc)(void *data, unsigned int size); - void *(*realloc)(void *data, void *element, unsigned int size); - void (*garbage_collect)(void *data); - void (*statistics)(void *data); - void (*shutdown)(void *data); - void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data); -}; - -struct _Eina_Mempool_Backend_ABI1 -{ - const char *name; - void *(*init)(const char *context, const char *options, va_list args); - void (*free)(void *data, void *element); - void *(*alloc)(void *data, unsigned int size); - void *(*realloc)(void *data, void *element, unsigned int size); - void (*garbage_collect)(void *data); - void (*statistics)(void *data); - void (*shutdown)(void *data); -}; - -struct _Eina_Mempool_Backend_ABI2 -{ - void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data); -}; - -struct _Eina_Mempool -{ - Eina_Mempool_Backend_ABI1 backend; - void *backend_data; - Eina_Mempool_Backend_ABI2 *backend2; -}; - -/** - * @brief Re-allocate an amount memory by the given mempool. - * - * @param mp The mempool. - * @param element The element to re-allocate. - * @param size The size in bytes to re-allocate. - * @return The newly re-allocated data. - * - * This function re-allocates and returns @p element with @p size bytes using the - * mempool @p mp. If not used anymore, the data must be freed with eina_mempool_free(). - * @warning No checks are done for @p mp. - */ -static inline void * -eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) -{ - return mp->backend.realloc(mp->backend_data, element, size); -} - -/** - * @brief Allocate 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 and returns @p size bytes using the mempool @p mp. - * If not used anymore, the data must be freed with eina_mempool_free(). - * @warning No checks are done for @p mp. - */ -static inline void * -eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) -{ - return mp->backend.alloc(mp->backend_data, size); -} - -/** - * @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 mempool @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 element The data to free. - * - * This function frees @p element allocated by @p mp. @p element must - * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or - * eina_mempool_realloc(). - * @warning No checks are done for @p mp. - */ -static inline void -eina_mempool_free(Eina_Mempool *mp, void *element) -{ - mp->backend.free(mp->backend_data, element); -} - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_inline_rbtree.x b/libraries/eina/src/include/eina_inline_rbtree.x deleted file mode 100644 index 954774b..0000000 --- a/libraries/eina/src/include/eina_inline_rbtree.x +++ /dev/null @@ -1,50 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_RBTREE_INLINE_H_ -#define EINA_RBTREE_INLINE_H_ - -/** - * @addtogroup Eina_Rbtree_Group Red-Black tree - * - * @brief These functions provide Red-Black trees management. - * - * @{ - */ - -static inline Eina_Rbtree * -eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) -{ - int result; - - while (root) - { - result = cmp(root, key, length, (void*) data); - if (result == 0) return (Eina_Rbtree*) root; - - root = root->son[result < 0 ? 0 : 1]; - } - - return NULL; -} - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_inline_rectangle.x b/libraries/eina/src/include/eina_inline_rectangle.x deleted file mode 100644 index 29ad24b..0000000 --- a/libraries/eina/src/include/eina_inline_rectangle.x +++ /dev/null @@ -1,254 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_RECTANGLE_H__ -#define EINA_INLINE_RECTANGLE_H__ - -/** - * @addtogroup Eina_Rectangle_Group Rectangle - * - * @brief These functions provide rectangle management. - * - * @{ - */ - -/** - * @brief Check if the given spans intersect. - * - * @param c1 The column of the first span. - * @param l1 The length of the first span. - * @param c2 The column of the second span. - * @param l2 The length of the second span. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if the given spans intersect, - * #EINA_FALSE otherwise. - */ -static inline int -eina_spans_intersect(int c1, int l1, int c2, int l2) -{ - return (!(((c2 + l2) <= c1) || (c2 >= (c1 + l1)))); -} - -/** - * @brief Check if the given rectangle is empty. - * - * @param r The rectangle to check. - * @return #EINA_TRUE if the rectangle is empty, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p r is empty, #EINA_FALSE - * otherwise. No check is done on @p r, so it must be a valid - * rectangle. - */ -static inline Eina_Bool -eina_rectangle_is_empty(const Eina_Rectangle *r) -{ - return ((r->w < 1) || (r->h < 1)) ? EINA_TRUE : EINA_FALSE; -} - -/** - * @brief Set the coordinates and size of the given rectangle. - * - * @param r The rectangle. - * @param x The top-left x coordinate of the rectangle. - * @param y The top-left y coordinate of the rectangle. - * @param w The width of the rectangle. - * @param h The height of the rectangle. - * - * This function sets its top-left x coordinate to @p x, its top-left - * y coordinate to @p y, its width to @p w and its height to @p h. No - * check is done on @p r, so it must be a valid rectangle. - */ -static inline void -eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) -{ - r->x = x; - r->y = y; - r->w = w; - r->h = h; -} - -/** - * @brief Check if the given rectangles intersect. - * - * @param r1 The first rectangle. - * @param r2 The second rectangle. - * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p r1 and @p r2 intersect, - * #EINA_FALSE otherwise. No check is done on @p r1 and @p r2, so they - * must be valid rectangles. - */ -static inline Eina_Bool -eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) -{ - return (eina_spans_intersect(r1->x, r1->w, r2->x, r2->w) && eina_spans_intersect(r1->y, r1->h, r2->y, r2->h)) ? EINA_TRUE : EINA_FALSE; -} - -/** - * @brief Check if the given x-coordinate is in the rectangle . - * - * @param r The rectangle. - * @param x The x coordinate. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p x is in @p r with respect to - * the horizontal direction, #EINA_FALSE otherwise. No check is done - * on @p r, so it must be a valid rectangle. - */ -static inline Eina_Bool -eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) -{ - return ((x >= r->x) && (x < (r->x + r->w))) ? EINA_TRUE : EINA_FALSE; -} - -/** - * @brief Check if the given y-coordinate is in the rectangle . - * - * @param r The rectangle. - * @param y The y coordinate. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p y is in @p r with respect to - * the vertical direction, #EINA_FALSE otherwise. No check is done - * on @p r, so it must be a valid rectangle. - */ -static inline Eina_Bool -eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) -{ - return ((y >= r->y) && (y < (r->y + r->h))) ? EINA_TRUE : EINA_FALSE; -} - -/** - * @brief Check if the given point is in the rectangle . - * - * @param r The rectangle. - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if the point of coordinate (@p x, - * @p y) is in @p r, #EINA_FALSE otherwise. No check is done on @p r, - * so it must be a valid rectangle. - */ -static inline Eina_Bool -eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) -{ - return (eina_rectangle_xcoord_inside(r, x) && eina_rectangle_ycoord_inside(r, y)) ? EINA_TRUE : EINA_FALSE; -} - -/** - * @brief Get the union of two rectangles. - * - * @param dst The first rectangle. - * @param src The second rectangle. - * - * This function get the union of the rectangles @p dst and @p src. The - * result is stored in @p dst. No check is done on @p dst or @p src, - * so they must be valid rectangles. - */ -static inline void -eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) -{ - /* left */ - if (dst->x > src->x) - { - dst->w += dst->x - src->x; - dst->x = src->x; - } - /* right */ - if ((dst->x + dst->w) < (src->x + src->w)) - dst->w = src->x + src->w; - /* top */ - if (dst->y > src->y) - { - dst->h += dst->y - src->y; - dst->y = src->y; - } - /* bottom */ - if ((dst->y + dst->h) < (src->y + src->h)) - dst->h = src->y + src->h; -} - -/** - * @brief Get the intersection of two rectangles. - * - * @param dst The first rectangle. - * @param src The second rectangle. - * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE - * otherwise. - * - * This function get the intersection of the rectangles @p dst and - * @p src. The result is stored in @p dst. No check is done on @p dst - * or @p src, so they must be valid rectangles. - */ -static inline Eina_Bool -eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) -{ - if (!(eina_rectangles_intersect(dst, src))) - return EINA_FALSE; - - /* left */ - if (dst->x < src->x) - { - dst->w += dst->x - src->x; - dst->x = src->x; - if (dst->w < 0) - dst->w = 0; - } - /* right */ - if ((dst->x + dst->w) > (src->x + src->w)) - dst->w = src->x + src->w - dst->x; - /* top */ - if (dst->y < src->y) - { - dst->h += dst->y - src->y; - dst->y = src->y; - if (dst->h < 0) - dst->h = 0; - } - /* bottom */ - if ((dst->y + dst->h) > (src->y + src->h)) - dst->h = src->y + src->h - dst->y; - - return EINA_TRUE; -} - -static inline void -eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) -{ - res->x = in->x - out->x; - res->y = in->y - out->y; - res->w = in->w; - res->h = in->h; -} - -static inline void -eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) -{ - res->x = out->x + in->x; - res->y = out->y + in->y; - res->w = out->w; - res->h = out->h; -} - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_inline_str.x b/libraries/eina/src/include/eina_inline_str.x deleted file mode 100644 index 2daeb85..0000000 --- a/libraries/eina/src/include/eina_inline_str.x +++ /dev/null @@ -1,76 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_STR_INLINE_H_ -#define EINA_STR_INLINE_H_ - -/** - * @addtogroup Eina_String_Group String - * - * @{ - */ - -/** - * @brief Count up to a given amount of bytes of the given string. - * - * @param str The string pointer. - * @param maxlen The maximum length to allow. - * @return the string size or (size_t)-1 if greater than @a maxlen. - * - * This function returns the size of @p str, up to @p maxlen - * characters. It avoid needless iterations after that size. @p str - * must be a valid pointer and MUST not be @c NULL, otherwise this - * function will crash. This function returns the string size, or - * (size_t)-1 if the size is greater than @a maxlen. - */ -static inline size_t -eina_strlen_bounded(const char *str, size_t maxlen) -{ - const char *itr, *str_maxend = str + maxlen; - for (itr = str; *itr != '\0'; itr++) - if (itr == str_maxend) return (size_t)-1; - return itr - str; -} - -/** - * @brief Join two strings of known length. - * - * @param dst The buffer to store the result. - * @param size Size (in byte) of the buffer. - * @param sep The separator character to use. - * @param a First string to use, before @p sep. - * @param b Second string to use, after @p sep. - * @return The number of characters printed. - * - * This function is similar to eina_str_join_len(), but will compute - * the length of @p a and @p b using strlen(). - * - * @see eina_str_join_len() - * @see eina_str_join_static() - */ -static inline size_t -eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) -{ - return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b)); -} - -/** - * @} - */ - -#endif /* EINA_STR_INLINE_H_ */ diff --git a/libraries/eina/src/include/eina_inline_stringshare.x b/libraries/eina/src/include/eina_inline_stringshare.x deleted file mode 100644 index 19827c5..0000000 --- a/libraries/eina/src/include/eina_inline_stringshare.x +++ /dev/null @@ -1,91 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_STRINGSHARE_INLINE_H_ -#define EINA_STRINGSHARE_INLINE_H_ - -#include -#include "eina_stringshare.h" -/** - * @addtogroup Eina_Stringshare_Group Stringshare - * - * @{ - */ - -/** - * Replace the previously stringshared pointer with new content. - * - * The string pointed by @a p_str should be previously stringshared or - * @c NULL and it will be eina_stringshare_del(). The new string will - * be passed to eina_stringshare_add() and then assigned to @c *p_str. - * - * @param p_str pointer to the stringhare to be replaced. Must not be - * @c NULL, but @c *p_str may be @c NULL as it is a valid - * stringshare handle. - * @param news new string to be stringshared, may be @c NULL. - * - * @return #EINA_TRUE if the strings were different and thus replaced, - * #EINA_FALSE if the strings were the same after shared. - */ -static inline Eina_Bool -eina_stringshare_replace(Eina_Stringshare **p_str, const char *news) -{ - if (*p_str == news) return EINA_FALSE; - - news = eina_stringshare_add(news); - eina_stringshare_del(*p_str); - if (*p_str == news) - return EINA_FALSE; - *p_str = news; - return EINA_TRUE; -} - -/** - * Replace the previously stringshared pointer with a new content. - * - * The string pointed by @a p_str should be previously stringshared or - * @c NULL and it will be eina_stringshare_del(). The new string will - * be passed to eina_stringshare_add_length() and then assigned to @c *p_str. - * - * @param p_str pointer to the stringhare to be replaced. Must not be - * @c NULL, but @c *p_str may be @c NULL as it is a valid - * stringshare handle. - * @param news new string to be stringshared, may be @c NULL. - * @param slen The string size (<= strlen(str)). - * - * @return #EINA_TRUE if the strings were different and thus replaced, - * #EINA_FALSE if the strings were the same after shared. - */ -static inline Eina_Bool -eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen) -{ - if (*p_str == news) return EINA_FALSE; - - news = eina_stringshare_add_length(news, slen); - eina_stringshare_del(*p_str); - if (*p_str == news) - return EINA_FALSE; - *p_str = news; - return EINA_TRUE; -} - -/** - * @} - */ - -#endif /* EINA_STRINGSHARE_INLINE_H_ */ diff --git a/libraries/eina/src/include/eina_inline_tiler.x b/libraries/eina/src/include/eina_inline_tiler.x deleted file mode 100644 index 2a8b205..0000000 --- a/libraries/eina/src/include/eina_inline_tiler.x +++ /dev/null @@ -1,151 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2009 Rafael Antognolli - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_TILER_INLINE_H_ -#define EINA_TILER_INLINE_H_ - -#include "eina_safety_checks.h" - -/** - * @cond LOCAL - * This struct should not be accessed directly, it is used by - * eina_tile_grid_slicer functions to maintain context and fill "info" - * member with correct values for given iteration. - */ -struct _Eina_Tile_Grid_Slicer -{ - unsigned long col1, col2, row1, row2; // initial and final col,row - int tile_w, tile_h; // tile width, height - int x_rel, y_rel; // starting x,y coordinates of the first col,row - int w1_rel, h1_rel; // width,height of the first col,row - int w2_rel, h2_rel; // width,height of the last col,row - struct Eina_Tile_Grid_Info info; // info about the current tile - Eina_Bool first; -}; - -/** - * @endcond - */ - -static inline Eina_Bool -eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0); - - if (slc->first) - { - slc->first = 0; - *rect = &slc->info; - return EINA_TRUE; - } - - slc->info.col++; - - if (slc->info.col > slc->col2) - { - slc->info.row++; - if (slc->info.row > slc->row2) - return EINA_FALSE; - else if (slc->info.row < slc->row2) - slc->info.rect.h = slc->tile_h; - else - slc->info.rect.h = slc->h2_rel; - slc->info.rect.y = 0; - slc->info.col = slc->col1; - slc->info.rect.x = slc->x_rel; - slc->info.rect.w = slc->w1_rel; - } - else - { - slc->info.rect.x = 0; - if (slc->info.col < slc->col2) - slc->info.rect.w = slc->tile_w; - else - slc->info.rect.w = slc->w2_rel; - } - - if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h) - slc->info.full = EINA_TRUE; - else - slc->info.full = EINA_FALSE; - - *rect = &slc->info; - - return EINA_TRUE; -} - -static inline Eina_Bool -eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h) -{ - int tx1, tx2, ty1, ty2; - - EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0); - - tx1 = x; - ty1 = y; - tx2 = x + w - 1; - ty2 = y + h - 1; - - if (x < 0 || y < 0 || w <= 0 || h <= 0 || tile_w <= 0 || tile_h <= 0) - { - slc->first = 0; - slc->col1 = slc->row1 = 0; - slc->col2 = slc->row2 = 0; - slc->info.col = slc->col1; - slc->info.row = slc->row1; - return EINA_TRUE; - } - - slc->col1 = tx1 / tile_w; - slc->row1 = ty1 / tile_h; - slc->col2 = (tx2 - 0) / tile_w; - slc->row2 = (ty2 - 0) / tile_h; - slc->x_rel = tx1 % tile_w; - slc->y_rel = ty1 % tile_h; - slc->w1_rel = tile_w - slc->x_rel; - slc->h1_rel = tile_h - slc->y_rel; - slc->w2_rel = tx2 % tile_w + 1; - slc->h2_rel = ty2 % tile_h + 1; - - slc->tile_w = tile_w; - slc->tile_h = tile_h; - - slc->first = 1; - slc->info.col = slc->col1; - slc->info.row = slc->row1; - slc->info.rect.x = slc->x_rel; - slc->info.rect.y = slc->y_rel; - - if (slc->info.col == slc->col2) - slc->w1_rel = slc->w2_rel - slc->x_rel; - - if (slc->info.row == slc->row2) - slc->h1_rel = slc->h2_rel - slc->y_rel; - - slc->info.rect.w = slc->w1_rel; - slc->info.rect.h = slc->h1_rel; - - if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h) - slc->info.full = EINA_TRUE; - else - slc->info.full = EINA_FALSE; - - return EINA_TRUE; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_trash.x b/libraries/eina/src/include/eina_inline_trash.x deleted file mode 100644 index 4a50611..0000000 --- a/libraries/eina/src/include/eina_inline_trash.x +++ /dev/null @@ -1,90 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_TRASH_X__ -#define EINA_INLINE_TRASH_X__ - -/** - * @brief Initialize a trash before using it. - * - * @param trash The trash. - * - * This function just set to zero the trash to correctly - * initialize it. - * - * @note You can just set *trash to NULL and you will have - * the same result. - */ -static inline void -eina_trash_init(Eina_Trash **trash) -{ - *trash = NULL; -} - -/** - * @brief Push an unused pointer in the trash instead of freeing it. - * - * @param trash A pointer to an Eina_Trash. - * @param data An unused pointer big enougth to put a (void*). - * - * Instead of freeing a pointer and put pressure on malloc/free - * you can push it in a trash for a later use. This function just - * provide a fast way to push a now unused pointer into a trash. - * - * @note Do never use the pointer after insertion or bad things will - * happens. - * - * @note This trash will not resize, nor do anything with the size of - * the region pointed by @p data, so it's your duty to manage the size. - */ -static inline void -eina_trash_push(Eina_Trash **trash, void *data) -{ - Eina_Trash *tmp; - - tmp = (Eina_Trash *)data; - tmp->next = *trash; - *trash = tmp; -} - -/** - * @brief Pop an available pointer from the trash if possible. - * - * @param trash A pointer to an Eina_Trash. - * - * Instead of calling malloc, and putting pressure on malloc/free - * you can recycle the content of the trash, if it's not empty. - * - * @note This trash will not resize, nor do anything with the size of - * the region pointed by pointer inside the trash, so it's your duty - * to manage the size of the returned pointer. - */ -static inline void* -eina_trash_pop(Eina_Trash **trash) -{ - void *tmp; - - tmp = *trash; - - if (*trash) - *trash = (*trash)->next; - - return tmp; -} - -#endif diff --git a/libraries/eina/src/include/eina_inline_ustringshare.x b/libraries/eina/src/include/eina_inline_ustringshare.x deleted file mode 100644 index ace6fdc..0000000 --- a/libraries/eina/src/include/eina_inline_ustringshare.x +++ /dev/null @@ -1,93 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri - Tom Hacohen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_USTRINGSHARE_INLINE_H_ -#define EINA_USTRINGSHARE_INLINE_H_ - -#include "eina_unicode.h" -#include "eina_ustringshare.h" - -/** - * @addtogroup Eina_UStringshare_Group Unicode Stringshare - * - * @{ - */ - -/** - * Replace the previously stringshared pointer with new content. - * - * The string pointed by @a p_str should be previously stringshared or - * @c NULL and it will be eina_ustringshare_del(). The new string will - * be passed to eina_ustringshare_add() and then assigned to @c *p_str. - * - * @param p_str pointer to the stringhare to be replaced. Must not be - * @c NULL, but @c *p_str may be @c NULL as it is a valid - * stringshare handle. - * @param news new string to be stringshared, may be @c NULL. - * - * @return #EINA_TRUE if the strings were different and thus replaced, - * #EINA_FALSE if the strings were the same after shared. - */ -static inline Eina_Bool -eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) -{ - if (*p_str == news) return EINA_FALSE; - - news = eina_ustringshare_add(news); - eina_ustringshare_del(*p_str); - if (*p_str == news) - return EINA_FALSE; - *p_str = news; - return EINA_TRUE; -} - -/** - * Replace the previously stringshared pointer with a new content. - * - * The string pointed by @a p_str should be previously stringshared or - * @c NULL and it will be eina_ustringshare_del(). The new string will - * be passed to eina_ustringshare_add_length() and then assigned to @c *p_str. - * - * @param p_str pointer to the stringhare to be replaced. Must not be - * @c NULL, but @c *p_str may be @c NULL as it is a valid - * stringshare handle. - * @param news new string to be stringshared, may be @c NULL. - * @param slen The string size (<= strlen(str)). - * - * @return #EINA_TRUE if the strings were different and thus replaced, - * #EINA_FALSE if the strings were the same after shared. - */ -static inline Eina_Bool -eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) -{ - if (*p_str == news) return EINA_FALSE; - - news = eina_ustringshare_add_length(news, slen); - eina_ustringshare_del(*p_str); - if (*p_str == news) - return EINA_FALSE; - *p_str = news; - return EINA_TRUE; -} - -/** - * @} - */ - -#endif /* EINA_USTRINGSHARE_INLINE_H_ */ diff --git a/libraries/eina/src/include/eina_inline_value.x b/libraries/eina/src/include/eina_inline_value.x deleted file mode 100644 index 33c83f5..0000000 --- a/libraries/eina/src/include/eina_inline_value.x +++ /dev/null @@ -1,1790 +0,0 @@ -/* Eina - EFL data type library - * Copyright (C) 2012 ProFUSION embedded systems - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLINE_VALUE_X_ -#define EINA_INLINE_VALUE_X_ - -#include -#include - -#include "eina_stringshare.h" - -/* NOTE: most of value is implemented here for performance reasons */ - -//#define EINA_VALUE_NO_OPTIMIZE 1 -#ifdef EINA_VALUE_NO_OPTIMIZE -#define EINA_VALUE_TYPE_DEFAULT(type) (0) -#else - -/** - * @var _EINA_VALUE_TYPE_BASICS_START - * pointer to the first basic type. - * @since 1.2 - * @private - */ -EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START; - -/** - * @var _EINA_VALUE_TYPE_BASICS_END - * pointer to the last (inclusive) basic type. - * @since 1.2 - * @private - */ -EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END; -#define EINA_VALUE_TYPE_DEFAULT(type) \ - ((_EINA_VALUE_TYPE_BASICS_START <= type) && \ - (type <= _EINA_VALUE_TYPE_BASICS_END)) -#endif - -#define EINA_VALUE_TYPE_CHECK_RETURN(value) \ - EINA_SAFETY_ON_NULL_RETURN(value); \ - EINA_SAFETY_ON_FALSE_RETURN(eina_value_type_check(value->type)) - -#define EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, retval) \ - EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), retval) - -#define EINA_VALUE_TYPE_DISPATCH(type, method, no_method_err, ...) \ - do \ - { \ - if (type->method) \ - type->method(type, ##__VA_ARGS__); \ - else \ - eina_error_set(no_method_err); \ - } \ - while (0) - -#define EINA_VALUE_TYPE_DISPATCH_RETURN(value, method, no_method_err, def_ret, ...) \ - do \ - { \ - if (type->method) \ - return type->method(type, ##__VA_ARGS__); \ - eina_error_set(no_method_err); \ - return def_ret; \ - } \ - while (0) - -/** - * @brief Get memory for given value (inline or allocated buffer). - * @since 1.2 - * @private - */ -static inline void * -eina_value_memory_get(const Eina_Value *value) -{ - if (value->type->value_size <= 8) - return (void *)value->value.buf; - return value->value.ptr; -} - -/** - * @brief Allocate memory for internal value types. - * @since 1.2 - * @private - */ -EAPI void *eina_value_inner_alloc(size_t size); -/** - * @brief Releases memory for internal value types. - * @since 1.2 - * @private - */ -EAPI void eina_value_inner_free(size_t size, void *mem); - -static inline Eina_Bool -eina_value_setup(Eina_Value *value, const Eina_Value_Type *type) -{ - void *mem; - - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - EINA_SAFETY_ON_FALSE_RETURN_VAL(type->value_size > 0, EINA_FALSE); - - value->type = type; - - if (type->value_size <= 8) mem = &value->value; - else - { - mem = value->value.ptr = eina_value_inner_alloc(type->value_size); - EINA_SAFETY_ON_NULL_RETURN_VAL(mem, EINA_FALSE); - } - - memset(mem, 0, type->value_size); - - if (EINA_VALUE_TYPE_DEFAULT(type)) - { - eina_error_set(0); - return EINA_TRUE; - } - - EINA_VALUE_TYPE_DISPATCH_RETURN(type, setup, - EINA_ERROR_VALUE_FAILED, EINA_FALSE, mem); -} - -static inline void -eina_value_flush(Eina_Value *value) -{ - const Eina_Value_Type *type; - void *mem; - - EINA_VALUE_TYPE_CHECK_RETURN(value); - - type = value->type; - mem = eina_value_memory_get(value); - - if (EINA_VALUE_TYPE_DEFAULT(type)) - { - if (type == EINA_VALUE_TYPE_STRINGSHARE) - { - if (value->value.ptr) eina_stringshare_del((const char*) value->value.ptr); - } - else if (type == EINA_VALUE_TYPE_STRING) - { - if (value->value.ptr) free(value->value.ptr); - } - else if (type->value_size > 8) - eina_value_inner_free(type->value_size, mem); - eina_error_set(0); - return; - } - - EINA_VALUE_TYPE_DISPATCH(type, flush, EINA_ERROR_VALUE_FAILED, mem); - if (type->value_size > 8) - eina_value_inner_free(type->value_size, mem); - value->type = NULL; -} - -static inline int -eina_value_compare(const Eina_Value *a, const Eina_Value *b) -{ - const Eina_Value_Type *type; - void *pa, *pb; - - EINA_VALUE_TYPE_CHECK_RETURN_VAL(a, -1); - EINA_SAFETY_ON_NULL_RETURN_VAL(b, -1); - EINA_SAFETY_ON_FALSE_RETURN_VAL(a->type == b->type, -1); - - eina_error_set(0); - type = a->type; - pa = eina_value_memory_get(a); - pb = eina_value_memory_get(b); - -#ifndef EINA_VALUE_NO_OPTIMIZE - if (type == EINA_VALUE_TYPE_UCHAR) - { - unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_USHORT) - { - unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_UINT) - { - unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP)) - { - unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_UINT64) - { - uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_CHAR) - { - char *ta = (char *) pa, *tb = (char *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_SHORT) - { - short *ta = (short *) pa, *tb = (short *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_INT) - { - int *ta = (int *) pa, *tb = (int *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_LONG) - { - long *ta = (long *) pa, *tb = (long *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_INT64) - { - int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_FLOAT) - { - float *ta = (float *) pa, *tb = (float *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_DOUBLE) - { - double *ta = (double *) pa, *tb = (double *) pb; - if (*ta < *tb) - return -1; - else if (*ta > *tb) - return 1; - return 0; - } - else if (type == EINA_VALUE_TYPE_STRINGSHARE || - type == EINA_VALUE_TYPE_STRING) - { - const char *sa = *(const char **)pa; - const char *sb = *(const char **)pb; - if (sa == sb) - return 0; - if (sa == NULL) - return -1; - if (sb == NULL) - return 1; - return strcmp(sa, sb); - } -#endif - - EINA_VALUE_TYPE_DISPATCH_RETURN(type, compare, EINA_ERROR_VALUE_FAILED, - EINA_FALSE, pa, pb); -} - -static inline Eina_Bool -eina_value_set(Eina_Value *value, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, value); - ret = eina_value_vset(value, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_get(const Eina_Value *value, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, value); - ret = eina_value_vget(value, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_vset(Eina_Value *value, va_list args) -{ - const Eina_Value_Type *type; - void *mem; - - EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); - - type = value->type; - mem = eina_value_memory_get(value); - eina_error_set(0); -#ifndef EINA_VALUE_NO_OPTIMIZE - if (type == EINA_VALUE_TYPE_UCHAR) - { - unsigned char *tmem = (unsigned char *) mem; - *tmem = va_arg(args, unsigned int); /* promoted by va_arg */ - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_USHORT) - { - unsigned short *tmem = (unsigned short *) mem; - *tmem = va_arg(args, unsigned int); /* promoted by va_arg */ - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_UINT) - { - unsigned int *tmem = (unsigned int *) mem; - *tmem = va_arg(args, unsigned int); - return EINA_TRUE; - } - else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP)) - { - unsigned long *tmem = (unsigned long *) mem; - *tmem = va_arg(args, unsigned long); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_UINT64) - { - uint64_t *tmem = (uint64_t *) mem; - *tmem = va_arg(args, uint64_t); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_CHAR) - { - char *tmem = (char *) mem; - *tmem = va_arg(args, int); /* promoted by va_arg */ - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_SHORT) - { - short *tmem = (short *) mem; - *tmem = va_arg(args, int); /* promoted by va_arg */ - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_INT) - { - int *tmem = (int *) mem; - *tmem = va_arg(args, int); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_LONG) - { - long *tmem = (long *) mem; - *tmem = va_arg(args, long); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_INT64) - { - int64_t *tmem = (int64_t *) mem; - *tmem = va_arg(args, int64_t); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_FLOAT) - { - float *tmem = (float *) mem; - *tmem = va_arg(args, double); /* promoted by va_arg */ - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_DOUBLE) - { - double *tmem = (double *) mem; - *tmem = va_arg(args, double); - return EINA_TRUE; - } - else if (type == EINA_VALUE_TYPE_STRINGSHARE) - { - const char *str = (const char *) va_arg(args, const char *); - return eina_stringshare_replace((const char **)&value->value.ptr, str); - } - else if (type == EINA_VALUE_TYPE_STRING) - { - const char *str = (const char *) va_arg(args, const char *); - if (value->value.ptr == str) return EINA_TRUE; - if (!str) - { - free(value->value.ptr); - value->value.ptr = NULL; - } - else - { - char *tmp = strdup(str); - if (!tmp) - { - eina_error_set(EINA_ERROR_OUT_OF_MEMORY); - return EINA_FALSE; - } - free(value->value.ptr); - value->value.ptr = tmp; - } - return EINA_TRUE; - } -#endif - - EINA_VALUE_TYPE_DISPATCH_RETURN(value, vset, EINA_ERROR_VALUE_FAILED, - EINA_FALSE, mem, args); -} - -static inline Eina_Bool -eina_value_vget(const Eina_Value *value, va_list args) -{ - const Eina_Value_Type *type; - const void *mem; - void *ptr; - - EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); - - type = value->type; - mem = eina_value_memory_get(value); - ptr = va_arg(args, void *); - eina_error_set(0); - if (EINA_VALUE_TYPE_DEFAULT(type)) - { - memcpy(ptr, mem, type->value_size); - return EINA_TRUE; - } - - EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED, - EINA_FALSE, mem, ptr); -} - -static inline Eina_Bool -eina_value_pset(Eina_Value *value, const void *ptr) -{ - const Eina_Value_Type *type; - void *mem; - - EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); - - type = value->type; - mem = eina_value_memory_get(value); - eina_error_set(0); - - if (EINA_VALUE_TYPE_DEFAULT(type)) - { - if (type == EINA_VALUE_TYPE_STRINGSHARE) - { - const char * const *pstr = (const char * const *) ptr; - const char *str = *pstr; - - return eina_stringshare_replace((const char **)&value->value.ptr, - str); - } - else if (type == EINA_VALUE_TYPE_STRING) - { - const char * const * pstr = (const char * const *) ptr; - const char *str = *pstr; - if (value->value.ptr == str) return EINA_TRUE; - if (!str) - { - free(value->value.ptr); - value->value.ptr = NULL; - } - else - { - char *tmp = strdup(str); - if (!tmp) - { - eina_error_set(EINA_ERROR_OUT_OF_MEMORY); - return EINA_FALSE; - } - free(value->value.ptr); - value->value.ptr = tmp; - } - return EINA_TRUE; - } - else - memcpy(mem, ptr, type->value_size); - return EINA_TRUE; - } - - EINA_VALUE_TYPE_DISPATCH_RETURN(value, pset, EINA_ERROR_VALUE_FAILED, - EINA_FALSE, mem, ptr); -} - -static inline Eina_Bool -eina_value_pget(const Eina_Value *value, void *ptr) -{ - const Eina_Value_Type *type; - const void *mem; - - EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); - - type = value->type; - mem = eina_value_memory_get(value); - eina_error_set(0); - if (EINA_VALUE_TYPE_DEFAULT(type)) - { - memcpy(ptr, mem, type->value_size); - return EINA_TRUE; - } - - EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED, - EINA_FALSE, mem, ptr); -} - -static inline const Eina_Value_Type * -eina_value_type_get(const Eina_Value *value) -{ - EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, NULL); - return value->type; -} - -#define EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, retval) \ - EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_ARRAY, retval) - -static inline Eina_Bool -eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int step) -{ - Eina_Value_Array desc = { subtype, step, NULL }; - if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY)) - return EINA_FALSE; - if (!eina_value_pset(value, &desc)) - { - eina_value_flush(value); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline unsigned int -eina_value_array_count(const Eina_Value *value) -{ - Eina_Value_Array desc; - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return 0; - return eina_inarray_count(desc.array); -} - -static inline Eina_Bool -eina_value_array_remove(Eina_Value *value, unsigned int position) -{ - Eina_Value_Array desc; - void *mem; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_nth(desc.array, position); - if (!mem) - return EINA_FALSE; - - eina_value_type_flush(desc.subtype, mem); - return eina_inarray_remove_at(desc.array, position); -} - -static inline Eina_Bool -eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args) -{ - Eina_Value_Array desc; - void *mem; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_nth(desc.array, position); - if (!mem) - return EINA_FALSE; - - return eina_value_type_vset(desc.subtype, mem, args); -} - -static inline Eina_Bool -eina_value_array_vget(const Eina_Value *value, unsigned int position, va_list args) -{ - Eina_Value_Array desc; - const void *mem; - void *ptr; - Eina_Bool ret; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_nth(desc.array, position); - if (!mem) - return EINA_FALSE; - - ptr = va_arg(args, void *); - ret = eina_value_type_pget(desc.subtype, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_array_vinsert(Eina_Value *value, unsigned int position, va_list args) -{ - Eina_Value_Array desc; - void *mem; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_alloc_at(desc.array, position, 1); - if (!mem) - return EINA_FALSE; - - if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; - if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc.subtype, mem); - error_setup: - eina_inarray_remove_at(desc.array, position); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_array_vappend(Eina_Value *value, va_list args) -{ - Eina_Value_Array desc; - void *mem; - int position; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - position = eina_inarray_count(desc.array); - mem = eina_inarray_alloc_at(desc.array, position, 1); - if (!mem) - return EINA_FALSE; - - if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; - if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc.subtype, mem); - error_setup: - eina_inarray_remove_at(desc.array, position); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_array_set(Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_array_vset(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_array_get(const Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_array_vget(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_array_insert(Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_array_vinsert(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool eina_value_array_append(Eina_Value *value, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, value); - ret = eina_value_array_vappend(value, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr) -{ - Eina_Value_Array desc; - void *mem; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_nth(desc.array, position); - if (!mem) - return EINA_FALSE; - - return eina_value_type_pset(desc.subtype, mem, ptr); -} - -static inline Eina_Bool -eina_value_array_pget(const Eina_Value *value, unsigned int position, void *ptr) -{ - Eina_Value_Array desc; - const void *mem; - Eina_Bool ret; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_nth(desc.array, position); - if (!mem) - return EINA_FALSE; - - ret = eina_value_type_pget(desc.subtype, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_array_pinsert(Eina_Value *value, unsigned int position, const void *ptr) -{ - Eina_Value_Array desc; - void *mem; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - mem = eina_inarray_alloc_at(desc.array, position, 1); - if (!mem) - return EINA_FALSE; - - if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; - if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc.subtype, mem); - error_setup: - eina_inarray_remove_at(desc.array, position); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_array_pappend(Eina_Value *value, const void *ptr) -{ - Eina_Value_Array desc; - void *mem; - int position; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); - if (!eina_value_pget(value, &desc)) - return EINA_FALSE; - - position = eina_inarray_count(desc.array); - mem = eina_inarray_alloc_at(desc.array, position, 1); - if (!mem) - return EINA_FALSE; - - if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; - if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc.subtype, mem); - error_setup: - eina_inarray_remove_at(desc.array, position); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_array_value_get(const Eina_Value *src, unsigned int position, Eina_Value *dst) -{ - Eina_Value_Array desc; - - EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(src, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE); - - if (!eina_value_pget(src, &desc)) - return EINA_FALSE; - if (position >= eina_inarray_count(desc.array)) - return EINA_FALSE; - if (!eina_value_setup(dst, desc.subtype)) - return EINA_FALSE; - if (!eina_value_pset(dst, eina_inarray_nth(desc.array, position))) - { - eina_value_flush(dst); - return EINA_FALSE; - } - - return EINA_TRUE; -} - -#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL - -#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \ - EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_LIST, retval) - -static inline void * -eina_value_list_node_memory_get(const Eina_Value_Type *type, const Eina_List *node) -{ - if (node == NULL) return NULL; - if (type->value_size <= sizeof(void*)) - return (void *)&(node->data); - return node->data; -} - -static inline void * -eina_value_list_node_memory_setup(const Eina_Value_Type *type, Eina_List *node) -{ - if (type->value_size <= sizeof(void*)) - return (void *)&(node->data); - node->data = malloc(type->value_size); - return node->data; -} - -static inline void -eina_value_list_node_memory_flush(const Eina_Value_Type *type, Eina_List *node) -{ - if (type->value_size <= sizeof(void*)) - return; - free(node->data); -} - -static inline Eina_Bool -eina_value_list_setup(Eina_Value *value, const Eina_Value_Type *subtype) -{ - Eina_Value_List desc = { subtype, NULL }; - if (!eina_value_setup(value, EINA_VALUE_TYPE_LIST)) - return EINA_FALSE; - if (!eina_value_pset(value, &desc)) - { - eina_value_flush(value); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline unsigned int -eina_value_list_count(const Eina_Value *value) -{ - Eina_Value_List *desc; - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return 0; - return eina_list_count(desc->list); -} - -static inline Eina_Bool -eina_value_list_remove(Eina_Value *value, unsigned int position) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - node = eina_list_nth_list(desc->list, position); - mem = eina_value_list_node_memory_get(desc->subtype, node); - if (!mem) - return EINA_FALSE; - - eina_value_type_flush(desc->subtype, mem); - eina_value_list_node_memory_flush(desc->subtype, node); - desc->list = eina_list_remove_list(desc->list, node); - return EINA_TRUE; -} - -static inline Eina_Bool -eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - node = eina_list_nth_list(desc->list, position); - mem = eina_value_list_node_memory_get(desc->subtype, node); - if (!mem) - return EINA_FALSE; - - return eina_value_type_vset(desc->subtype, mem, args); -} - -static inline Eina_Bool -eina_value_list_vget(const Eina_Value *value, unsigned int position, va_list args) -{ - const Eina_Value_List *desc; - const Eina_List *node; - const void *mem; - void *ptr; - Eina_Bool ret; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (const Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - node = eina_list_nth_list(desc->list, position); - mem = eina_value_list_node_memory_get(desc->subtype, node); - if (!mem) - return EINA_FALSE; - - ptr = va_arg(args, void *); - ret = eina_value_type_pget(desc->subtype, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_list_vinsert(Eina_Value *value, unsigned int position, va_list args) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - if (!desc->list) - node = desc->list = eina_list_append(NULL, (void*)1L); - else if (position == 0) - node = desc->list = eina_list_prepend(desc->list, (void*)1L); - else - { - Eina_List *rel = eina_list_nth_list(desc->list, position - 1); - desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel); - node = rel->next; - } - EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); - EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); - - mem = eina_value_list_node_memory_setup(desc->subtype, node); - if (!mem) - { - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; - } - - if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; - if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc->subtype, mem); - error_setup: - eina_value_list_node_memory_flush(desc->subtype, node); - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_list_vappend(Eina_Value *value, va_list args) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - desc->list = eina_list_append(desc->list, (void*)1L); - node = eina_list_last(desc->list); - EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); - EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); - - mem = eina_value_list_node_memory_setup(desc->subtype, node); - if (!mem) - { - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; - } - - if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; - if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc->subtype, mem); - error_setup: - eina_value_list_node_memory_flush(desc->subtype, node); - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_list_set(Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_list_vset(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_list_get(const Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_list_vget(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_list_insert(Eina_Value *value, unsigned int position, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, position); - ret = eina_value_list_vinsert(value, position, args); - va_end(args); - return ret; -} - -static inline Eina_Bool eina_value_list_append(Eina_Value *value, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, value); - ret = eina_value_list_vappend(value, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - node = eina_list_nth_list(desc->list, position); - mem = eina_value_list_node_memory_get(desc->subtype, node); - if (!mem) - return EINA_FALSE; - - return eina_value_type_pset(desc->subtype, mem, ptr); -} - -static inline Eina_Bool -eina_value_list_pget(const Eina_Value *value, unsigned int position, void *ptr) -{ - const Eina_Value_List *desc; - const Eina_List *node; - const void *mem; - Eina_Bool ret; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (const Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - node = eina_list_nth_list(desc->list, position); - mem = eina_value_list_node_memory_get(desc->subtype, node); - if (!mem) - return EINA_FALSE; - - ret = eina_value_type_pget(desc->subtype, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_list_pinsert(Eina_Value *value, unsigned int position, const void *ptr) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - if (!desc->list) - node = desc->list = eina_list_append(NULL, (void*)1L); - else if (position == 0) - node = desc->list = eina_list_prepend(desc->list, (void*)1L); - else - { - Eina_List *rel = eina_list_nth_list(desc->list, position - 1); - desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel); - node = rel->next; - } - EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); - EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); - - mem = eina_value_list_node_memory_setup(desc->subtype, node); - if (!mem) - { - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; - } - - if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; - if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc->subtype, mem); - error_setup: - eina_value_list_node_memory_flush(desc->subtype, node); - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; -} - -static inline Eina_Bool -eina_value_list_pappend(Eina_Value *value, const void *ptr) -{ - Eina_Value_List *desc; - Eina_List *node; - void *mem; - - EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_List *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - desc->list = eina_list_append(desc->list, (void*)1L); - node = eina_list_last(desc->list); - EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); - EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); - - mem = eina_value_list_node_memory_setup(desc->subtype, node); - if (!mem) - { - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; - } - - if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; - if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; - return EINA_TRUE; - - error_set: - eina_value_type_flush(desc->subtype, mem); - error_setup: - eina_value_list_node_memory_flush(desc->subtype, node); - desc->list = eina_list_remove_list(desc->list, node); - return EINA_FALSE; -} -#undef EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL - -#define EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, retval) \ - EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_HASH, retval) - -static inline Eina_Bool -eina_value_hash_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size) -{ - Eina_Value_Hash desc = { subtype, buckets_power_size, NULL }; - if (!eina_value_setup(value, EINA_VALUE_TYPE_HASH)) - return EINA_FALSE; - if (!eina_value_pset(value, &desc)) - { - eina_value_flush(value); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline unsigned int -eina_value_hash_population(const Eina_Value *value) -{ - Eina_Value_Hash *desc; - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); - desc = (Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return 0; - return eina_hash_population(desc->hash); -} - -static inline Eina_Bool -eina_value_hash_del(Eina_Value *value, const char *key) -{ - Eina_Value_Hash *desc; - void *mem; - - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); - desc = (Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - mem = eina_hash_find(desc->hash, key); - if (!mem) - return EINA_FALSE; - - eina_value_type_flush(desc->subtype, mem); - free(mem); - eina_hash_del_by_key(desc->hash, key); - return EINA_TRUE; -} - -static inline Eina_Bool -eina_value_hash_vset(Eina_Value *value, const char *key, va_list args) -{ - Eina_Value_Hash *desc; - void *mem; - - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); - desc = (Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - mem = eina_hash_find(desc->hash, key); - if (!mem) - { - mem = malloc(desc->subtype->value_size); - if (!mem) - { - eina_error_set(EINA_ERROR_OUT_OF_MEMORY); - return EINA_FALSE; - } - if (!eina_hash_add(desc->hash, key, mem)) - { - free(mem); - return EINA_FALSE; - } - if (!eina_value_type_setup(desc->subtype, mem)) - { - eina_value_type_flush(desc->subtype, mem); - eina_hash_del_by_key(desc->hash, key); - free(mem); - } - } - - return eina_value_type_vset(desc->subtype, mem, args); -} - -static inline Eina_Bool -eina_value_hash_vget(const Eina_Value *value, const char *key, va_list args) -{ - const Eina_Value_Hash *desc; - const void *mem; - void *ptr; - Eina_Bool ret; - - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); - desc = (const Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - mem = eina_hash_find(desc->hash, key); - if (!mem) - return EINA_FALSE; - - ptr = va_arg(args, void *); - ret = eina_value_type_pget(desc->subtype, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_hash_set(Eina_Value *value, const char *key, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, key); - ret = eina_value_hash_vset(value, key, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_hash_get(const Eina_Value *value, const char *key, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, key); - ret = eina_value_hash_vget(value, key, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr) -{ - Eina_Value_Hash *desc; - void *mem; - - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); - desc = (Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - mem = eina_hash_find(desc->hash, key); - if (!mem) - { - mem = malloc(desc->subtype->value_size); - if (!mem) - { - eina_error_set(EINA_ERROR_OUT_OF_MEMORY); - return EINA_FALSE; - } - if (!eina_hash_add(desc->hash, key, mem)) - { - free(mem); - return EINA_FALSE; - } - if (!eina_value_type_setup(desc->subtype, mem)) - { - eina_value_type_flush(desc->subtype, mem); - eina_hash_del_by_key(desc->hash, key); - free(mem); - } - } - - return eina_value_type_pset(desc->subtype, mem, ptr); -} - -static inline Eina_Bool -eina_value_hash_pget(const Eina_Value *value, const char *key, void *ptr) -{ - const Eina_Value_Hash *desc; - const void *mem; - Eina_Bool ret; - - EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); - desc = (const Eina_Value_Hash *)eina_value_memory_get(value); - if (!desc) - return EINA_FALSE; - - mem = eina_hash_find(desc->hash, key); - if (!mem) - return EINA_FALSE; - - ret = eina_value_type_pget(desc->subtype, mem, ptr); - return ret; -} -#undef EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL - -#define EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, retval) \ - EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ - EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_STRUCT, retval) - -/** - * @brief Find member of struct - * @since 1.2 - * @internal - */ -EAPI const Eina_Value_Struct_Member *eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -static inline Eina_Bool -eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc) -{ - Eina_Value_Struct desc = {sdesc, NULL}; - if (!eina_value_setup(value, EINA_VALUE_TYPE_STRUCT)) - return EINA_FALSE; - if (!eina_value_pset(value, &desc)) - { - eina_value_flush(value); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline void * -eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member) -{ - unsigned char *base = (unsigned char *)st->memory; - if (!base) return NULL; - return base + member->offset; -} - -static inline Eina_Bool -eina_value_struct_vset(Eina_Value *value, const char *name, va_list args) -{ - const Eina_Value_Struct_Member *member; - Eina_Value_Struct *st; - void *mem; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - st = (Eina_Value_Struct *)eina_value_memory_get(value); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - return eina_value_type_vset(member->type, mem, args); -} - -static inline Eina_Bool -eina_value_struct_vget(const Eina_Value *value, const char *name, va_list args) -{ - const Eina_Value_Struct_Member *member; - const Eina_Value_Struct *st; - const void *mem; - void *ptr; - Eina_Bool ret; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - st = (const Eina_Value_Struct *)eina_value_memory_get(value); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - ptr = va_arg(args, void *); - ret = eina_value_type_pget(member->type, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_struct_set(Eina_Value *value, const char *name, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, name); - ret = eina_value_struct_vset(value, name, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_struct_get(const Eina_Value *value, const char *name, ...) -{ - va_list args; - Eina_Bool ret; - va_start(args, name); - ret = eina_value_struct_vget(value, name, args); - va_end(args); - return ret; -} - -static inline Eina_Bool -eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr) -{ - const Eina_Value_Struct_Member *member; - Eina_Value_Struct *st; - void *mem; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); - st = (Eina_Value_Struct *)eina_value_memory_get(value); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - return eina_value_type_pset(member->type, mem, ptr); -} - -static inline Eina_Bool -eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr) -{ - const Eina_Value_Struct_Member *member; - const Eina_Value_Struct *st; - const void *mem; - Eina_Bool ret; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); - st = (const Eina_Value_Struct *)eina_value_memory_get(value); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - ret = eina_value_type_pget(member->type, mem, ptr); - return ret; -} - -static inline Eina_Bool -eina_value_struct_value_get(const Eina_Value *src, const char *name, Eina_Value *dst) -{ - const Eina_Value_Struct_Member *member; - const Eina_Value_Struct *st; - const void *mem; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE); - st = (const Eina_Value_Struct *)eina_value_memory_get(src); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - if (!eina_value_setup(dst, member->type)) - return EINA_FALSE; - if (!eina_value_pset(dst, mem)) - { - eina_value_flush(dst); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline Eina_Bool -eina_value_struct_value_set(Eina_Value *dst, const char *name, const Eina_Value *src) -{ - const Eina_Value_Struct_Member *member; - Eina_Value_Struct *st; - void *mem; - const void *ptr; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE); - - st = (Eina_Value_Struct *)eina_value_memory_get(dst); - if (!st) - return EINA_FALSE; - member = eina_value_struct_member_find(st, name); - if (!member) - return EINA_FALSE; - EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE); - - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - ptr = eina_value_memory_get(src); - if (!ptr) - return EINA_FALSE; - - return eina_value_type_pset(member->type, mem, ptr); -} - -static inline Eina_Bool -eina_value_struct_member_value_get(const Eina_Value *src, const Eina_Value_Struct_Member *member, Eina_Value *dst) -{ - const Eina_Value_Struct *st; - const void *mem; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE); - st = (const Eina_Value_Struct *)eina_value_memory_get(src); - if (!st) - return EINA_FALSE; - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - if (!eina_value_setup(dst, member->type)) - return EINA_FALSE; - if (!eina_value_pset(dst, mem)) - { - eina_value_flush(dst); - return EINA_FALSE; - } - return EINA_TRUE; -} - -static inline Eina_Bool -eina_value_struct_member_value_set(Eina_Value *dst, const Eina_Value_Struct_Member *member, const Eina_Value *src) -{ - Eina_Value_Struct *st; - void *mem; - const void *ptr; - - EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE); - - st = (Eina_Value_Struct *)eina_value_memory_get(dst); - if (!st) - return EINA_FALSE; - EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE); - - mem = eina_value_struct_member_memory_get(st, member); - if (!mem) - return EINA_FALSE; - - ptr = eina_value_memory_get(src); - if (!ptr) - return EINA_FALSE; - - return eina_value_type_pset(member->type, mem, ptr); -} - -#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL - - -static inline Eina_Bool -eina_value_type_setup(const Eina_Value_Type *type, void *mem) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->setup) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->setup(type, mem); -} - -static inline Eina_Bool -eina_value_type_flush(const Eina_Value_Type *type, void *mem) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->flush) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->flush(type, mem); -} - -static inline Eina_Bool -eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->copy) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->copy(type, src, dst); -} - -static inline int -eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->compare) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->compare(type, a, b); -} - -static inline Eina_Bool -eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->convert_to) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->convert_to(type, convert, type_mem, convert_mem); -} - -static inline Eina_Bool -eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->convert_from) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->convert_from(type, convert, type_mem, convert_mem); -} - -static inline Eina_Bool -eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->vset) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->vset(type, mem, args); -} - -static inline Eina_Bool -eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->pset) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->pset(type, mem, ptr); -} - -static inline Eina_Bool -eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); - if (!type->pget) - { - eina_error_set(EINA_ERROR_VALUE_FAILED); - return EINA_FALSE; - } - return type->pget(type, mem, ptr); -} - -#undef EINA_VALUE_TYPE_DEFAULT -#undef EINA_VALUE_TYPE_CHECK_RETURN -#undef EINA_VALUE_TYPE_CHECK_RETURN_VAL -#undef EINA_VALUE_TYPE_DISPATCH -#undef EINA_VALUE_TYPE_DISPATCH_RETURN -#endif diff --git a/libraries/eina/src/include/eina_inlist.h b/libraries/eina/src/include/eina_inlist.h deleted file mode 100644 index cfb3159..0000000 --- a/libraries/eina/src/include/eina_inlist.h +++ /dev/null @@ -1,814 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_INLIST_H_ -#define EINA_INLIST_H_ - -#include "eina_types.h" -#include "eina_iterator.h" -#include "eina_accessor.h" -#include - -/** - * @page eina_inlist_01_example_page Eina_Inlist basic usage - * @dontinclude eina_inlist_01.c - * - * To see the full source for this example, click here: @ref - * eina_inlist_01_c - * - * As explained before, inline lists mean its nodes pointers are part of same - * memory block/blob. This is done by using the macro @ref EINA_INLIST inside the - * data structure that will be used: - * - * @skip struct - * @until }; - * - * The resulting node representing this struct can be exemplified by the - * following picture: - * - * @image html eina_inlist-node_eg1-my-struct.png - * @image rtf eina_inlist-node_eg1-my-struct.png - * @image latex eina_inlist-node_eg1-my-struct.eps - * - * Let's define a comparison function that will be used later during the - * sorting of the list: - * - * @skip int - * @until } - * - * The @ref Eina_Inlist can be used exactly the same way as @ref Eina_List when - * appending, prepending and removing items. But since we already have the node - * pointers inside the structure, they need to be retrieved with the macro @ref - * EINA_INLIST_GET : - * - * @skip malloc - * @until append - * - * Notice that @ref eina_inlist_append always receives the head of the list as - * first argument, and its return value should be used as the list pointer - * (head): - * - * @skip malloc - * @until append - * - * After appending 3 items, the list now should look similar to this: - * - * @image html eina_inlist-node_eg1-inlist.png - * @image rtf eina_inlist-node_eg1-inlist.png - * @image latex eina_inlist-node_eg1-inlist.eps width=\textwidth - * - * The macro @ref EINA_INLIST_FOREACH can be used to iterate over the list: - * - * @skip printf - * @until cur->a - * - * @ref eina_inlist_promote(), @ref eina_inlist_demote(), @ref - * eina_inlist_append_relative() and similar functions all work in the same way - * as the @ref Eina_List : - * - * @skip eina_inlist_promote - * @until eina_inlist_demote - * - * Now let's use the @c sort_cb function declared above to sort our list: - * - * @skipline eina_inlist_sort - * - * Removing an element from the inlist is also similar to @ref Eina_List : - * - * @skip inlist_remove - * @until free - * - * Another way of walking through the inlist. - * - * @skip for - * @until } - * - * Notice that in the previous piece of code, since we only have the pointers to - * the inlist nodes, we have to use the @ref EINA_INLIST_CONTAINER_GET macro - * that will return the pointer to the entire structure. Of course, in this case - * it is the same as the list pointer, since the @ref EINA_INLIST macro was used - * in the beginning of the structure. - * - * Now to finish this example, lets delete this list: - * - * @skip while - * @until } - */ - -/** - * @page eina_inlist_02_example_page Eina_Inlist advanced usage - lists and inlists - * @dontinclude eina_inlist_02.c - * - * 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 members - * are also added to a normal list. Later we remove the elements divisible by 3 - * from this normal list. - * - * The struct that is going to be used is the same used in @ref - * eina_inlist_01_example_page , since we still need the @ref EINA_INLIST macro to - * declare the inlist node info: - * - * @skip struct - * @until }; - * - * The resulting node representing this struct can be exemplified by the - * following picture: - * - * @image html eina_inlist-node_eg2-my-struct.png - * @image rtf eina_inlist-node_eg2-my-struct.png - * @image latex eina_inlist-node_eg2-my-struct.eps - * - * Now we need some pointers and auxiliar variables that will help us iterate on - * the lists: - * - * @skip struct - * @until l_next; - * - * Allocating 100 elements and putting them into an inlist, and the even - * elements also go to the normal list: - * - * @skip for - * @until } - * - * After this point, what we have are two distinct lists that share some - * elements. The first list (inlist) is defined by the pointers inside the - * elements data structure, while the second list (normal list) has its own node - * data structure that is kept outside of the elements. - * - * The two lists, sharing some elements, can be represented by the following - * picture: - * - * @htmlonly - * - * @endhtmlonly - * @image rtf eina_inlist-node_eg2-list-inlist.png - * @image latex eina_inlist-node_eg2-list-inlist.eps width=\textwidth - * - * Accessing both lists is done normally, as if they didn't have any elements in - * common: - * - * @skip printf - * @until eina_list_count - * - * We can remove elements from the normal list, but we just don't free them - * because they are still stored in the inlist: - * - * @skip EINA_LIST_FOREACH_SAFE - * @until eina_list_count - * - * To finish this example, we want to free both lists, we can't just free all - * elements on the second list (normal list) because they are still being used - * in the inlist. So we first discard the normal list without freeing its - * elements, then we free all elements in the inlist (that contains all elements - * allocated until now): - * - * @skip eina_list_free - * @until } - * - * Here is the full source code for this example: @ref eina_inlist_02_c - */ - -/** - * @page eina_inlist_03_example_page Eina_Inlist advanced usage - multi-inlists - * @dontinclude eina_inlist_03.c - * - * This example describes the usage of multiple inlists storing the same data. - * It means that some data may appear in more than one inlist at the same time. - * We will demonstrate this by creating an inlist with 100 numbers, and adding - * the odd numbers to the second inlist, then remove the numbers divisible by 3 - * from the second list. - * - * To accomplish this, it is necessary to have two inlist pointers in the struct - * that is going to be stored. We are using the default inlist member @ref - * EINA_INLIST, and adding another member @c even that is of type @ref - * Eina_Inlist too: - * - * @skip struct - * @until }; - * - * The representation for this struct is: - * - * @image html eina_inlist-node_eg3-my-struct.png - * @image rtf eina_inlist-node_eg3-my-struct.png - * @image latex eina_inlist-node_eg3-my-struct.eps - * - * And we will define some convenience macros that are equivalent to @ref - * EINA_INLIST_GET and @ref EINA_INLIST_CONTAINER_GET : - * - * @skip define - * @until offsetof - * - * We need two pointers, one for each list, and a pointer that will be used as - * an iterator: - * - * @skipline Eina_Inlist - * - * Now we allocate and add to the first list every number from 0 to 99. These - * nodes data also have the @ref Eina_Inlist node info for the second list (@c - * even). We will use them to add just the even numbers to the second list, the - * @c list_even. Also notice that we are using our macro @c EVEN_INLIST_GET to - * get the pointer to the even list node info: - * - * @skip for - * @until } - * - * And the resulting lists will be as follow: - * - * @htmlonly - * - * @endhtmlonly - * @image rtf eina_inlist-node_eg3-two-inlists.png - * @image latex eina_inlist-node_eg3-two-inlists.eps width=\textwidth - * - * For the first list, we can use the macro @ref EINA_INLIST_FOREACH to iterate - * over its elements: - * - * @skip FOREACH - * @until printf - * - * But for the second list, we have to do it manually. Of course we could create - * a similar macro to @ref EINA_INLIST_FOREACH, but since this macro is more - * complex than the other two and we are using it only once, it's better to just - * do it manually: - * - * @skip for - * @until } - * - * Let's just check that the two lists have the expected number of elements: - * - * @skip list count - * @until list_even count - * - * And removing the numbers divisible by 3 only from the second list: - * - * @skip itr - * @until list_even count - * - * Now that we don't need the two lists anymore, we can just free all the items. - * Since all of the allocated data was put into the first list, and both lists - * are made of pointers to inside the data structures, we can free only the - * first list (that contains all the elements) and the second list will be gone - * with it: - * - * @skip while - * @until free - * - * To see the full source code for this example, click here: @ref - * eina_inlist_03_c - * - */ - -/** - * @page eina_inlist_01_c eina_inlist_01.c Eina_Inlist basic usage source - * @include eina_inlist_01.c - */ - -/** - * @page eina_inlist_02_c eina_inlist_02.c Eina_Inlist advanced usage - lists and inlists source - * @include eina_inlist_02.c - */ - -/** - * @page eina_inlist_03_c eina_inlist_03.c Eina_Inlist advanced usage - multi-inlists source - * @include eina_inlist_03.c - */ - -/** - * @addtogroup Eina_Inline_List_Group Inline List - * - * @brief These functions provide inline list management. - * - * Inline lists mean its nodes pointers are part of same memory as - * data. This has the benefit of fragmenting memory less and avoiding - * @c node->data indirection, but has the drawback of higher cost for some - * common operations like count and sort. - * - * It is possible to have inlist nodes to be part of regular lists, created with - * @ref eina_list_append() or @ref eina_list_prepend(). It's also possible to - * have a structure with two inlist pointers, thus be part of two different - * inlists at the same time, but the current convenience macros provided won't - * work for both of them. Consult @ref inlist_advanced for more info. - * - * Inline lists have their purposes, but if you don't know what those purposes are, go with - * regular lists instead. - * - * Tip: When using inlists in more than one place (that is, passing them around - * 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 - * 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 - * exactly what type this list is. - * - * A simple example demonstrating the basic usage of an inlist can be found - * here: @ref eina_inlist_01_example_page - * - * @section inlist_algo Algorithm - * - * The basic structure can be represented by the following picture: - * - * @image html eina_inlist-node.png - * @image rtf eina_inlist-node.png - * @image latex eina_inlist-node.eps - * - * One data structure will also have the node information, with three pointers: - * @a prev, @a next and @a last. The @a last pointer is just valid for the first - * element (the list head), otherwise each insertion in the list would have to - * be done updating every node with the correct pointer. This means that it's - * always very important to keep a pointer to the first element of the list, - * since it is the only one that has the correct information to allow a proper - * O(1) append to the list. - * - * @section inlist_perf Performance - * - * Due to the nature of the inlist, there's no accounting information, and no - * easy access to the last element from each list node. This means that @ref - * eina_inlist_count() is order-N, while @ref eina_list_count() is order-1 (constant - * time). - * - * For the same reasons, @ref eina_inlist_sort() is slower than @ref - * eina_list_sort() . If the list is intended to have faster access, be - * sorted/merged frequently, or needs to have other complex operations, consider - * using @ref Eina_List instead. - * - * @section inlist_advanced Advanced Usage - * - * The basic usage considers a struct that will have the user data, and also - * have an inlist node information (prev, next and last pointers) created with - * @ref EINA_INLIST during the struct declaration. This allows one to use the - * convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GET(), - * @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_INLIST - * macro declares a struct member with the name @a __inlist, and all the other - * 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 - * @ref Eina_List too. If this happens, the inlist nodes can be added to the - * @ref Eina_List without any problems. This example demonstrates this case: - * @ref inlist_02_example_page - * - * It's also possible to have some data that is part of two different inlists. - * If this is the case, then it won't be possible to use the convenience macros - * 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 usage can - * be found here: - * @ref inlist_03_example_page - * - * List of examples: - * @li @ref eina_inlist_01_example_page - * @li @ref eina_inlist_02_example_page - * @li @ref eina_inlist_03_example_page - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Inline_List_Group Inline List - * - * @{ - */ - -/** - * @typedef Eina_Inlist - * Inlined list type. - */ -typedef struct _Eina_Inlist Eina_Inlist; - -/** - * @typedef Eina_Inlist_Sorted_State - * @since 1.1.0 - * State of sorted Eina_Inlist - */ -typedef struct _Eina_Inlist_Sorted_State Eina_Inlist_Sorted_State; - -/** - * @struct _Eina_Inlist - * Inlined list type. - */ -struct _Eina_Inlist -{ - Eina_Inlist *next; /**< next node */ - Eina_Inlist *prev; /**< previous node */ - Eina_Inlist *last; /**< last node */ -}; -/** Used for declaring an inlist member in a struct */ -#define EINA_INLIST Eina_Inlist __in_list -/** Utility macro to get the inlist object of a struct */ -#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list)) -/** Utility macro to get the container object of an inlist */ -#define EINA_INLIST_CONTAINER_GET(ptr, \ - type) ((type *)((char *)ptr - \ - offsetof(type, __in_list))) - - -/** - * Add a new node to end of a list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a in_list. - * - * @note @a in_item is considered to be in no list. If it was in another - * list before, eina_inlist_remove() it before adding. No - * check of @a new_l prev and next pointers is done, so it's safe - * to have them uninitialized. - * - * @param in_list existing list head or NULL to create a new list. - * @param in_item new list node, must not be NULL. - * - * @return the new list head. Use it and not @a in_list anymore. - */ -EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, - Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * Add a new node to beginning of list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a in_list. - * - * @note @a new_l is considered to be in no list. If it was in another - * list before, eina_inlist_remove() it before adding. No - * check of @a new_l prev and next pointers is done, so it's safe - * to have them uninitialized. - * - * @param in_list existing list head or NULL to create a new list. - * @param in_item new list node, must not be NULL. - * - * @return the new list head. Use it and not @a in_list anymore. - */ -EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, - Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * Add a new node after the given relative item in list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a in_list. - * - * @note @a in_item_l is considered to be in no list. If it was in another - * list before, eina_inlist_remove() it before adding. No - * check of @a in_item prev and next pointers is done, so it's safe - * to have them uninitialized. - * - * @note @a in_relative is considered to be inside @a in_list, no checks are - * done to confirm that and giving nodes from different lists - * will lead to problems. Giving NULL @a in_relative is the same as - * eina_list_append(). - * - * @param in_list existing list head or NULL to create a new list. - * @param in_item new list node, must not be NULL. - * @param in_relative reference node, @a in_item will be added after it. - * - * @return the new list head. Use it and not @a list anymore. - */ -EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list, - Eina_Inlist *in_item, - Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * Add a new node before the given relative item in list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a in_list. - * - * @note @a in_item is considered to be in no list. If it was in another - * list before, eina_inlist_remove() it before adding. No - * check of @a in_item prev and next pointers is done, so it's safe - * to have them uninitialized. - * - * @note @a in_relative is considered to be inside @a in_list, no checks are - * done to confirm that and giving nodes from different lists - * will lead to problems. Giving NULL @a in_relative is the same as - * eina_list_prepend(). - * - * @param in_list existing list head or NULL to create a new list. - * @param in_item new list node, must not be NULL. - * @param in_relative reference node, @a in_item will be added before it. - * - * @return the new list head. Use it and not @a in_list anymore. - */ -EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, - Eina_Inlist *in_item, - Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * Remove node from list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a list. - * - * @note @a in_item is considered to be inside @a in_list, no checks are - * done to confirm that and giving nodes from different lists - * will lead to problems, especially if @a in_item is the head since - * it will be different from @a list and the wrong new head will - * be returned. - * - * @param in_list existing list head, must not be NULL. - * @param in_item existing list node, must not be NULL. - * - * @return the new list head. Use it and not @a list anymore. - */ -EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list, - Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * Find given node in list, returns itself if found, NULL if not. - * - * @warning this is an expensive call and has O(n) cost, possibly - * walking the whole list. - * - * @param in_list existing list to search @a in_item in, must not be NULL. - * @param in_item what to search for, must not be NULL. - * - * @return @a in_item if found, NULL if not. - */ -EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list, - Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * Move existing node to beginning of list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a list. - * - * @note @a item is considered to be inside @a list. No checks are - * done to confirm this, and giving nodes from different lists - * will lead to problems. - * - * @param list existing list head or NULL to create a new list. - * @param item list node to move to beginning (head), must not be NULL. - * - * @return the new list head. Use it and not @a list anymore. - */ -EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist *list, - Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * Move existing node to end of list. - * - * @note this code is meant to be fast: appends are O(1) and do not - * walk @a list. - * - * @note @a item is considered to be inside @a list. No checks are - * done to confirm this, and giving nodes from different lists - * will lead to problems. - * - * @param list existing list head or NULL to create a new list. - * @param item list node to move to end (tail), must not be NULL. - * - * @return the new list head. Use it and not @a list anymore. - */ -EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist *list, - Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the count of the number of items in a list. - * - * @param list The list whose count to return. - * @return The number of members in the list. - * - * This function returns how many members @p list contains. If the - * list is @c NULL, 0 is returned. - * - * @warning This is an order-N operation and so the time will depend - * on the number of elements on the list, so, it might become - * slow for big lists! - */ -EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Returns a new iterator associated to @a list. - * - * @param in_list The list. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * in_list. If @p in_list is @c NULL or the count member of @p in_list is less - * or equal than 0, this function still returns a valid iterator that - * will always return false on eina_iterator_next(), thus keeping API - * sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the list structure changes then the iterator becomes - * invalid, and if you add or remove nodes iterator - * behavior is undefined, and your program may crash! - */ -EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returns a new accessor associated to a list. - * - * @param in_list The list. - * @return A new accessor. - * - * This function returns a newly allocated accessor associated to - * @p in_list. If @p in_list is @c NULL or the count member of @p in_list is - * less or equal than 0, this function returns @c NULL. If the memory can - * not be allocated, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is - * set. Otherwise, a valid accessor is returned. - */ -EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Insert a new node into a sorted list. - * - * @param list The given linked list, @b must be sorted. - * @param item list node to insert, must not be NULL. - * @param func The function called for the sort. - * @return A list pointer. - * @since 1.1.0 - * - * This function inserts item into a linked list assuming it was - * sorted and the result will be sorted. If @p list is @c NULLL, item - * is returned. On success, a new list pointer that should be - * used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. See eina_error_get(). - * - * @note O(log2(n)) comparisons (calls to @p func) average/worst case - * performance. As said in eina_list_search_sorted_near_list(), - * lists do not have O(1) access time, so walking to the correct node - * can be costly, consider worst case to be almost O(n) pointer - * dereference (list walk). - */ -EAPI Eina_Inlist *eina_inlist_sorted_insert(Eina_Inlist *list, Eina_Inlist *item, Eina_Compare_Cb func) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create state with valid data in it. - * - * @return A valid Eina_Inlist_Sorted_State. - * @since 1.1.0 - * - * See eina_inlist_sorted_state_insert() for more information. - */ -EAPI Eina_Inlist_Sorted_State *eina_inlist_sorted_state_new(void); - -/** - * @brief Force an Eina_Inlist_Sorted_State to match the content of a list. - * - * @param state The state to update - * @param list The list to match - * @return The number of item in the actually in the list - * @since 1.1.0 - * - * See eina_inlist_sorted_state_insert() for more information. This function is - * usefull if you didn't use eina_inlist_sorted_state_insert() at some point, but - * still think you have a sorted list. It will only correctly work on a sorted list. - */ -EAPI int eina_inlist_sorted_state_init(Eina_Inlist_Sorted_State *state, Eina_Inlist *list); - -/** - * @brief Free an Eina_Inlist_Sorted_State. - * - * @param state The state to destroy - * @since 1.1.0 - * - * See eina_inlist_sorted_state_insert() for more information. - */ -EAPI void eina_inlist_sorted_state_free(Eina_Inlist_Sorted_State *state); - -/** - * @brief Insert a new node into a sorted list. - * - * @param list The given linked list, @b must be sorted. - * @param item list node to insert, must not be NULL. - * @param func The function called for the sort. - * @param state The current array for initial dichotomic search - * @return A list pointer. - * @since 1.1.0 - * - * This function inserts item into a linked list assuming @p state match - * the exact content order of the list. It use @p state to do a fast - * first step dichotomic search before starting to walk the inlist itself. - * This make this code much faster than eina_inlist_sorted_insert() as it - * doesn't need to walk the list at all. The result is of course a sorted - * list with an updated state.. If @p list is @c NULLL, item - * is returned. On success, a new list pointer that should be - * used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. See eina_error_get(). - * - * @note O(log2(n)) comparisons (calls to @p func) average/worst case - * performance. As said in eina_list_search_sorted_near_list(), - * lists do not have O(1) access time, so walking to the correct node - * can be costly, but this version try to minimize that by making it a - * O(log2(n)) for number small number. After n == 256, it start to add a - * linear cost again. Consider worst case to be almost O(n) pointer - * dereference (list walk). - */ -EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list, - Eina_Inlist *item, - Eina_Compare_Cb func, - Eina_Inlist_Sorted_State *state); -/** - * @brief Sort a list according to the ordering func will return. - * - * @param head The list handle to sort. - * @param func A function pointer that can handle comparing the list data - * nodes. - * @return the new head of list. - * - * This function sorts all the elements of @p head. @p func is used to - * compare two elements of @p head. If @p head or @p func are @c NULL, - * this function returns @c NULL. - * - * @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. - * - * @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 - * elements, sort will usually do 1,000,000 comparisons, but may do up - * to 20,000,000. - * - * Example: - * @code - * typedef struct _Sort_Ex Sort_Ex; - * struct _Sort_Ex - * { - * INLIST; - * const char *text; - * }; - * - * int - * sort_cb(const Inlist *l1, const Inlist *l2) - * { - * const Sort_Ex *x1; - * const Sort_Ex *x2; - * - * x1 = EINA_INLIST_CONTAINER_GET(l1, Sort_Ex); - * x2 = EINA_INLIST_CONTAINER_GET(l2, Sort_Ex); - * - * return(strcmp(x1->text, x2->text)); - * } - * extern Eina_Inlist *list; - * - * list = eina_inlist_sort(list, sort_cb); - * @endcode - */ -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 */ -#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref)) - -#if !defined(__cplusplus) -#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \ - _EINA_INLIST_OFFSET(ref)) -#else -/* - * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's typeof - * operator. - */ -#define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \ - _EINA_INLIST_OFFSET(ref)) -#endif - -/** Macro to iterate over an inlist */ -#define EINA_INLIST_FOREACH(list, l) \ - for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ - l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL)) -#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; \ - l; \ - l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next : NULL) -#define EINA_INLIST_REVERSE_FOREACH(list, l) \ - for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \ - l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL)) - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /*EINA_INLIST_H_*/ diff --git a/libraries/eina/src/include/eina_iterator.h b/libraries/eina/src/include/eina_iterator.h deleted file mode 100644 index 10a9ece..0000000 --- a/libraries/eina/src/include/eina_iterator.h +++ /dev/null @@ -1,337 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_ITERATOR_H__ -#define EINA_ITERATOR_H__ - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_magic.h" - -/** - * @page eina_iterator_example_page Eina_Iterator usage - * @dontinclude eina_iterator_01.c - * - * As always when using eina we need to include it: - * @skip #include - * @until Eina.h - * - * Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prints - * some data: - * @until } - * @note Returning EINA_TRUE is important so we don't stop iterating over the - * container. - * - * 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 - * the type of container, it works for anything that can provide an iterator: - * @until } - * - * And on to our main function were we declare some variables and initialize - * eina, nothing too special: - * @until eina_init - * - * Next we populate both an array and a list with our strings, for more details - * see @ref eina_list_01_example_page and @ref eina_array_01_example_page : - * @until } - * - * And now we create an array and because the first element of the container - * doesn't interest us we skip it: - * @until iterator_next - * - * Having our iterator now pointing to interesting data we go ahead and print: - * @until print_eina_container - * - * 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 - * iterator itself: - * @until eina_iterator_free - * - * But so far you're not impressed in @ref eina_array_01_example_page an array is - * also printed, so now we go to the cool stuff and use an iterator to do same - * stuff to a list: - * @until eina_iterator_free - * @note The only significant diference to the block above is in the - * function used to create the iterator. - * - * And now we free the list and shut eina down: - * @until } - */ - -/** - * @page eina_iterator_01_c Eina_Iterator usage - * @page eina_iterator_01_c Eina_Iterator usage - * - * @include eina_iterator_01.c - * @example eina_iterator_01.c - */ - -/** - * @addtogroup Eina_Iterator_Group Iterator Functions - * - * @brief These functions manage iterators on containers. - * - * These functions allow to access elements of a container in a - * generic way, without knowing which container is used (a bit like - * iterators in the C++ STL). Iterators only allows sequential access - * (that is, from an element to the next one). For random access, see - * @ref Eina_Accessor_Group. - * - * An iterator is created from container data types, so no creation - * function is available here. An iterator is deleted with - * eina_iterator_free(). To get the data and iterate, use - * eina_iterator_next(). To call a function on all the elements of a - * container, use eina_iterator_foreach(). - * - * Here an @ref eina_iterator_example_page "example" - */ - -/** - * @addtogroup Eina_Content_Access_Group Content Access - * - * @{ - */ - -/** - * @defgroup Eina_Iterator_Group Iterator Functions - * - * @{ - */ - -/** - * @typedef Eina_Iterator - * Abstract type for iterators. - */ -typedef struct _Eina_Iterator Eina_Iterator; - -/** - * @typedef Eina_Iterator_Next_Callback - * Type for a callback that returns the next element in a container. - */ -typedef Eina_Bool (*Eina_Iterator_Next_Callback)(Eina_Iterator *it, void **data); - -/** - * @typedef Eina_Iterator_Get_Container_Callback - * Type for a callback that returns the container. - */ -typedef void *(*Eina_Iterator_Get_Container_Callback)(Eina_Iterator *it); - -/** - * @typedef Eina_Iterator_Free_Callback - * Type for a callback that frees the container. - */ -typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it); - -/** - * @typedef Eina_Iterator_Lock_Callback - * Type for a callback that lock the container. - */ -typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it); - -/** - * @struct _Eina_Iterator - * structure of an iterator - */ -struct _Eina_Iterator -{ -#define EINA_ITERATOR_VERSION 1 - int version; /**< Version of the Iterator API. */ - - Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; /**< Callback called when a next element is requested. */ - Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */ - Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */ - - Eina_Iterator_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */ - Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */ - -#define EINA_MAGIC_ITERATOR 0x98761233 - EINA_MAGIC -}; - -/** - * @def FUNC_ITERATOR_NEXT(Function) - * Helper macro to cast @p Function to a Eina_Iterator_Next_Callback. - */ -#define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function) - -/** - * @def FUNC_ITERATOR_GET_CONTAINER(Function) - * Helper macro to cast @p Function to a Eina_Iterator_Get_Container_Callback. - */ -#define FUNC_ITERATOR_GET_CONTAINER(Function) ((Eina_Iterator_Get_Container_Callback)Function) - -/** - * @def FUNC_ITERATOR_FREE(Function) - * Helper macro to cast @p Function to a Eina_Iterator_Free_Callback. - */ -#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function) - -/** - * @def FUNC_ITERATOR_LOCK(Function) - * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback. - */ -#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback)Function) - - -/** - * @brief Free an iterator. - * - * @param iterator The iterator to free. - * - * This function frees @p iterator if it is not @c NULL; - */ -EAPI void eina_iterator_free(Eina_Iterator *iterator) EINA_ARG_NONNULL(1); - - -/** - * @brief Return the container of an iterator. - * - * @param iterator The iterator. - * @return The container which created the iterator. - * - * This function returns the container which created @p iterator. If - * @p iterator is @c NULL, this function returns @c NULL. - */ -EAPI void *eina_iterator_container_get(Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE; - -/** - * @brief Return the value of the current element and go to the next one. - * - * @param iterator The iterator. - * @param data The data of the element. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns the value of the current element pointed by - * @p iterator in @p data, then goes to the next element. If @p - * iterator is @c NULL or if a problem occurred, #EINA_FALSE is - * returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_iterator_next(Eina_Iterator *iterator, - void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Iterate over the container and execute a callback on each element. - * - * @param iterator The iterator. - * @param callback The callback called on each iteration. - * @param fdata The data passed to the callback. - * - * This function iterates over the elements pointed by @p iterator, - * beginning from the current element. For Each element, the callback - * @p cb is called with the data @p fdata. If @p iterator is @c NULL, - * the function returns immediately. Also, if @p cb returns @c - * EINA_FALSE, the iteration stops at that point, if @p cb returns @c EINA_TRUE - * the iteration continues. - */ -EAPI void eina_iterator_foreach(Eina_Iterator *iterator, - Eina_Each_Cb callback, - const void *fdata) EINA_ARG_NONNULL(1, 2); - - -/** - * @brief Lock the container of the iterator. - * - * @param iterator The iterator. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * If the container of the @p iterator permits it, it will be locked. When a - * container is locked calling eina_iterator_foreach() on it will return - * immediately. If @p iterator is @c NULL or if a problem occurred, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. If the container isn't - * lockable, it will return EINA_TRUE. - * - * @warning None of the existing eina data structures are lockable. - */ -EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1); - -/** - * @brief Unlock the container of the iterator. - * - * @param iterator The iterator. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * If the container of the @p iterator permits it and was previously - * locked, it will be unlocked. If @p iterator is @c NULL or if a - * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE - * is returned. If the container is not lockable, it will return - * EINA_TRUE. - * - * @warning None of the existing eina data structures are lockable. - */ -EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1); - -/** - * @def EINA_ITERATOR_FOREACH - * @brief Macro to iterate over all elements easily. - * - * @param itr The iterator to use. - * @param data Where to store * data, must be a pointer support getting - * its address since * eina_iterator_next() requires a pointer - * to pointer! - * - * This macro is a convenient way to use iterators, very similar to - * EINA_LIST_FOREACH(). - * - * This macro can be used for freeing the data of a list, like in the - * following example. It has the same goal as the one documented in - * EINA_LIST_FOREACH(), but using iterators: - * - * @code - * Eina_List *list; - * Eina_Iterator *itr; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings - * - * itr = eina_list_iterator_new(list); - * EINA_ITERATOR_FOREACH(itr, data) - * free(data); - * eina_iterator_free(itr); - * eina_list_free(list); - * @endcode - * - * @note this example is not optimal algorithm to release a list since - * it will walk the list twice, but it serves as an example. For - * optimized version use EINA_LIST_FREE() - * - * @warning The order in which the elements will be traversed depends on the - * underlying container and @b shouldn't be relied upon. - * - * @warning unless explicitly stated in functions returning iterators, - * do not modify the iterated object while you walk it, in this - * example using lists, do not remove list nodes or you might - * crash! This is not a limitiation of iterators themselves, - * rather in the iterators implementations to keep them as simple - * and fast as possible. - */ -#define EINA_ITERATOR_FOREACH(itr, \ - data) while (eina_iterator_next((itr), \ - (void **)(void *)&(data))) - -/** - * @} - */ - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_lalloc.h b/libraries/eina/src/include/eina_lalloc.h deleted file mode 100644 index dcb8773..0000000 --- a/libraries/eina/src/include/eina_lalloc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LALLOC_H_ -#define EINA_LALLOC_H_ - -#include "eina_types.h" - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Lalloc_Group Lazy allocator - * - * @{ - */ - -typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num); -#define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function) -typedef void (*Eina_Lalloc_Free)(void *user_data); -#define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function) - -typedef struct _Eina_Lalloc Eina_Lalloc; - -EAPI Eina_Lalloc *eina_lalloc_new(void *data, - Eina_Lalloc_Alloc alloc_cb, - Eina_Lalloc_Free free_cb, - int num_init) EINA_ARG_NONNULL(2, 3); -EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1); -EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, - int num) EINA_ARG_NONNULL(1); -EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_LALLOC_H_ */ diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h deleted file mode 100644 index c8ef06d..0000000 --- a/libraries/eina/src/include/eina_list.h +++ /dev/null @@ -1,1631 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LIST_H_ -#define EINA_LIST_H_ - -#include - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_iterator.h" -#include "eina_accessor.h" -#include "eina_magic.h" - -/** - * @page eina_list_01_example_page Adding elements to Eina_List - * @dontinclude eina_list_01.c - * - * Creating an @ref Eina_List and adding elements to it is very easy and can be - * understood from an example: - * First thing is always to include Eina.h, for this example we also - * include stdio.h so we can use printf. - * @skip #include - * @until Eina.h - * - * Just some boilerplate code, declaring some variable and initializing eina. - * @until eina_init - * Here we add a sequence of elements to our list. By using append we add - * elements to the end of the list, so the list will look like this:@n - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image rtf eina_list_example_01_a.png - * @image latex eina_list_example_01_a.eps width=\textwidth - * @until roslin - * There are a couple of interesting things happening here, first is that we are - * passing a NULL pointer to the first @ref eina_list_append() call, when this - * 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 - * be done every time we use a a function that alters the contents of the list. - * - * Now that we have a list we some elements in it we can look at it's contents. - * @until printf - * - * There are many ways of accessing elements in the list, including by it's - * index: - * @until nth - * @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 - * common requirement is to add an element in a specific position this can be - * accomplished using @ref eina_list_append_relative() and - * @ref eina_list_append_relative_list(): - * @until zarek - * First @a "cain" is added after the second element(remember that indexes are - * 0 based) and then we add @a "zarek" after @a "cain". - * - * @ref Eina_List also has prepend analogs to append functions we have used so - * far: - * @until lampkin - * With this additions our list now looks like this:@n - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image rtf eina_list_example_01_b.png - * @image latex eina_list_example_01_b.eps width=\textwidth - * - * Once done using the list it needs to be freed, and since we are done with - * eina that also need to be shutdown: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_list_01_c "eina_list_01.c" file. - */ - -/** - * @page eina_list_01_c Adding elements to Eina_List example - * - * @include eina_list_01.c - * @example eina_list_01.c - */ - -/** - * @page eina_list_02_example_page Sorting Eina_List elements - * @dontinclude eina_list_02.c - * - * If you don't know how to create lists see - * @ref eina_list_01_example_page. - * - * @skip #include - * @until boomer - * This is the code we have already seen to create a list. Now if we need to - * search the list we can do it like this: - * @until return - * - * However if searching the list multiple times it probably is better to sort - * the list since the sorted_search functions are much faster: - * @until return - * - * Once the list is sorted it's not a good idea to use append/prepend functions - * since that would add the element in the wrong place, instead elements should - * be added with @ref eina_list_sorted_insert(): - * @until sorted_insert - * - * A noteworthy use case is adding an element to a list only if it doesn't exist - * already, this can accomplished by searching for the element that is closest - * to what is being added, and if that doesn't match add: - * @until append - * @note @ref eina_list_search_sorted_near_list() will tell you not only the - * nearest node to what was searched for but how it compares to your term, this - * way it is easy to know if you have to add before or after that node. - * - * It is sometimes useful to get a portion of the list as another list, here we - * take every element that comes after "boomer" and split it into "other_list": - * @until split_list - * - * It is also possible to add entire lists of elements using - * @ref eina_list_sorted_merge(): - * @until sorted_merge - * - * And as always release memory and shutdown eina before ending: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_list_02_c "eina_list_02.c" file. - */ - -/** - * @page eina_list_02_c Sorting Eina_List elements example - * - * @include eina_list_02.c - * @example eina_list_02.c - */ - -/** - * @page eina_list_03_example_page Reordering Eina_List elments - * @dontinclude eina_list_03.c - * - * If you don't know how to create lists see - * @ref eina_list_01_example_page. - * - * We start out with code that should be familiar by now: - * @skip #include - * @until gemenon - * - * You can move elements around in a list using @ref eina_list_move() or using - * @ref eina_list_promote_list() and @ref eina_list_demote_list() which move a - * list node to the head and end of the list respectevely: - * @until demote - * - * Removing elements from a list can be done with ease: - * @until sagitarius - * - * To replace an element in the list it is not necessary to remove it and then - * add with the new value, it is possible to just change the value of a node: - * @until aquarius - * - * We will now take a peek to see if the list still has the right number of - * elements: - * @until printf - * - * Now that the list is in alphabetical order let's create a copy of it in - * reverse order and print every element to see if worked as expected: - * @until iterator_free - * @note Always remember to free your iterators when done using them. - * - * And as always release memory and shutdown eina before ending: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_list_03_c "eina_list_03.c" file. - */ - -/** - * @page eina_list_03_c Reordering Eina_List elments example - * - * @include eina_list_03.c - * @example eina_list_03.c - */ - -/** - * @page eina_list_04_example_page Eina_List and memory allocation - * @dontinclude eina_list_04.c - * - * If you don't know how to create lists see - * @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 - * regardless of previous knowledge about it. - * - * 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. - * @skip #include - * @until Sharon - * - * This time we are going to iterate over our list in a different way: - * @until printf - * - * And now we are going to iterate over the list backwards: - * @until printf - * - * And now we need to free up the memory allocated during creation of the list: - * @until stringshare_del - * @note We don't need to use eina_list_free() since @ref EINA_LIST_FREE takes - * care of that. - * - * And shut everything down: - * @until } - * - * The full source code can be found on the examples folder - * on the @ref eina_list_04_c "eina_list_04.c" file. - */ - -/** - * @page eina_list_04_c Eina_List and memory allocation example - * - * @include eina_list_04.c - * @example eina_list_04.c - */ - -/** - * @addtogroup Eina_List_Group List - * - * @brief These functions provide double linked list management. - * - * Eina_List is a doubly linked list. It can store data of any type in the - * form of void pointers. It has convenience functions to do all the common - * operations which means it should rarely if ever be necessary to directly - * access the struct's fields. Nevertheless it can be useful to understand the - * inner workings of the data structure being used. - * - * @ref Eina_List nodes keep references to the previous node, the next node, its - * data and to an accounting structure. - * - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image rtf eina_list.png - * @image latex eina_list.eps width=5cm - * - * @ref Eina_List_Accounting is used to improve the performance of some - * functions. It is private and should not be modified. It contains a - * reference to the end of the list and the number of elements in the list. - * - * @note Every function that modifies the contents of the list returns a pointer - * to the head of the list and it is essential that this be pointer be used in - * any future references to the list. - * - * Most functions have two versions that have the same effect but operate on - * different arguments, the @a plain functions operate over data(eg.: - * @ref eina_list_append_relative, @ref eina_list_remove, - * @ref eina_list_data_find), the @a list versions of these functions operate - * on @ref Eina_List nodes. - * - * @warning You must @b always use the pointer to the first element of the list - * as the list! - * @warning You must @b never use a pointer to an element in the middle of the - * list as the list! - * - * Here are some examples of @ref Eina_List usage: - * @li @ref eina_list_01_example_page - * @li @ref eina_list_02_example_page - * @li @ref eina_list_03_example_page - * @li @ref eina_list_04_example_page - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_List_Group List - * - * @{ - */ - -/** - * @typedef Eina_List - * Type for a generic double linked list. - */ -typedef struct _Eina_List Eina_List; - -/** - * @typedef Eina_List_Accounting - * Cache used to store the last element of a list and the number of - * elements, for fast access. - */ -typedef struct _Eina_List_Accounting Eina_List_Accounting; - -/** - * @struct _Eina_List - * Type for a generic double linked list. - */ -struct _Eina_List -{ - void *data; /**< Pointer to list element payload */ - Eina_List *next; /**< Next member in the list */ - Eina_List *prev; /**< Previous member in the list */ - Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */ - - EINA_MAGIC -}; - -/** - * @struct _Eina_List_Accounting - * Cache used to store the last element of a list and the number of - * elements, for fast access. It is for private used and must not be - * touched. - */ -struct _Eina_List_Accounting -{ - Eina_List *last; /**< Pointer to the last element of the list - don't touch */ - unsigned int count; /**< Number of elements of the list - don't touch */ - EINA_MAGIC -}; - - -/** - * @brief Append the given data to the given linked list. - * - * @param list The given list. - * @param data The data to append. - * @return A list pointer. - * - * This function appends @p data to @p list. If @p list is @c NULL, a - * new list is returned. On success, a new list pointer that should be - * used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. - * - * The following example code demonstrates how to ensure that the - * given data has been successfully appended. - * - * @code - * Eina_List *list = NULL; - * extern void *my_data; - * - * list = eina_list_append(list, my_data); - * if (eina_error_get()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list(or NULL). - */ -EAPI Eina_List *eina_list_append(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Prepends the given data to the given linked list. - * - * @param list The given list. - * @param data The data to prepend. - * @return A list pointer. - * - * This function prepends @p data to @p list. If @p list is @c NULL, a - * new list is returned. On success, a new list pointer that should be - * used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. - * - * The following example code demonstrates how to ensure that the - * given data has been successfully prepended. - * - * Example: - * @code - * Eina_List *list = NULL; - * extern void *my_data; - * - * list = eina_list_prepend(list, my_data); - * if (eina_error_get()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_prepend(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Insert the given data into the given linked list after the specified data. - * - * @param list The given linked list. - * @param data The data to insert. - * @param relative The data to insert after. - * @return A list pointer. - * - * This function inserts @p data to @p list after @p relative. If - * @p relative is not in the list, @p data is appended to the end of - * the list. If @p list is @c NULL, a new list is returned. If there - * are multiple instances of @p relative in the list, @p data is - * inserted after the first instance.On success, a new list pointer - * that should be used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. - * - * The following example code demonstrates how to ensure that the - * given data has been successfully inserted. - * - * @code - * Eina_List *list = NULL; - * extern void *my_data; - * extern void *relative_member; - * - * list = eina_list_append(list, relative_member); - * if (eina_error_get()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * list = eina_list_append_relative(list, my_data, relative_member); - * if (eina_error_get()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_append_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Append a list node to a linked list after the specified member - * - * @param list The given linked list. - * @param data The data to insert. - * @param relative The list node to insert after. - * @return A list pointer. - * - * This function inserts @p data to @p list after the list node - * @p relative. If @p list or @p relative are @c NULL, @p data is just - * appended to @p list using eina_list_append(). If @p list is - * @c NULL, a new list is returned. If there are multiple instances - * of @p relative in the list, @p data is inserted after the first - * instance. On success, a new list pointer that should be used in - * place of the one given to this function is returned. Otherwise, the - * old pointer is returned. - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Prepend a data pointer to a linked list before the specified member - * - * @param list The given linked list. - * @param data The data to insert. - * @param relative The data to insert before. - * @return A list pointer. - * - * This function inserts @p data to @p list before @p relative. If - * @p relative is not in the list, @p data is prepended to the list - * with eina_list_prepend(). If @p list is @c NULL, a new list is - * returned. If there are multiple instances of @p relative in the - * list, @p data is inserted before the first instance. On success, a - * new list pointer that should be used in place of the one given to - * this function is returned. Otherwise, the old pointer is returned. - * - * The following code example demonstrates how to ensure that the - * given data has been successfully inserted. - * - * @code - * Eina_List *list = NULL; - * extern void *my_data; - * extern void *relative_member; - * - * list = eina_list_append(list, relative_member); - * if (eina_error_get_error()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * list = eina_list_prepend_relative(list, my_data, relative_member); - * if (eina_error_get()) - * { - * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n"); - * exit(-1); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Prepend a list node to a linked list before the specified member - * - * @param list The given linked list. - * @param data The data to insert. - * @param relative The list node to insert before. - * @return A list pointer. - * - * This function inserts @p data to @p list before the list node - * @p relative. If @p list or @p relative are @c NULL, @p data is just - * prepended to @p list using eina_list_prepend(). If @p list is - * @c NULL, a new list is returned. If there are multiple instances - * of @p relative in the list, @p data is inserted before the first - * instance. On success, a new list pointer that should be used in - * place of the one given to this function is returned. Otherwise, the - * old pointer is returned. - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Insert a new node into a sorted list. - * - * @param list The given linked list, @b must be sorted. - * @param func The function called for the sort. - * @param data The data to insert sorted. - * @return A list pointer. - * - * This function inserts values into a linked list assuming it was - * sorted and the result will be sorted. If @p list is @c NULLL, a new - * list is returned. On success, a new list pointer that should be - * used in place of the one given to this function is - * returned. Otherwise, the old pointer is returned. See eina_error_get(). - * - * @note O(log2(n)) comparisons (calls to @p func) average/worst case - * performance as it uses eina_list_search_sorted_near_list() and thus - * is bounded to that. As said in eina_list_search_sorted_near_list(), - * lists do not have O(1) access time, so walking to the correct node - * can be costly, consider worst case to be almost O(n) pointer - * dereference (list walk). - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Remove the first instance of the specified data from the given list. - * - * @param list The given list. - * @param data The specified data. - * @return A list pointer. - * - * This function removes the first instance of @p data from - * @p list. If the specified data is not in the given list (tihis - * 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 - * pointer that should be used in place of the one passed to this - * function. - * - * @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 *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Remove the specified list node. - * - * @param list The given linked list. - * @param remove_list The list node which is to be removed. - * @return A list pointer. - * - * 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 - * @c NULL, this function returns @c NULL. If @p remove_list is - * @c NULL, it returns @p list, otherwise, a new list pointer that - * should be used in place of the one passed to this function. - * - * The following code gives an example (notice we use EINA_LIST_FOREACH - * instead of EINA_LIST_FOREACH_SAFE because we stop the loop after - * removing the current node). - * - * @code - * extern Eina_List *list; - * Eina_List *l; - * extern void *my_data; - * void *data - * - * EINA_LIST_FOREACH(list, l, data) - * { - * if (data == my_data) - * { - * list = eina_list_remove_list(list, l); - * break; - * } - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_remove_list(Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Move the specified data to the head of the list. - * - * @param list The list handle to move the data. - * @param move_list The list node to move. - * @return A new list handle to replace the old one - * - * This function move @p move_list to the front of @p list. If list is - * @c NULL, @c NULL is returned. If @p move_list is @c NULL, - * @p list is returned. Otherwise, a new list pointer that should be - * used in place of the one passed to this function. - * - * Example: - * @code - * extern Eina_List *list; - * Eina_List *l; - * extern void *my_data; - * void *data; - * - * EINA_LIST_FOREACH(list, l, data) - * { - * if (data == my_data) - * { - * list = eina_list_promote_list(list, l); - * break; - * } - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_promote_list(Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Move the specified data to the tail of the list. - * - * @param list The list handle to move the data. - * @param move_list The list node to move. - * @return A new list handle to replace the old one - * - * This function move @p move_list to the back of @p list. If list is - * @c NULL, @c NULL is returned. If @p move_list is @c NULL, - * @p list is returned. Otherwise, a new list pointer that should be - * used in place of the one passed to this function. - * - * Example: - * @code - * extern Eina_List *list; - * Eina_List *l; - * extern void *my_data; - * void *data; - * - * EINA_LIST_FOREACH(list, l, data) - * { - * if (data == my_data) - * { - * list = eina_list_demote_list(list, l); - * break; - * } - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_demote_list(Eina_List *list, Eina_List *move_list); - - -/** - * @brief Find a member of a list and return the member. - * - * @param list The list to search for a data. - * @param data The data pointer to find in the list. - * @return The found member data pointer if found, @c NULL otherwise. - * - * This function searches in @p list from beginning to end for the - * first member whose data pointer is @p data. If it is found, @p data - * will be returned, otherwise NULL will be returned. - * - * Example: - * @code - * extern Eina_List *list; - * extern void *my_data; - * - * if (eina_list_data_find(list, my_data) == my_data) - * { - * printf("Found member %p\n", my_data); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Find a member of a list and return the list node containing that member. - * - * @param list The list to search for data. - * @param data The data pointer to find in the list. - * @return The found members list node on success, @c NULL otherwise. - * - * This function searches in @p list from beginning to end for the - * first member whose data pointer is @p data. If it is found, the - * list node containing the specified member is returned, otherwise - * @c NULL is returned. - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_data_find_list(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Move a data pointer from one list to another - * - * @param to The list to move the data to - * @param from The list to move from - * @param data The data to move - * @return #EINA_TRUE on success, else #EINA_FALSE - * - * This function is a shortcut for doing the following: - * to = eina_list_append(to, data); - * from = eina_list_remove(from, data); - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_Bool eina_list_move(Eina_List **to, Eina_List **from, void *data); - -/** - * @brief Move a list node from one list to another - * - * @param to The list to move the data to - * @param from The list to move from - * @param data The list node containing the data to move - * @return #EINA_TRUE on success, else #EINA_FALSE - * - * This function is a shortcut for doing the following: - * to = eina_list_append(to, data->data); - * from = eina_list_remove_list(from, data); - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_Bool eina_list_move_list(Eina_List **to, Eina_List **from, Eina_List *data); - - -/** - * @brief Free an entire list and all the nodes, ignoring the data contained. - - * @param list The list to free - * @return A NULL pointer - * - * This function frees all the nodes of @p list. It does not free the - * data of the nodes. To free them, use #EINA_LIST_FREE. - */ -EAPI Eina_List *eina_list_free(Eina_List *list); - - -/** - * @brief Get the nth member's data pointer in a list. - * - * @param list The list to get the specified member number from. - * @param n The number of the element (0 being the first). - * @return The data pointer stored in the specified element. - * - * This function returns the data pointer of element number @p n, in - * the @p list. The first element in the array is element number 0. If - * the element number @p n does not exist, @c NULL is - * returned. Otherwise, the data of the found element is returned. - * - * @note Worst case is O(n). - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Get the nth member's list node in a list. - * - * @param list The list to get the specfied member number from. - * @param n The number of the element (0 being the first). - * @return The list node stored in the numbered element. - * - * This function returns the list node of element number @p n, in - * @p list. The first element in the array is element number 0. If the - * element number @p n does not exist or @p list is @c NULL or @p n is - * greater than the count of elements in @p list minus 1, @c NULL is - * returned. Otherwise the list node stored in the numbered element is - * returned. - * - * @note Worst case is O(n). - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_nth_list(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Reverse all the elements in the list. - * - * @param list The list to reverse. - * @return The list head after it has been reversed. - * - * This function reverses the order of all elements in @p list, so the - * last member is now first, and so on. If @p list is @c NULL, this - * functon returns @c NULL. - * - * @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. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_reverse_clone() - * @see eina_list_iterator_reversed_new() - */ -EAPI Eina_List *eina_list_reverse(Eina_List *list) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Clone (copy) all the elements in the list in reverse order. - * - * @param list The list to reverse. - * @return The new list that has been reversed. - * - * This function reverses the order of all elements in @p list, so the - * last member is now first, and so on. If @p list is @c NULL, this - * functon returns @c NULL. This returns a copy of the given list. - * - * @note @b copy: this will copy the list and you should then - * eina_list_free() when it is not required anymore. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_reverse() - * @see eina_list_clone() - */ -EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Clone (copy) all the elements in the list in exactly same order. - * - * @param list The list to clone. - * @return The new list that has been cloned. - * - * This function clone in order of all elements in @p list. If @p list - * is @c NULL, this functon returns @c NULL. This returns a copy of - * the given list. - * - * @note @b copy: this will copy the list and you should then - * eina_list_free() when it is not required anymore. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_reverse_clone() - */ -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. - * - * @param list The list handle to sort. - * @param limit The maximum number of list elements to sort. - * @param func A function pointer that can handle comparing the list data - * nodes. - * @return the new head of list. - * - * This function sorts @p list. @p size if the number of the first - * 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 - * compare two elements of @p list. If @p list or @p func are @c NULL, - * this function returns @c NULL. - * - * @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. - * - * @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 - * elements, sort will usually do 1,000,000 comparisons, but may do up - * to 20,000,000. - * - * Example: - * @code - * int - * sort_cb(const void *d1, const void *d2) - * { - * const char *txt = d1; - * const char *txt2 = d2; - * - * if(!txt) return(1); - * if(!txt2) return(-1); - * - * return(strcmp(txt, txt2)); - * } - * extern Eina_List *list; - * - * list = eina_list_sort(list, eina_list_count(list), sort_cb); - * @endcode - * - * @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 limit, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Merge two list. - * - * @param left Head list to merge. - * @param right Tail list to merge. - * @return A new merged list. - * - * This function puts right at the end of left and return the head. - * - * Both left and right does not exist anymore after the merge. - * - * @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, - * making count and last access O(1). - * - * @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 *right) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Merge two sorted list according to the ordering func will return. - * - * @param left First list to merge. - * @param right Second list to merge. - * @param func A function pointer that can handle comparing the list data - * nodes. - * @return A new sorted list. - * - * 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 process - * for all entry of both list. - * - * Both left and right does not exist anymore after the merge. - * If @p func is NULL, it will return NULL. - * - * Example: - * @code - * int - * sort_cb(void *d1, void *d2) - * { - * const char *txt = NULL; - * const char *txt2 = NULL; - * - * if(!d1) return(1); - * if(!d2) return(-1); - * - * return(strcmp((const char*)d1, (const char*)d2)); - * } - * extern Eina_List *sorted1; - * extern Eina_List *sorted2; - * - * list = eina_list_sorted_merge(sorted1, sorted2, sort_cb); - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Split a list into 2 lists. - * - * @param list List to split. - * @param relative The list will be split after @p relative. - * @param right The head of the new right list. - * @return The new left list - * - * This function splits @p list into two lists ( left and right ) after the node @p relative. @p Relative - * will become the last node of the left list. If @p list or @p right are NULL list is returns. - * If @p relative is NULL right is set to @p list and NULL is returns. - * If @p relative is the last node of @p list list is returns and @p right is set to NULL. - * - * list does not exist anymore after the split. - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Returns node nearest to data is in the sorted list. - * - * @param list The list to search for data, @b must be sorted. - * @param func A function pointer that can handle comparing the list data nodes. - * @param data reference value to search. - * @param result_cmp if provided returns the result of - * func(node->data, data) node being the last (returned) node. If node - * was found (exact match), then it is 0. If returned node is smaller - * than requested data, it is less than 0 and if it's bigger it's - * greater than 0. It is the last value returned by func(). - * @return the nearest node, NULL if not found. - * - * This function searches for a node containing @p data as it's data in @p list, - * if such a node exists it will be returned and @p result_cmp will be @p 0. If - * the data of no node in @p list is equal to @p data, the node with the nearest - * value to that will be returned and @p result_cmp will be the return value of - * @p func with @p data and the returned node's data as arguments. - * - * This function is useful for inserting an element in the list only in case it - * isn't already present in the list, the naive way of doing this would be: - * @code - * void *ptr = eina_list_data_find(list, "my data"); - * if (!ptr) - * eina_list_sorted_insert(list, "my data"); - * @endcode - * - * However this has the downside of walking through the list twice, once to - * check if the data is already present and another to insert the element in the - * corret position. This can be done more eficiently: - * @code - * int cmp_result; - * l = eina_list_search_sorted_near_list(list, cmp_func, "my data", - * &cmp_result); - * if (cmp_result > 0) - * list = eina_list_prepend_relative_list(list, "my data", l); - * else if (cmp_result < 0) - * list = eina_list_append_relative_list(list, "my data", l); - * @endcode - * - * If @a cmp_result is 0 the element is already in the list and we need not - * insert it, if @a cmp_result is greater than zero @a "my @a data" needs to - * come after @a l(the nearest node present), if less than zero before. - * - * @note O(log2(n)) average/worst case performance, for 1,000,000 - * elements it will do a maximum of 20 comparisons. This is much - * faster than the 1,000,000 comparisons made naively walking the list - * from head to tail, so depending on the number of searches and - * insertions, it may be worth to eina_list_sort() the list and do the - * searches later. As lists do not have O(1) access time, walking to - * the correct node can be costly, consider worst case to be almost - * O(n) pointer dereference (list walk). - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_search_sorted_list() - * @see eina_list_sort() - * @see eina_list_sorted_merge() - */ -EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp); - - -/** - * @brief Returns node if data is in the sorted list. - * - * @param list The list to search for data, @b must be sorted. - * @param func A function pointer that can handle comparing the list data nodes. - * @param data reference value to search. - * @return the node if func(node->data, data) == 0, NULL if not found. - * - * This can be used to check if some value is inside the list and get - * the container node in this case. It should be used when list is - * known to be sorted as it will do binary search for results. - * - * Example: imagine user gives a string, you check if it's in the list - * before duplicating its contents. - * - * @note O(log2(n)) average/worst case performance, for 1,000,000 - * elements it will do a maximum of 20 comparisons. This is much - * faster than the 1,000,000 comparisons made by - * eina_list_search_unsorted_list(), so depending on the number of - * searches and insertions, it may be worth to eina_list_sort() the - * list and do the searches later. As said in - * eina_list_search_sorted_near_list(), lists do not have O(1) access - * time, so walking to the correct node can be costly, consider worst - * case to be almost O(n) pointer dereference (list walk). - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_search_sorted() - * @see eina_list_sort() - * @see eina_list_sorted_merge() - * @see eina_list_search_unsorted_list() - * @see eina_list_search_sorted_near_list() - */ -EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data); - - -/** - * @brief Returns node data if it is in the sorted list. - * - * @param list The list to search for data, @b must be sorted. - * @param func A function pointer that can handle comparing the list data nodes. - * @param data reference value to search. - * @return the node value (@c node->data) if func(node->data, data) == 0, - * NULL if not found. - * - * This can be used to check if some value is inside the list and get - * the existing instance in this case. It should be used when list is - * known to be sorted as it will do binary search for results. - * - * Example: imagine user gives a string, you check if it's in the list - * before duplicating its contents. - * - * @note O(log2(n)) average/worst case performance, for 1,000,000 - * elements it will do a maximum of 20 comparisons. This is much - * faster than the 1,000,000 comparisons made by - * eina_list_search_unsorted(), so depending on the number of - * searches and insertions, it may be worth to eina_list_sort() the - * list and do the searches later. As said in - * eina_list_search_sorted_near_list(), lists do not have O(1) access - * time, so walking to the correct node can be costly, consider worst - * case to be almost O(n) pointer dereference (list walk). - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_search_sorted_list() - * @see eina_list_sort() - * @see eina_list_sorted_merge() - * @see eina_list_search_unsorted_list() - */ -EAPI void *eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data); - - -/** - * @brief Returns node if data is in the unsorted list. - * - * @param list The list to search for data, may be unsorted. - * @param func A function pointer that can handle comparing the list data nodes. - * @param data reference value to search. - * @return the node if func(node->data, data) == 0, NULL if not found. - * - * This can be used to check if some value is inside the list and get - * the container node in this case. - * - * Example: imagine user gives a string, you check if it's in the list - * before duplicating its contents. - * - * @note this is expensive and may walk the whole list, it's order-N, - * that is for 1,000,000 elements list it may walk and compare - * 1,000,000 nodes. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_search_sorted_list() - * @see eina_list_search_unsorted() - */ -EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data); - - -/** - * @brief Returns node data if it is in the unsorted list. - * - * @param list The list to search for data, may be unsorted. - * @param func A function pointer that can handle comparing the list data nodes. - * @param data reference value to search. - * @return the node value (@c node->data) if func(node->data, data) == 0, - * NULL if not found. - * - * This can be used to check if some value is inside the list and get - * the existing instance in this case. - * - * Example: imagine user gives a string, you check if it's in the list - * before duplicating its contents. - * - * @note this is expensive and may walk the whole list, it's order-N, - * that is for 1,000,000 elements list it may walk and compare - * 1,000,000 nodes. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_search_sorted() - * @see eina_list_search_unsorted_list() - */ -EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data); - -/** - * @brief Get the last list node in the list. - * - * @param list The list to get the last list node from. - * @return The last list node in the list. - * - * This function returns the last list node in the list @p list. If - * @p list is @c NULL or empty, @c NULL is returned. - * - * This is a order-1 operation (it takes the same short time - * regardless of the length of the list). - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline Eina_List *eina_list_last(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the next list node after the specified list node. - * - * @param list The list node to get the next list node from - * @return The next list node on success, @c NULL otherwise. - * - * This function returns the next list node after the current one in - * @p list. It is equivalent to list->next. If @p list is @c NULL or - * if no next list node exists, it returns @c NULL. - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline Eina_List *eina_list_next(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the previous list node before the specified list node. - * - * @param list The list node to get the previous list node from. - * @return The previous list node o success, @c NULL otherwise. - * if no previous list node exists - * - * This function returns the previous list node before the current one - * in @p list. It is equivalent to list->prev. If @p list is @c NULL or - * if no previous list node exists, it returns @c NULL. - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline Eina_List *eina_list_prev(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the list node data member. - * - * @param list The list node to get the data member of. - * @return The data member from the list node. - * - * This function returns the data member of the specified list node @p - * list. It is equivalent to list->data. If @p list is @c NULL, this - * function returns @c NULL. - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline void *eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set the list node data member. - * - * @param list The list node to get the data member of. - * @param data The data member to the list node. - * @return The previous data value. - * - * This function set the data member @p data of the specified list node - * @p list. It returns the previous data of the node. If @p list is - * @c NULL, this function returns @c NULL. - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline void *eina_list_data_set(Eina_List *list, const void *data); - -/** - * @brief Get the count of the number of items in a list. - * - * @param list The list whose count to return. - * @return The number of members in the list. - * - * This function returns how many members @p list contains. If the - * list is @c NULL, 0 is returned. - * - * NB: This is an order-1 operation and takes the same time regardless - * of the length of the list. - * - * @warning @p list must be a pointer to the first element of the list. - */ -static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE; - - -/** - * @brief Returned a new iterator associated to a list. - * - * @param list The list. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * list. If @p list is @c NULL or the count member of @p list is less - * or equal than 0, this function still returns a valid iterator that - * will always return false on eina_iterator_next(), thus keeping API - * sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @warning if the list structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Returned a new reversed iterator associated to a list. - * - * @param list The list. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * list. If @p list is @c NULL or the count member of @p list is less - * or equal than 0, this function still returns a valid iterator that - * will always return false on eina_iterator_next(), thus keeping API - * sane. - * - * Unlike eina_list_iterator_new(), this will walk the list backwards. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning @p list must be a pointer to the first element of the list. - * - * @warning if the list structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Returned a new accessor associated to a list. - * - * @param list The list. - * @return A new accessor. - * - * This function returns a newly allocated accessor associated to - * @p list. If @p list is @c NULL or the count member of @p list is - * less or equal than 0, this function returns NULL. If the memory can - * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is - * set. Otherwise, a valid accessor is returned. - * - * @warning @p list must be a pointer to the first element of the list. - */ -EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @def EINA_LIST_FOREACH - * @brief Macro to iterate over a list. - * - * @param list The list to iterate over. - * @param l A list that is used as an iterator and points to the current node. - * @param data Current item's data. - * - * This macro iterates over @p list from the first element to - * the last. @p data is the data related to the current element. - * @p l is an #Eina_List used as the list iterator. - * - * The following diagram ilustrates this macro iterating over a list of four - * elements("one", "two", "three" and "four"): - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image latex eina-list-foreach.eps width=\textwidth - * - * It can be used to free list data, as in the following example: - * - * @code - * Eina_List *list; - * Eina_List *l; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings, - * // EINA_LIST_FOREACH will be used to free those strings - * - * EINA_LIST_FOREACH(list, l, data) - * free(data); - * eina_list_free(list); - * @endcode - * - * @note This is not the optimal way to release memory allocated to - * a list, since it iterates over the list twice. - * For an optimized algorithm, use EINA_LIST_FREE(). - * - * @warning @p list must be a pointer to the first element of the list. - * - * @warning Be careful when deleting list nodes. - * If you remove the current node and continue iterating, - * the code will fail because the macro will not be able - * to get the next node. Notice that it's OK to remove any - * node if you stop the loop after that. - * For destructive operations such as this, consider - * using EINA_LIST_FOREACH_SAFE(). - */ -#define EINA_LIST_FOREACH(list, l, data) \ - for (l = list, \ - data = eina_list_data_get(l); \ - l; \ - l = eina_list_next(l), \ - data = eina_list_data_get(l)) - -/** - * @def EINA_LIST_REVERSE_FOREACH - * @brief Macro to iterate over a list in the reverse order. - * - * @param list The list to iterate over. - * @param l A list that is used as an iterator and points to the current node. - * @param data Current item's data. - * - * This macro works like EINA_LIST_FOREACH, but iterates from the - * last element of a list to the first. - * @p data is the data related to the current element, while @p l - * is an #Eina_List that is used as the list iterator. - * - * The following diagram ilustrates this macro iterating over a list of four - * elements("one", "two", "three" and "four"): - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image latex eina-list-reverse-foreach.eps width=\textwidth - * - * It can be used to free list data, as in the following example: - * - * @code - * Eina_List *list; - * Eina_List *l; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings, - * // EINA_LIST_REVERSE_FOREACH will be used to free those strings - * - * EINA_LIST_REVERSE_FOREACH(list, l, data) - * free(data); - * eina_list_free(list); - * @endcode - * - * @note This is not the optimal way to release memory allocated to - * a list, since it iterates over the list twice. - * For an optimized algorithm, use EINA_LIST_FREE(). - * - * @warning @p list must be a pointer to the first element of the list. - * - * @warning Be careful when deleting list nodes. - * If you remove the current node and continue iterating, - * the code will fail because the macro will not be able - * to get the next node. Notice that it's OK to remove any - * node if you stop the loop after that. - * For destructive operations such as this, consider - * using EINA_LIST_REVERSE_FOREACH_SAFE(). - */ -#define EINA_LIST_REVERSE_FOREACH(list, l, data) \ - for (l = eina_list_last(list), \ - data = eina_list_data_get(l); \ - l; \ - l = eina_list_prev(l), \ - data = eina_list_data_get(l)) - -/** - * @def EINA_LIST_FOREACH_SAFE - * @brief Macro to iterate over a list with support for node deletion. - * - * @param list The list to iterate over. - * @param l A list that is used as an iterator and points to the current node. - * @param l_next A list that is used as an iterator and points to the next node. - * @param data Current item's data. - * - * This macro iterates over @p list from the first element to - * the last. @p data is the data related to the current element. - * @p l is an #Eina_List used as the list iterator. - * - * Since this macro stores a pointer to the next list node in @p l_next, - * deleting the current node and continuing looping is safe. - * - * The following diagram ilustrates this macro iterating over a list of four - * elements("one", "two", "three" and "four"): - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image latex eina-list-foreach-safe.eps width=\textwidth - * - * This macro can be used to free list nodes, as in the following example: - * - * @code - * Eina_List *list; - * Eina_List *l; - * Eina_List *l_next; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings, - * // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key". - * - * EINA_LIST_FOREACH_SAFE(list, l, l_next, data) - * if (strcmp(data, "key") == 0) { - * free(data); - * list = eina_list_remove_list(list, l); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \ - for (l = list, \ - l_next = eina_list_next(l), \ - data = eina_list_data_get(l); \ - l; \ - l = l_next, \ - l_next = eina_list_next(l), \ - data = eina_list_data_get(l)) - -/** - * @def EINA_LIST_REVERSE_FOREACH_SAFE - * @brief Macro to iterate over a list in the reverse order with support - * for deletion. - * - * @param list The list to iterate over. - * @param l A list that is used as an iterator and points to the current node. - * @param l_prev A list that is used as an iterator and points to the previous node. - * @param data Current item's data. - * - * This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the - * last element of a list to the first. - * @p data is the data related to the current element, while @p l - * is an #Eina_List that is used as the list iterator. - * - * Since this macro stores a pointer to the previous list node in @p l_prev, - * deleting the current node and continuing looping is safe. - * - * The following diagram ilustrates this macro iterating over a list of four - * elements("one", "two", "three" and "four"): - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image latex eina-list-reverse-foreach-safe.eps width=\textwidth - * - * This macro can be used to free list nodes, as in the following example: - * - * @code - * Eina_List *list; - * Eina_List *l; - * Eina_List *l_prev; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings, - * // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that match "key". - * - * EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) - * if (strcmp(data, "key") == 0) { - * free(data); - * list = eina_list_remove_list(list, l); - * } - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - */ -#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \ - for (l = eina_list_last(list), \ - l_prev = eina_list_prev(l), \ - data = eina_list_data_get(l); \ - l; \ - l = l_prev, \ - l_prev = eina_list_prev(l), \ - data = eina_list_data_get(l)) - -/** - * @def EINA_LIST_FREE - * @brief Macro to remove each list node while having access to each node's data. - * - * @param list The list that will be cleared. - * @param data Current node's data. - * - * This macro will call #eina_list_remove_list for each list node, and store - * the data contained in the current node in @p data. - * - * The following diagram ilustrates this macro iterating over a list of four - * elements("one", "two", "three" and "four"): - * @htmlonly - * - * Full-size - * @endhtmlonly - * @image latex eina-list-free.eps width=\textwidth - * - * If you do not need to release node data, it is easier to call #eina_list_free(). - * - * @code - * Eina_List *list; - * char *data; - * - * // list is already filled, - * // its elements are just duplicated strings, - * - * EINA_LIST_FREE(list, data) - * free(data); - * @endcode - * - * @warning @p list must be a pointer to the first element of the list. - * - * @see eina_list_free() - */ -#define EINA_LIST_FREE(list, data) \ - for (data = eina_list_data_get(list); \ - list; \ - list = eina_list_remove_list(list, list), \ - data = eina_list_data_get(list)) - -#include "eina_inline_list.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_LIST_H_ */ diff --git a/libraries/eina/src/include/eina_lock.h b/libraries/eina/src/include/eina_lock.h deleted file mode 100644 index 16f4314..0000000 --- a/libraries/eina/src/include/eina_lock.h +++ /dev/null @@ -1,129 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Vincent Torri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LOCK_H_ -#define EINA_LOCK_H_ - -#include "eina_config.h" -#include "eina_types.h" -#include "eina_error.h" - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Lock_Group Lock - * - * @{ - */ - -typedef enum -{ - EINA_LOCK_FAIL = EINA_FALSE, - EINA_LOCK_SUCCEED = EINA_TRUE, - EINA_LOCK_DEADLOCK -} Eina_Lock_Result; - -#ifdef EINA_HAVE_THREADS -# ifdef _WIN32_WCE -# include "eina_inline_lock_wince.x" -# elif defined(_WIN32) -# include "eina_inline_lock_win32.x" -# else -# include "eina_inline_lock_posix.x" -# endif -#else -# include "eina_inline_lock_void.x" -#endif - -EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP; - -static inline Eina_Bool eina_lock_new(Eina_Lock *mutex); -static inline void eina_lock_free(Eina_Lock *mutex); -static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex); -static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex); -static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex); -static inline void eina_lock_debug(const Eina_Lock *mutex); - -static inline Eina_Bool eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex); -static inline void eina_condition_free(Eina_Condition *cond); -static inline Eina_Bool eina_condition_wait(Eina_Condition *cond); -static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, double t); -static inline Eina_Bool eina_condition_broadcast(Eina_Condition *cond); -static inline Eina_Bool eina_condition_signal(Eina_Condition *cond); - -static inline Eina_Bool eina_rwlock_new(Eina_RWLock *mutex); -static inline void eina_rwlock_free(Eina_RWLock *mutex); -static inline Eina_Lock_Result eina_rwlock_take_read(Eina_RWLock *mutex); -static inline Eina_Lock_Result eina_rwlock_take_write(Eina_RWLock *mutex); -static inline Eina_Lock_Result eina_rwlock_release(Eina_RWLock *mutex); - -static inline Eina_Bool eina_tls_new(Eina_TLS *key); -static inline void eina_tls_free(Eina_TLS key); -static inline void *eina_tls_get(Eina_TLS key); -static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); - -static inline Eina_Bool eina_semaphore_new(Eina_Semaphore *sem, int count_init); -static inline Eina_Bool eina_semaphore_free(Eina_Semaphore *sem); -static inline Eina_Bool eina_semaphore_lock(Eina_Semaphore *sem); -static inline Eina_Bool eina_semaphore_release(Eina_Semaphore *sem, int count_release); - -#ifdef EINA_HAVE_DEBUG_THREADS -# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ - do { \ - if (EINA_UNLIKELY(!eina_main_loop_is())) \ - { \ - eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ - EINA_LOG_ERR("You are calling %s from outside" \ - "of the main loop threads in %s at line %i", \ - __FUNCTION__, \ - __FILE__, \ - __LINE__); \ - return val; \ - } \ - } while (0) -# define EINA_MAIN_LOOP_CHECK_RETURN \ - do { \ - if (EINA_UNLIKELY(!eina_main_loop_is())) \ - { \ - eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \ - EINA_LOG_ERR("You are calling %s from outside" \ - "of the main loop threads in %s at line %i", \ - __FUNCTION__, \ - __FILE__, \ - __LINE__); \ - return ; \ - } \ - } while (0) -#else -# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) -# define EINA_MAIN_LOOP_CHECK_RETURN -#endif - -/** - * @} - */ - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_log.h b/libraries/eina/src/include/eina_log.h deleted file mode 100644 index 186397d..0000000 --- a/libraries/eina/src/include/eina_log.h +++ /dev/null @@ -1,903 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_LOG_H_ -#define EINA_LOG_H_ - -#include -#include -#include - -#include "eina_types.h" - -#define EINA_COLOR_LIGHTRED "\033[31;1m" -#define EINA_COLOR_RED "\033[31m" -#define EINA_COLOR_LIGHTBLUE "\033[34;1m" -#define EINA_COLOR_BLUE "\033[34m" -#define EINA_COLOR_GREEN "\033[32;1m" -#define EINA_COLOR_YELLOW "\033[33;1m" -#define EINA_COLOR_ORANGE "\033[0;33m" -#define EINA_COLOR_WHITE "\033[37;1m" -#define EINA_COLOR_LIGHTCYAN "\033[36;1m" -#define EINA_COLOR_CYAN "\033[36m" -#define EINA_COLOR_RESET "\033[0m" -#define EINA_COLOR_HIGH "\033[1m" - - -/** - * @page tutorial_log_page Log Tutorial - * - * @section tutorial_log_introduction Introduction - * - * The Eina Log module provides logging facilities for libraries and - * applications. It provides colored logging, basic logging levels (error, - * warning, debug, info, critical) and loggers - called logging domains - - * which will be covered on next sections. - * - * @section tutorial_log_basic_usage Basic Usage - * - * Log messages can be displayed using the following macros: - * - * @li EINA_LOG_ERR(), - * @li EINA_LOG_INFO(), - * @li EINA_LOG_WARN(), - * @li EINA_LOG_DBG(). - * - * Here is an example: - * - * @include eina_log_02.c - * - * If you compiled Eina without debug mode, execution will yield only one log - * message, which is "argument is negative". - * - * Here we introduce the concept of logging domains (or loggers), which might - * already be familiar to readers. It is basically a way to separate a set of - * log messages into a context (e.g. a module) and provide a way of controlling - * this set as a whole. - * - * For example, suppose you have 3 different modules on your application and you - * want to get logging only from one of them (e.g. create some sort of filter). - * For achieving that, all you need to do is create a logging domain for each - * module so that all logging inside a module can be considered as a whole. - * - * Logging domains are specified by a name, color applied to the name and the - * level. The first two (name and color) are set through code, that is, inside - * your application/module/library. - * - * The level is used for controlling which messages should appear. It - * specifies the lowest level that should be displayed (e.g. a message - * with level 11 being logged on a domain with level set to 10 would be - * displayed, while a message with level 9 wouldn't). - * - * The domain level is set during runtime (in contrast with the name and - * color) through the environment variable EINA_LOG_LEVELS. This variable - * expects a list in the form domain_name1:level1,domain_name2:level2,... . For - * example: - * - * @verbatim EINA_LOG_LEVELS=mymodule1:5,mymodule2:2,mymodule3:0 ./myapp@endverbatim - * - * This line would set mymodule1 level to 5, mymodule2 level to 2 and mymodule3 - * level to 0. - * - * There's also a global logger to which EINA_LOG_(ERR, DBG, INFO, CRIT, WARN) - * macros do log on. It is a logger that is created internally by Eina Log with - * an empty name and can be used for general logging (where logging domains do - * not apply). - * - * Since this global logger doesn't have a name, you can't set its level through - * EINA_LOG_LEVELS variable. Here we introduce a second environment variable - * that is a bit more special: EINA_LOG_LEVEL. - * - * This variable specifies the level of the global logging domain and the level - * of domains that haven't been set through EINA_LOG_LEVELS. Here's an example: - * - * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS=module1:10,module3:2 ./myapp@endverbatim - * - * Supposing you have modules named "module1", "module2" and "module3", this - * line would result in module1 with level 10, module2 with level 3 and module3 - * with level 2. Note that module2's level wasn't specified, so it's level is - * set to the global level. This way we can easily apply filters to multiple - * domains with only one parameter (EINA_LOG_LEVEL=num). - * - * The global level (EINA_LOG_LEVEL) can also be set through code, using - * eina_log_level_set() function. - * - * While developing your libraries or applications, you may notice that - * EINA_LOG_DOM_(ERR, DBG, INFO, CRIT, WARN) macros also print out - * messages from eina itself. Here we introduce another environment variable - * that is a bit more special: EINA_LOG_LEVELS_GLOB. - * - * This variable allows you to disable the logging of any/all code in eina itself. - * This is useful when developing your libraries or applications so that you can - * see your own domain's messages easier without having to sift through a lot of - * internal eina debug messages. Here's an example: - * - * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS_GLOB=eina_*:0 ./myapp@endverbatim - * - * This will disable eina_log output from all internal eina code thus allowing - * you to see your own domain messages easier. - * - * @section tutorial_log_advanced_display Advanced usage of print callbacks - * - * The log module allows the user to change the way - * eina_log_print() displays the messages. It suffices to pass to - * eina_log_print_cb_set() the function used to display the - * message. That function must be of type #Eina_Log_Print_Cb. As a - * custom data can be passed to that callback, powerful display - * messages can be displayed. - * - * It is suggested to not use __FILE__, __FUNCTION__ or __LINE__ when - * writing that callback, but when defining macros (like - * EINA_LOG_ERR() and other macros). - * - * Here is an example of custom callback, whose behavior can be - * changed at runtime: - * - * @include eina_log_03.c - * @example eina_log_02.c - * @example eina_log_03.c - */ - -/** - * @addtogroup Eina_Log_Group Log - * - * @brief Full-featured logging system. - * - * Eina provides eina_log_print(), a standard function to manage all - * logging messages. This function may be called directly or using the - * helper macros such as EINA_LOG_DBG(), EINA_LOG_ERR() or those that - * take a specific domain as argument EINA_LOG_DOM_DBG(), - * EINA_LOG_DOM_ERR(). Internally, eina_log_print() will call the - * function defined with eina_log_print_cb_set(), that defaults to - * eina_log_print_cb_stderr(), but may be changed to do whatever you - * need, such as networking or syslog logging. - * - * The logging system is thread safe once initialized with - * eina_log_threads_enable(). The thread that calls this function - * first is considered "main thread" and other threads will have their - * thread id (pthread_self()) printed in the log message so it is easy - * to detect from where it is coming. - * - * Log domains is the Eina way to differentiate messages. There might - * be different domains to represent different modules, different - * feature-set, different categories and so on. Filtering can be - * applied to domain names by means of @c EINA_LOG_LEVELS environment - * variable or eina_log_domain_level_set(). - * - * The different logging levels serve to customize the amount of - * debugging one want to take and may be used to automatically call - * abort() once some given level message is printed. This is - * controlled by environment variable @c EINA_LOG_ABORT and the level - * to be considered critical with @c EINA_LOG_ABORT_LEVEL. These can - * be changed with eina_log_abort_on_critical_set() and - * eina_log_abort_on_critical_level_set(). - * - * The default maximum level to print is defined by environment - * variable @c EINA_LOG_LEVEL, but may be set per-domain with @c - * EINA_LOG_LEVELS. It will default to #EINA_LOG_ERR. This can be - * changed with eina_log_level_set(). - * - * To use the log system Eina must be initialized with eina_init() and - * later shut down with eina_shutdown(). Here is a straightforward - * example: - * - * @include eina_log_01.c - * - * Compile this code with the following command: - * - * @verbatim gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --libs eina`@endverbatim - * - * Now execute the program with: - * - * @verbatim EINA_LOG_LEVEL=2 ./eina_log_01@endverbatim - * - * You should see a message displayed in the terminal. - * - * For more information, you can look at the @ref tutorial_log_page. - * - * @example eina_log_01.c - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Log_Group Log - * - * @{ - */ - -/** - * EINA_LOG_DOMAIN_GLOBAL is the general purpose log domain to be - * used, it is always registered and available everywhere. - */ -EAPI extern int EINA_LOG_DOMAIN_GLOBAL; - -#ifndef EINA_LOG_DOMAIN_DEFAULT - -/** - * @def EINA_LOG_DOMAIN_DEFAULT - * This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(), - * EINA_LOG_DOM_INFO(), EINA_LOG_DOM_WARN(), EINA_LOG_DOM_ERR() and - * EINA_LOG_DOM_CRIT(). - * - * If not defined prior to the inclusion of this header, then it - * defaults to #EINA_LOG_DOMAIN_GLOBAL. - * - * @note One may like to redefine this in its code to avoid typing too - * much. In this case the recommended way is: - * - * @code - * #include - * #undef EINA_LOG_DOMAIN_DEFAULT - * #define EINA_LOG_DOMAIN_DEFAULT _log_dom - * static int _log_dom = -1; - * - * int main(void) - * { - * eina_init(); - * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN); - * EINA_LOG_ERR("using my own domain"); - * return 0; - * } - * @endcode - * - * @warning If one defines the domain prior to inclusion of this - * header, the defined log domain symbol must be defined - * prior as well, otherwise the inlined functions defined by - * Eina will fail to find the symbol, causing build failure. - * - * @code - * #define EINA_LOG_DOMAIN_DEFAULT _log_dom - * static int _log_dom = -1; // must come before inclusion of Eina.h! - * #include - * - * int main(void) - * { - * eina_init(); - * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN); - * EINA_LOG_ERR("using my own domain"); - * return 0; - * } - * @endcode - * - */ -# define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL - -#endif /* EINA_LOG_DOMAIN_DEFAULT */ - -/** - * @def EINA_LOG(DOM, LEVEL, fmt, ...) - * Logs a message on the specified domain, level and format. - * - * @note if @c EINA_LOG_LEVEL_MAXIMUM is defined, then messages larger - * than this value will be ignored regardless of current domain - * level, the eina_log_print() is not even called! Most - * compilers will just detect the two integers make the branch - * impossible and remove the branch and function call all - * together. Take this as optimization tip and possible remove - * debug messages from binaries to be deployed, saving on hot - * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public - * header files. - */ -#ifdef EINA_ENABLE_LOG -# ifdef EINA_LOG_LEVEL_MAXIMUM -# define EINA_LOG(DOM, LEVEL, fmt, ...) \ - do { \ - if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ - eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ - fmt, ## __VA_ARGS__); } \ - } while (0) -# else -# define EINA_LOG(DOM, LEVEL, fmt, ...) \ - eina_log_print(DOM, \ - LEVEL, \ - __FILE__, \ - __FUNCTION__, \ - __LINE__, \ - fmt, \ - ## __VA_ARGS__) -# endif -#else -#define EINA_LOG(DOM, LEVEL, fmt, ...) \ - do { (void) DOM; (void) LEVEL; (void) fmt; } while (0) -#endif - -/** - * @def EINA_LOG_DOM_CRIT(DOM, fmt, ...) - * Logs a message with level CRITICAL on the specified domain and format. - */ -#define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \ - EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_DOM_ERR(DOM, fmt, ...) - * Logs a message with level ERROR on the specified domain and format. - */ -#define EINA_LOG_DOM_ERR(DOM, fmt, ...) \ - EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_DOM_INFO(DOM, fmt, ...) - * Logs a message with level INFO on the specified domain and format. - */ -#define EINA_LOG_DOM_INFO(DOM, fmt, ...) \ - EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_DOM_DBG(DOM, fmt, ...) - * Logs a message with level DEBUG on the specified domain and format. - */ -#define EINA_LOG_DOM_DBG(DOM, fmt, ...) \ - EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_DOM_WARN(DOM, fmt, ...) - * Logs a message with level WARN on the specified domain and format. - */ -#define EINA_LOG_DOM_WARN(DOM, fmt, ...) \ - EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_CRIT(fmt, ...) - * Logs a message with level CRITICAL on the default domain with the specified - * format. - */ -#define EINA_LOG_CRIT(fmt, ...) \ - EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \ - EINA_LOG_LEVEL_CRITICAL, \ - fmt, \ - ## __VA_ARGS__) - -/** - * @def EINA_LOG_ERR(fmt, ...) - * Logs a message with level ERROR on the default domain with the specified - * format. - */ -#define EINA_LOG_ERR(fmt, ...) \ - EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_INFO(fmt, ...) - * Logs a message with level INFO on the default domain with the specified - * format. - */ -#define EINA_LOG_INFO(fmt, ...) \ - EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_WARN(fmt, ...) - * Logs a message with level WARN on the default domain with the specified - * format. - */ -#define EINA_LOG_WARN(fmt, ...) \ - EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__) - -/** - * @def EINA_LOG_DBG(fmt, ...) - * Logs a message with level DEBUG on the default domain with the specified - * format. - */ -#define EINA_LOG_DBG(fmt, ...) \ - EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__) - -/** - * @typedef Eina_Log_Domain - * The domain used for logging. - */ -typedef struct _Eina_Log_Domain Eina_Log_Domain; - -/** - * @struct _Eina_Log_Domain - * The domain used for logging. - */ -struct _Eina_Log_Domain -{ - int level; /**< Max level to log */ - const char *domain_str; /**< Formatted string with color to print */ - const char *name; /**< Domain name */ - size_t namelen; /**< strlen(name) */ - - /* Private */ - Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */ -}; - -/** - * Enable logging module to handle threads. - * - * There is no disable option on purpose, if it is enabled, there is - * no way back until you call the last eina_shutdown(). - * - * There is no function to retrieve if threads are enabled as one is - * not supposed to know this from outside. - * - * After this call is executed at least once, if Eina was compiled - * with threads support then logging will lock around debug messages - * and threads that are not the main thread will have its identifier - * printed. - * - * The main thread is considered the thread where the first - * eina_init() was called. - */ -EAPI void eina_log_threads_enable(void); - -/** - * @enum _Eina_Log_Level - * List of available logging levels. - */ -typedef enum _Eina_Log_Level -{ - EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */ - EINA_LOG_LEVEL_ERR, /**< Error log level */ - EINA_LOG_LEVEL_WARN, /**< Warning log level */ - EINA_LOG_LEVEL_INFO, /**< Information log level */ - EINA_LOG_LEVEL_DBG, /**< Debug log level */ - EINA_LOG_LEVELS, /**< Count of default log levels */ - EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */ -} Eina_Log_Level; - -/** - * @typedef Eina_Log_Print_Cb - * Type for print callbacks. - */ -typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, const char *fnc, int line, - const char *fmt, void *data, va_list args); - -/* - * Customization - */ - -/** - * Sets logging method to use. - * - * @param cb The callback to call when printing a log. - * @param data The data to pass to the callback. - * - * By default, eina_log_print_cb_stderr() is used. - * - * @note MT: safe to call from any thread. - * - * @note MT: given function @a cb will be called protected by mutex. - * This means you're safe from other calls but you should never - * call eina_log_print(), directly or indirectly. - */ -EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1); - - -/** - * @brief Set the default log level. - * - * @param level The log level. - * - * This function sets the log level @p level. It is used in - * eina_log_print(). - * - * @note this is initially set to envvar EINA_LOG_LEVEL by eina_init(). - * - * @see eina_log_level_get() - */ -EAPI void eina_log_level_set(int level); - -/** - * @brief Get the default log level. - * - * @return the log level that limits eina_log_print(). - * - * @see eina_log_level_set() - */ -EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT; - -static inline Eina_Bool eina_log_level_check(int level); - -/** - * Checks if current thread is the main thread. - * - * @return #EINA_TRUE if threads were enabled and the current thread - * is the one that called eina_log_threads_init(). If there is - * no thread support (compiled with --disable-pthreads) or - * they were not enabled, then #EINA_TRUE is also - * returned. The only case where #EINA_FALSE is returned is - * when threads were successfully enabled but the current - * thread is not the main (one that called - * eina_log_threads_init()). - */ -EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Set if color logging should be disabled. - * - * @param disabled if #EINA_TRUE, color logging should be disabled. - * - * @note this is initially set to envvar EINA_LOG_COLOR_DISABLE by eina_init(). - * - * @see eina_log_color_disable_get() - */ -EAPI void eina_log_color_disable_set(Eina_Bool disabled); - -/** - * @brief Get if color logging should be disabled. - * - * @return if #EINA_TRUE, color logging should be disabled. - * - * @see eina_log_color_disable_set() - */ -EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set if originating file name logging should be disabled. - * - * @param disabled if #EINA_TRUE, file name logging should be disabled. - * - * @note this is initially set to envvar EINA_LOG_FILE_DISABLE by eina_init(). - * - * @see eina_log_file_disable_get() - */ -EAPI void eina_log_file_disable_set(Eina_Bool disabled); - -/** - * @brief Get if originating file name logging should be disabled. - * - * @return if #EINA_TRUE, file name logging should be disabled. - * - * @see eina_log_file_disable_set() - */ -EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set if originating function name logging should be disabled. - * - * @param disabled if #EINA_TRUE, function name logging should be disabled. - * - * @note this is initially set to envvar EINA_LOG_FUNCTION_DISABLE by - * eina_init(). - * - * @see eina_log_function_disable_get() - */ -EAPI void eina_log_function_disable_set(Eina_Bool disabled); - -/** - * @brief Get if originating function name logging should be disabled. - * - * @return if #EINA_TRUE, function name logging should be disabled. - * - * @see eina_log_function_disable_set() - */ -EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set if critical messages should abort the program. - * - * @param abort_on_critical if #EINA_TRUE, messages with level equal - * or smaller than eina_log_abort_on_critical_level_get() will - * abort the program. - * - * @note this is initially set to envvar EINA_LOG_ABORT by - * eina_init(). - * - * @see eina_log_abort_on_critical_get() - * @see eina_log_abort_on_critical_level_set() - */ -EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical); - -/** - * @brief Get if critical messages should abort the program. - * - * @return if #EINA_TRUE, any messages with level equal or smaller - * than eina_log_abort_on_critical_level_get() will abort the - * program. - * - * @see eina_log_abort_on_critical_set() - * @see eina_log_abort_on_critical_level_set() - */ -EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set level that triggers abort if abort-on-critical is set. - * - * @param critical_level levels equal or smaller than the given value - * will trigger program abortion if - * eina_log_abort_on_critical_get() returns #EINA_TRUE. - * - * @note this is initially set to envvar EINA_LOG_ABORT_LEVEL by - * eina_init(). - * - * @see eina_log_abort_on_critical_level_get() - * @see eina_log_abort_on_critical_get() - */ -EAPI void eina_log_abort_on_critical_level_set(int critical_level); - -/** - * @brief Get level that triggers abort if abort-on-critical is set. - * - * @return critical level equal or smaller than value will trigger - * program abortion if eina_log_abort_on_critical_get() returns - * #EINA_TRUE. - * - * @see eina_log_abort_on_critical_level_set() - * @see eina_log_abort_on_critical_get() - */ -EAPI int eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT; - - -/** - * Set the domain level given its name. - * - * This call has the same effect as setting - * EINA_LOG_LEVELS=<@p domain_name>:<@p level> - * - * @param domain_name domain name to change the level. It may be of a - * still not registered domain. If the domain is not registered - * yet, it will be saved as a pending set and applied upon - * registration. - * @param level level to use to limit eina_log_print() for given domain. - */ -EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1); - -/** - * Get the domain level given its name. - * - * @param domain_name domain name to retrieve the level. It may be of - * a still not registered domain. If the domain is not - * registered yet, but there is a pending value, either from - * eina_log_domain_level_set(),EINA_LOG_LEVELS environment - * variable or from EINA_LOG_LEVELS_GLOB, these are - * returned. If nothing else was found, then the global/default - * level (eina_log_level_get()) is returned. - * - * @return level to use to limit eina_log_print() for given - * domain. On error (@p domain_name == NULL), - * EINA_LOG_LEVEL_UNKNOWN is returned. - * - * @see eina_log_domain_level_set() - * @see eina_log_domain_registered_level_get() - */ -EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * Get the domain level given its identifier. - * - * @param domain identifier, so it must be previously registered with - * eina_log_domain_register(). It's a much faster version of - * eina_log_domain_level_get(), but relies on domain being - * present. - * - * @return level to use to limit eina_log_print() for given domain. On - * error EINA_LOG_LEVEL_UNKNOWN is returned. - */ -EAPI int eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT; - -static inline Eina_Bool eina_log_domain_level_check(int domain, int level); - -/* - * Logging domains - */ - -/** - * @param name Domain name - * @param color Color of the domain name - * - * @return Domain index that will be used as the DOMAIN parameter on log - * macros. A negative return value means an log occurred. - * - * @note MT: safe to call from any thread. - */ -EAPI int eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1); - -/** - * Forget about a logging domain registered by eina_log_domain_register() - * - * @param domain domain identifier as reported by eina_log_domain_register(), - * must be >= 0. - * - * @note MT: safe to call from any thread. - */ -EAPI void eina_log_domain_unregister(int domain); - -/* - * Logging functions. - */ - -/** - * Print out log message using given domain and level. - * - * @note Usually you'll not use this function directly but the helper - * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and - * so on. See eina_log.h - * - * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if - * you registered none. It is recommended that modules and - * applications have their own logging domain. - * @param level message level, those with level greater than user - * specified value (eina_log_level_set() or environment - * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored. - * @param file filename that originated the call, must @b not be @c NULL. - * @param function function that originated the call, must @b not be @c NULL. - * @param line originating line in @a file. - * @param fmt printf-like format to use. Should not provide trailing - * '\n' as it is automatically included. - * - * @note MT: this function may be called from different threads if - * eina_log_threads_enable() was called before. - */ -EAPI void eina_log_print(int domain, - Eina_Log_Level level, - const char *file, - const char *function, - int line, - const char *fmt, - ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT; - -/** - * Print out log message using given domain and level. - * - * @note Usually you'll not use this function directly but the helper - * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and - * so on. See eina_log.h - * - * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if - * you registered none. It is recommended that modules and - * applications have their own logging domain. - * @param level message level, those with level greater than user - * specified value (eina_log_level_set() or environment - * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored. - * @param file filename that originated the call, must @b not be @c NULL. - * @param fnc function that originated the call, must @b not be @c NULL. - * @param line originating line in @a file. - * @param fmt printf-like format to use. Should not provide trailing - * '\n' as it is automatically included. - * @param args the arguments needed by the format. - * - * @note MT: this function may be called from different threads if - * eina_log_threads_enable() was called before. - * - * @see eina_log_print() - */ -EAPI void eina_log_vprint(int domain, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT; - -/* - * Logging methods (change how logging is done). - */ - -/** - * @brief Alternative logging method, this will output to standard output stream. - * - * @param d The domain. - * @param level The level. - * @param file The file which is logged. - * @param fnc The function which is logged. - * @param line The line which is logged. - * @param fmt The ouptut format to use. - * @param data Not used. - * @param args The arguments needed by the format. - * - * This method will colorize output based on domain provided color and - * message logging level. To disable color, set environment variable - * EINA_LOG_COLOR_DISABLE=1. Similarly, to disable file and line - * information, set EINA_LOG_FILE_DISABLE=1 or - * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is - * not acceptable to have both EINA_LOG_FILE_DISABLE and - * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just - * EINA_LOG_FUNCTION_DISABLE will be considered and file information - * will be printed anyways. - * - * @note MT: if threads are enabled, this function is called within locks. - * @note MT: Threads different from main thread will have thread id - * appended to domain name. - */ -EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - -/** - * @brief Default logging method, this will output to standard error stream. - * - * @param d The domain. - * @param level The level. - * @param file The file which is logged. - * @param fnc The function which is logged. - * @param line The line which is logged. - * @param fmt The ouptut format to use. - * @param data Not used. - * @param args The arguments needed by the format. - * - * This method will colorize output based on domain provided color and - * message logging level. - * - * To disable color, set environment variable - * EINA_LOG_COLOR_DISABLE=1. To enable color, even if directing to a - * file or when using a non-supported color terminal, use - * EINA_LOG_COLOR_DISABLE=0. If EINA_LOG_COLOR_DISABLE is unset (or - * -1), then Eina will disable color if terminal ($TERM) is - * unsupported or if redirecting to a file. - - . Similarly, to disable file and line - * information, set EINA_LOG_FILE_DISABLE=1 or - * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is - * not acceptable to have both EINA_LOG_FILE_DISABLE and - * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just - * EINA_LOG_FUNCTION_DISABLE will be considered and file information - * will be printed anyways. - * - * @note MT: if threads are enabled, this function is called within locks. - * @note MT: Threads different from main thread will have thread id - * appended to domain name. - */ -EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - -/** - * Alternative logging method, this will output to given file stream. - * - * @param d The domain. - * @param level Not used. - * @param file The file which is logged. - * @param fnc The function which is logged. - * @param line The line which is logged. - * @param fmt The ouptut format to use. - * @param data The file which will store the output (as a FILE *). - * @param args The arguments needed by the format. - * - * This method will never output color. - * - * @note MT: if threads are enabled, this function is called within locks. - * @note MT: Threads different from main thread will have thread id - * appended to domain name. - */ -EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - -#include "eina_inline_log.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_LOG_H_ */ diff --git a/libraries/eina/src/include/eina_magic.h b/libraries/eina/src/include/eina_magic.h deleted file mode 100644 index d4909d8..0000000 --- a/libraries/eina/src/include/eina_magic.h +++ /dev/null @@ -1,330 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MAGIC_H_ -#define EINA_MAGIC_H_ - -#include "eina_config.h" -#include "eina_types.h" -#include "eina_error.h" - -/** - * @page eina_magic_example_01_page - * @dontinclude eina_magic_01.c - * - * Whenever using Eina we must include it: - * @skipline #include - * - * For this example we are going to define two classes, person and pilot, and - * since every pilot is a person we use inheritance. To be type safe we are - * going to add EINA_MAGIC to our classes: - * @until struct _pilot pilot - * @note The values of BASETYPE_MAGIC and SUBTYPE_MAGIC have no meaning, the - * only important thing about them is that they be unique. - * - * Here we have a function to create a perso given a name, nothing too fancy: - * @until } - * - * And now the counterpart, a function the free a person. - * @until { - * Before we start releasing resources we check that the pointer we were given - * actually points to a person, and if not we will print an error message and - * quit: - * @until } - * @note EINA_MAGIC_FAIL is a macro that make's it easy to print an appropriate - * (and consistent) error message. - * Now knowing that ptr is indeed of type person we prooced to set EINA_MAGIC to - * EINA_MAGIC_NONE and free alocated memory: - * @until } - * @note Setting EINA_MAGIC to EINA_MAGIC_NONE is important to prevent the - * struct from being used after freed. - * - * Now we have our function to create a pilot, this one is a little more complex - * because we need to set EINA_MAGIC for the pilot and pilot->base, this is very - * important so that checking the EINA_MAGIC of (person*)my_pilot will work: - * @until } - * - * The function to free a pilot is not too different from the one that frees a - * person: - * @until } - * @until } - * - * We also create functions to print a person or a pilot that check the type of - * the pointers they receive: - * @until } - * @until } - * - * And on to our main function where we declare some variables and initialize - * Eina: - * @until eina_init - * - * For Eina to be able to provide more informative error messages we are going - * to give names to our EINA_MAGIC types: - * @until string_set - * - * Since our types won't live longer than the scope of the current function we - * can set the name without eina making a copy of the string: - * @until static_set - * - * Now we create a person, a pilot and print both as persons: - * @until person * - * - * Now we try to print both as pilots, which will obvisouly not work since base - * is not a pilot: - * @until pilot(sub - * - * That's all folks: - * @until } - * - * See full source @ref eina_magic_example_01_c "here". - */ -/** - * @page eina_magic_example_01_c Eina_Magic - * @include eina_magic_01.c - * @example eina_magic_01.c - */ -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ -/** - * @defgroup Eina_Magic_Group Magic - * - * @brief Eina_Magic provides run-time type-checking. - * - * C is a weak statically typed language, in other words, it will just check for - * types during compile time and any cast will make the compiler believe the - * type is correct. - * - * In real world code we often need to deal with casts, either explicit or - * implicit by means of @c void*. We also need to resort to casts when doing - * inheritance in C. - * - * Eina_Magic give us a way to do casts and still be certain of the type we are - * opearting on. - * - * @note It should be noted that it is considered good practice to @b disable - * Eina_Magic for production code. The reasoning is that any Eina_Magic errors - * should have been caught during testing and therefore there is no reason to - * incur the performance downside of Eina_Magic. - * - * An @ref eina_magic_example_01_page "example" should elucidate matters. - * - * @{ - */ - -/** - * An abstract type for a magic number. - */ -typedef unsigned int Eina_Magic; - -/** - * @brief Return the string associated to the given magic identifier. - * - * @param magic The magic identifier. - * @return The string associated to the identifier. - * - * This function returns the string associated to @p magic. Even if none are - * found this function still returns non @c NULL, in this case an identifier - * such as "(none)", "(undefined)" or "(unknown)". - * - * The following identifiers may be returned whenever magic is - * invalid, with their meanings: - * - * - (none): no magic was registered exists at all. - * - (undefined): magic was registered and found, but no string associated. - * - (unknown): magic was not found in the registry. - * - * @warning The returned value must not be freed. - */ -EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_WARN_UNUSED_RESULT; -/** - * @brief Set the string associated to the given magic identifier. - * - * @param magic The magic identifier. - * @param magic_name The string associated to the identifier, must not - * be @c NULL. - * - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function sets the string @p magic_name to @p magic. It is not - * checked if number or string are already set, in which case you will end with - * duplicates. Internally, eina will make a copy of @p magic_name. - * - * @see eina_magic_string_static_set() - */ -EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic, - const char *magic_name) EINA_ARG_NONNULL(2); - -/** - * @brief Set the string associated to the given magic identifier. - * - * @param magic The magic identifier. - * @param magic_name The string associated to the identifier, must not be - * @c NULL. - * - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function sets the string @p magic_name to @p magic. It is not checked if - * number or string are already set, in which case you might end with - * duplicates. Eina will @b not make a copy of @p magic_name, this means that - * @p magic_name has to be a valid pointer for as long as @p magic is used. - * - * @see eina_magic_string_set() - */ -EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, - const char *magic_name) EINA_ARG_NONNULL(2); - -/** - * @def EINA_MAGIC_NONE - * Random value for specifying that a structure using the magic - * feature has already been freed. It is used by eina_magic_fail(). - * - * If the magic feature of Eina is disabled, #EINA_MAGIC_NONE is just - * @c 0. - */ -#define EINA_MAGIC_NONE 0x1234fedc - -/** - * @var EINA_ERROR_MAGIC_FAILED - * Error identifier corresponding to magic check failure. - */ -EAPI extern Eina_Error EINA_ERROR_MAGIC_FAILED; - - -#ifdef EINA_MAGIC_DEBUG - -/** - * @def EINA_MAGIC - * Declaration of a variable of type #Eina_Magic. To put in a structure - * when one wants to use the magic feature of Eina with the functions - * of that structure, like that: - * - * @code - * struct Foo - * { - * int i; - * - * EINA_MAGIC - * }; - * @endcode - * - * If the magic feature of Eina is disabled, #EINA_MAGIC does nothing. - */ -#define EINA_MAGIC Eina_Magic __magic; - -/** - * @def EINA_MAGIC_SET(d, m) - * Set the magic number of @p d to @p m. @p d must be a valid pointer - * to a structure holding an Eina magic number declaration. Use - * #EINA_MAGIC to add such declaration. - * - * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just - * the value @c 0. - */ -#define EINA_MAGIC_SET(d, m) (d)->__magic = (m) - -/** - * @def EINA_MAGIC_CHECK(d, m) - * Test if @p d is @c NULL or not, and if not @c NULL, if - * @p d->__eina_magic is equal to @p m. @p d must be a structure that - * holds an Eina magic number declaration. Use #EINA_MAGIC to add such - * declaration. - * - * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just - * the value @c 1. - */ -#define EINA_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m))) - -/** - * @def EINA_MAGIC_FAIL(d, m) - * Call eina_magic_fail() with the parameters @p d, @p d->__magic, @p - * m, __FILE__, __FUNCTION__ and __LINE__. @p d must be a structure that - * holds an Eina magic number declaration. Use #EINA_MAGIC to add such - * declaration. - * - * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does - * nothing. - */ -#define EINA_MAGIC_FAIL(d, m) \ - eina_magic_fail((void *)(d), \ - (d) ? (d)->__magic : 0, \ - (m), \ - __FILE__, \ - __FUNCTION__, \ - __LINE__); - -/** - * @brief Display a message or abort if a magic check failed. - * - * @param d The checked data pointer. - * @param m The magic identifer to check. - * @param req_m The requested magic identifier to check. - * @param file The file in which the magic check failed. - * @param fnc The function in which the magic check failed. - * @param line The line at which the magic check failed. - * - * @warning You should @b strongly consider using @ref EINA_MAGIC_FAIL(d, m) - * instead. - * - * This function displays an error message if a magic check has - * failed, using the following logic in the following order: - * @li If @p d is @c NULL, a message warns about a @c NULL pointer. - * @li Otherwise, if @p m is equal to #EINA_MAGIC_NONE, a message - * warns about a handle that was already freed. - * @li Otherwise, if @p m is equal to @p req_m, a message warns about - * a handle that is of wrong type. - * @li Otherwise, a message warns you about ab-using that function... - * - * If the environment variable EINA_LOG_ABORT is set, abort() is - * called and the program stops. It is useful for debugging programs - * with gdb. - */ -EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m, - const char *file, const char *fnc, - int line) EINA_ARG_NONNULL(4, 5); - -#else - -/** - * @cond LOCAL - */ - -#define EINA_MAGIC -#define EINA_MAGIC_SET(d, m) ((void)0) -#define EINA_MAGIC_CHECK(d, m) (1) -#define EINA_MAGIC_FAIL(d, m) ((void)0) - -#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void)0) - -/** - * @endcond - */ - -#endif - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_MAGIC_H_ */ diff --git a/libraries/eina/src/include/eina_main.h b/libraries/eina/src/include/eina_main.h deleted file mode 100644 index 4baf40e..0000000 --- a/libraries/eina/src/include/eina_main.h +++ /dev/null @@ -1,165 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MAIN_H_ -#define EINA_MAIN_H_ - -#include "eina_types.h" - -/** - * @addtogroup Eina_Main_Group Main - * - * @brief These functions provide general initialisation and shut down - * functions. - */ - -/** - * @addtogroup Eina_Core_Group Core - * - * @{ - */ - -/** - * @defgroup Eina_Main_Group Main - * - * @{ - */ - -/** - * @def EINA_VERSION_MAJOR - * @brief Major version of Eina - */ -#define EINA_VERSION_MAJOR 1 - -/** - * @def EINA_VERSION_MINOR - * @brief Minor version of Eina - */ -#define EINA_VERSION_MINOR 2 - -/** - * @typedef Eina_Version - * The version of Eina. - */ -typedef struct _Eina_Version -{ - int major; /**< Major component of the version */ - int minor; /**< Minor component of the version */ - int micro; /**< Micro component of the version */ - int revision; /**< Revision component of the version */ -} Eina_Version; - -EAPI extern Eina_Version *eina_version; - -/** - * @brief Initialize the Eina library. - * - * @return 1 or greater on success, 0 on error. - * - * This function sets up all the eina modules. It returns 0 on - * failure (that is, when one of the module fails to initialize), - * otherwise it returns the number of times it has already been - * called. - * - * When Eina is not used anymore, call eina_shutdown() to shut down - * the Eina library. - */ -EAPI int eina_init(void); - -/** - * @brief Shut down the Eina library. - * - * @return 0 when all the modules is completely shut down, 1 or - * greater otherwise. - * - * This function shuts down the Eina library. It returns 0 when it has - * been called the same number of times than eina_init(). In that case - * it shut down all the Eina modules. - * - * Once this function succeeds (that is, @c 0 is returned), you must - * not call any of the Eina function anymore. You must call - * eina_init() again to use the Eina functions again. - */ -EAPI int eina_shutdown(void); - -/** - * @brief Initialize the mutexes of the Eina library. - * - * @return 1 or greater on success, 0 on error. - * - * This function sets up all the mutexes in all eina modules. It returns 0 on - * failure (that is, when one of the module fails to initialize), - * otherwise it returns the number of times it has already been - * called. - * - * When the mutexes are not used anymore, call eina_threads_shutdown() to shut down - * the mutexes. - * - * This function should never be called outside of the main loop. - */ -EAPI int eina_threads_init(void); - -/** - * @brief Shut down mutexes in the Eina library. - * - * @return 0 when all mutexes are completely shut down, 1 or - * greater otherwise. - * - * This function shuts down the mutexes in the Eina library. It returns 0 when it has - * been called the same number of times than eina_threads_init(). In that case - * it shut down all the mutexes. - * - * Once this function succeeds (that is, @c 0 is returned), you must - * not call any of the Eina function in a thread anymore. You must call - * eina_threads_init() again to use the Eina functions in a thread again. - * - * This function should never be called outside of the main loop. - */ -EAPI int eina_threads_shutdown(void); - -/** - * @brief Check if you are calling this function from the same thread Eina was initialized or not - * - * @return #EINA_TRUE is the calling function is the same thread, #EINA_FALSE otherwise. - * - * @since 1.1.0 - * - * Most EFL function are not thread safe and all the call need to happen in - * the main loop. With this call you could know if you can call an EFL - * function or not. - */ -EAPI Eina_Bool eina_main_loop_is(void); - -/** - * @brief You should never use that function excpet if you really really know what your are doing. - * @since 1.1.0 - * - * If you are reading this documentation, that certainly means you don't know what is the purpose of - * this call and you should just not use it. - */ -EAPI void eina_main_loop_define(void); - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_MAIN_H_ */ diff --git a/libraries/eina/src/include/eina_matrixsparse.h b/libraries/eina/src/include/eina_matrixsparse.h deleted file mode 100644 index 97d1ca5..0000000 --- a/libraries/eina/src/include/eina_matrixsparse.h +++ /dev/null @@ -1,399 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2009 Gustavo Sverzut Barbieri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MATRIXSPARSE_H_ -#define EINA_MATRIXSPARSE_H_ - -#include - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_iterator.h" -#include "eina_accessor.h" - -/** - * @addtogroup Eina_Matrixsparse_Group Sparse Matrix - * - * @brief These functions provide matrix sparse management. - * - * For more information, you can look at the @ref tutorial_matrixsparse_page. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Matrixsparse_Group Sparse Matrix - * - * @{ - */ - -/** - * @typedef Eina_Matrixsparse - * Type for a generic sparse matrix. - */ -typedef struct _Eina_Matrixsparse Eina_Matrixsparse; - -/** - * @typedef Eina_Matrixsparse_Row - * Type for a generic sparse matrix row, opaque for users. - */ -typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row; - -/** - * @typedef Eina_Matrixsparse_Cell - * Type for a generic sparse matrix cell, opaque for users. - */ -typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell; - -/* constructors and destructors */ - -/** - * @brief Create a new Sparse Matrix. - * - * @param rows number of rows in matrix. Operations with rows greater than this - * value will fail. - * @param cols number of columns in matrix. Operations with columns greater - * than this value will fail. - * @param free_func used to delete cell data contents, used by - * eina_matrixsparse_free(), eina_matrixsparse_size_set(), - * eina_matrixsparse_row_idx_clear(), - * eina_matrixsparse_column_idx_clear(), - * eina_matrixsparse_cell_idx_clear() and possible others. - * @param user_data given to @a free_func as first parameter. - * - * @return newly allocated matrix or NULL if allocation failed and eina_error - * is set. - */ -EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows, - unsigned long cols, - void (*free_func)(void *user_data, - void *cell_data), - const void *user_data); - -/** - * @brief Free resources allocated to Sparse Matrix. - * - * @param m The Sparse Matrix instance to free, must @b not be @c NULL. - */ -EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m); - -/* size manipulation */ - -/** - * @brief Get the current size of Sparse Matrix. - * - * The given parameters are guaranteed to be set if they're not NULL, - * even if this function fails (ie: @a m is not a valid matrix instance). - * - * @param m the sparse matrix to operate on. - * @param rows returns the number of rows, may be NULL. If @a m is invalid, - * returned value is zero, otherwise it's a positive integer. - * @param cols returns the number of columns, may be NULL. If @a m is - * invalid, returned value is zero, otherwise it's a positive integer. - */ -EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m, - unsigned long *rows, - unsigned long *cols); - -/** - * @brief Resize the Sparse Matrix. - * - * This will resize the sparse matrix, possibly freeing cells on rows - * and columns that will cease to exist. - * - * @param m the sparse matrix to operate on. - * @param rows the new number of rows, must be greater than zero. - * @param cols the new number of columns, must be greater than zero. - * @return 1 on success, 0 on failure. - * - * @warning cells, rows or columns are not reference counted and thus - * after this call any reference might be invalid if instance were - * freed. - */ -EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m, - unsigned long rows, - unsigned long cols); - -/* data getting */ - -/** - * Get the cell reference inside Sparse Matrix. - * - * @param m the sparse matrix to operate on. - * @param row the new number of row to clear. - * @param col the new number of column to clear. - * @param cell pointer to return cell reference, if any exists. - * - * @return 1 on success, 0 on failure. It is considered success if did not - * exist but index is inside matrix size, in this case @c *cell == NULL - * - * @see eina_matrixsparse_cell_data_get() - * @see eina_matrixsparse_data_idx_get() - */ -EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell); - -/** - * Get data associated with given cell reference. - * - * @param cell given cell reference, must @b not be @c NULL. - * - * @return data associated with given cell. - * - * @see eina_matrixsparse_cell_idx_get() - * @see eina_matrixsparse_data_idx_get() - */ -EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell); - -/** - * Get data associated with given cell given its indexes. - * - * @param m the sparse matrix to operate on. - * @param row the new number of row to clear. - * @param col the new number of column to clear. - * - * @return data associated with given cell or NULL if nothing is associated. - * - * @see eina_matrixsparse_cell_idx_get() - * @see eina_matrixsparse_cell_data_get() - */ -EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col); - -/** - * Get position (indexes) of the given cell. - * - * @param cell the cell reference, must @b not be @c NULL. - * @param row where to store cell row number, may be @c NULL. - * @param col where to store cell column number, may be @c NULL. - * - * @return 1 on success, 0 otherwise (@c cell is @c NULL). - */ -EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col); - -/* data setting */ - -/** - * Change cell reference value without freeing the possibly existing old value. - * - * @param cell the cell reference, must @b not be @c NULL. - * @param data new data to set. - * @param p_old returns the old value intact (not freed). - * - * @return 1 on success, 0 otherwise (@a cell is @c NULL). - * - * @see eina_matrixsparse_cell_data_set() - * @see eina_matrixsparse_data_idx_replace() - */ -EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old); - -/** - * Change cell value freeing the possibly existing old value. - * - * In contrast to eina_matrixsparse_cell_data_replace(), this function will - * call @c free_func() on existing value. - * - * @param cell the cell reference, must @b not be @c NULL. - * @param data new data to set. - * - * @return 1 on success, 0 otherwise (@a cell is @c NULL). - * - * @see eina_matrixsparse_cell_data_replace() - * @see eina_matrixsparse_data_idx_set() - */ -EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data); - -/** - * Change cell value without freeing the possibly existing old value, using - * indexes. - * - * @param m the sparse matrix, must @b not be @c NULL. - * @param row the row number to set the value. - * @param col the column number to set the value. - * @param data new data to set. - * @param p_old returns the old value intact (not freed). - * - * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid). - * - * @see eina_matrixsparse_cell_data_replace() - * @see eina_matrixsparse_data_idx_set() - */ -EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old); - -/** - * Change cell value freeing the possibly existing old value, using - * indexes. - * - * In contrast to eina_matrixsparse_data_idx_replace(), this function will - * call @c free_func() on existing value. - * - * @param m the sparse matrix, must @b not be @c NULL. - * @param row the row number to set the value. - * @param col the column number to set the value. - * @param data new data to set. - * - * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid). - * - * @see eina_matrixsparse_cell_data_replace() - */ -EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data); - -/* data deleting */ - -/** - * Clear (erase all cells) of row given its index. - * - * Existing cells will be cleared with @c free_func() given to - * eina_matrixsparse_new(). - * - * @param m the sparse matrix to operate on. - * @param row the new number of row to clear. - * - * @return 1 on success, 0 on failure. It is considered success if row - * had no cells filled. Failure is asking for clear row outside - * matrix size. - * - * @warning cells, rows or columns are not reference counted and thus - * after this call any reference might be invalid if instance were - * freed. - */ -EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row); - -/** - * Clear (erase all cells) of column given its index. - * - * Existing cells will be cleared with @c free_func() given to - * eina_matrixsparse_new(). - * - * @param m the sparse matrix to operate on. - * @param col the new number of column to clear. - * - * @return 1 on success, 0 on failure. It is considered success if column - * had no cells filled. Failure is asking for clear column outside - * matrix size. - * - * @warning cells, rows or columns are not reference counted and thus - * after this call any reference might be invalid if instance were - * freed. - */ -EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col); - -/** - * Clear (erase) cell given its indexes. - * - * Existing cell will be cleared with @c free_func() given to - * eina_matrixsparse_new(). - * - * @param m the sparse matrix to operate on. - * @param row the new number of row to clear. - * @param col the new number of column to clear. - * - * @return 1 on success, 0 on failure. It is considered success if did not - * exist but index is inside matrix size. - * - * @warning cells, rows or columns are not reference counted and thus - * after this call any reference might be invalid if instance were - * freed. Note that this call might delete container column and - * row if this cell was the last remainder. - */ -EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col); - -/** - * Clear (erase) cell given its reference. - * - * @param cell the cell reference, must @b not be @c NULL. - * - * @return 1 on success, 0 on failure. - * - * @warning cells, rows or columns are not reference counted and thus - * after this call any reference might be invalid if instance were - * freed. Note that this call might delete container column and - * row if this cell was the last remainder. - */ -EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell); - -/* iterators */ - -/** - * Creates a new iterator over existing matrix cells. - * - * This is a cheap walk, it will just report existing cells and holes - * in the sparse matrix will be ignored. That means the reported - * indexes will not be sequential. - * - * The iterator data will be the cell reference, one may query current - * position with eina_matrixsparse_cell_position_get() and cell value - * with eina_matrixsparse_cell_data_get(). - * - * @param m The Sparse Matrix reference, must @b not be @c NULL. - * @return A new iterator. - * - * @warning if the matrix structure changes then the iterator becomes - * invalid! That is, if you add or remove cells this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m); - -/** - * Creates a new iterator over all matrix cells. - * - * Unlike eina_matrixsparse_iterator_new() this one will report all - * matrix cells, even those that are still empty (holes). These will - * be reported as dummy cells that contains no data. - * - * Be aware that iterating a big matrix (1000x1000) will call your - * function that number of times (1000000 times in that case) even if - * your matrix have no elements at all! - * - * The iterator data will be the cell reference, one may query current - * position with eina_matrixsparse_cell_position_get() and cell value - * with eina_matrixsparse_cell_data_get(). If cell is empty then the - * reference will be a dummy/placeholder, thus setting value with - * eina_matrixsparse_cell_data_set() will leave pointer unreferenced. - * - * @param m The Sparse Matrix reference, must @b not be @c NULL. - * @return A new iterator. - * - * @warning if the matrix structure changes then the iterator becomes - * invalid! That is, if you add or remove cells this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_MATRIXSPARSE_H_ */ diff --git a/libraries/eina/src/include/eina_mempool.h b/libraries/eina/src/include/eina_mempool.h deleted file mode 100644 index 796bc9e..0000000 --- a/libraries/eina/src/include/eina_mempool.h +++ /dev/null @@ -1,123 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MEMPOOL_H_ -#define EINA_MEMPOOL_H_ - -#include "eina_types.h" -#include "eina_error.h" -#include "eina_module.h" - - -/** - * @addtogroup Eina_Memory_Pool_Group Memory Pool - * - * @brief These functions provide memory pool management. - * - * Several mempool are available: - * - * @li @c buddy: It uses the - * "buddy - * allocator" algorithm but the Eina implementation differs in the - * sense that the chunk information is not stored on the chunk itself, - * but on another memory area. This is useful for cases where the - * memory to manage might be slower to access, or limited (like video - * memory). - * @li @c chained_pool: It is the default one. It allocates a big - * chunk of memory with malloc() and split the result in chunks of the - * requested size that are pushed inside a stack. When requested, it - * takes this pointer from the stack to give them to whoever wants - * them. - * @li @c ememoa_fixed and @c ememoa_unknown: experimental allocators - * which could be useful when a fixed amount of memory is needed. - * @li @c fixed_bitmap: It allocates with malloc) 32* the requested - * size and push the pool pointer in an rbtree. To find empty space in - * a pool, it will just search for the first bit set in an int (32 - * bits). Then, when a pointer is freed, it will do a search inside - * the rbtree. - * @li @c pass_through: it just call malloc() and free(). It may be - * faster on some computers than using our own allocators (like having - * a huge L2 cache, over 4MB). - * @li @c one_big: It call just one time malloc for the requested number - * of items. Useful when you know in advance how many object of some - * type will live during the life of the mempool. - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Memory_Pool_Group Memory Pool - * - * @{ - */ - -/** - * @typedef Eina_Mempool - * Mempool type. - */ -typedef struct _Eina_Mempool Eina_Mempool; - -/** - * @typedef Eina_Mempool_Backend - * Mempool backend type. - */ -typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend; - - -/** - * @typedef Eina_Mempool_Repack_Cb - * Type for a callback who need to unreference an old object from a mempool - * and reference the new one instead. Memcpy is taken care by the mempool. - */ -typedef void (*Eina_Mempool_Repack_Cb)(void *dst, void *src, void *data); - -EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE; - -EAPI Eina_Mempool *eina_mempool_add(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); -EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1); - -static inline void *eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline void *eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1); - -EAPI void eina_mempool_repack(Eina_Mempool *mp, - Eina_Mempool_Repack_Cb cb, - void *data) EINA_ARG_NONNULL(1, 2); -EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1); -EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1); - -EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1); -EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1); - -EAPI unsigned int eina_mempool_alignof(unsigned int size); - -#include "eina_inline_mempool.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_MEMPOOL_H_ */ diff --git a/libraries/eina/src/include/eina_mmap.h b/libraries/eina/src/include/eina_mmap.h deleted file mode 100644 index d7e3819..0000000 --- a/libraries/eina/src/include/eina_mmap.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef EINA_MMAP_H_ -#define EINA_MMAP_H_ - -/** - * @addtogroup Eina_Mmap_Group Mmap Group - * - * @brief These functions provide helpers for safe mmap handling - * - * @{ - * - * @since 1.1.0 - */ - -/** - * @brief Enable or disable safe mmaped IO handling - * - * @param enabled The enabled state (to enable, pass EINA_TRUE) - * - * This enables (if possible on your platform) a signal handler for - * SIGBUS, that replaces the "bad page" with a pzge of 0's (from /dev/zero) - * if a SIGBUS occurs. This allows for safe mmap() of files that may truncate - * or from files on devices with IO errors. Normally these cases will result - * in a SIGBUS being delivered (and termination of yyour process), but - * when "mmap safety" is enabled, this will not occur. Instead a page of - * bytes of the value 0 will replace the "bad page", allowing the process - * to continue and allow its own parsing error detection to safely abort - * the operation without the process falling apart. - * - * If you disable mmap safety, the SIGBUS handler will be restored to its - * default handler. Note that eina_file_map_all() and eina_file_map_new() - * will automatically enable mmap safety as they provide an mmaped file IO - * layer, and rely on mmap to not fail for any part of the file. - * - * If you set up your own SIGBUS handler, then this will effectively disable - * the safe mmap handling and make you liable to crashes on IO to or from - * such "damaged files" that would take down your process. - * - * @since 1.1.0 - */ -EAPI Eina_Bool -eina_mmap_safety_enabled_set(Eina_Bool enabled); - -/** - * @brief Get the enabled state of mmap safety. - * - * @return The safety state (EINA_TRUE if enabled) - * - * This returns the mmap safety state set by eina_mmap_safety_enabled_set(). - * See eina_mmap_safety_enabled_set() for more information. - * - * @since 1.1.0 - */ -EAPI Eina_Bool -eina_mmap_safety_enabled_get(void); - -/** - * @} - */ -#endif diff --git a/libraries/eina/src/include/eina_model.h b/libraries/eina/src/include/eina_model.h deleted file mode 100644 index 0a1566e..0000000 --- a/libraries/eina/src/include/eina_model.h +++ /dev/null @@ -1,3105 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2012 ProFUSION embedded systems - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MODEL_H_ -#define EINA_MODEL_H_ - -#include "eina_types.h" -#include "eina_value.h" -#include "eina_inlist.h" -#include - -/** - * @page eina_model_01_c Eina_Model inheritance and function overriding - * @include eina_model_01.c - */ - -/** - * @page eina_model_04_c Eina_Model inheritance, interfaces, and function overriding - * @include eina_model_04_main.c - * @include eina_model_04_animal.c - * @include eina_model_04_human.c - * @include eina_model_04_parrot.c - * @include eina_model_04_child.c - * @include eina_model_04_main.c - * @include eina_model_04_whistler.c - * @include eina_model_04_animal.h - * @include eina_model_04_human.h - * @include eina_model_04_whistler.h - * @include eina_model_04_child.h - * @include eina_model_04_parrot.h - */ - -/** - * @page eina_model_02_example_page Creating a simple model - * @dontinclude eina_model_02.c - * - * This example shows the creation of a model with five properties, named: - * 'a', 'b', 'c', 'd' and 'e' with values 0, 1, 2, 3 and 4 - * respectively. In addition to the 5 properties our model also add 5 children, - * and to each child we give a property named 'x' with a value of 1, 2, 3, 4 and - * 5. - * - * In other words this piece of code shows how to use eina_model to store a list - * of elements, given that the list itself has some properties. - * - * Now let's walk through the code and examine the interesting bits. - * - * This is some pretty standard initialization code. - * @until eina_init - * - * We now create our eina_model, the important detail here is the type of the - * model being created, for this example we use the generic type provided by - * eina: - * @until model_new - * - * Once our model has been created we can add callbacks to be notified of events - * that happen to our model, for this example we are just going to add a - * callback for the "delete" event. To get a list of events a given eina model - * can emit see @ref eina_model_event_names_list_get(). - * @until callback_add - * - * Once we have a model, we need to populate it with information. There are two - * types of information we can store on an eina model: properties and eina - * models. We are going to start by looking at properties. - * - * Properties are, simply put, named values. They have a char* identifier and an - * Eina_Value value. This means you can store in a property almost any type of - * data. For this example we are going to add some very simple numeric - * properties which will have single letter identifiers. - * @until } - * @until } - * - * Despite being able to store almost any value properties the least flexible - * information unit we can put in an eina model. We can add eina models to our - * eina model, this allows us to represt complex information hierarchies. This - * example adds 5 models(with no children of their own) to our parent model @c - * m. - * @until } - * The code here should be pretty easy to understand, we create a model, much - * like we did before, and we then add a property to our model, again a task we - * have already done. - * - * The important issue to note here is that we could have given each of our @c c - * child models as complex an structure as we needed, they could each be a list - * or a tree on their own right. - * - * Now that we have a populated model we print a string representation of - * it(without forgetting to free the string): - * @until free - * - * And since we are done using our model we release our reference to it(and - * since no else holds references to it, it will be freed): - * @until } - * - * Note that we don't need to iterate over the children of @c m unrefing it, - * this is because we don't hold references to it, we freed our references right - * after we added them to their parent model, so when the parent model dies(and - * releases the references to it's children) they will be freed. - * - * The only thing we are going to look at is the callback we registered for - * whenever a model is deleted, since our models don't do anything fancy we are - * just going to print the memory address of the model being freed. - * @until } - * - * Note that this means the memory address is still valid, our callback is - * called just before the memory is freed so we could still access its - * information here. - * - * The full code can be seen in @ref eina_model_02_c - */ - -/** - * @page eina_model_02_c eina_model_02.c - * @include eina_model_02.c - * @example eina_model_02.c - */ - -/** - * @page eina_model_03_example_page Using Eina_Model and inheritance - * @dontinclude eina_model_03.c - * - * This example will use two custom defined eina model types: @c PERSON_TYPE to - * represent a person and @c ADDRESS_BOOK_TYPE to represent the an address book. - * Both our types inherit from EINA_MODEL_TYPE_STRUCT, and, therefore, - * store it's data on a struct. Our address book will be very simple it will - * only contain one property, the name of the file where we store our address - * book. The person type will contain two fields a name and en email. Let's look - * at the code. - * - * We'll start with declaring the variables and functions we'll need to define - * our custom type. This will all be explained when the variables get used. - * @until address_book_init - * - * We then jump into our @c main function, declare a couple of variables and - * initialize eina: - * @until eina_init - * - * After eina is initialized we'll @c address_book_init() which will initialize - * both our @c PERSON_TYPE and our @c ADDRESS_BOOK_TYPE. Details of this will be - * shown latter on: - * @until address_book_init - * - * Now that everything is correctly initialized we can create the model that - * will represent our address book's - * @until eina_model_new - * - * Before we can load data into our model we need to tell it where to load from, - * we do this by setting it's filename property: - * @until value_flush - * - * We then load data into our model and display it as a string: - * @until free - * - * While @c eina_model_to_string allows you to see the contents of the model, - * it's display format is not user friendly, it's best used for debugging. So - * let's now print our model in a user friendly way. - * - * First we see how many people are in our address book and print that: - * @until printf - * - * And now we iterate over every child of our address book model, which - * represents a person: - * @until person - * - * But again simply calling @c eina_model_to_string would result in not very - * user friendly output, so we'll need to get the properties of the person(name - * and email) and print them with some formatting: - * @until printf - * - * We then free the resources we allocated to print this person: - * @until } - * - * And that's it for our main function, now just freeing our resources: - * @until } - * - * This however obviously doesn't conclude our example we need to examine how - * the the loading of data works to really understand what is happening in the - * @c main function. - * - * Let's start with the constructors(and the variables they use). Both our - * constructors do two very important tasks: - * @li Calls our parent's constructor, and - * @li Sets the description of the struct on our model - * - * For these constructors that's all we need to do since most of our - * functionality is provided by @c EINA_MODEL_TYPE_STRUCT. - * @until } - * @until } - * - * And now we have our load function, it opens the file from which we'll - * read the address book: - * @until EINA_SAFETY_ON_NULL_RETURN_VAL - * - * Once the file has been opened we read from it line by line and for each - * non-blank line we get a name and an email: - * @until email - * @until email - * - * Once we have the name and email we create our person model, set it's - * properties and make our person a child of the address book: - * @until } - * - * And now that we're done reading the file we close it: - * @until } - * - * This next function is perphaps the most interesting one of our example, it's - * the one that creates the definition of our derived types. - * - * First thing we'll do is the description of the members of our person type. - * @until person_members[1].type - * Now the description of the struct itself(which uses the members): - * @until } - * And finally we define the person type itself: - * @until person_type.constructor - * - * With the person now described we'll do the same process for our address book - * type: - * @until address_book_type.load - * - * So far everything we created has been in the scope of our function to make - * this available outside(such as in the @c main function where we use @c - * ADDRESS_BOOK_TYPE and on @c _address_book_load function where we use @c - * PERSON_TYPE) we need to assign our descriptions and type to global variables: - * @until } - * - * This concludes this example. A good exercise for the reader is to extend this - * example to have the model save the addres book, for example once it's - * unloaded, this can be done by overriding the .unload property of @c - * ADDRESS_BOOK_TYPE. - * - * For the full code see: @ref eina_model_03_c - */ - -/** - * @page eina_model_03_c eina_model_03.c - * @include eina_model_03.c - * @example eina_model_03.c - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @since 1.2 - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Model_Group Data Model API - * - * Abstracts data access to hierarchical data in an efficient way, - * extensible to different backing stores such as database or remote - * access. - * - * It is heavily based on #Eina_Value, as properties are exchanged - * using this data type as interface, although internally models may - * store them as they want. See @ref Eina_Value_Group. - * - * Although extensible and easy to optimize, a simple generic type is - * provided as #EINA_MODEL_TYPE_GENERIC. It is recommended that people - * use it during development, get the logic right and just then - * optimize what is needed (properties or children management). - * - * Not as generic as #EINA_MODEL_TYPE_GENERIC, but way more efficient - * is #EINA_MODEL_TYPE_STRUCT that instead of a hash of properties of - * any type, it uses a struct to map properties. Its properties are - * fixed set of names and they have fixed type, as defined by the - * #Eina_Value_Struct_Desc description used internally. - * - * Examples: - * @li @ref eina_model_01_c inheritance example, uses #EINA_MODEL_TYPE_GENERIC - * @li @ref eina_model_02_example_page contains an easy to follow - * example that demonstrates several of the important features of - * eina_model, uses #EINA_MODEL_TYPE_GENERIC. - * @li @ref eina_model_03_example_page walk-through example on how to - * inherit types, a suggestion of eina_model_load() usage and uses - * #EINA_MODEL_TYPE_STRUCT. - * @li @ref eina_model_04_c Advanced inheritance, interfaces and interface - * function overloading example. - * - * @{ - */ - -/** - * @var EINA_ERROR_MODEL_FAILED - * Defined when model-specific errors happens. - */ -EAPI extern Eina_Error EINA_ERROR_MODEL_FAILED; - -/** - * @var EINA_ERROR_MODEL_METHOD_MISSING - * Defined when model-specific errors happens. - */ -EAPI extern Eina_Error EINA_ERROR_MODEL_METHOD_MISSING; - -/** - * @typedef Eina_Model - * Data Model Object. - * - * This is an opaque handle that is created with eina_model_new() and - * released with eina_model_unref(). - * - * It contains properties, children and may emit events. See - * respectively: - * @li eina_model_property_get() and eina_model_property_set() - * @li eina_model_child_get() and eina_model_child_set() - * @li eina_model_event_names_list_get(), eina_model_event_callback_add() and eina_model_event_callback_del() - * - * @see eina_model_new() - * @see eina_model_ref() and eina_model_xref() - * @see eina_model_unref(), eina_model_xunref() and eina_model_del() - * @see eina_model_type_get() and eina_model_interface_get() - * @since 1.2 - */ -typedef struct _Eina_Model Eina_Model; - -/** - * @typedef Eina_Model_Type - * Data Model Type. - * - * @see #_Eina_Model_Type explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_Type Eina_Model_Type; - -/** - * @typedef Eina_Model_Interface - * Data Model Interface. - * - * @see #_Eina_Model_Interface explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_Interface Eina_Model_Interface; - -/** - * @typedef Eina_Model_Event_Description - * Data Model Event Description. - * - * This is used to declare events supported by types and interfaces - * and also to provide introspection to receivers of signals so they - * can know which data they are receiving as @c event_info. - * - * @see EINA_MODEL_EVENT_DESCRIPTION() - * @see #EINA_MODEL_EVENT_DESCRIPTION_SENTINEL - * @see #_Eina_Model_Event_Description explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_Event_Description Eina_Model_Event_Description; - -/** - * @brief Creates a new model of type @a Type. - * @param type The type of the model to create. - * @return If successfull pointer to model, NULL otherwise. - * - * @see _Eina_Model_Type - * @see eina_model_del() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_new(const Eina_Model_Type *type); -/** - * @brief Frees the memory associated with @a model - * @param model The model instance. - * - * @see eina_model_new() - * @since 1.2 - */ -EAPI void eina_model_del(Eina_Model *model) EINA_ARG_NONNULL(1); - -/** - * @brief Returns the type of @a model. - * @param model The model instance. - * @return The type of @a model. - * - * @see eina_model_new() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI const Eina_Model_Type *eina_model_type_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Returns the interface named @a name of @a model. - * @param model The model instance. - * @param name Name of interface to get. - * @return If successfull requested interface, NULL otherwise. - * - * The name of every interface of @a model will be compared to @a name, the - * first one to match will be returned. - * - * @see eina_model_new() - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI const Eina_Model_Interface *eina_model_interface_get(const Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Increases the refcount of @a model. - * @param model The model to increase reference. - * @return The @a model with reference increased. - * @return If successfull pointer to model, NULL otherwise. - * - * @see eina_model_new() - * @see eina_model_unref() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_ref(Eina_Model *model) EINA_ARG_NONNULL(1); - -/** - * @brief Increases the refcount of @a model, informs reference identifier. - * @param model The model to increase reference. - * @param id An identifier to mark this reference. - * @param label An optional label to help debug, may be @c NULL. - * @return The @a model with reference increased. - * - * This extended version of reference explicitly marks the origin of - * the reference and eina_model_xunref() should be used to check and - * remove it. - * - * Usually the @a id is another object, like a parent object, or some - * class/structure/file/function that is holding the reference for - * some reason. - * - * Its purpose is to help debuging if Eina was compiled with model - * usage debug enabled and environment variable @c EINA_MODEL_DEBUG=1 - * is set. - * - * It is recommended to use eina_model_xref() and eina_model_xunref() - * pair whenever you want to be sure you released your - * references. Both at your own type, or using applications. As an - * example #EINA_MODEL_INTERFACE_CHILDREN_INARRAY will use this to - * make sure it deleted every managed children. - * - * In order to debug leaks, consider using eina_model_xrefs_get() or - * eina_models_usage_dump() for a global picture. However, some - * references are not tracked, namely: - * - * @li eina_model_new() - * @li eina_model_child_get() - * @li eina_model_child_iterator_get() - * @li eina_model_child_reversed_iterator_get() - * @li eina_model_child_sorted_iterator_get() - * @li eina_model_child_filtered_iterator_get() - * @li eina_model_child_slice_iterator_get() - * @li eina_model_child_slice_reversed_iterator_get() - * @li eina_model_child_slice_sorted_iterator_get() - * @li eina_model_child_slice_filtered_iterator_get() - * - * @note this function is slower than eina_model_ref() if - * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". Otherwise it - * should have the same performance cost. - * - * @see eina_model_ref() - * @see eina_model_xunref() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_xref(Eina_Model *model, - const void *id, - const char *label) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Decreases the refcount of @a model. - * @param model The model to decrease reference. - * @return If successfull pointer to model, NULL otherwise. - * - * After this function returns, consider @a model pointer invalid. - * - * @see eina_model_ref() - * @see eina_model_del() - * @since 1.2 - */ -EAPI void eina_model_unref(Eina_Model *model) EINA_ARG_NONNULL(1); - -/** - * @brief Decreases the refcount of @a model, informs reference identifier. - * @param model The model to decrease reference. - * @param id An identifier to mark this reference. - * @return If successfull pointer to model, NULL otherwise. - * - * This function will match eina_model_xref() and the @a id must match - * a previously call, otherwise it will produce an error if @c - * EINA_MODEL_DEBUG is set to "1" or "backtrace", and the reference is - * not decreased! - * - * After this function returns, consider @a model pointer invalid. - * - * @note this function is slower than eina_model_unref() if - * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". Otherwise it - * should have the same performance cost. - * - * @see eina_model_xref() - * @since 1.2 - */ -EAPI void eina_model_xunref(Eina_Model *model, - const void *id) EINA_ARG_NONNULL(1, 2); - - - -/** - * @defgroup Eina_Model_Event_Group Data Model Events - * Events and their usage with models. - * - * Events are specified by each type and interface level using - * #Eina_Model_Event_Description. One can know all events supported by - * a model with eina_model_event_names_list_get() and then - * eina_model_event_description_get() to retrieve details. - * - * By default the following events are supported in every object: - * @li deleted: last reference was released or eina_model_del() was called. - * @li freed: memory was destroyed, destructors were called. - * @li property,set: eina_model_property_set() was done. - * @li property,deleted: eina_model_property_del() was done. - * @li children,changed: children was changed somehow (added, modified, deleted) - * @li child,inserted: new child was added (eina_model_child_append() or eina_model_child_insert_at()) - * @li child,set: child was replaced (eina_model_child_set()) - * @li child,deleted: eina_model_child_del() was done. - * @li loaded: eina_model_load() was done. - * @li unloaded: eina_model_unload() was done. - * - * Mix-in interfaces may emit these: - * @li properties,loaded - * @li properties,unloaded - * @li children,loaded - * @li children,unloaded - * - * One can be notified of events with eina_model_event_callback_add(). - * - * Types emit these events with eina_model_event_callback_call(), - * these are handled asynchronously unless event is frozen with - * eina_model_event_callback_freeze() is blocking it. In this case the - * events are ignored. Usually this is used in some cases that want to - * avoid storm of events in batch operations. - * - * @{ - */ - -/** - * @typedef Eina_Model_Event_Cb - * Notifies of events in this model. - * - * @since 1.2 - */ -typedef void (*Eina_Model_Event_Cb)(void *data, Eina_Model *model, const Eina_Model_Event_Description *desc, void *event_info); - -/** - * @brief Add a callback to be called when @a event_name is emited. - * @param model The model instance. - * @param event_name The name of event for which @a cb will be called. - * @param cb The function to be called. - * @param data Data @a cb will be called with. May be NULL. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_event_callback_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_event_callback_add(Eina_Model *model, - const char *event_name, - Eina_Model_Event_Cb cb, - const void *data) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Remove a callback that was to be called when @a event_name was emited. - * @param model The model instance. - * @param event_name The name of event for which to delete callback. - * @param cb The function given to eina_model_event_callback_add(). - * @param data Data given to eina_model_event_callback_add(). A NULL value means - * every @a data will not be compared. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_event_callback_add() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_event_callback_del(Eina_Model *model, - const char *event_name, - Eina_Model_Event_Cb cb, - const void *data) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Returns a description of the event named @c event_name - * @param model The model instance. - * @param event_name Name of event whose description is wanted. - * @return Description of event. - * - * @see Eina_Model_Event_Description - * @since 1.2 - */ -EAPI const Eina_Model_Event_Description *eina_model_event_description_get(const Eina_Model *model, - const char *event_name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Returns list of events this model may emit. - * @param model The model whose events are to be listed. - * @return An Eina_List of stringshares with the name of every event. Free the - * list with eina_model_event_names_list_free(). - * - * @since 1.2 - */ -EAPI Eina_List *eina_model_event_names_list_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -/** - * @brief Frees the list of event's names gotten from - * eina_model_event_names_list_get(). - * @param list The list to free. - * - * @see eina_model_event_names_list_get() - * @since 1.2 - */ -EAPI void eina_model_event_names_list_free(Eina_List *list); - -/** - * @brief Calls every callback associated to @a name on model @a model with @a - * event_info. - * @param model The model instance. - * @param name The event whose callbacks will be called. - * @param event_info The data given to the callback as event_info. May be NULL. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_event_callback_add() - * @see eina_model_event_callback_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_event_callback_call(Eina_Model *model, - const char *name, - const void *event_info) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Makes @a model not call the callbacks associated with @a name. - * @param model The model instance. - * @param name The event whose callbacks are to be frozen. - * @return Count of freezes called on this event. - * - * @see eina_model_event_callback_call() - * @see eina_model_event_callback_thaw() - * @since 1.2 - */ -EAPI int eina_model_event_callback_freeze(Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2); -/** - * @brief Makes @a model able to call the callbacks associated with @a name. - * @param model The model instance. - * @param name The event whose callbacks are to be frozen. - * @return Count of freezes still valid in this event. - * - * @warning Behavior is undefined if called on a @a model, @a name not frozen. - * - * @see eina_model_event_callback_call() - * @see eina_model_event_callback_freeze() - * @since 1.2 - */ -EAPI int eina_model_event_callback_thaw(Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2); - -/** - * @} - */ - - -/** - * @brief Makes a shallow copy of @a model. - * @param model The model instance. - * @return Copied model. - * - * The returned model will have a copy of the properties of @a model and a - * reference to the children of @a model. - * - * @see eina_model_deep_copy() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_copy(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC; -/** - * @brief Makes a deep(complete) copy of @a model. - * @param model The model instance. - * @return Copied model. - * - * The returned model will have a copy of the properties of @a model, its - * children will be created by making a deep copy of the children of @a model. - * - * @see eina_model_copy() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_deep_copy(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - -/** - * @brief Compares two models. - * @param a The first model to compare. - * @param b The second model to compare. - * @return Greater than zero if @a a > @a b, zero if @a a == @a b and less than - * zero if @a a < @a b - * - * The default comparison checks that the properties of @a a and @a b all have - * the same name and value, and then recursively compares all children. - * - * A model with less properties or children is considered smaller than one with - * more properties. - * - * @since 1.2 - */ -EAPI int eina_model_compare(const Eina_Model *a, const Eina_Model *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2); - -/** - * @brief Loads the @a model's data. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * By convention this means loading data from an external source and populating - * the models properties and children with it. For example in the case of file - * system backed model, this means opening the relevant files and reading the - * data from them(creating the properties and children from it). - * @warning This convention should be followed, but no guarantees of behaviour - * by user defined types can be given. - * - * @note The types provided by Eina_Model don't implement this method. - * @note Calling this function on a model that doesn't implement it returns @c - * EINA_TRUE without any effect on @a model. - * - * @see eina_model_unload() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_load(Eina_Model *model) EINA_ARG_NONNULL(1); -/** - * @brief Unloads the @a model's data. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * By convention this means releasing data gotten from an external source. For - * example of a database backed model this might mean releasing the iterator for - * the currently loaded data or deleting a temporary table. - * @warning This convention should be followed, but no guarantees of behaviour - * by user defined types can be given. - * - * @note The types provided by Eina_Model don't implement this method. - * @note Calling this function on a model that doesn't implement it returns @c - * EINA_TRUE without any effect on @a model. - * - * @see eina_model_load() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_unload(Eina_Model *model) EINA_ARG_NONNULL(1); - - -/** - * @defgroup Eina_Model_Properties_Group Data Model Properties - * Properties and their usage with models. - * - * Properties are attributes of model. They have a name and contain a - * data value (@ref Eina_Value_Group). - * - * The actual values and their types, if it is possible to read and - * write them and if new properties can be created or deleted it is up - * to the type. - * - * @{ - */ -/** - * @brief Gets the value of @a model's property named @a name. - * @param[in] model The model from which to get the property. - * @param[in] name The name of the property whose value is wanted. - * @param[out] value A pointer to an Eina_Value to receive the property's value. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @return EINA_TRUE if @a model has a property named @a name, EINA_FALSE - * otherwise. - * - * @see eina_model_property_set() - * @see eina_model_property_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_property_get(const Eina_Model *model, - const char *name, - Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Sets the value of @a model's property named @a name to @a value. - * @param model The model in which to set the property. - * @param name The name of the property whose value is to set. - * @param value A pointer to a const Eina_Value to containing the property's - * value. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_property_get() - * @see eina_model_property_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_property_set(Eina_Model *model, - const char *name, - const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Deletes @a model's property named @a name. - * @param model The model from which to delete the property. - * @param name The name of the property to delete. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_property_set() - * @see eina_model_property_get() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_property_del(Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Gets a list of the names of every property of @a model. - * @param model The model instance. - * @return #Eina_List of names. - * - * @note The returned list should be freed with @c - * eina_model_properties_names_list_free(). - * - * @see eina_model_properties_names_list_free() - * @see eina_model_property_get() - * @since 1.2 - */ -EAPI Eina_List *eina_model_properties_names_list_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -/** - * @brief Frees a list of names of properties gotten with @c - * eina_model_properties_names_list_get(). - * @param list The list to free. - * - * @warning Behavior is undefined if called on a list not gotten from @c - * eina_model_properties_names_list_get(). - * - * @see eina_model_properties_names_list_get() - * @see eina_model_property_get() - * @since 1.2 - */ -EAPI void eina_model_properties_names_list_free(Eina_List *list); - -/** - * @} - */ - -/** - * @defgroup Eina_Model_Children_Group Data Model Children - * Children and their usage with models. - * - * Children are other model instances that are kept sequentially in - * the model. They are accessed by their integer index within the - * model. Their index may change if child are inserted or deleted - * before them, as in an array. - * - * @{ - */ - -/** - * @brief Returns the number of child models in @a model. - * @param model The model instance. - * @return Number of children in @a model. - * - * @see eina_model_child_append() - * @see eina_model_child_get() - * @see eina_model_child_del() - * @since 1.2 - */ -EAPI int eina_model_child_count(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the child at a given position from a model. - * @param model the model instance. - * @param position index of child to get. - * @return child instance with reference @b increased, or @c NULL on error. - * - * The given @a position must be valid, otherwise it may fail and - * return @c NULL, one should check for a valid position with - * eina_model_child_count(). - * - * @warning The returned model has its reference increased, you must release it - * with eina_model_unref(). This convention is imposed to avoid the - * object being removed before the caller function has time to use it. - */ -EAPI Eina_Model *eina_model_child_get(const Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Set the child at a given position from a model. - * @param model the model instance. - * @param position index of child to set. - * @param child the child to use at given position. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * The given @a position must be valid, otherwise it may fail and - * return #EINA_FALSE, one should check for a valid position with - * eina_model_child_count(). - * - * The existing child is replaced. Its reference will be decreased - * automatically. To insert a new item instead of replacing, use - * eina_model_child_insert_at() or eina_model_child_append(). - * - * The given model will be adopted by @a model, that is, the @a child - * will have its reference increased if this call succeeds. - * - * @see eina_model_child_append() - * @see eina_model_child_insert_at() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_child_set(Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Deletes the child model in @a position-th of @a model. - * @param model The model instance. - * @param position The position of the child to be deleted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning This decrements the reference count of the child being deleted, - * which may, or not, cause it to be deconstructed and freed. - * - * @see eina_model_child_append() - * @see eina_model_child_get() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_child_del(Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1); - -/** - * @brief Insert @a child in the @a position-th of the list of children of @a - * model. - * @param model The model instance. - * @param position Position in which to insert child. - * @param child The child to be inserted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning This increments the reference count of the child being inserted, if - * it will no longer be used by the inserting code it should call - * eina_model_unref() on it. - * - * @see eina_model_child_append() - * @see eina_model_child_set() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_child_insert_at(Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Appends @a child in @a model. - * @param model The model instance. - * @param child The child to be appended. - * @return The position of the added child, or -1 on failure. - * - * @warning This increments the reference count of the child being inserted, if - * it will no longer be used by the inserting code it should call - * eina_model_unref() on it. - * - * @see eina_model_child_insert_at() - * @see eina_model_child_set() - * @since 1.2 - */ -EAPI int eina_model_child_append(Eina_Model *model, - Eina_Model *child) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Returns the position of @a other amongst the children of @a model. - * @param model The parent model whose children will be searched. - * @param start_position The first children to be compared with @a other. - * @param other The model whose position is desired. - * @return The position of the searched for child, or -1 if not found. - * - * @since 1.2 - */ -EAPI int eina_model_child_find(const Eina_Model *model, - unsigned int start_position, - const Eina_Model *other) EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returns the position of a child of @a model that mathes the criteria. - * @param model The model whose children will be searched. - * @param start_position The position of the first child to be checked. - * @param match The function used to check if a child matches the criteria. - * @param data Data given the to the @a match function. - * @return The position of the first child to match the criteria or -1 if no - * child matches it. - * - * Returns the position of the first(from @a start_position) child of @a model - * to which @a match returns EINA_TRUE. - * - * @since 1.2 - */ -EAPI int eina_model_child_criteria_match(const Eina_Model *model, - unsigned int start_position, - Eina_Each_Cb match, - const void *data) EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Sorts the children of @a model according to @a compare. - * @param model The model instance. - * @param compare The function to be used in the comparison. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * The @a compare function receives to const pointer to eina models(const - * *Eina_Model). - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_child_sort(Eina_Model *model, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2); - -/** - * @} - */ - -/** - * @defgroup Eina_Model_Iterators_Group Data Model Iterators - * Iterators and their usage with models. - * - * One of the most common tasks of models is to iterate over their - * children, either forwards or backwards, filtering by some criteria - * or a different ordering function. - * - * @{ - */ - -/** - * @brief create an iterator that outputs a child model on each iteration. - * @param model the model instance. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @code - * Eina_Model *child; - * Eina_Iterator *it = eina_model_child_iterator_get(model); - * EINA_ITERATOR_FOREACH(it, child) - * { - * use_child(child); - * eina_model_unref(child); - * } - * eina_iterator_free(it); - * @endcode - * This code shows how to use iterators to do something (in this example call - * use_child()) on every child element. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_iterator_get(Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -/** - * @brief Gets an iterator to a slice of @a model's children. - * @param model The model whose children to iterate over. - * @param start The first child included in the iterator. - * @param count The number of children included in the iterator. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_iterator_get() - * @see eina_model_child_slice_reversed_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_slice_iterator_get(Eina_Model *model, - unsigned int start, - unsigned int count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief create an iterator that outputs a child model in reversed order. - * @param model the model instance. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * Each iteration output a child model with reference @b increased! - * You must call eina_model_unref() after you're done with it. - * - * The order is reversed, that is, the last element is outputted first. - * - * @code - * Eina_Model *child; - * Eina_Iterator *it = eina_model_child_reversed_iterator_get(model); - * EINA_ITERATOR_FOREACH(it, child) - * { - * use_child(child); - * eina_model_unref(child); - * } - * eina_iterator_free(it); - * @endcode - * This code shows how to use iterators to do something (in this example call - * use_child()) on every child element starting from last to first. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_reversed_iterator_get(Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Gets a reversed iterator to a slice of @a model's children. - * @param model The model whose children to iterate over. - * @param start The first child included in the iterator. - * @param count The number of children included in the iterator. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_slice_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_slice_reversed_iterator_get(Eina_Model *model, - unsigned int start, - unsigned int count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief create an iterator that outputs a child model using sort criteria. - * @param model the model instance. - * @param compare compare function to use as sort criteria. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * Each iteration output a child model with reference @b increased! - * You must call eina_model_unref() after you're done with it. - * - * The sort will not affect the main object @a model, it's just a view - * of it. - * - * @code - * Eina_Model *child; - * Eina_Iterator *it = eina_model_child_sorted_iterator_get(model, EINA_COMPARE_CB(eina_model_compare)); - * EINA_ITERATOR_FOREACH(it, child) - * { - * use_child(child); - * eina_model_unref(child); - * } - * eina_iterator_free(it); - * @endcode - * This bit of code shows how to use iterators to do something (in this example - * call use_child()) on every child element in the order given by the @a compare - * function. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_sorted_iterator_get(Eina_Model *model, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returns a sorted iterator to a slice of @a model's children. - * @param model The model whose children to iterate over. - * @param start The position(before sorting) of the first child included in - * the iterator. - * @param count The number of children included in the iterator. - * @param compare The function used to sort the children. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning Each iteration(call to eina_iterator_next()) gives a child model - * with reference @b increased! You must call eina_model_unref() after you're - * done with it. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_slice_sorted_iterator_get(Eina_Model *model, - unsigned int start, - unsigned int count, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 4) EINA_WARN_UNUSED_RESULT; - -/** - * @brief create an iterator that indexes of children that matches. - * @param model the model instance. - * @param match function to select children. - * @param data extra context given to @a match function. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * Unlike other iterators, each iteration output an integer index! - * This is useful if you want to highlight the matching model - * somewhere else. - * - * If no child element matches a valid, and empty, iterator will be returned. - * Indexes returned by this iterator are guaranteed to exists. - * - * @code - * unsigned int idx; - * Eina_Iterator *it = eina_model_child_filtered_iterator_get(model, filter, ctx); - * EINA_ITERATOR_FOREACH(it, idx) - * { - * Eina_Model *child = eina_model_child_get(model, idx); - * printf("matches at %u %p\n", idx, child); - * eina_model_unref(child); - * } - * eina_iterator_free(it); - * @endcode - * This bit of code shows how to use iterators to do something (in this example - * print the address) on child elements that match the criteria given of @a match. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_filtered_iterator_get(Eina_Model *model, - Eina_Each_Cb match, - const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returns a filtered slice of the @a model's children. - * @param model The model whose children to iterate over. - * @param start The position of the first child to be tested for inclusion in - * the iterator. - * @param count The number of children to be tested for inclusion in the - * iterator. - * @param match The function used to decide which children will be included in - * the iterator. - * @param data Data passed to the @a match function. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @note Only children for whom @a match returns EINA_TRUE will be included in - * the iterator. - * - * @note Each iteration(call to eina_iterator_next()) gives an integer index! - * - * @warning The iterator may have less than @a count children, but not more. - * - * @see eina_model_child_slice_iterator_get() - * @see eina_model_child_reversed_iterator_get() - * @see eina_model_child_sorted_iterator_get() - * @see eina_model_child_filtered_iterator_get() - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_child_slice_filtered_iterator_get(Eina_Model *model, - unsigned int start, - unsigned int count, - Eina_Each_Cb match, - const void *data) EINA_ARG_NONNULL(1, 4) EINA_WARN_UNUSED_RESULT; - - -/** - * @} - */ - -/** - * @brief Convert model to string. - * @param model the model instance. - * @return Newly allocated memory or @c NULL on failure. - * - * The default format of the ouput is: - * Type_Name({Property_Name: Property_Value, ...}, [Child0, Child1, ...]) - * - * Where: - * @li Type_Name: eina_model_type_name_get(eina_model_type_get(model)) - * @li Properties are sorted alphabetically. - * @li Property_Value is created using eina_value_to_string(). - * @li Children are converted using eina_model_to_string() - * - * @since 1.2 - */ -EAPI char *eina_model_to_string(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - -/** - * @defgroup Eina_Model_Type_Group Data Model Type management - * - * Functions and structures related to implementing new types or - * extending existing ones. - * - * All eina_model_type functions takes an Eina_Model_Type or - * Eina_Model_Interface as parameter and may be used to validate or - * query information about them. - * - * The functions with prefix eina_model_type that matches eina_model - * counterparts, such as eina_model_type_compare() and - * eina_model_compare() are used as "super", that is, calls the @c - * compare() method of the given type (or its parent) instead of the - * most specific type of provided Eina_Model. - * - * Examples: - * @li @ref eina_model_02_example_page contains an easy to follow - * example that demonstrates several of the important features of - * eina_model, uses #EINA_MODEL_TYPE_GENERIC. - * @li @ref eina_model_03_example_page walk-through example on how to - * inherit types, a suggestion of eina_model_load() usage and uses - * #EINA_MODEL_TYPE_STRUCT. - * - * @{ - */ - -/** - * @def EINA_MODEL_TYPE_VERSION - * Current API version, used to validate #_Eina_Model_Type. - */ -#define EINA_MODEL_TYPE_VERSION (1) - -/** - * @struct _Eina_Model_Type - * API to access models. - * - * Each type of the hierarchy and each interface will get its own - * private data of size @c private_size (defined at each subtype or - * interface), this can be retrieved with - * eina_model_type_private_data_get() and - * eina_model_interface_private_data_get(). - * - * Private are created @b automatically and should be setup with @c - * setup and flushed with @c flush. All types (or interfaces) - * functions that exist are called! Don't call your parent's @c setup or - * @c flush! The setup is done from parent to child. Flush is done from - * child to parent. - * - * After memory setup was done, @c constructor of the toplevel type - * defining it is called. If desired it may call parent's constructor - * in whatever order is desired. This may be used to create - * properties, children and may use parent's data if needed. The only - * constructor caled is that of the most specialized type, if interface - * constructors should be called, do them in the desired order from the type - * constructor. - * - * When the model is deleted, explicitly with eina_model_del() or - * implicitly with eina_model_unref() on the last reference, the @c - * destructor is called. It must release references to other - * models. When the last reference is dropped, every @c flush is - * called from child to parent, then memory is freed. The only - * destructor caled is that of the most specialized type, if interface - * destructors should be called, do them in the desired order from the type - * destructor. - * - * - * @note The methods @c setup and @c flush should exist if there is - * private data, otherwise memory may be uninitialized or leaks. - * @note It is recommended that @c constructor and @c destructor exist - * to correctly do their roles and call parents in the correct - * order. Whenever they do not exist, their parent pointer is - * called. - * @note a runtime check will enforce just types with ABI version - * #EINA_MODEL_TYPE_VERSION are used by comparing with the @c version - * member. - * - * @since 1.2 - */ -struct _Eina_Model_Type -{ - unsigned int version; /**< must be #EINA_MODEL_TYPE_VERSION */ - unsigned int private_size; /**< used to allocate type private data */ - unsigned int type_size; /**< used to know sizeof(Eina_Model_Type) or subtypes (which may be bigger, by including Eina_Model_Type as a header */ - const char *name; /**< name for debug and introspection */ - const Eina_Model_Type *parent; /**< parent type, must be EINA_MODEL_TYPE_BASE or a child of */ - const Eina_Model_Interface **interfaces; /**< null terminated array of interfaces */ - const Eina_Model_Event_Description *events; /**< null terminated array of events */ - Eina_Bool (*setup)(Eina_Model *model); /**< setup type private data, do @b not call parent type setup! */ - Eina_Bool (*flush)(Eina_Model *model); /**< flush type private data, do @b not call parent type flush! */ - Eina_Bool (*constructor)(Eina_Model *model); /**< construct type instance, setup was already called. Should call parent's or interfaces' constructor if needed */ - Eina_Bool (*destructor)(Eina_Model *model); /**< destruct type instance, flush will be called after it. Should call parent's or interfaces' destructor if needed. Release reference to other models here. */ - Eina_Bool (*copy)(const Eina_Model *src, Eina_Model *dst); /**< copy type private data, do @b not call parent type copy! */ - Eina_Bool (*deep_copy)(const Eina_Model *src, Eina_Model *dst); /**< deep copy type private data, do @b not call parent type deep copy! */ - Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp); - Eina_Bool (*load)(Eina_Model *model); - Eina_Bool (*unload)(Eina_Model *model); - Eina_Bool (*property_get)(const Eina_Model *model, const char *name, Eina_Value *value); - Eina_Bool (*property_set)(Eina_Model *model, const char *name, const Eina_Value *value); - Eina_Bool (*property_del)(Eina_Model *model, const char *name); - Eina_List *(*properties_names_list_get)(const Eina_Model *model); /**< list of stringshare */ - int (*child_count)(const Eina_Model *model); - Eina_Model *(*child_get)(const Eina_Model *model, unsigned int position); - Eina_Bool (*child_set)(Eina_Model *model, unsigned int position, Eina_Model *child); - Eina_Bool (*child_del)(Eina_Model *model, unsigned int position); - Eina_Bool (*child_insert_at)(Eina_Model *model, unsigned int position, Eina_Model *child); - int (*child_find)(const Eina_Model *model, unsigned int start_position, const Eina_Model *other); - int (*child_criteria_match)(const Eina_Model *model, unsigned int start_position, Eina_Each_Cb match, const void *data); - void (*child_sort)(Eina_Model *model, Eina_Compare_Cb compare); - Eina_Iterator *(*child_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count); - Eina_Iterator *(*child_reversed_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count); - Eina_Iterator *(*child_sorted_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count, Eina_Compare_Cb compare); - Eina_Iterator *(*child_filtered_iterator_get)(Eina_Model *model, unsigned int start, unsigned int count, Eina_Each_Cb match, const void *data); - char *(*to_string)(const Eina_Model *model); /**< used to represent model as string, usually for debug purposes or user convenience */ - void *__extension_ptr0; /**< not to be used */ - void *__extension_ptr1; /**< not to be used */ - void *__extension_ptr2; /**< not to be used */ - void *__extension_ptr3; /**< not to be used */ -}; - -#define EINA_MODEL_TYPE_INIT(name, type, private_type, parent, interfaces, events) \ - {EINA_MODEL_TYPE_VERSION, \ - sizeof(private_type), \ - sizeof(type), \ - name, \ - parent, \ - interfaces, \ - events, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -#define EINA_MODEL_TYPE_INIT_NOPRIVATE(name, type, parent, interfaces, events) \ - {EINA_MODEL_TYPE_VERSION, \ - 0, \ - sizeof(type), \ - name, \ - parent, \ - interfaces, \ - events, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -#define EINA_MODEL_TYPE_INIT_NULL \ - {0, \ - 0, \ - 0, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -/** - * @brief Calls the constructor of @a type for @a model. - * @param type The type whose constructor will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This should be used to call the parent's type constructor, something like: - * @code - * static Eina_Bool my_type_constructor(Eina_Model *m) - * { - * // call parents constructor: - * if (!eina_model_type_constructor(MY_TYPE->parent, m)) - * return EINA_FALSE; - * // do my stuff - * return EINA_TRUE; - * } - * @endcode - * @note You should only do your type's initialization after the parent type has - * done his own(this is as to ensure you can call on your parent's methods). - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_new() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_constructor(const Eina_Model_Type *type, - Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; -/** - * @brief Calls the destructor of @a type for @a model. - * @param type The type whose destructor will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This should be used to call the parent's type destructor, something like: - * @code - * static Eina_Bool my_type_destructor(Eina_Model *m) - * { - * // do my stuff - * // call parents destructor: - * if (!eina_model_type_destructor(MY_TYPE->parent, m)) - * return EINA_FALSE; - * return EINA_TRUE; - * } - * @endcode - * @note It's considered good practice to free your type's resources before - * calling the parent's destructor. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_del() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_destructor(const Eina_Model_Type *type, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the copy method of @a type for @a model. - * @param type The type whose copy method will be called. - * @param src Pointer to the model to be copied. - * @param dst Pointer to where copy will be put. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_copy() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_copy(const Eina_Model_Type *type, - const Eina_Model *src, - Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Calls the deep copy method of @a type for @a model. - * @param type The type whose copy method will be called. - * @param src Pointer to the model to be copied. - * @param dst Pointer to where copy will be put. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_deep_copy() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_deep_copy(const Eina_Model_Type *type, - const Eina_Model *src, - Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Calls the compare method of @a type for @a model. - * @param[in] type The type whose compare method will be called. - * @param[in] a Pointer to the first model to be compared. - * @param[in] b Pointer to the second model to be compared. - * @param[out] cmp The value of the comparison, 1 if @a b is greater than @a a, - * -1 if @a b is smaller than @a a, 0 if @a a and @a b are equal. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_compare() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_compare(const Eina_Model_Type *type, - const Eina_Model *a, - const Eina_Model *b, - int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4); -/** - * @brief Calls the load method of @a type for @a model. - * @param type The type whose load method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_load() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_load(const Eina_Model_Type *type, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the unload method of @a type for @a model. - * @param type The type whose unload method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_unload() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_unload(const Eina_Model_Type *type, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the property get method of @a type for @a model. - * @param[in] type The type whose property get method will be called. - * @param[in] model The model instance. - * @param[in] name Name of property to get. - * @param[out] value Pointer to where value of property will be placed. - * @return EINA_TRUE if able to get property, EINA_FALSE otherwise. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_property_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_property_get(const Eina_Model_Type *type, - const Eina_Model *model, - const char *name, - Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4); -/** - * @brief Calls the property set method of @a type for @a model. - * @param type The type whose property set method will be called. - * @param model The model instance. - * @param name Name of property whose value will be set. - * @param value The value to be set. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_property_set() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_property_set(const Eina_Model_Type *type, - Eina_Model *model, - const char *name, - const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4); -/** - * @brief Calls the property del method of @a type for @a model. - * @param type The type whose property delete method will be called. - * @param model The model instance. - * @param name The name of the property to be deleted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_property_del() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_property_del(const Eina_Model_Type *type, - Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Calls the properties name list method of @a type for @a model. - * @param type The type whose property name list get method will be called. - * @param model The model instance. - * @return #Eina_List of properties' names. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_properties_names_list_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_List *eina_model_type_properties_names_list_get(const Eina_Model_Type *type, - const Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child count method of @a type for @a model. - * @param type The type whose child count method will be called. - * @param model The model instance. - * @return Number of children in @a model. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_count() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI int eina_model_type_child_count(const Eina_Model_Type *type, - const Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child get method of @a type for @a model. - * @param type The type whose child get method will be called. - * @param model The model instance. - * @param position The position of the child to get. - * @return The child model, or NULL on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Model *eina_model_type_child_get(const Eina_Model_Type *type, - const Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child set method of @a type for @a model. - * @param type The type whose child set method will be called. - * @param model The model instance. - * @param position The position of the child to be set. - * @param child Pointer to value(child) to be set. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_set() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_child_set(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Calls the child del method of @a type for @a model. - * @param type The type whose child delete method will be called. - * @param model The model instance. - * @param position Position of child to be deleted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_del() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_child_del(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child insert at method of @a type for @a model. - * @param type The type whose child insert method will be called. - * @param model The model instance. - * @param position Position in which @a child will be inserted. - * @param child The child to be inserted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_insert_at() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_child_insert_at(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Calls the child find method of @a type for @a model. - * @param type The type whose find method will be called. - * @param model The model instance. - * @param start_position The first position to search for. - * @param other The child being searched for. - * @return The index of the searched child, or -1 if not found. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_find() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI int eina_model_type_child_find(const Eina_Model_Type *type, - const Eina_Model *model, - unsigned int start_position, - const Eina_Model *other) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Calls the child criteria match method of @a type for @a model. - * @param type The type whose child criteria match method will be called. - * @param model The model instance. - * @param start_position The first position to be checked. - * @param match The function used to determine if a child matches the criteria. - * @param data Data given to the @a match function. May be NULL. - * @return The position of the first child to match the criteria or -1 if no - * child matches it. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_criteria_match() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI int eina_model_type_child_criteria_match(const Eina_Model_Type *type, - const Eina_Model *model, - unsigned int start_position, - Eina_Each_Cb match, - const void *data) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Calls the child sort method of @a type for @a model. - * @param type The type whose child sort method will be called. - * @param model The model instance. - * @param compare Function used to compare children. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_sort() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI void eina_model_type_child_sort(const Eina_Model_Type *type, - Eina_Model *model, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Calls the child iterator get method of @a type for @a model. - * @param type The type whose child iterator get method will be called. - * @param model The model instance. - * @param start The first child to be a part of the iterator. - * @param count The number of children included in the iterator. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_iterator_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_type_child_iterator_get(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int start, - unsigned int count) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child reversed iterator get method of @a type for @a model. - * @param type The type whose child reversed iterator get method will be called. - * @param model The model instance. - * @param start The first child to be a part of the iterator. - * @param count The number of children included in the iterator. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_reversed_iterator_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_type_child_reversed_iterator_get(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int start, - unsigned int count) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the child sorted iterator get method of @a type for @a model. - * @param type The type whose child sorted iterator get method will be called. - * @param model The model instance. - * @param start The first child to be a part of the iterator. - * @param count The number of children included in the iterator. - * @param compare Function used to compare children. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_sorted_iterator_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_type_child_sorted_iterator_get(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int start, - unsigned int count, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 5); -/** - * @brief Calls the child filtered get method of @a type for @a model. - * @param type The type whose child filtered iterator get method will be called. - * @param model The model instance. - * @param start The first child to be a part of the iterator. - * @param count Number of children to be checked for inclusion in the iterator. - * @param match Function used to check if child will be included in the iterator. - * @param data Data given to the @a match function. May be NULL. - * @return Newly created iterator instance on success or @c NULL on failure. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_child_filtered_iterator_get() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Iterator *eina_model_type_child_filtered_iterator_get(const Eina_Model_Type *type, - Eina_Model *model, - unsigned int start, - unsigned int count, - Eina_Each_Cb match, - const void *data) EINA_ARG_NONNULL(1, 2, 5); -/** - * @brief Calls the to string method of @a type for @a model. - * @param type The type whose to string method will be called. - * @param model The model instance. - * @return String representationof @a model. - * - * @warning If model doesn't inherit from(or is of) @a type does nothing and - * returns EINA_FALSE. - * - * @see eina_model_to_string() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI char *eina_model_type_to_string(const Eina_Model_Type *type, - const Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - - -/** - * @brief Get resolved method from types that extend Eina_Model_Type given @a offset. - * @param model the model to query the method - * @param offset the byte offset in the structure given as type, it - * must be bigger than Eina_Model_Type itself. - * @return Address to resolved method, or @c NULL if method is not implemented. - * - * The use of this function is discouraged, you should use - * eina_model_method_resolve() instead. - * - * When implementing new types that augments the basic methods from - * Eina_Model_Type, the recommended structure layout is as follow: - * @code - * typedef struct _My_Type My_Type; - * struct _My_Type { - * Eina_Model_Type base; - * int (*my_method)(Eina_Model *model); - * }; - * - * int my_type_my_method(Eina_Model *model); - * @endcode - * - * Then the implementation of @c my_type_my_method() needs to get the - * most specific @c my_method that is not @c NULL from type hierarchy, - * also called "resolve the method". - * - * To do this in an efficient way, Eina_Model infrastructure - * pre-resolves all methods and provides this function for efficient - * query. The recommended implementation of my_type_my_method() would - * be: - * @code - * int my_type_my_method(Eina_Model *model) - * { - * int (*meth)(Eina_Model *); - * - * EINA_SAFETY_ON_FALSE_RETURN(eina_model_instance_check(model, MY_TYPE), -1); - * - * meth = eina_model_method_offset_resolve(model, offsetof(My_Type, my_method)); - * EINA_SAFETY_ON_NULL_RETURN(meth, -1); - * return meth(model); - * } - * @endcode - * - * @note offset must be bigger than Eina_Model_Type, otherwise use - * specific functions such as eina_model_property_get(). - * - * @see eina_model_method_resolve - * @see eina_model_type_method_resolve - * @since 1.2 - */ -EAPI const void *eina_model_method_offset_resolve(const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Gets resolved method from @a type of @a model given @a offset. - * @param type The type whose method offset resolve method will be called. - * @param model The model instance. - * @param offset The offset of the wanted method. - * @return Address to resolved method, or @c NULL if method is not implemented. - * - * @see eina_model_method_offset_resolve() - * @since 1.2 - */ -EAPI const void *eina_model_type_method_offset_resolve(const Eina_Model_Type *type, const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -#define eina_model_method_resolve(model, struct_type, method) eina_model_method_offset_resolve((model), offsetof(struct_type, method)) - -#define eina_model_type_method_resolve(type, model, struct_type, method) eina_model_type_method_offset_resolve((type), (model), offsetof(struct_type, method)) - -/** - * @def EINA_MODEL_INTERFACE_VERSION - * Current API version, used to validate #_Eina_Model_Interface. - */ -#define EINA_MODEL_INTERFACE_VERSION (1) - -/** - * @struct _Eina_Model_Interface - * API to access models. - * - * Interfaces are managed by name, then multiple Eina_Model_Interface - * may have the same name meaning it implements that name. - * - * Each interface will get its own private data of size @c - * private_size (defined at each sub interface), this can be retrieved - * with eina_model_interface_private_data_get(). - * - * Private are created @b automatically and should be setup with @c - * setup and flushed with @c flush. All interfaces functions that - * exist are called! Don't call your parent's @c setup or @c flush! - * The setup is done from parent to child. Flush is done from child to - * parent (topological sort is applied to interface graph). - * - * @note The methods @c setup and @c flush should exist if there is - * private data, otherwise memory may be uninitialized or leaks. - * @note It is recommended that @c constructor and @c destructor exist - * to correctly do their roles and call parents in the correct - * order. Whenever they do not exist, their parent pointer is - * called. - * @note Interface's constructor and destructor are only called by - * type counterparts. Unlike setup and flush, they are not - * guaranteed to be called. - * @note use the same name pointer on queries to speed up the lookups! - * @note a runtime check will enforce just types with ABI version - * #EINA_MODEL_INTERFACE_VERSION are used by comparing with the - * @c version member. - * - * @since 1.2 - */ -struct _Eina_Model_Interface -{ - unsigned int version; /**< must be #EINA_MODEL_INTERFACE_VERSION */ - unsigned int private_size; /**< used to allocate interface private data */ - unsigned int interface_size; /**< used to know sizeof(Eina_Model_Interface) or subtypes (which may be bigger, by including Eina_Model_Interface as header */ - const char *name; /**< name for debug and introspection */ - const Eina_Model_Interface **interfaces; /**< null terminated array of parent interfaces */ - const Eina_Model_Event_Description *events; /**< null terminated array of events */ - Eina_Bool (*setup)(Eina_Model *model); /**< setup interface private data, do @b not call parent interface setup! */ - Eina_Bool (*flush)(Eina_Model *model); /**< flush interface private data, do @b not call parent interface flush! */ - Eina_Bool (*constructor)(Eina_Model *model); /**< construct interface instance, setup was already called. Should call parent's constructor if needed */ - Eina_Bool (*destructor)(Eina_Model *model); /**< destruct interface instance, flush will be called after it. Should call parent's destructor if needed. Release reference to other models here. */ - Eina_Bool (*copy)(const Eina_Model *src, Eina_Model *dst); /**< copy interface private data, do @b not call parent interface copy! */ - Eina_Bool (*deep_copy)(const Eina_Model *src, Eina_Model *dst); /**< deep copy interface private data, do @b not call parent interface deep copy! */ - void *__extension_ptr0; /**< not to be used @internal */ - void *__extension_ptr1; /**< not to be used @internal */ - void *__extension_ptr2; /**< not to be used @internal */ - void *__extension_ptr3; /**< not to be used @internal */ -}; - -#define EINA_MODEL_INTERFACE_INIT(name, iface, private_type, parent, events) \ - {EINA_MODEL_INTERFACE_VERSION, \ - sizeof(private_type), \ - sizeof(iface), \ - name, \ - parent, \ - events, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -#define EINA_MODEL_INTERFACE_INIT_NOPRIVATE(name, iface, parent, events) \ - {EINA_MODEL_INTERFACE_VERSION, \ - 0, \ - sizeof(iface), \ - name, \ - parent, \ - events, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -#define EINA_MODEL_INTERFACE_INIT_NULL \ - {0, \ - 0, \ - 0, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL \ - } - -/** - * @brief Calls the constructor of @a iface on @a model. - * @param iface The interface whose constructor will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If @a model doesn't implement @a iface does nothing and returns - * EINA_FALSE. - * - * @see eina_model_new() - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_constructor(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; -/** - * @brief Calls the destructor of @a iface on @a model. - * @param iface The interface whose destructor will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If @a model doesn't implement @a iface does nothing and returns - * EINA_FALSE. - * - * @see eina_model_del() - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_destructor(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Calls the copy method of @a iface on @a model. - * @param iface The interface whose copy method will be called. - * @param src Pointer to the model to be copied. - * @param dst Pointer to where copy will be put. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If @a model doesn't implement @a iface does nothing and returns - * EINA_FALSE. - * - * @see eina_model_copy() - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_copy(const Eina_Model_Interface *iface, - const Eina_Model *src, - Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Calls the deep copy method of @a iface on @a model. - * @param iface The interface whose deep copy method will be called. - * @param src Pointer to the model to be copied. - * @param dst Pointer to where copy will be put. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If @a model doesn't implement @a iface does nothing and returns - * EINA_FALSE. - * - * @see eina_model_deep_copy() - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_deep_copy(const Eina_Model_Interface *iface, - const Eina_Model *src, - Eina_Model *dst) EINA_ARG_NONNULL(1, 2, 3); - -#define eina_model_interface_method_resolve(iface, model, struct_type, method) eina_model_interface_method_offset_resolve((iface), (model), offsetof(struct_type, method)) - -/** - * @brief Gets the @a iface's method for @a model at @a offset. - * @param iface The interface whose method offset resolve method will be called. - * @param model The model instance. - * @param offset The offset of the wanted method. - * @return Address to resolved method, or @c NULL if method is not implemented. - * - * @see eina_model_method_offset_resolve() - * @since 1.2 - */ -EAPI const void *eina_model_interface_method_offset_resolve(const Eina_Model_Interface *iface, const Eina_Model *model, unsigned int offset) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - - -/** - * @struct _Eina_Model_Event_Description - * Data Model Event Description. - * - * @see EINA_MODEL_EVENT_DESCRIPTION() - * @see #EINA_MODEL_EVENT_DESCRIPTION_SENTINEL - * @since 1.2 - */ -struct _Eina_Model_Event_Description -{ - const char *name; /**< name used for lookups */ - const char *type; /**< used for introspection purposes, documents what goes as callback event information (@c event_info) */ - const char *doc; /**< documentation for introspection purposes */ -}; - -/** - * @def EINA_MODEL_EVENT_DESCRIPTION - * - * Helper to define Eina_Model_Event_Description fields. - * - * @since 1.2 - */ -#define EINA_MODEL_EVENT_DESCRIPTION(name, type, doc) {name, type, doc} - -/** - * @def EINA_MODEL_EVENT_DESCRIPTION_SENTINEL - * - * Helper to define Eina_Model_Event_Description fields for sentinel (last - * item). - * - * @since 1.2 - */ -#define EINA_MODEL_EVENT_DESCRIPTION_SENTINEL {NULL, NULL, NULL} - -/** - * @brief Check @a type is valid. - * @param type The type to be checked. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_check(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; -/** - * @brief Gets the name @a type. - * @param type The type whose name is wanted. - * @return Name of @a type. - * - * @since 1.2 - */ -EAPI const char *eina_model_type_name_get(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; -/** - * @brief Gets the parent type of @a type. - * @param type The type whose parent is wanted. - * @return Type of parent. - * - * @since 1.2 - */ -EAPI const Eina_Model_Type *eina_model_type_parent_get(const Eina_Model_Type *type) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Setup the type to be a subclass of another parent type. - * @param type type to be modified - * @param parent type to be used as parent - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Although @a type is modified, the following properties are not - * touched or they are actually used for validation: - * - * @li @c type->version must be #EINA_MODEL_TYPE_VERSION; - * @li @c type->private_size unmodified, should be set to type's size; - * @li @c type->name unmodified, should be set to type's name. - * - * - * All other fields are modified as follow: - * - * @li @c type->type_size initiated to parent->type_size - * @li @c type->interfaces = NULL; - * @li @c type->events = NULL; - * @li @c type->setup = NULL; - * @li @c type->flush = NULL; - * @li @c type->constructor = NULL; - * @li @c type->destructor = NULL; - * @li @c type->copy = NULL; - * @li @c type->deep_copy = NULL; - * @li @c type->compare = NULL; - * @li @c type->load = NULL; - * @li @c type->unload = NULL; - * @li @c type->property_get = NULL; - * @li @c type->property_set = NULL; - * @li @c type->property_del = NULL; - * @li @c type->properties_names_list_get = NULL; - * @li @c type->child_count = NULL; - * @li @c type->child_get = NULL; - * @li @c type->child_set = NULL; - * @li @c type->child_del = NULL; - * @li @c type->child_insert_at = NULL; - * @li @c type->child_find = NULL; - * @li @c type->child_criteria_match = NULL; - * @li @c type->child_sort = NULL; - * @li @c type->child_iterator_get = NULL; - * @li @c type->child_reversed_iterator_get = NULL; - * @li @c type->child_sorted_iterator_get = NULL; - * @li @c type->child_filtered_iterator_get = NULL; - * @li @c type->to_string = NULL; - * - * If you have custom methods, overload them afterwards - * eina_model_type_subclass_setup() returns with #EINA_TRUE. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_subclass_setup(Eina_Model_Type *type, - const Eina_Model_Type *parent) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Checks if @a type is a subclass of(or the same as) @a self_or_parent. - * @param type The type to be checked. - * @param self_or_parent The type being checked for. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_type_subclass_check(const Eina_Model_Type *type, - const Eina_Model_Type *self_or_parent) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - - -/** - * @brief Gets a interface with name @a name from @a type. - * @param type The type instance. - * @param name The name of the desired interface. - * @return The interface implemented by @a type with name @a name, or null if - * this type doesn't implement any interface with name @a name. - * - * @since 1.2 - */ -EAPI const Eina_Model_Interface *eina_model_type_interface_get(const Eina_Model_Type *type, - const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Gets the private date of @a model for type @a type. - * @param model The model instance. - * @param type The type whose private data will be gotten. - * @return Pointer to type's private data. - * - * @since 1.2 - */ -EAPI void *eina_model_type_private_data_get(const Eina_Model *model, - const Eina_Model_Type *type) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE; - -/** - * @brief Checks if @a iface is a valid interface. - * @param iface The interface instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_check(const Eina_Model_Interface *iface) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Gets the private date of @a model for interface @a iface. - * @param model The model instance. - * @param iface The interface whose private data will be gotten. - * @return Pointer to interface's private data. - * - * @since 1.2 - */ -EAPI void *eina_model_interface_private_data_get(const Eina_Model *model, - const Eina_Model_Interface *iface) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE; - -/** - * @def EINA_MODEL_INTERFACE_PROPERTIES_VERSION - * Current API version, used to validate #_Eina_Model_Interface_Properties. - */ -#define EINA_MODEL_INTERFACE_PROPERTIES_VERSION (1) - -/** - * @typedef Eina_Model_Interface_Properties - * Interface to manage model's properties. - * - * This extends #Eina_Model_Interface as expected by interface name - * #EINA_MODEL_INTERFACE_NAME_PROPERTIES. - * - * This interface is meant to help managing properties of a model, it - * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for - * children independently from properties. - * - * @see #_Eina_Model_Interface_Properties explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_Interface_Properties Eina_Model_Interface_Properties; - -/** - * @struct _Eina_Model_Interface_Properties - * Interface to manage model's properties. - * - * This extends #Eina_Model_Interface as expected by interface name - * #EINA_MODEL_INTERFACE_NAME_PROPERTIES. - * - * This interface is meant to help managing properties of a model, it - * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for - * children independently from properties. - * - * @since 1.2 - */ -struct _Eina_Model_Interface_Properties -{ - Eina_Model_Interface base; /**< common interface methods */ - unsigned int version; /**< must be #EINA_MODEL_INTERFACE_PROPERTIES_VERSION */ - Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp); /**< How to compare properties of this model */ - Eina_Bool (*load)(Eina_Model *model); /**< How to load properties of this model */ - Eina_Bool (*unload)(Eina_Model *model); /**< How to unload properties of this model */ - Eina_Bool (*get)(const Eina_Model *model, const char *name, Eina_Value *value); /**< Retrieve a property of this model given its name. The value will be returned as a copy and must be flushed with eina_value_flush(). The previous contents of value is ignored. */ - Eina_Bool (*set)(Eina_Model *model, const char *name, const Eina_Value *value); /**< Set a property of this model given its name. The value is assumed to be valied and is copied internally, thus it can be safely cleared with eina_value_flush() after this function returns. */ - Eina_Bool (*del)(Eina_Model *model, const char *name); /**< Delete a property given its name */ - Eina_List *(*names_list_get)(const Eina_Model *model); /**< List of stringshare with known property names */ -}; - -/** - * @brief Compares properties using @a iface's comparing function. - * - * @param[in] iface The interface used to compare the properties. - * @param[in] a The first model whose properties will be compared. - * @param[in] b The second model whose properties will be compared. - * @param[out] cmp A pointer to an integer which will contain the result of the - * comparison. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_compare() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_compare(const Eina_Model_Interface *iface, - const Eina_Model *a, - const Eina_Model *b, - int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Loads properties using @a iface's loading function. - * @param iface The properties interface whose load method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_load() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_load(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Unloads properties using @a iface's unloading function. - * @param iface The properties interface whose unload method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_unload() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_unload(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Gets property named @a name using @a iface's function to get properties. - * @param iface The properties interface whose property get method will be called. - * @param model The model instance. - * @param name The name of the property to get. - * @param value Pointer to where value will be stored. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_property_get() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_get(const Eina_Model_Interface *iface, - const Eina_Model *model, - const char *name, - Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4); -/** - * @brief Sets property named @a name using @a iface's function to set properties. - * @param iface The properties interface whose property set method will be called. - * @param model The model instance. - * @param name The name of the property to set. - * @param value The value to be set. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_property_set() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_set(const Eina_Model_Interface *iface, - Eina_Model *model, - const char *name, - const Eina_Value *value) EINA_ARG_NONNULL(1, 2, 3, 4); -/** - * @brief Deletes property named @a name using @a iface's function to delete properties. - * @param iface The properties interface whose property delete method will be called. - * @param model The model instance. - * @param name The name of the property to delete. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_property_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_properties_del(const Eina_Model_Interface *iface, - Eina_Model *model, - const char *name) EINA_ARG_NONNULL(1, 2, 3); -/** - * @brief Gets properties name list using @a iface's function to get properties - * name list. - * @param iface The properties interface whose property name list get method - * will be called. - * @param model The model instance. - * @return #Eina_List of properties' names. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_properties_names_list_get() - * @since 1.2 - */ -EAPI Eina_List *eina_model_interface_properties_names_list_get(const Eina_Model_Interface *iface, - const Eina_Model *model) EINA_ARG_NONNULL(1, 2); /**< list of stringshare */ - -/** - * @typedef Eina_Model_Interface_Children - * Interface to manage model's children. - * - * This extends #Eina_Model_Interface as expected by interface name - * #EINA_MODEL_INTERFACE_NAME_CHILDREN. - * - * This interface is meant to help managing properties of a model, it - * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for - * children independently from properties. - * - * @see #_Eina_Model_Interface_Children explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_Interface_Children Eina_Model_Interface_Children; - -/** - * @def EINA_MODEL_INTERFACE_CHILDREN_VERSION - * Current API version, used to validate #_Eina_Model_Interface_Children. - */ -#define EINA_MODEL_INTERFACE_CHILDREN_VERSION (1) - -/** - * @struct _Eina_Model_Interface_Children - * Interface to manage model's children. - * - * This extends #Eina_Model_Interface as expected by interface name - * #EINA_MODEL_INTERFACE_NAME_CHILDREN. - * - * This interface is meant to help managing properties of a model, it - * is used by #EINA_MODEL_TYPE_MIXIN in order to configure methods for - * children independently from properties. - * - * @since 1.2 - */ -struct _Eina_Model_Interface_Children -{ - Eina_Model_Interface base; /**< common interface methods */ - unsigned int version; /**< must be #EINA_MODEL_INTERFACE_CHILDREN_VERSION */ - Eina_Bool (*compare)(const Eina_Model *a, const Eina_Model *b, int *cmp); /**< How to compare children of this model */ - Eina_Bool (*load)(Eina_Model *model); /**< How to load children of this model */ - Eina_Bool (*unload)(Eina_Model *model); /**< How to unload children of this model */ - int (*count)(const Eina_Model *model); /**< How many children of this model */ - Eina_Model *(*get)(const Eina_Model *model, unsigned int position); /**< Retrieve a child of this model, returned child must have reference increased! */ - Eina_Bool (*set)(Eina_Model *model, unsigned int position, Eina_Model *child); /**< Set (replace) a child of this model, given child will have reference increased! */ - Eina_Bool (*del)(Eina_Model *model, unsigned int position); /**< Delete a child of this model. Existing child will have reference decreased! */ - Eina_Bool (*insert_at)(Eina_Model *model, unsigned int position, Eina_Model *child); /**< Insert a child into this model, given child will have reference increased! All elements towards the end of the internal list will be shifted to the end to make room for the new child. */ - void (*sort)(Eina_Model *model, Eina_Compare_Cb compare); /**< Reorder children to be sorted respecting comparison function @c compare() */ -}; - -/** - * @brief Compares children using @a iface's comparing function. - * - * @param[in] iface The interface used to compare the properties. - * @param[in] a The first model whose properties will be compared. - * @param[in] b The second model whose properties will be compared. - * @param[out] cmp A pointer to an integer which will contain the result of the - * comparison. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_compare() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_compare(const Eina_Model_Interface *iface, - const Eina_Model *a, - const Eina_Model *b, - int *cmp) EINA_ARG_NONNULL(1, 2, 3, 4) EINA_WARN_UNUSED_RESULT; -/** - * @brief Loads children using @a iface's loading function. - * @param iface The children interface whose load method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_load() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_load(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Unloads children using @a iface's unloading function. - * @param iface The children interface whose unload method will be called. - * @param model The model instance. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return EINA_FALSE. - * - * @see eina_model_unload() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_unload(const Eina_Model_Interface *iface, - Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Count children using @a iface's counting function. - * @param iface The children interface whose count method will be called. - * @param model The model instance. - * @return Number of children in @a model. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_count() - * @since 1.2 - */ -EAPI int eina_model_interface_children_count(const Eina_Model_Interface *iface, - const Eina_Model *model) EINA_ARG_NONNULL(1, 2); -/** - * @brief Get child using @a iface's function to get children. - * @param iface The children interface whose get method will be called. - * @param model The model instance. - * @param position Position of child to be retrieved. - * @return The requested child. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_get() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_interface_children_get(const Eina_Model_Interface *iface, - const Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1, 2); -/** - * @brief Set child using @a iface's function to set children. - * @param iface The children interface whose set method will be called. - * @param model The model instance. - * @param position Position of child to be set. - * @param child Value(child) to be set. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_set() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_set(const Eina_Model_Interface *iface, - Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Delete child using @a iface's function to delete children. - * @param iface The children interface whose delete method will be called. - * @param model The model instance. - * @param position Position of child to be deleted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_del() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_del(const Eina_Model_Interface *iface, - Eina_Model *model, - unsigned int position) EINA_ARG_NONNULL(1, 2); -/** - * @brief Insert child using @a iface's function to insert children. - * @param iface The children interface whose insert method will be called. - * @param model The model instance. - * @param position Position in which to insert @a child. - * @param child Value(child) to be inserted. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_insert_at() - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_children_insert_at(const Eina_Model_Interface *iface, - Eina_Model *model, - unsigned int position, - Eina_Model *child) EINA_ARG_NONNULL(1, 2, 4); -/** - * @brief Sort children using @a iface's function to sort children. - * @param iface The children interface whose sort method will be called. - * @param model The model instance. - * @param compare Function used to compare children. - * - * @warning If either model doesn't implement @a iface will do nothing and - * return -1. - * - * @see eina_model_child_sort(). - * @since 1.2 - */ -EAPI void eina_model_interface_children_sort(const Eina_Model_Interface *iface, - Eina_Model *model, - Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); - - -/** - * @} - */ - -/** - * @defgroup Eina_Model_Utils_Group Data Model Utilities - * - * Miscellaneous utilities to help usage or debug of @ref Eina_Model_Group. - * - * @{ - */ - -/** - * @brief Checks if @a model is an instance of @a type. - * @param model The model instance. - * @param type The type being checked for. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_model_new() - * @see _Eina_Model_Type - * @since 1.2 - */ -EAPI Eina_Bool eina_model_instance_check(const Eina_Model *model, - const Eina_Model_Type *type) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Checks if @a model implements @a iface. - * @param model The model instance. - * @param iface The interface being checked for. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see _Eina_Model_Interface - * @since 1.2 - */ -EAPI Eina_Bool eina_model_interface_implemented(const Eina_Model *model, const Eina_Model_Interface *iface) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Returns the number of references to @a model. - * @param model The model to query number of references. - * @return Number of references to model. - * - * @see eina_model_ref() - * @see eina_model_unref() - * @see eina_model_xref() - * @see eina_model_xunref() - * @see eina_model_xrefs_get() - * @since 1.2 - */ -EAPI int eina_model_refcount(const Eina_Model *model) EINA_ARG_NONNULL(1); - -/** - * @typedef Eina_Model_XRef - * Extended reference to model. - * - * This is returned by eina_model_xrefs_get() and should never be - * modified. It is managed by eina_model_xref() and - * eina_model_xunref() when @c EINA_MODEL_DEBUG is set to "1" or - * "backtrace". - * - * @see #_Eina_Model_XRef explains fields. - * @since 1.2 - */ -typedef struct _Eina_Model_XRef Eina_Model_XRef; - -/** - * @struct _Eina_Model_XRef - * Extended reference to model. - * - * This is returned by eina_model_xrefs_get() and should never be - * modified. It is managed by eina_model_xref() and - * eina_model_xunref() when @c EINA_MODEL_DEBUG is set to "1" or - * "backtrace". - * - * @see eina_model_xrefs_get() - * @see eina_models_usage_dump() - * @since 1.2 - */ -struct _Eina_Model_XRef -{ - EINA_INLIST; - const void *id; /**< as given to eina_model_xref() */ - struct { - const void * const *symbols; /**< only if @c EINA_MODEL_DEBUG=backtrace is set, otherwise is @c NULL */ - unsigned int count; /**< only if @c EINA_MODEL_DEBUG=backtrace is set, otherwise is 0 */ - } backtrace; - char label[]; /**< Any given label given to eina_model_xref(). */ -}; - -/** - * @brief Returns the current references of this model. - * @param model The model to query references. - * @return List of reference holders as Eina_Model_XRef. This is the internal - * list for speed purposes, do not modify or free it in anyway! - * - * @note This list only exist if environment variable - * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". - * - * @note The backtrace information is only available if environment - * variable @c EINA_MODEL_DEBUG=backtrace is set. - * @since 1.2 - */ -EAPI const Eina_Inlist *eina_model_xrefs_get(const Eina_Model *model) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - -/** - * @brief Dump usage of all existing modules. - * @since 1.2 - */ -EAPI void eina_models_usage_dump(void); - -/** - * @brief Return a list of all live models. - * @return a newly allocated list of Eina_Model. Free using - * eina_models_list_free() - * - * @note this is meant to debug purposes, do not modify the models in - * any way! - * - * @note due performance reasons, this is only @b enabled when - * @c EINA_MODEL_DEBUG is set to "1" or "backtrace". - * - * @since 1.2 - */ -EAPI Eina_List *eina_models_list_get(void); - -/** - * @brief Release list returned by eina_models_list_get() - * @param list the list to release. - */ -EAPI void eina_models_list_free(Eina_List *list); - -/** - * @} - */ - -/** - * @var EINA_MODEL_INTERFACE_CHILDREN_INARRAY - * - * Implements #Eina_Model_Interface_Children - * (#EINA_MODEL_INTERFACE_NAME_CHILDREN) using #Eina_Inarray. It - * should be efficient in space and time for most operations. - * - * @note it may become slow if eina_model_child_insert_at() is used at(or near) - * the beginning of the array as the members from that position - * to the end must be memmove()d. - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_CHILDREN_INARRAY; - - -/** - * @var EINA_MODEL_TYPE_BASE - * Base type for all eina model types. - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_BASE; - -/** - * @var EINA_MODEL_TYPE_MIXIN - * - * Type that uses #EINA_MODEL_INTERFACE_NAME_PROPERTIES and - * #EINA_MODEL_INTERFACE_NAME_CHILDREN to manage the model. - * - * This is an abstract type, it does not work out of the box as one - * needs to subclass it and define the interface implementations for - * properties and children, as done by #EINA_MODEL_TYPE_GENERIC - * - * @see EINA_MODEL_TYPE_GENERIC - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_MIXIN; - -/** - * @var EINA_MODEL_TYPE_GENERIC - * - * Subclass of #EINA_MODEL_TYPE_MIXIN that uses - * #EINA_MODEL_INTERFACE_PROPERTIES_HASH and - * #EINA_MODEL_INTERFACE_CHILDREN_INARRAY. - * - * Should be generic enough to hold lots of items with runtime - * configurable properties of any type. - * - * @see #EINA_MODEL_TYPE_STRUCT - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_GENERIC; - -/** - * @var EINA_MODEL_TYPE_STRUCT - * - * Subclass of #EINA_MODEL_TYPE_MIXIN that uses - * #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT and - * #EINA_MODEL_INTERFACE_CHILDREN_INARRAY. - * - * Should be struct enough to hold lots of items with compile time - * configurable properties of any type. - * - * @see #EINA_MODEL_TYPE_GENERIC - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Type *EINA_MODEL_TYPE_STRUCT; - -/** - * @brief Create and setup an instance of #EINA_MODEL_TYPE_STRUCT. - * @param desc struct description to use for properties. - * @return newly created and set model, or @c NULL on errors. - * - * @see eina_model_type_struct_new() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - -/** - * @brief Create and setup an instance of type subclass of #EINA_MODEL_TYPE_STRUCT. - * @param type a type which is subclass of #EINA_MODEL_TYPE_STRUCT. - * @param desc struct description to use for properties. - * @return newly created and set model, or @c NULL on errors. - * - * @see eina_model_struct_new() - * @since 1.2 - */ -EAPI Eina_Model *eina_model_type_struct_new(const Eina_Model_Type *type, - const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT EINA_MALLOC; - - -/** - * @brief Configure the internal properties of model implementing #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT. - * @param model The model instance to configure. - * @param desc The structure description to use. - * @param memory If not @c NULL, will be copied by model. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This will setup the internal pointers so that the given @a desc is - * used to manage the properties of this struct. - * - * If a given memory is provided, it will be copied (including - * members) and no references are taken after this function returns. - * - * @see #EINA_VALUE_TYPE_STRUCT - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_struct_set(Eina_Model *model, - const Eina_Value_Struct_Desc *desc, - void *memory) EINA_ARG_NONNULL(1, 2); -/** - * @brief Get the internal properties of model implementing #EINA_MODEL_INTERFACE_PROPERTIES_STRUCT. - * @param model the model instance. - * @param p_desc where to return the structure description in use. - * @param p_memory where to return the structure memory in use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * No copies are made! The memory and description may be invalidaded - * by calls to eina_model_struct_set() or eina_model_del(). - * - * @since 1.2 - */ -EAPI Eina_Bool eina_model_struct_get(const Eina_Model *model, - const Eina_Value_Struct_Desc **p_desc, - void **p_memory) EINA_ARG_NONNULL(1, 2); - -/** - * @var EINA_MODEL_INTERFACE_NAME_PROPERTIES - * - * Interface that uses #Eina_Model_Interface_Properties as - * #Eina_Model_Interface and can manage the model properties. - * - * @since 1.2 - */ -EAPI extern const char *EINA_MODEL_INTERFACE_NAME_PROPERTIES; - -/** - * @var EINA_MODEL_INTERFACE_PROPERTIES_HASH - * - * Implements #Eina_Model_Interface_Properties - * (#EINA_MODEL_INTERFACE_NAME_PROPERTIES) using #Eina_Hash. - * - * @note This function is generic but uses too much space given the - * hash data type. For huge number of elements it's better to - * use custom implementation instead. - * - * @see EINA_MODEL_INTERFACE_PROPERTIES_STRUCT - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_PROPERTIES_HASH; - -/** - * @var EINA_MODEL_INTERFACE_PROPERTIES_STRUCT - * - * Implements #Eina_Model_Interface_Properties - * (#EINA_MODEL_INTERFACE_NAME_PROPERTIES) using #Eina_Value_Struct. - * - * The interface private data is #Eina_Value of type - * #EINA_VALUE_TYPE_STRUCT. Properties will be accessed using - * Eina_Value_Struct::desc information that can be set by types such - * as #EINA_MODEL_TYPE_STRUCT - * - * @see EINA_MODEL_INTERFACE_PROPERTIES_HASH - * - * @since 1.2 - */ -EAPI extern const Eina_Model_Interface *EINA_MODEL_INTERFACE_PROPERTIES_STRUCT; - -/** - * @var EINA_MODEL_INTERFACE_NAME_CHILDREN - * - * Interface that uses #Eina_Model_Interface_Children as - * #Eina_Model_Interface and can manage the model children. - * - * @since 1.2 - */ -EAPI extern const char *EINA_MODEL_INTERFACE_NAME_CHILDREN; - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -#endif diff --git a/libraries/eina/src/include/eina_module.h b/libraries/eina/src/include/eina_module.h deleted file mode 100644 index 178fa9a..0000000 --- a/libraries/eina/src/include/eina_module.h +++ /dev/null @@ -1,350 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_MODULE_H_ -#define EINA_MODULE_H_ - -#include "eina_types.h" -#include "eina_array.h" -#include "eina_error.h" - -/** - * @addtogroup Eina_Module_Group Module - * - * @brief These functions provide module management. - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Module_Group Module - * - * Eina module provides some helpers over POSIX dlopen(). It is not - * meant to replace, abstract or make a "portable" version of the - * POSIX, but enhance its usage by defining some good practices. - * - * Modules are created with eina_module_new() and later loaded with - * 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 - * dlclose(). This makes simple to have different users for the same - * module. - * - * The loaded shared objects may have two visible functions that will - * be called and might provide initialization and shutdown - * proceedures. The symbols are @c __eina_module_init and - * @c __eina_module_shutdown and will be defined by the macros - * EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN(). - * - * There are some helpers to automatically create modules based on - * directory listing. See eina_module_arch_list_get(), - * eina_module_list_get() and eina_module_find(). - * - * @{ - */ - -/** - * @typedef Eina_Module - * Dynamic module loader handle. - */ -typedef struct _Eina_Module Eina_Module; - -/** - * @typedef Eina_Module_Cb - * Dynamic module loader callback. - */ -typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data); - -/** - * @typedef Eina_Module_Init - * If a function with such signature is exported by module as - * __eina_module_init, it will be called on the first load after - * dlopen() and if #EINA_FALSE is returned, load will fail, #EINA_TRUE - * means the module was successfully initialized. - * @see Eina_Module_Shutdown - */ -typedef Eina_Bool (*Eina_Module_Init)(void); - -/** - * @typedef Eina_Module_Shutdown - * If a function with such signature is exported by module as - * __eina_module_shutdown, it will be called before calling dlclose() - * @see Eina_Module_Init - */ -typedef void (*Eina_Module_Shutdown)(void); - -/** - * @def EINA_MODULE_INIT - * declares the given function as the module initializer (__eina_module_init). - * It must be of signature #Eina_Module_Init - */ -#define EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f - -/** - * @def EINA_MODULE_SHUTDOWN - * declares the given function as the module shutdownializer - * (__eina_module_shutdown). It must be of signature - * #Eina_Module_Shutdown - */ -#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shutdown = &f - -/** - * @var EINA_ERROR_WRONG_MODULE - * Error identifier corresponding to a wrong module. - */ -extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE; - -/** - * @var EINA_ERROR_MODULE_INIT_FAILED - * Error identifier corresponding to a failure during the initialisation of a module. - */ -extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED; - -/** - * @brief Return a new module. - * - * @param file The name of the file module to load. - * - * This function returns a new module. If @p file is @c NULL, the - * function returns @c NULL, otherwise, it allocates an Eina_Module, - * stores a duplicate string of @p file, sets its reference to @c 0 - * and its handle to @c NULL. - * - * When the new module is not needed anymore, use eina_module_free() - * to free the allocated memory. - * - * @see eina_module_load - */ -EAPI Eina_Module * - eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Delete a module. - * - * @param module The module to delete. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * This function calls eina_module_unload() if @p module has been previously - * loaded and frees the allocated memory. On success this function - * returns EINA_TRUE and EINA_FALSE otherwise. If @p module is @c NULL, the - * function returns immediately. - */ -EAPI Eina_Bool - eina_module_free(Eina_Module *module) EINA_ARG_NONNULL(1); - -/** - * @brief Load a module. - * - * @param module The module to load. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * This function load the shared file object passed in - * eina_module_new(). If it is a internal Eina module (like the - * mempools), it also initialize it. It the shared file object can not - * be loaded, the error #EINA_ERROR_WRONG_MODULE is set and - * #EINA_FALSE is returned. If it is a internal Eina module and the - * module can not be initialized, the error - * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is - * returned. If the module has already been loaded, it's refeence - * counter is increased by one and #EINA_TRUE is returned. If @p module is - * @c NULL, the function returns immediately #EINA_FALSE. - * - * When the symbols of the shared file objetcts are not needed - * anymore, call eina_module_unload() to unload the module. - */ -EAPI Eina_Bool - eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1); - -/** - * @brief Unload a module. - * - * @param module The module to load. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * This function unload the module @p module that has been previously - * loaded by eina_module_load(). If the reference counter of @p module is - * 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 - * is shutted down just before. In that case, #EINA_TRUE is - * returned. In all case, the reference counter is decreased. If @p module - * is @c NULL, the function returns immediately #EINA_FALSE. - */ -EAPI Eina_Bool - eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1); - -/** - * @brief Retrive the data associated to a symbol. - * - * @param module The module. - * @param symbol The symbol. - * @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 - * module must have been loaded before with eina_module_load(). If @p module - * is @c NULL, or if it has not been correctly loaded before, the - * function returns immediately @c NULL. - */ -EAPI void * - eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Return the file name associated to the module. - * - * @param module The module. - * @return The file name. - * - * This function returns the file name passed in eina_module_new(). If - * @p module is @c NULL, the function returns immediately @c NULL. The - * returned value must no be freed. - */ -EAPI const char * - eina_module_file_get(const Eina_Module *module) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - - -/** - * @brief Return the path built from the location of a library and a - * given sub directory. - * - * @param symbol The symbol to search for. - * @param sub_dir The subdirectory to append. - * @return The built path on success, @c NULL otherwise. - * - * 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 - * 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, - * or allocation fails, this function returns @c NULL. - */ -EAPI char * - 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 and a - * given sub directory. - * - * @param env The environment variable to expand. - * @param sub_dir The subdirectory to append. - * @return The built path on success, @c NULL otherwise. - * - * This function returns the path built by concatenating the value of - * 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 - * anymore. If the symbol is not found, or @p env does not exist, or - * allocation fails, this function returns @c NULL. - */ -EAPI char * - eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2); - - -/** - * @brief Get an array of modules found on the directory path matching an arch type. - * - * @param array The array that stores the list of the modules. - * @param path The directory's path to search for modules. - * @param arch The architecture string. - * @return The array of modules found in @p path matching @p arch. - * - * This function adds to @p array the module names found in @p path - * which match the cpu architecture @p arch. If @p path or @p arch is - * @c NULL, the function returns immediately @p array. @p array can be - * @c NULL. In that case, it is created with 4 elements. - */ -EAPI Eina_Array * - eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch); - -/** - * @brief Get a list of modules found on the directory path. - * - * @param array The array that stores the list of the modules. - * @param path The directory's path to search for modules. - * @param recursive Iterate recursively on the path. - * @param cb Callback function to call on each module. - * @param data Data passed to the callback function. - * @return The array of modules found in @p path. - * - * This function adds to @p array the list of modules found in - * @p path. If @p recursive is #EINA_TRUE, then recursive search is - * done. The callback @p cb is called on each module found, and @p data - * is passed to @p cb. If @p path is @c NULL, the function returns - * immediately @p array. If the returned value of @p cb is 0, the - * module will not be added to the list, otherwise it will be added. - * @p array can be @c NULL. In that case, it is created with 4 - * elements. @p cb can be @c NULL. - */ -EAPI Eina_Array * - eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Load every module on the list of modules. - * - * @param array The array of modules to load. - * - * This function calls eina_module_load() on each element found in - * @p array. If @p array is @c NULL, this function does nothing. - */ -EAPI void - eina_module_list_load(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @brief Unload every module on the list of modules. - * - * @param array The array of modules to unload. - * - * This function calls eina_module_unload() on each element found in - * @p array. If @p array is @c NULL, this function does nothing. - */ -EAPI void - eina_module_list_unload(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @p Free every module on the list of modules. - * - * @param array The array of modules to free. - * - * This function calls eina_module_free() on each element found in - * @p array. If @p array is @c NULL, this function does nothing. - */ -EAPI void - eina_module_list_free(Eina_Array *array) EINA_ARG_NONNULL(1); - -/** - * @brief Find an module in array. - * - * @param array The array to find the module. - * @param module The name of module to be searched. - * @return The module to find on success, @c NULL otherwise. - * - * This function finds an @p module in @p array. - * If the element is found the function returns the module, else - * @c NULL is returned. - */ -EAPI Eina_Module * - eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2); - -/** - * @} - */ - -/** - * @} - */ - -#endif /*EINA_MODULE_H_*/ diff --git a/libraries/eina/src/include/eina_prefix.h b/libraries/eina/src/include/eina_prefix.h deleted file mode 100644 index b59080b..0000000 --- a/libraries/eina/src/include/eina_prefix.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef EINA_PREFIX_H_ -#define EINA_PREFIX_H_ - -/** - * @addtogroup Eina_Prefix_Group Prefix Group - * - * @brief These functions provide the ability to determine the runtime - * location of a software package - * - * @{ - * - * @since 1.1.0 - */ - -/** - * @typedef Eina_Prefix - * This is a prefix object that is returned by eina_prefix_new() when trying - * to determine the runtime location of the software in question so other - * data files such as images, sound files, other executable utilities, - * libraries, modules and locale files can be found. - * - * @since 1.1.0 - */ -typedef struct _Eina_Prefix Eina_Prefix; - -/** - * @brief Create a new prefix handle given some input information - * - * @param argv0 If this is an executable this is argv[0] of the binary, or NULL if it is used from a shared library - * @param symbol This is a symbol (function for example) inside the binary or library to find the source location of. Provide NULL if not used - * @param envprefix This is the prefix to any environment variables that may 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 magicsharefile This is a magic file to check existence of to determine the prefix find was correct, and it must be located in the data dir under the share dir provided above, or NULL if the check is not to be done - * @param pkg_bin This is the compile-time binary 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_locale This is the compile-time locale install dir - * @return The prefix handle, or NULL on failure - * - * Applications and libraries are most often not just single executables nor - * single shared library binares, but also come with extra modules they - * have to load, extra binary utilities they need to run, or have data files - * they need to load. A very primitve application ASSUMES a fixed install - * location at compile-time, but this disallows the ability to re-locate - * the application (or library) somewhere else after compilation (if you run - * out of space on a given disk, partition etc. for example), or necessitate - * 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 - * symlinks pointing from the compiled location to the new one. - * - * Being re-locatable at runtime allows much easier distribution and - * installation into places like the users own home directory, instead of - * on a system partition, if the developer wishes for easier distribution - * of pre-compiled binaries. - * - * The prefix system is designed to locate where the given software is - * installed (under a common prefix) at runtime and then report specific - * locations of this prefix and common directories inside this prefix like - * the binary, library, data and locale directories. - * - * To do this some information needs to be provided to eina_prefix_new(). If - * you have developed a binary executable, then provide argv[0] as the @p argv0 - * argument. This plus the PATH environment variable help the prefix system - * to determine its location. Call eina_prefix_new() early on before you - * change working directory or anything about argv[0] so it gets accurate - * information. It will use the first argument, being the executable itself, - * to look in absolute directories, relative paths and PATH to see if it - * finds the right executable to determine just where the actual binary is - * installed and being run from. If you develop a share library, just pass - * NULL as argv0 - * - * It would prefer to use the @p symbol function to determine location as - * that function will be unique inside the application and try and trace - * back which file this function comes from (be it a binary or shared library) - * as this avoids more expensive searches via @p argv0. It will use this - * symbol if given in preference to argv0. - * - * The @p envprefix parameter, provides a string prefix to prepend before - * environment variables to allow a fallback to specific environment variables - * to locate the software. For example if "MYAPP" is provided a the prefix, - * then it uses "MYAPP_PREFIX" as a master environment variable to specify - * the exact install prefix for the software, or more specific environment - * variables like "MYAPP_BIN_DIR", "MYAPP_LIB_DIR", "MYAPP_DATA_DIR" and - * "MYAPP_LOCALE_DIR" which can be set by the user or scripts before - * launching. If not provided (NULL) environment variables will not be - * used to override compiled-in defaults or auto detections. - * - * The @p sharedir string provides a subdirectory inside the system shared - * data dir for data files. For example, if the system dir is - * /usr/local/share then this dir name is appended, creating - * /usr/local/share/appname if this dir was the "appname" string. It is - * expected the application or library installs data files in this directory. - * - * The @p magicsharefile is a filename or path of something inside the share - * or data dir to be used to test that the prefix detection worked. For - * example, your app will install a wallpaper image as - * /usr/local/share/appname/images/wallpaper.jpg and so to check that this - * worked, provide "images/wallpaper.jpg" as the @p magicsharefile string - * 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-time - * 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 - * to determine actual names of directories like libdirs maybe changing to - * be lib32 or lib64 instead of lib etc. - * - * Compile the following defining at compile time your prefixes like (example): - * - * gcc appname.c -o appname \ - * -DPACKAGE_BIN_DIR=/usr/local/bin \ - * -DPACKAGE_LIB_DIR=/usr/local/lib \ - * -DPACKAGE_DATA_DIR=/usr/local/share/appname \ - * -DLOCALE_DIR=/usr/local/share/locale - * - * (of course add appropriate compile flags to linking etc. etc. and note that - * 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 and - * ensuring that the prefix check is correct. this file must be installed - * in the application data dir (eg /usr/local/share/appname) and be referred - * to using a unix-style relative path from that dir, eg directory/filename.png) - * - * @code - * static Eina_Prefix *pfx = NULL; - * - * int main(argc, char **argv) - * { - * pfx = eina_prefix_new(argv[0], main, "APPNAME", "appname", NULL, - * PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, - * PACKAGE_DATA_DIR, LOCALE_DIR); - * if (!pfx) printf("ERROR: Critical error in finding prefix\n"); - * printf("install prefix is: %s\n", eina_prefix_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("data files are in: %s\n", eina_prefix_data_get(pfx)); - * eina_prefix_free(pfx); - * } - * @endcode - * - * @since 1.1.0 - */ -EAPI Eina_Prefix * -eina_prefix_new(const char *argv0, void *symbol, const char *envprefix, - const char *sharedir, const char *magicsharefile, - const char *pkg_bin, const char *pkg_lib, - const char *pkg_data, const char *pkg_locale); - -/** - * @brief Free the prefix object and all its contents - * - * @param pfx The prefix object - * - * Free the prefix object and all its allocated content. It will be invalid - * to access the object after being freed. - * - * @since 1.1.0 - */ -EAPI void -eina_prefix_free(Eina_Prefix *pfx); - -/** - * @brief Get the prefix base directory - * - * @param pfx The prefix object - * - * This returns the base prefix (eg "/usr/local", "/usr", "/opt/appname" or - * "/home/user/myapps/appname" etc.) that the software resides in at runtime. - * - * @since 1.1.0 - */ -EAPI const char * -eina_prefix_get(Eina_Prefix *pfx); - -/** - * @brief Get the binary installation directory - * - * @param pfx The prefix object - * - * This returns the location of installed binaries (eg "/usr/local/bin", - * "/usr/bin", "/opt/appname/bin", "/home/user/myapps/appname/bin" etc.). - * - * @since 1.1.0 - */ -EAPI const char * -eina_prefix_bin_get(Eina_Prefix *pfx); - -/** - * @brief Get the library installation directory - * - * @param pfx The prefix object - * - * This returns the location of installed binaries (eg "/usr/local/lib", - * "/usr/lib32", "/opt/appname/lib64", "/home/user/myapps/appname/lib" etc.). - * - * @since 1.1.0 - */ -EAPI const char * -eina_prefix_lib_get(Eina_Prefix *pfx); - -/** - * @brief Get the data installation directory - * - * @param pfx The prefix object - * - * This returns the location of installed binaries (eg "/usr/local/share/appname", - * "/usr/share/appname", "/opt/appname/share/appname", "/home/user/myapps/appname/share/appname" etc.). - * - * @since 1.1.0 - */ -EAPI const char * -eina_prefix_data_get(Eina_Prefix *pfx); - -/** - * @brief Get the locale installation directory - * - * @param pfx The prefix object - * - * This returns the location of installed binaries (eg "/usr/local/share/locale", - * "/usr/share/locale", "/opt/appname/share/locale", "/home/user/myapps/appname/share/locale" etc.). - * - * @since 1.1.0 - */ -EAPI const char * -eina_prefix_locale_get(Eina_Prefix *pfx); - -/** - * @} - */ -#endif diff --git a/libraries/eina/src/include/eina_quadtree.h b/libraries/eina/src/include/eina_quadtree.h deleted file mode 100644 index 2638d8b..0000000 --- a/libraries/eina/src/include/eina_quadtree.h +++ /dev/null @@ -1,53 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2010 Cedric BAIL - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_QUADTREE_H_ -#define EINA_QUADTREE_H_ - -#include "eina_config.h" - -#include "eina_inlist.h" - -typedef struct _Eina_QuadTree Eina_QuadTree; -typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item; - -typedef enum { - EINA_QUAD_LEFT, - EINA_QUAD_RIGHT, - EINA_QUAD_BOTH -} Eina_Quad_Direction; - -typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle); - -EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h, Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal); -EAPI void eina_quadtree_free(Eina_QuadTree *q); -EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h); - -EAPI void eina_quadtree_cycle(Eina_QuadTree *q); -EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object); - -EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object); -EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object); -EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object); -EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object); -EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object); - -EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h); -EAPI void *eina_quadtree_object(Eina_Inlist *list); - -#endif diff --git a/libraries/eina/src/include/eina_rbtree.h b/libraries/eina/src/include/eina_rbtree.h deleted file mode 100644 index 8e5b730..0000000 --- a/libraries/eina/src/include/eina_rbtree.h +++ /dev/null @@ -1,271 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_RBTREE_H__ -#define EINA_RBTREE_H__ - -#include - -#include "eina_types.h" -#include "eina_error.h" -#include "eina_iterator.h" - -/** - * @addtogroup Eina_Rbtree_Group Red-Black tree - * - * @brief These functions provide Red-Black trees management. - * - * For a brief description look at http://en.wikipedia.org/wiki/Red-black_tree . - * This code is largely inspired from a tutorial written by Julienne Walker at : - * http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx . The - * main difference is that this set of function never allocate any data, making - * them particularly useful for memory management. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Rbtree_Group Red-Black tree - * - * @{ - */ - -/** - * @typedef Eina_Rbtree_Color - * node color. - */ -typedef enum { - EINA_RBTREE_RED, - EINA_RBTREE_BLACK -} Eina_Rbtree_Color; - -/** - * @typedef Eina_Rbtree_Direction - * walk direction. - */ -typedef enum { - EINA_RBTREE_LEFT = 0, - EINA_RBTREE_RIGHT = 1 -} Eina_Rbtree_Direction; - -/** - * @typedef Eina_Rbtree - * Type for a Red-Black tree node. It should be inlined into user's type. - */ -typedef struct _Eina_Rbtree Eina_Rbtree; -struct _Eina_Rbtree -{ - Eina_Rbtree *son[2]; - - Eina_Rbtree_Color color : 1; -}; - -/** - * @def EINA_RBTREE - * recommended way to declare the inlined Eina_Rbtree in your type. - * - * @code - * struct my_type { - * EINA_RBTREE; - * int my_value; - * char *my_name; - * }; - * @endcode - * - * @see EINA_RBTREE_GET() - */ -#define EINA_RBTREE Eina_Rbtree __rbtree - -/** - * @def EINA_RBTREE_GET - * access the inlined node if it was created with #EINA_RBTREE. - */ -#define EINA_RBTREE_GET(Rbtree) (&((Rbtree)->__rbtree)) - -/** - * @def EINA_RBTREE_CONTAINER_GET - * find back the container of an red black tree. - */ -#define EINA_RBTREE_CONTAINER_GET(Ptr, Type) ((Type *)((char *)Ptr - offsetof(Type, __rbtree))) - -/** - * @typedef Eina_Rbtree_Cmp_Node_Cb - * Function used compare two nodes and see which direction to navigate. - */ -typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data); - -/** - * @def EINA_RBTREE_CMP_NODE_CB - * Cast using #Eina_Rbtree_Cmp_Node_Cb - */ -#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function) - -/** - * @typedef Eina_Rbtree_Cmp_Key_Cb - * Function used compare node with a given key of specified length. - */ -typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data); -/** - * @def EINA_RBTREE_CMP_KEY_CB - * Cast using #Eina_Rbtree_Cmp_Key_Cb - */ -#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function) - -/** - * @typedef Eina_Rbtree_Free_Cb - * Function used free a node. - */ -typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data); -/** - * @def EINA_RBTREE_FREE_CB - * Cast using #Eina_Rbtree_Free_Cb - */ -#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function) - - -/** - * @brief Insert a new node inside an existing red black tree. - * - * @param root The root of an exisiting valid red black tree. - * @param node The new node to insert. - * @param cmp The callback that is able to compare two nodes. - * @param data Private data to help the compare function. - * @return The new root of the red black tree. - * - * This function insert a new node in a valid red black tree. NULL is - * an empty valid red black tree. The resulting new tree is a valid red - * black tree. This function doesn't allocate any data. - */ -EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Remove a node from an existing red black tree. - * - * @param root The root of a valid red black tree. - * @param node The node to remove from the tree. - * @param cmp The callback that is able to compare two nodes. - * @param data Private data to help the compare function. - * @return The new root of the red black tree. - * - * This function remove a new node in a valid red black tree that should - * contain the node that you are removing. This function will return NULL - * when the red black tree got empty. This function doesn't free any data. - */ -EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Delete all nodes from a valid red black tree. - * - * @param root The root of a valid red black tree. - * @param func The callback that will free each node. - * @param data Private data to help the compare function. - * - */ -EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2); - -static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Returned a new prefix iterator associated to a rbtree. - * - * @param root The root of rbtree. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * root. It will iterate the tree using prefix walk. If @p root is @c - * NULL, this function still returns a valid iterator that will always - * return false on eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the rbtree structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new prefix iterator associated to a rbtree. - * - * @param root The root of rbtree. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * root. It will iterate the tree using infix walk. If @p root is @c - * NULL, this function still returns a valid iterator that will always - * return false on eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the rbtree structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Returned a new prefix iterator associated to a rbtree. - * - * @param root The root of rbtree. - * @return A new iterator. - * - * This function returns a newly allocated iterator associated to @p - * root. It will iterate the tree using postfix walk. If @p root is @c - * NULL, this function still returns a valid iterator that will always - * return false on eina_iterator_next(), thus keeping API sane. - * - * If the memory can not be allocated, NULL is returned and - * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is - * returned. - * - * @warning if the rbtree structure changes then the iterator becomes - * invalid! That is, if you add or remove nodes this iterator - * behavior is undefined and your program may crash! - */ -EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -#include "eina_inline_rbtree.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_rectangle.h b/libraries/eina/src/include/eina_rectangle.h deleted file mode 100644 index 57e562c..0000000 --- a/libraries/eina/src/include/eina_rectangle.h +++ /dev/null @@ -1,239 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_RECTANGLE_H_ -#define EINA_RECTANGLE_H_ - -#include "eina_types.h" - -/** - * @addtogroup Eina_Rectangle_Group Rectangle - * - * @brief These functions provide rectangle management. - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Rectangle_Group Rectangle - * - * @{ - */ - -/** - * @typedef Eina_Rectangle - * Simple rectangle structure. - */ -typedef struct _Eina_Rectangle -{ - int x; /**< top-left x co-ordinate of rectangle */ - int y; /**< top-left y co-ordinate of rectangle */ - int w; /**< width of rectangle */ - int h; /**< height of rectangle */ -} Eina_Rectangle; - -/** - * @typedef Eina_Rectangle_Pool - * Type for an opaque pool of rectangle. - */ -typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool; - -static inline int eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT; -static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1); -static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; -static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; -static inline void eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2); -static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; -static inline void eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3); -static inline void eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3); - - -/** - * @brief Add a rectangle in a new pool. - * - * @param w The width of the rectangle. - * @param h The height of the rectangle. - * @return A newly allocated pool on success, @c NULL otherwise. - * - * This function adds the rectangle of size (@p width, @p height) to a - * new pool. If the pool can not be created, @c NULL is - * returned. Otherwise the newly allocated pool is returned. - */ -EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Return the pool of the given rectangle. - * - * @param rect The rectangle. - * @return The pool of the given rectangle. - * - * This function returns the pool in which @p rect is. If @p rect is - * @c NULL, @c NULL is returned. - */ -EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Return the width and height of the given pool. - * - * @param pool The pool. - * @param w The returned width. - * @param h The returned height. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * This function returns the width and height of @p pool and store - * them in respectively @p w and @p h if they are not @c NULL. If - * @p pool is @c NULL, #EINA_FALSE is returned. Otherwise #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Get the data from the given pool. - * - * @param pool The pool. - * @return The returned data. - * - * This function gets the data from @p pool set by - * eina_rectangle_pool_data_set(). If @p pool is @c NULL, this - * function returns @c NULL. - */ -EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Set the data to the given pool. - * - * @param pool The pool. - * @param data The data to set. - * - * This function sets @p data to @p pool. If @p pool is @c NULL, this - * function does nothing. - */ -EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1); - -/** - * @brief Free the given pool. - * - * @param pool The pool to free. - * - * This function frees the allocated data of @p pool. If @p pool is - * @c NULL, ths function returned immediately. - */ -EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1); - -/** - * @brief Return the number of rectangles in the given pool. - * - * @param pool The pool. - * @return The number of rectangles in the pool. - * - * This function returns the number of rectangles in @p pool. - */ -EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Request a rectangle of given size in the given pool. - * - * @param pool The pool. - * @param w The width of the rectangle to request. - * @param h The height of the rectangle to request. - * @return The requested rectangle on success, @c NULL otherwise. - * - * This function retrieve from @p pool the rectangle of width @p w and - * height @p h. If @p pool is @c NULL, or @p w or @p h are non-positive, - * the function returns @c NULL. If @p w or @p h are greater than the - * pool size, the function returns @c NULL. On success, the function - * returns the rectangle which matches the size (@p w, @p h). - * Otherwise it returns @c NULL. - */ -EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Remove the given rectangle from the pool. - * - * @param rect The rectangle to remove from the pool. - * - * This function removes @p rect from the pool. If @p rect is - * @c NULL, the function returns immediately. Otherwise it remoes @p - * rect from the pool. - */ -EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1); - -/** - * @def EINA_RECTANGLE_SET - * @brief Macro to set the values of a #Eina_Rectangle. - * - * @param Rectangle The rectangle to set the values. - * @param X The X coordinate of the top left corner of the rectangle. - * @param Y The Y coordinate of the top left corner of the rectangle. - * @param W The width of the rectangle. - * @param H The height of the rectangle. - * - * This macro set the values of @p Rectangle. (@p X, @p Y) is the - * coordinates of the top left corner of @p Rectangle, @p W is its - * width and @p H is its height. - */ -#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \ - (Rectangle)->x = X; \ - (Rectangle)->y = Y; \ - (Rectangle)->w = W; \ - (Rectangle)->h = H; - - -/** - * @brief Create a new rectangle. - * - * @param x The X coordinate of the top left corner of the rectangle. - * @param y The Y coordinate of the top left corner of the rectangle. - * @param w The width of the rectangle. - * @param h The height of the rectangle. - * @return The new rectangle on success, @ NULL otherwise. - * - * This function creates a rectangle which top left corner has the - * coordinates (@p x, @p y), with height @p w and height @p h and adds - * it to the rectangles pool. No check is done on @p w and @p h. This - * function returns a new rectangle on success, @c NULL otherwhise. - */ -EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free the given rectangle. - * - * @param rect The rectangle to free. - * - * This function removes @p rect from the rectangles pool. - */ -EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1); - -#include "eina_inline_rectangle.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /*_EINA_RECTANGLE_H_*/ diff --git a/libraries/eina/src/include/eina_refcount.h b/libraries/eina/src/include/eina_refcount.h deleted file mode 100644 index 6650b01..0000000 --- a/libraries/eina/src/include/eina_refcount.h +++ /dev/null @@ -1,76 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 20011 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_REFCOUNT_H_ -#define EINA_REFCOUNT_H_ - -/** - * @addtogroup Eina_Refcount References counting - * - * @brief Small macro that simplify references counting. - * - * References counting is not a difficult task, but you must - * handle it correctly every where, and that the issue. This - * set of macro do provide helper that will force to use the - * correct code in most case and reduce the bug likeliness. - * Of course this without affecting speed ! - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_Refcount References counting - * - * @{ - */ - -/** - * @typedef Eina_Refcount - * Inlined references counting type. - */ -typedef int Eina_Refcount; - -/** Used for declaring a reference counting member in a struct */ -#define EINA_REFCOUNT Eina_Refcount __refcount - -/** Used just after allocating a object */ -#define EINA_REFCOUNT_INIT(Variable) (Variable)->__refcount = 1 - -/** Used when using referring to an object one more time */ -#define EINA_REFCOUNT_REF(Variable) (Variable)->__refcount++ - -/** Used when removing a reference to an object. The code just after will automatically be called when necessary */ -#define EINA_REFCOUNT_UNREF(Variable) \ - if (--((Variable)->__refcount) == 0) - -/** Get refcounting value */ -#define EINA_REFCOUNT_GET(Variable) (Variable)->__refcount - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_REFCOUNT_H_ */ diff --git a/libraries/eina/src/include/eina_safety_checks.h b/libraries/eina/src/include/eina_safety_checks.h deleted file mode 100644 index 4751e5f..0000000 --- a/libraries/eina/src/include/eina_safety_checks.h +++ /dev/null @@ -1,254 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2008 Gustavo Sverzut Barbieri - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_SAFETY_CHECKS_H_ -#define EINA_SAFETY_CHECKS_H_ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Safety_Checks_Group Safety Checks - * - * @warning @c eina_safety_checks.h should only be included by source - * files, after all other includes and before the source file - * specific includes. By source file specific includes we - * mean those that define the functions that are being - * checked. The reason for such complexity is the trick to - * avoid compiler optimizations. If compilers are told that - * some given function will never receive @c NULL - * (EINA_ARG_NONNULL(), then compiler will emit a warning if - * it detects so (good!) but will remove any checks for that - * condition as it believes it will never happen, removing - * all safety checks! By including @c eina_safety_checks.h it - * will redefine EINA_ARG_NONNULL() to void and compiler - * warning will not be emitted, but checks will be there. The - * files already processed with the old macro - * EINA_ARG_NONNULL() will still work and emit the warnings. - * - * - * @code - * - * // all these files will emit warning from EINA_ARG_NONNULL() - * #include // third party headers - * #include - * #include // eina own header - * - * #include - * // all these files below will NOT emit warning from EINA_ARG_NONNULL(), - * // but this is required to have the functions defined there to be checked - * // for NULL pointers - * #include "my_functions1.h" - * #include "my_functions2.h" - * - * @endcode - */ - -/** - * @addtogroup Eina_Safety_Checks_Group Safety Checks - * - * Safety checks are a set of macros to check for parameters or values - * that should never happen, it is similar in concept to assert(), but - * will log and return instead of abort() your program. - * - * Since these cases should never happen, one may wantto keep safety - * checks enabled during tests but disable then during deploy, not - * doing any checks at all. This is a common requirement for embedded - * systems. Whenever to check or not should be set during compile time - * by using @c --disable-safety-checks or @c --enable-safety-checks - * options to @c configure script. - * - * Whenever these macros capture an error, EINA_LOG_ERR() will be - * called and @c eina_error set to @c EINA_ERROR_SAFETY_FAILED and can - * be checked with eina_error_get() after call. - * - * @see EINA_SAFETY_ON_NULL_RETURN(), EINA_SAFETY_ON_NULL_RETURN_VAL() - * and other macros. - * - * @{ - */ - -#include "eina_config.h" -#include "eina_error.h" - -/** - * @var EINA_ERROR_SAFETY_FAILED - * Error identifier corresponding to safety check failure. - */ -EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED; - -#ifdef EINA_SAFETY_CHECKS - -#include "eina_log.h" - -#define EINA_SAFETY_ON_NULL_RETURN(exp) \ - do \ - { \ - if (EINA_UNLIKELY((exp) == NULL)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ - return; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ - do \ - { \ - if (EINA_UNLIKELY((exp) == NULL)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ - return (val); \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ - do \ - { \ - if (EINA_UNLIKELY((exp) == NULL)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ - goto label; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ - do \ - { \ - if (EINA_UNLIKELY(exp)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ - return; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ - do \ - { \ - if (EINA_UNLIKELY(exp)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ - return val; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ - do \ - { \ - if (EINA_UNLIKELY(exp)) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ - goto label; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ - do \ - { \ - if (EINA_UNLIKELY(!(exp))) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ - return; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ - do \ - { \ - if (EINA_UNLIKELY(!(exp))) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ - return val; \ - } \ - } \ - while (0) - -#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ - do \ - { \ - if (EINA_UNLIKELY(!(exp))) \ - { \ - eina_error_set(EINA_ERROR_SAFETY_FAILED); \ - EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ - goto label; \ - } \ - } \ - while (0) - -#ifdef EINA_ARG_NONNULL -/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */ -#undef EINA_ARG_NONNULL -#define EINA_ARG_NONNULL(idx, ...) -#endif - -#else /* no safety checks */ - -#define EINA_SAFETY_ON_NULL_RETURN(exp) \ - do { (void)(!(exp)); } while (0) - -#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ - do { if (0 && !(exp)) { (void)val; } } while (0) - -#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ - do { if (0 && (exp) == NULL) { goto label; } } while (0) - -#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ - do { (void)(exp); } while (0) - -#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ - do { if (0 && (exp)) { (void)val; } } while (0) - -#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ - do { if (0 && (exp)) { goto label; } } while (0) - -#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ - do { (void)(!(exp)); } while (0) - -#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ - do { if (0 && !(exp)) { (void)val; } } while (0) - -#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ - do { if (0 && !(exp)) { goto label; } } while (0) - -#endif /* safety checks macros */ -#endif /* EINA_SAFETY_CHECKS_H_ */ - -/** - * @} - */ - -/** - * @} - */ diff --git a/libraries/eina/src/include/eina_sched.h b/libraries/eina/src/include/eina_sched.h deleted file mode 100644 index 43f32b9..0000000 --- a/libraries/eina/src/include/eina_sched.h +++ /dev/null @@ -1,39 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2010 ProFUSION embedded systems - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_SCHED_H_ -#define EINA_SCHED_H_ - -#include "eina_types.h" - - -/** - * @brief Lower priority of current thread. - * - * It's used by worker threads so they use up background cpu and do not stall - * the main thread If current thread is running with real-time priority, we - * decrease our priority by @c RTNICENESS. This is done in a portable way. - * - * Otherwise (we are running with SCHED_OTHER policy) there's no portable way to - * set the nice level on current thread. In Linux, it does work and it's the - * only one that is implemented as of now. In this case the nice level is - * incremented on this thread by @c NICENESS. - */ -EAPI void eina_sched_prio_drop(void); - -#endif /* EINA_SCHED_H_ */ diff --git a/libraries/eina/src/include/eina_simple_xml_parser.h b/libraries/eina/src/include/eina_simple_xml_parser.h deleted file mode 100644 index 78660ef..0000000 --- a/libraries/eina/src/include/eina_simple_xml_parser.h +++ /dev/null @@ -1,390 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Gustavo Sverzut Barbieri - * Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_SIMPLE_XML_H_ -#define EINA_SIMPLE_XML_H_ - -#include "eina_config.h" - -#include "eina_types.h" -#include "eina_magic.h" -#include "eina_inlist.h" - -/** - * @defgroup Eina_Simple_XML_Group Simple_XML - * - * Simplistic relaxed SAX-like XML parser. - * - * 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 - * and will not vary in future with strange corner cases, then you can - * use it safely. - * - * The parser is SAX like, that is, it will tokenize contents and call - * you back so you can take some action. No contents are allocated - * during this parser work and it's not recursive, so you can use it - * with a very large document without worries. - * - * It will not validate the document anyhow, neither it will create a - * tree hierarchy. That's up to you. - * - * Accordingly to XML, open tags may contain attributes. This parser - * will not tokenize this. If you want you can use - * eina_simple_xml_tag_attributes_find() and then - * eina_simple_xml_attributes_parse(). - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @defgroup Eina_Simple_XML_Group Simple_XML - * - * @{ - */ - -typedef struct _Eina_Simple_XML_Node Eina_Simple_XML_Node; -typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Root; -typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Tag; -typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Data; -typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_CData; -typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Processing; -typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Doctype; -typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Comment; -typedef struct _Eina_Simple_XML_Attribute Eina_Simple_XML_Attribute; - -struct _Eina_Simple_XML_Attribute -{ - EINA_INLIST; - EINA_MAGIC; - - Eina_Simple_XML_Node_Tag *parent; - const char *key; - const char *value; -}; - -typedef enum _Eina_Simple_XML_Node_Type -{ - EINA_SIMPLE_XML_NODE_ROOT = 0, - EINA_SIMPLE_XML_NODE_TAG, - EINA_SIMPLE_XML_NODE_DATA, - EINA_SIMPLE_XML_NODE_CDATA, - EINA_SIMPLE_XML_NODE_PROCESSING, - EINA_SIMPLE_XML_NODE_DOCTYPE, - EINA_SIMPLE_XML_NODE_COMMENT -} Eina_Simple_XML_Node_Type; - -struct _Eina_Simple_XML_Node -{ - EINA_INLIST; - EINA_MAGIC; - - Eina_Simple_XML_Node_Tag *parent; - Eina_Simple_XML_Node_Type type; -}; - -struct _Eina_Simple_XML_Node_Tag -{ - Eina_Simple_XML_Node base; - Eina_Inlist *children; - Eina_Inlist *attributes; - const char *name; -}; - -struct _Eina_Simple_XML_Node_Data -{ - Eina_Simple_XML_Node base; - size_t length; - char data[]; -}; - -typedef enum _Eina_Simple_XML_Type -{ - EINA_SIMPLE_XML_OPEN = 0, /*!< */ - EINA_SIMPLE_XML_OPEN_EMPTY, /*!< */ - EINA_SIMPLE_XML_CLOSE, /*!< */ - EINA_SIMPLE_XML_DATA, /*!< tag text data */ - EINA_SIMPLE_XML_CDATA, /*!< */ - EINA_SIMPLE_XML_ERROR, /*!< error contents */ - EINA_SIMPLE_XML_PROCESSING, /*!< */ - EINA_SIMPLE_XML_DOCTYPE, /*!< */ - EINA_SIMPLE_XML_IGNORED /*!< whatever is ignored by parser, like whitespace */ -} Eina_Simple_XML_Type; - -typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length); -typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *key, const char *value); - - -/** - * Parse a section of XML string text - * - * @param buf the input string. May not contain \0 terminator. - * @param buflen the input string size. - * @param strip whenever this parser should strip leading and trailing - * whitespace. These whitespace will still be issued, but as type - * #EINA_SIMPLE_XML_IGNORED. - * @param func what to call back while parse to do some action. The - * first parameter is the given user @a data, the second is the - * token type, the third is the pointer to content start (it's - * not a NULL terminated string!), the forth is where this - * content is located inside @a buf (does not include tag - * start, for instance "" the offset points at - * "value"), the fifth is the size of the content. Whenever this - * function return EINA_FALSE the parser will abort. @param - * data what to give as context to @a func. - * - * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or - * parsing error. - */ -EAPI Eina_Bool eina_simple_xml_parse(const char *buf, unsigned buflen, - Eina_Bool strip, - Eina_Simple_XML_Cb func, const void *data); - - -/** - * Given the contents of a tag, find where the attributes start. - * - * @param buf the input string. May not contain \0 terminator. - * @param buflen the input string size. - * @return pointer to the start of attributes, it can be used - * to feed eina_simple_xml_attributes_parse(). NULL is returned - * if no attributes were found. - * - * The tag contents is returned by eina_simple_xml_parse() when - * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY. - * - */ -EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen); - -/** - * Given a buffer with xml attributes, parse them to key=value pairs. - * - * @param buf the input string. May not contain \0 terminator. - * @param buflen the input string size. - * @param func what to call back while parse to do some action. The - * first parameter is the given user @a data, the second is the - * key (null-terminated) and the last is the value (null - * terminated). These strings should not be modified and - * reference is just valid until the function return. - * @param data data to pass to the callback function. - * - * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or - * parsing error. - */ -EAPI Eina_Bool eina_simple_xml_attributes_parse(const char *buf, unsigned buflen, - Eina_Simple_XML_Attribute_Cb func, const void *data); - -/** - * Create (and append) new attribute to tag. - * - * @param parent if provided, will be set in the resulting structure - * as well as the attribute will be appended to attributes list. - * @param key null-terminated string. Must not be NULL. - * @param value null-terminated string. If NULL, the empty string will be used. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_attribute_free() or indirectly - * with eina_simple_xml_node_tag_free(). - */ -EAPI Eina_Simple_XML_Attribute * eina_simple_xml_attribute_new(Eina_Simple_XML_Node_Tag *parent, const char *key, const char *value); - -/** - * Remove attribute from parent and delete it. - * - * @param attr attribute to release memory. - */ -EAPI void eina_simple_xml_attribute_free(Eina_Simple_XML_Attribute *attr); - - -/** - * Create new tag. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the tag will be appended to children list. - * @param name null-terminated string. Must not be NULL. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_tag_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_Tag * eina_simple_xml_node_tag_new(Eina_Simple_XML_Node_Tag *parent, const char *name); - -/** - * Remove tag from parent and delete it. - * - * @param tag to release memory. - */ -EAPI void eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag); - - -/** - * Create new data. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the data will be appended to children list. - * @param contents string to be used. Must not be NULL. - * @param length size in bytes of @a contents. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_data_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_Data * eina_simple_xml_node_data_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length); - -/** - * Remove data from parent and delete it. - * - * @param node to release memory. - */ -EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node); - - -/** - * Create new cdata. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the cdata will be appended to children list. - * @param contents string to be used. Must not be NULL. - * @param length size in bytes of @a content. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_cdata_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_CData * eina_simple_xml_node_cdata_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length); - -/** - * Remove cdata from parent and delete it. - * - * @param node to release memory. - */ -EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node); - - -/** - * Create new processing. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the processing will be appended to children list. - * @param contents string to be used. Must not be NULL. - * @param length size in bytes of @a contents. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_processing_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_Processing * eina_simple_xml_node_processing_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length); - -/** - * Remove processing from parent and delete it. - * - * @param node processing to release memory. - */ -EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node); - - -/** - * Create new doctype. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the doctype will be appended to children list. - * @param contents string to be used. Must not be NULL. - * @param length size in bytes of @a contents. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_doctype_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_Doctype * eina_simple_xml_node_doctype_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length); - -/** - * Remove doctype from parent and delete it. - * - * @param node doctype to release memory. - */ -EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node); - - -/** - * Create new comment. If parent is provided, it is automatically appended. - * - * @param parent if provided, will be set in the resulting structure - * as well as the comment will be appended to children list. - * @param contents string to be used. Must not be NULL. - * @param length size in bytes of @a contents. - * - * @return newly allocated memory or NULL on error. This memory should be - * released with eina_simple_xml_node_comment_free() or indirectly - * with eina_simple_xml_node_tag_free() of the parent. - */ -EAPI Eina_Simple_XML_Node_Comment * eina_simple_xml_node_comment_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length); - -/** - * Remove comment from parent and delete it. - * - * @param node comment to release memory. - */ -EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node); - - -/** - * Load a XML node tree based on the given string. - * - * @param buf the input string. May not contain \0 terminator. - * @param buflen the input string size. - * @param strip whenever this parser should strip leading and trailing - * whitespace. - * - * @return document root with children tags, or NULL on errors. - * Document with errors may return partial tree instead of NULL, - * we'll do our best to avoid returning nothing. - */ -EAPI Eina_Simple_XML_Node_Root * eina_simple_xml_node_load(const char *buf, unsigned buflen, Eina_Bool strip); - -/** - * Free node tree build with eina_simple_xml_node_load() - * - * @param root memory returned by eina_simple_xml_node_load() - */ -EAPI void eina_simple_xml_node_root_free(Eina_Simple_XML_Node_Root *root); - -/** - * Converts the node tree under the given element to a XML string. - * - * @param node the base node to convert. - * @param indent indentation string, or NULL to disable it. - * - * @return NULL on errors or a newly allocated string on success. - */ -EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent); - - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_SIMPLE_XML_H_ */ diff --git a/libraries/eina/src/include/eina_str.h b/libraries/eina/src/include/eina_str.h deleted file mode 100644 index 2913fbf..0000000 --- a/libraries/eina/src/include/eina_str.h +++ /dev/null @@ -1,325 +0,0 @@ -#ifndef _EINA_STR_H -#define _EINA_STR_H - -#include -#include - -#include "eina_types.h" - -/** - * @page tutorial_eina_string Eina String example - * @dontinclude eina_str_01.c - * - * Whenever using eina we need to include it: - * @skipline #include - * @line #include - * - * In our main function we declare(and initialize) some variables and initialize - * eina: - * @until eina_init - * - * It's frequentely necessary to split a string into its constituent parts, - * eina_str_split() make's it easy to do so: - * @until printf - * - * Another common need is to make a string uppercase or lowercase, so let's - * create a string and make it uppercase and then make it lowercase again: - * @until printf - * @until printf - * - * Next we use eina to check if our @p names string starts or ends with some - * values: - * @until Has - * - * When strings will be used in a terminal(or a number of other places) it - * necessary to escape certain characters that appear in them: - * @until printf - * - * Much as we previously split a string we will now join two strings: - * @until printf - * - * With strlcpy() we can copy what portion of the @p prologue fits in @p str and - * be sure that it's still NULL terminated: - * @until printf - * - * Since we are done with @p prologue and @p str we should free them: - * @until free(str - * - * Finally we see strlcat in action: - * @until printf(" - * - * And then shut eina down and exit: - * @until } - * @example eina_str_01.c - */ -/** - * @addtogroup Eina_String_Group String - * - * @brief Provide useful functions for C string manipulation. - * - * This group of functions allow you to more easily manipulate strings, they - * provide functionality not available through string.h. - * - * @warning Since these functions modify the strings they can't be used with - * shared strings(eina_stringshare). - * - * See an example @ref tutorial_eina_string "here". - */ - -/** - * @addtogroup Eina_Tools_Group Tools - * - * For more information refer to the @ref tutorial_eina_string "string example". - * - * @{ - */ - -/** - * @defgroup Eina_String_Group String - * - * @{ - */ - -/* strlcpy implementation for libc's lacking it */ - -/** - * @brief Copy a c-string to another. - * - * @param dst The destination string. - * @param src The source string. - * @param siz The size of the destination string. - * @return The length of the source string. - * - * This function copies up to @p siz - 1 characters from the - * NUL-terminated string @p src to @p dst, NUL-terminating the result - * (unless @p siz is equal to 0). The returned value is the length of - * @p src. If the returned value is greater than @p siz, truncation - * occurred. - * - * @note The main difference between eina_strlcpy and strncpy is that this - * ensures @p dst is NULL terminated even if no NULL byte is found in the first - * @p siz bytes of src. - */ -EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a c-string. - * - * @param dst The destination string. - * @param src The source string. - * @param siz The size of the destination string. - * @return The length of the source string plus MIN(siz, strlen(initial dst)) - * - * This function appends @p src to @p dst of size @p siz (unlike - * strncat, @p siz is the full size of @p dst, not space left). At - * most @p siz - 1 characters will be copied. Always NUL terminates - * (unless @p siz <= strlen(dst)). This function returns strlen(src) + - * MIN(siz, strlen(initial dst)). If the returned value is greater or - * equal than @p siz, truncation occurred. - */ -EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2); - - -/** - * @brief Check if the given string has the given prefix. - * - * @param str The string to work with. - * @param prefix The prefix to check for. - * @return #EINA_TRUE if the string has the given prefix, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p str has the prefix - * @p prefix, #EINA_FALSE otherwise. If the length of @p prefix is - * greater than @p str, #EINA_FALSE is returned. - */ -EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Check if the given string has the given suffix. - * - * @param str The string to work with. - * @param suffix The suffix to check for. - * @return #EINA_TRUE if the string has the given suffix, #EINA_FALSE otherwise. - * - * This function returns #EINA_TRUE if @p str has the suffix - * @p suffix, #EINA_FALSE otherwise. If the length of @p suffix is - * greater than @p str, #EINA_FALSE is returned. - */ -EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Check if the given string has the given extension. - * - * @param str The string to work with. - * @param ext The extension to check for. - * @return #EINA_TRUE if the string has the given extension, #EINA_FALSE otherwise. - * - * This function does the same as eina_str_has_suffix(), except it's case - * insensitive. - */ -EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Split a string using a delimiter. - * - * @param string The string to split. - * @param delimiter The string which specifies the places at which to split the string. - * @param max_tokens The maximum number of strings to split string into. - * @return A newly-allocated NULL-terminated array of strings or NULL if it - * fails to allocate the array. - * - * This functin splits @p string into a maximum of @p max_tokens pieces, - * using the given delimiter @p delimiter. @p delimiter is not included in any - * of the resulting strings, unless @p max_tokens is reached. If - * @p max_tokens is less than @c 1, the string is splitted completely. If - * @p max_tokens is reached, the last string in the returned string - * array contains the remainder of string. The returned value is a - * newly allocated NULL-terminated array of strings or NULL if it fails to - * allocate the array. To free it, free the first element of the array and the - * array itself. - * - * @note If you need the number of elements in the returned array see - * eina_str_split_full(). - */ -EAPI char **eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Split a string using a delimiter and returns number of elements. - * - * @param string The string to split. - * @param delimiter The string which specifies the places at which to split the string. - * @param max_tokens The maximum number of strings to split string into. - * @param elements Where to return the number of elements in returned - * array (not counting the terminating @c NULL). May be @c NULL. - * @return A newly-allocated NULL-terminated array of strings or NULL if it - * fails to allocate the array. - * - * This function splits @p string into a maximum of @p max_tokens pieces, - * using the given delimiter @p delimiter. @p delimiter is not included in any - * of the resulting strings, unless @p max_tokens is reached. If - * @p max_tokens is less than @c 1, the string is splitted completely. If - * @p max_tokens is reached, the last string in the returned string - * array contains the remainder of string. The returned value is a - * newly allocated NULL-terminated array of strings or NULL if it fails to - * allocate the array. To free it, free the first element of the array and the - * array itself. - * - * @see eina_str_split() - */ -EAPI char **eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Join two strings of known length. - * - * @param dst The buffer to store the result. - * @param size Size (in byte) of the buffer. - * @param sep The separator character to use. - * @param a First string to use, before @p sep. - * @param a_len length of @p a. - * @param b Second string to use, after @p sep. - * @param b_len length of @p b. - * @return The number of characters printed. - * - * This function joins the strings @p a and @p b (in that order) and - * separate them with @p sep. The result is stored in the buffer - * @p dst and at most @p size - 1 characters will be written and the - * string is NULL-terminated. @p a_len is the length of @p a (not - * including '\\0') and @p b_len is the length of @p b (not including - * '\\0'). This function returns the number of characters printed (not - * including the trailing '\\0' used to end output to strings). Just - * like snprintf(), it will not write more than @p size bytes, thus a - * returned value of @p size or more means that the output was - * truncated. - * - * @see eina_str_join() - * @see eina_str_join_static() - */ -EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6); - - -/** - * @brief Use Iconv to convert a text string from one encoding to another. - * - * @param enc_from Encoding to convert from. - * @param enc_to Encoding to convert to. - * @param text The text to convert. - * @return The converted text. - * - * This function converts @p text, encoded in @p enc_from. On success, - * the converted text is returned and is encoded in @p enc_to. On - * failure, @c NULL is returned. Iconv is used to convert @p text. If - * Iconv is not available, @c NULL is returned. When not used anymore, - * the returned value must be freed. - */ -EAPI char *eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3); - - -/** - * @brief Escape slashes, spaces and apostrophes in strings. - * - * @param str The string to escape. - * @return The escaped string. - * - * Escaping is done by adding a slash "\" before any occurrence of slashes "\", - * spaces " " or apostrophes "'". This function returns a newly allocated - * escaped string on success, @c NULL on failure. When not used anymore, the - * returned value must be freed. - */ -EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1); - - -/** - * @brief Lowercase all the characters in range [A-Z] in the given string. - * - * @param str The string to lowercase. - * - * This function modifies the original string, changing all characters - * in [A-Z] to lowercase. If @p str is @c NULL or is an empty string, - * this function does nothing. - */ -EAPI void eina_str_tolower(char **str); - -/** - * @brief Uppercase all the characters in range [a-z] in the given string. - * - * @param str The string to uppercase. - * - * This function modifies the original string, changing all characters - * in [a-z] to uppercase. If @p str is @c NULL or is an empty string, - * this function does nothing. - */ -EAPI void eina_str_toupper(char **str); - -static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5); - -/** - * @def eina_str_join_static(dst, sep, a, b) - * @brief Join two static strings and store the result in a static buffer. - * - * @param dst The buffer to store the result. - * @param sep The separator character to use. - * @param a First string to use, before @p sep. - * @param b Second string to use, after @p sep. - * @return The number of characters printed. - * - * This function is similar to eina_str_join_len(), but will assume - * string sizes are know using sizeof(X). - * - * @see eina_str_join() - * @see eina_str_join_static() - */ -#define eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0) - -static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -#include "eina_inline_str.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STR_H */ diff --git a/libraries/eina/src/include/eina_strbuf.h b/libraries/eina/src/include/eina_strbuf.h deleted file mode 100644 index 34c200f..0000000 --- a/libraries/eina/src/include/eina_strbuf.h +++ /dev/null @@ -1,623 +0,0 @@ -#ifndef EINA_STRBUF_H -#define EINA_STRBUF_H - -#include -#include - -#include "eina_types.h" - - -/** - * @page tutorial_strbuf Eina_Strbuf example - * @dontinclude eina_strbuf_01.c - * - * First thing always is including Eina: - * @skipline #include - * @until #include - * - * Next we initialize eina and create a string buffer to play with: - * @until strbuf_new - * - * Here you can see two different ways of creating a buffer with the same - * contents. We could create them in simpler ways, but this gives us an - * opportunity to demonstrate several functions in action: - * @until strbuf_reset - * @until strbuf_reset - * - * Next we use the printf family of functions to create a formated string, - * add, remove and replace some content: - * @until strbuf_string_get - * @until strbuf_string_get - * @until strbuf_string_get - * - * Once done we free our string buffer, shut down Eina and end the application: - * @until } - * - * @example eina_strbuf_01.c - */ -/** - * @addtogroup Eina_String_Buffer_Group String Buffer - * - * @brief These functions provide string buffers management. - * - * The String Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. - * - * For more information see @ref tutorial_strbuf "this example". - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_String_Buffer_Group String Buffer - * - * @{ - */ - -/** - * @typedef Eina_Strbuf - * Type for a string buffer. - */ -typedef struct _Eina_Strbuf Eina_Strbuf; - -/** - * @brief Create a new string buffer. - * - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_strbuf_free(). - * - * @see eina_strbuf_free() - * @see eina_strbuf_append() - * @see eina_strbuf_string_get() - */ -EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_strbuf_string_steal . The passed string must be malloced. - * - * @param str the string to manage - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_strbuf_free(). - * - * @see eina_strbuf_free() - * @see eina_strbuf_append() - * @see eina_strbuf_string_get() - * @since 1.1.0 - */ -EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_strbuf_string_steal . The passed string must be malloced. - * - * @param str the string to manage - * @param length the length of the string. - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_strbuf_free(). - * - * @see eina_strbuf_manage_new() - * @since 1.2.0 - */ -EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free a string buffer. - * - * @param buf The string buffer to free. - * - * This function frees the memory of @p buf. @p buf must have been - * created by eina_strbuf_new(). - */ -EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Reset a string buffer. - * - * @param buf The string buffer to reset. - * - * This function reset @p buf: the buffer len is set to 0, and the - * string is set to '\\0'. No memory is free'd. - */ -EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Append a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends @p str to @p buf. It computes the length of - * @p str, so is slightly slower than eina_strbuf_append_length(). If - * the length is known beforehand, consider using that variant. If - * @p buf can't append it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - * - * @see eina_strbuf_append() - * @see eina_strbuf_append_length() - */ -EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append an escaped string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function escapes and then appends the string @p str to @p buf. If @p str - * can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a string to a buffer, reallocating as necessary, - * limited by the given length. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @param maxlen The maximum number of characters to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends at most @p maxlen characters of @p str to - * @p buf. It can't append more than the length of @p str. It - * computes the length of @p str, so it is slightly slower than - * eina_strbuf_append_length(). If the length is known beforehand, - * consider using that variant (@p maxlen should then be checked so - * that it is greater than the size of @p str). If @p str can not be - * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. - * - * @see eina_strbuf_append() - * @see eina_strbuf_append_length() - */ -EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_strbuf_append() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_stringshare. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_strbuf_append() - * @see eina_strbuf_append_n() - */ -EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to append to. - * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf. If it can not insert it, - * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1); - -/** - * @brief Append a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param fmt The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends the string defined by the format @p fmt to @p buf. @p - * fmt must be of a valid format for printf family of functions. If it can't - * insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. - * - * @see eina_strbuf_append() - */ -EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3); - -/** - * @brief Append a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param fmt The string to append. - * @param args The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_strbuf_append_printf() - */ -EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert. - * @param str The string to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf at position @p pos. It - * computes the length of @p str, so is slightly slower than - * eina_strbuf_insert_length(). If the length is known beforehand, - * consider using that variant. If @p buf can't insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert an escaped string to a buffer, reallocating as - * necessary. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function escapes and inserts the string @p str to @p buf at - * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is - * returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param maxlen The maximum number of chars to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf at position @p pos, with at - * most @p maxlen bytes. The number of inserted characters can not be - * greater than the length of @p str. It computes the length of - * @p str, so is slightly slower than eina_strbuf_insert_length(). If the - * length is known beforehand, consider using that variant (@p maxlen - * should then be checked so that it is greater than the size of - * @p str). If @p str can not be inserted, #EINA_FALSE is returned, - * otherwise, #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param length The exact length to use. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_strbuf_insert() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_strbuf_insert() - * @see eina_strbuf_insert_n() - */ -EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to insert to. - * @param c The char to insert. - * @param pos The position to insert the char. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf at position @p pos. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert. - * @param fmt The string to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function insert a string as described by the format @p fmt to @p buf at - * the position @p pos. @p fmt must be of a valid format for printf family of - * functions. If it can't insert it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert. - * @param fmt The string to insert. - * @param pos The position to insert the string. - * @param args The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * @see eina_strbuf_insert_printf - */ -EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2); - -/** - * @def eina_strbuf_prepend(buf, str) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert() at position 0. If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf, str, 0) - -/** - * @def eina_strbuf_prepend_escaped(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_escaped() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0) - -/** - * @def eina_strbuf_prepend_n(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @param maxlen The maximum number of chars to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_n() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0) - -/** - * @def eina_strbuf_prepend_length(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_length() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0) - -/** - * @def eina_strbuf_prepend_char(buf, str) - * @brief Prepend the given character to the given buffer - * - * @param buf The string buffer to prepend to. - * @param c The character to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_char() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_strbuf_prepend_char(buf, c) eina_strbuf_insert_char(buf, c, 0) - -/** - * @def eina_strbuf_prepend_printf(buf, fmt, ...) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param fmt The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_printf() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__) - -/** - * @def eina_strbuf_prepend_vprintf(buf, fmt, args) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param fmt The string to prepend. - * @param args The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_insert_vprintf() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args) - -/** - * @brief Remove a slice of the given string buffer. - * - * @param buf The string buffer to remove a slice. - * @param start The initial (inclusive) slice position to start - * removing, in bytes. - * @param end The final (non-inclusive) slice position to finish - * removing, in bytes. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function removes a slice of @p buf, starting at @p start - * (inclusive) and ending at @p end (non-inclusive). Both values are - * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. - */ - -EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve a pointer to the contents of a string buffer - * - * @param buf The string buffer. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. The returned - * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_strbuf_append() or similar will - * make that pointer invalid. The pointer returned by this function must - * not be freed. - * - * @see eina_strbuf_string_steal() - */ -EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Steal the contents of a string buffer. - * - * @param buf The string buffer to steal. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. @p buf is - * then initialized and does not own the returned string anymore. The - * caller must release the memory of the returned string by calling - * free(). - * - * @see eina_strbuf_string_get() - */ -EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Free the contents of a string buffer but not the buffer. - * - * @param buf The string buffer to free the string of. - * - * This function frees the string contained in @p buf without freeing - * @p buf. - */ -EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve the length of the string buffer content. - * - * @param buf The string buffer. - * @return The current length of the string, in bytes. - * - * This function returns the length of @p buf. - */ -EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - - -/** - * @brief Replace the n-th string with an other string. - * - * @param buf The string buffer to work with. - * @param str The string to replace. - * @param with The replaceing string. - * @param n The number of the fitting string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function replaces the n-th occurrence of @p str in @p buf with - * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. - */ -EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @def eina_strbuf_replace_first(buf, str, with) - * @brief Prepend the given character to the given buffer - * - * @param buf The string buffer to work with. - * @param str The string to replace. - * @param with The replaceing string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_strbuf_replace() with the n-th occurrence - * equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned, - * otherwise #EINA_TRUE is returned. - */ -#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1) - - -/** - * @brief Replace all strings with an other string. - - * @param buf the string buffer to work with. - * @param str The string to replace. - * @param with The replaceing string. - * @return How often the string was replaced. - * - * This function replaces all the occurrences of @p str in @p buf with - * the string @p with. This function returns the number of times @p str - * has been replaced. On failure, it returns 0. - */ -EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Trim the string buffer - - * @param buf the string buffer to work with. - * - * This function skips whitespaces in the beginning and the end of the buffer. - */ -EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Left trim the string buffer - - * @param buf the string buffer to work with. - * - * This function skips whitespaces in the beginning of the buffer. - */ -EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Right trim the string buffer - - * @param buf the string buffer to work with. - * - * This function skips whitespaces in the end of the buffer. - */ -EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRBUF_H */ diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h deleted file mode 100644 index 8edadd2..0000000 --- a/libraries/eina/src/include/eina_stringshare.h +++ /dev/null @@ -1,345 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright (C) 2008 Peter Wehrfritz - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies of the Software and its Copyright notices. In addition publicly - * documented acknowledgment must be given that this software has been used if no - * source code of this software is made available publicly. This includes - * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing - * documents or any documentation provided with any product containing this - * software. This License does not apply to any software that links to the - * libraries provided by this software (statically or dynamically), but only to - * the software provided. - * - * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice - * and it's intent. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef EINA_STRINGSHARE_H_ -#define EINA_STRINGSHARE_H_ - -#include - -#include "eina_types.h" - -/** - * @page eina_stringshare_example_01_page - * @dontinclude eina_stringshare_01.c - * - * Like all examples we start by including Eina: - * @skip #include - * @line #include - * - * Here we declare some variables and initialize eina: - * @until eina_init - * - * We start the substantive part of the example by showing how to make a part - * of a string shared and how to get the length of a shared string: - * @until stringshare_strlen - * As we add shared strings we also need to delete them when done using them: - * @line del - * - * There are many ways of creating shared strings including an equivalent to - * sprintf: - * @until del - * - * An equivalent to snprintf: - * @until printf - * - * But the simplest way of creating a shared string is through - * eina_stringshare_add(): - * @until printf - * - * Sometimes you already have a pointer to a shared string and want to use it, - * so to make sure the provider of the pointer won't free it while you're using - * it you can increase the shared string's ref count: - * @until printf - * - * Whenever you have a pointer to a shared string and would like to change it's - * value you should use eina_stringshare_replace(): - * @until printf - * @warning @b Don't use eina_stringshare_del() followed by - * eina_share_common_add(), under some circunstances you might end up deleting - * a shared string some other piece of code is using. - * - * We created str but haven't deleted it yet, and while we called - * eina_stringshare_del() on str2, we created it and then increased the ref - * count so it's still alive: - * @until str2 - * - * You can see the full source code @ref eina_stringshare_example_01 "here". - */ -/** - * @page eina_stringshare_example_01 - * @include eina_stringshare_01.c - * @example eina_stringshare_01.c - */ -/** - * @addtogroup Eina_Stringshare_Group Stringshare - * - * These functions allow you to store a single copy of a string, and use in - * multiple places throughout your program. - * - * This is a method to reduce the number of duplicated strings kept in - * memory. It's pretty common for the same strings to be dynamically - * allocated repeatedly between applications and libraries, especially in - * circumstances where you could have multiple copies of a structure that - * allocates the string. So rather than duplicating and freeing these - * strings, you request a read-only pointer to an existing string and - * only incur the overhead of a hash lookup. - * - * 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 - * string creation/destruction speed, reduces memory use and decreases - * 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 still - * exist the string share will live until those are released. - * - * The following diagram gives an idea of what happens as you create strings - * with eina_stringshare_add(): - * - * @image html eina_stringshare.png - * @image latex eina_stringshare.eps height=\textheight - * - * For more information, see @ref eina_stringshare_example_01_page - * "this example". - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @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. - * - * @param str The string to retrieve an instance of. - * @param slen The string size (<= strlen(str)). - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * 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 - * is just returned and its reference counter is increased. Otherwise - * a duplicated string of @p str is returned. - * - * This function does not check string size, but uses the - * exact given size. This can be used to share_common part of a larger - * buffer or substring. - * - * @see eina_share_common_add() - */ -EAPI Eina_Stringshare *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Retrieve an instance of a string for use in a program. - * - * @param str The NULL terminated string to retrieve an instance of. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * 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 - * is just returned and its reference counter is increased. Otherwise - * a duplicated string of @p str is returned. - * - * 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 - * terminated, use eina_stringshare_add_length() instead. - * - * @see eina_stringshare_add_length() - */ -EAPI Eina_Stringshare *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Retrieve an instance of a string for use in a program - * from a format string. - * - * @param fmt The NULL terminated format string to retrieve an instance of. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * 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 - * is just returned and its reference counter is increased. Otherwise - * a duplicated string is returned. - * - * 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 - * terminated, use eina_stringshare_nprintf() instead. - * - * @see eina_stringshare_nprintf() - */ -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 - * from a format string. - * - * @param fmt The NULL terminated format string to retrieve an instance of. - * @param args The va_args for @p fmt - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * This function retrieves an instance of @p fmt with @p args. If @p fmt is - * @c NULL, then @c NULL is returned. If @p fmt with @p args is already stored, it - * is just returned and its reference counter is increased. Otherwise - * a duplicated string is returned. - * - * 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 - * terminated, use eina_stringshare_nprintf() instead. - * - * @see eina_stringshare_nprintf() - */ -EAPI Eina_Stringshare *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Retrieve an instance of a string for use in a program - * from a format string with size limitation. - * @param len The length of the format string to use - * @param fmt The format string to retrieve an instance of. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * This function retrieves an instance of @p fmt limited by @p len. If @p fmt is - * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting string - * is already stored, it is returned and its reference counter is increased. - * Otherwise a duplicated string is returned. - * - * @p len length of the format string will be used. To use the - * entire format string, use eina_stringshare_printf() instead. - * - * @see eina_stringshare_printf() - */ -EAPI Eina_Stringshare *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); - -/** - * Increment references of the given shared string. - * - * @param str The shared string. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * This is similar to eina_share_common_add(), but it's faster since it will - * avoid lookups if possible, but on the down side it requires the parameter - * to be shared string. In other words, it must be the return of a previous - * call to one of the stringshare functions. - * - * There is no unref since this is the work of eina_share_common_del(). - */ -EAPI Eina_Stringshare *eina_stringshare_ref(Eina_Stringshare *str); - -/** - * @brief Note that the given string has lost an instance. - * - * @param str string The given string. - * - * This function decreases the reference counter associated to @p str - * if it exists. If that counter reaches 0, the memory associated to - * @p str is freed. If @p str is NULL, the function returns - * immediately. - * - * Note that if the given pointer is not shared or NULL, bad things - * will happen, likely a segmentation fault. - */ -EAPI void eina_stringshare_del(Eina_Stringshare *str); - -/** - * @brief Note that the given string @b must be shared. - * - * @param str the shared string to know the length. It is safe to - * give NULL, in that case -1 is returned. - * @return The length of a shared string. - * - * This function is a cheap way to known the length of a shared - * string. Note that if the given pointer is not shared, bad - * things will happen, likely a segmentation fault. If in doubt, try - * strlen(). - */ -EAPI int eina_stringshare_strlen(Eina_Stringshare *str) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Dump the contents of the share_common. - * - * This function dumps all strings in the share_common to stdout with a - * DDD: prefix per line and a memory usage summary. - */ -EAPI void eina_stringshare_dump(void); - -static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, const char *news) EINA_ARG_NONNULL(1); -static inline Eina_Bool eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1); - -#include "eina_inline_stringshare.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRINGSHARE_H_ */ diff --git a/libraries/eina/src/include/eina_tiler.h b/libraries/eina/src/include/eina_tiler.h deleted file mode 100644 index 5272099..0000000 --- a/libraries/eina/src/include/eina_tiler.h +++ /dev/null @@ -1,310 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_TILER_H_ -#define EINA_TILER_H_ - -#include "eina_types.h" -#include "eina_iterator.h" -#include "eina_rectangle.h" - -/** - * @page eina_tiler_example_01 - * @dontinclude eina_tiler_01.c - * - * 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: - * x++ - * 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 given by the tiler. The rectangles will be added one by one every - * two seconds. A lot of the example deals with actually painting the rectangles - * so we'll skip over quite a bit of code, but you can see all of it in @ref - * eina_tiler_01.c "eina_tiler_01.c". - * - * The first thing of note in our example is the creation of the tiler: - * @skipline eina_tiler_new - * @note @p maxw and @p maxh are calculated such that the tiler's size will - * fully encompass all given rectangles. - * - * We'll now look at the function that actually adds rectangles to our tiler. It - * first checks if we added all rectangles already and if so stops right there: - * @dontinclude eina_tiler_01.c - * @skip static Eina_Bool - * @until } - * - * Our function then clears all rectangles given to us by tiler from the last - * execution. It does this because each rectangle we add may change everything - * about the output of eina_tiler: - * @until output_rects_reset - * - * Next we get another rectangle, print it and show it in the input panel: - * @until add_input_rect - * - * We now come to the tiler stuff, we add our new rectangle to it and get a new - * iterator for the tiler: - * @until itr - * - * We now iterate over our tiler printing every rect it gives us and sowing it - * in the output panel: - * @until } - * - * We of course must remember to free our iterator and that's it for this - * function: - * @until } - * - * You should try many different inputs to see how the tiler works, here are a - * few suggestions: - * @li 100x100+0+0 100x100+200+200 - * @li 100x100+0+0 100x100+5+5 100x100+10+10 100x100+15+15 100x100+20+20 - * @li 100x100+0+0 100x100+100+100 100x100+200+0 100x100+0+200 100x100+200+200 - * @li 10x10+0+0 10x10+10+10 10x10+20+0 10x10+0+20 10x10+20+20 - * - * @example eina_tiler_01.c - */ -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_Tiler_Group Tiler - * - * @warning This is a very low level tool, in most situations(for example if - * you're using evas) you won't need this. - * - * @section basic Basic usage - * - * Eina_Tiler is a tool to facilitate calculations of which areas are damaged - * and thus need to be re-rendered. The basic usage of Eina_Tiler is to give it - * the size of your canvas and a set of rectangular areas that need - * re-rendering, from that and using heuristics it'll tell you an efficient way - * to re-render in the form of a set of non-overlapping rectangles that covers - * the whole area that needs re-rendering. - * - * The following is pseudo-code showing some simple use of Eina_Tiler: - * @code - * tiler = eina_tiler_new(MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT); - * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering, l, rect) - * eina_tiler_add(tiler, rect); - * itr = eina_tiler_iterator_new(tiler); - * EINA_ITERATOR_FOREACH(itr, rect) - * my_function_that_repaints_areas_of_the_canvas(rect); - * @endcode - * - * @see eina_tiler_new() - * @see eina_tiler_rect_add() - * @see eina_tiler_iterator_new() - * - * @warning There are no guarantees that this will be the most efficient way to - * re-render for any particular case. - * - * @section grid_slicer Grid Slicer - * - * 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 API - * to divide an area in tiles which is usefull in certain applications to divide - * the area that will be rendered into tiles. It's customary to, then create one - * Eina_Tiler for each tile. - * - * The following is pseudo-code showing a very simplified use of grid slicer - * together with Eina_Tiler: - * @code - * itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT, TILE_WIDTH, TILE_HEIGHT); - * EINA_ITERATOR_FOREACH(itr, grid_info) - * { - * tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w); - * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering_in_this_tile, l, rect) - * eina_tiler_add(tiler, rect); - * itr = eina_tiler_iterator_new(tiler); - * EINA_ITERATOR_FOREACH(itr, rect) - * my_function_that_repaints_areas_of_the_canvas(rect); - * } - * @endcode - * - * @see eina_tiler_new() - * @see eina_tiler_rect_add() - * @see eina_tile_grid_slicer_setup() - * @see eina_tile_grid_slicer_next() - * @see eina_tile_grid_slicer_iterator_new() - * - * @{ - */ - -/** - * @typedef Eina_Tiler - * Tiler type. - */ -typedef struct _Eina_Tiler Eina_Tiler; - -/** - * @typedef Eina_Tile_Grid_Info - * Grid type of a tiler. - */ -typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info; - -/** - * @struct Eina_Tile_Grid_Info - * Grid type of a tiler. - */ -struct Eina_Tile_Grid_Info -{ - unsigned long col; /**< column of the tile grid */ - unsigned long row; /**< row of the tile grid*/ - Eina_Rectangle rect; /**< rectangle of the tile grid, coordinates are - relative to tile*/ - Eina_Bool full; /**< whether the grid is full or not */ -}; - -typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer; - -/** - * @brief Creates a new tiler with @p w width and @p h height. - * - * @param w Width of the tiler - * @param h Height of the tiler - * @return The newly created tiler - * - * @see eina_tiler_free() - */ -EAPI Eina_Tiler *eina_tiler_new(int w, int h); -/** - * @brief Frees a tiler. - * - * @param t The tiler to free. - * - * This function frees @p t. It does not free the memory allocated for the - * elements of @p t. - */ -EAPI void eina_tiler_free(Eina_Tiler *t); -/** - * @brief Sets the size of tiles for a tiler. - * - * @param t The tiler whose tile size will be set. - * @param w Width of the tiles. - * @param h Height of the tiles. - * - * @warning @p w and @p h @b must be greater than zero, otherwise tile size - * won't be changed. - * @warning Tile size is not used! - */ -EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h); -/** - * @brief Adds a rectangle to a tiler. - * - * @param t The tiler in which to add a container. - * @param r The rectangle to be added. - * - * @see eina_tiler_rect_del() - */ -EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r); -/** - * @brief Removes a rectangle from a tiler. - * - * @param t The tiler in which to add a container. - * @param r The rectangle to be removed. - * - * @see eina_tiler_rect_add() - * @see eina_tiler_clear() - */ -EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r); -/** - * @brief Removes all rectangles from tiles. - * - * @param t The tiler to clear. - * - * @see eina_tiler_rect_del() - */ -EAPI void eina_tiler_clear(Eina_Tiler *t); -/** - * @brief Create a iterator to access the tilers calculated rectangles. - * - * @param t The tiler to iterate over. - * @return A iterator containing Eina_Rectangle. - */ -EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t); - -/** - * @brief Creates a new Eina_Iterator that iterates over a list of tiles. - * - * @param x X axis coordinate. - * @param y Y axis coordinate. - * @param w width. - * @param h height. - * @param tile_w tile width. - * @param tile_h tile height. - * @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 grid of - * tiles of width @a tile_w and height @p tile_h, the returned iterator will - * iterate over every tile in the grid having as its data a - * #Eina_Tile_Grid_Info. - * - * @note This is a convinience function, iterating over the returned iterator is - * equivalent to calling eina_tile_grid_slicer_setup() and calling - * eina_tile_grid_slicer_next() untill it returns EINA_FALSE. - */ -EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h); -/** - * @brief Iterates over the tiles set by eina_tile_grid_slicer_setup(). - * - * @param slc Pointer to an Eina_Tile_Grid_Slicer struct. - * @param rect Pointer to a struct Eina_Tile_Grid_Info *. - * @return @c EINA_TRUE if the current rect is valid. - * @c EINA_FALSE if there is no more rects to iterate over (and - * thus the current one isn't valid). - * - * This functions iterates over each Eina_Tile_Grid_Info *rect of the grid. - * eina_tile_grid_slicer_setup() must be called first, and *rect is only valid - * if this function returns EINA_TRUE. Its content shouldn't be modified. - * - * @note Consider using eina_tile_grid_slicer_iterator_new() instead. - */ -static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect); -/** - * @brief Setup an Eina_Tile_Grid_Slicer struct. - * - * @param slc Pointer to an Eina_Tile_Grid_Slicer struct. - * @param x X axis coordinate. - * @param y Y axis coordinate. - * @param w width. - * @param h height. - * @param tile_w tile width. - * @param tile_h tile height. - * @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 grid of - * tiles of width @a tile_w and height @p tile_h, @p slc can then be used with - * eina_tile_grid_slicer_next() to access each tile. - * - * @note Consider using eina_tile_grid_slicer_iterator_new() instead. - */ -static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h); - -#include "eina_inline_tiler.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_TILER_H_ */ diff --git a/libraries/eina/src/include/eina_trash.h b/libraries/eina/src/include/eina_trash.h deleted file mode 100644 index f53d99e..0000000 --- a/libraries/eina/src/include/eina_trash.h +++ /dev/null @@ -1,100 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_TRASH_H__ -#define EINA_TRASH_H__ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Trash_Group Trash - * - * @{ - */ - -/** - * @typedef Eina_Trash - * Type for a generic container of unused allocated pointer. - */ -typedef struct _Eina_Trash Eina_Trash; - -/** - * @struct _Eina_Trash - * Type for a generic container of unused allocated pointer. - */ -struct _Eina_Trash -{ - Eina_Trash *next; /**< next item in trash. */ -}; - -static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1); -static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1); -static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @def EINA_TRASH_CLEAN - * @brief Macro to remove all pointer from the trash. - * - * @param trash The trash to clean. - * @param data The pointer extracted from the trash. - * - * This macro allow the cleaning of @p trash in an easy way. It will - * remove all pointers from @p trash until it's empty. - * - * This macro can be used for freeing the data in the trash, like in - * the following example: - * - * @code - * Eina_Trash *trash = NULL; - * char *data; - * - * // trash is filled with pointer to some duped strings. - * - * EINA_TRASH_CLEAN(&trash, data) - * free(data); - * @endcode - * - * @note this macro is useful when you implement some memory pool. - */ -#define EINA_TRASH_CLEAN(trash, data) while ((data = eina_trash_pop(trash))) - -#include "eina_inline_trash.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_TRASH_H_ */ diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h deleted file mode 100644 index b0a7cf8..0000000 --- a/libraries/eina/src/include/eina_types.h +++ /dev/null @@ -1,300 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_TYPES_H_ -#define EINA_TYPES_H_ - -/** - * @addtogroup Eina_Core_Group Core - * - * @{ - */ - -/** - * @defgroup Eina_Types_Group Types - * - * @{ - */ - -#ifdef EAPI -# undef EAPI -#endif - -#ifdef _WIN32 -# ifdef EFL_EINA_BUILD -# ifdef DLL_EXPORT -# define EAPI __declspec(dllexport) -# else -# define EAPI -# endif /* ! DLL_EXPORT */ -# else -# define EAPI __declspec(dllimport) -# endif /* ! EFL_EINA_BUILD */ -#else -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else -# define EAPI -# endif -# else -# define EAPI -# endif -#endif - -#include "eina_config.h" - -#ifdef EINA_WARN_UNUSED_RESULT -# undef EINA_WARN_UNUSED_RESULT -#endif -#ifdef EINA_ARG_NONNULL -# undef EINA_ARG_NONNULL -#endif -#ifdef EINA_DEPRECATED -# undef EINA_DEPRECATED -#endif -#ifdef EINA_MALLOC -# undef EINA_MALLOC -#endif -#ifdef EINA_PURE -# undef EINA_PURE -#endif -#ifdef EINA_PRINTF -# undef EINA_PRINTF -#endif -#ifdef EINA_SCANF -# undef EINA_SCANF -#endif -#ifdef EINA_FORMAT -# undef EINA_FORMAT -#endif -#ifdef EINA_CONST -# undef EINA_CONST -#endif -#ifdef EINA_NOINSTRUMENT -# undef EINA_NOINSTRUMENT -#endif -#ifdef EINA_UNLIKELY -# undef EINA_UNLIKELY -#endif -#ifdef EINA_LIKELY -# undef EINA_LIKELY -#endif - -#ifdef __GNUC__ -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# define EINA_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) -# else -# define EINA_WARN_UNUSED_RESULT -# endif - -# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((__nonnull__(idx, ## __VA_ARGS__))) -# else -# define EINA_ARG_NONNULL(idx, ...) -# endif - -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -# define EINA_DEPRECATED __attribute__ ((__deprecated__)) -# else -# define EINA_DEPRECATED -# endif - -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define EINA_MALLOC __attribute__ ((__malloc__)) -# define EINA_PURE __attribute__ ((__pure__)) -# else -# define EINA_MALLOC -# define EINA_PURE -# endif - -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3) -# define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__gnu_printf__, fmt, arg))) -# else -# 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_LIKELY(exp) __builtin_expect((exp), 1) -# else -# define EINA_PRINTF(fmt, arg) -# define EINA_SCANF(fmt, arg) -# define EINA_FORMAT(fmt) -# define EINA_CONST -# define EINA_NOINSTRUMENT -# define EINA_UNLIKELY(exp) exp -# define EINA_LIKELY(exp) exp -# endif - -#elif defined(_WIN32) -# define EINA_WARN_UNUSED_RESULT -# define EINA_ARG_NONNULL(idx, ...) -# if defined(_MSC_VER) && _MSC_VER >= 1300 -# define EINA_DEPRECATED __declspec(deprecated) -# else -# define EINA_DEPRECATED -# endif -# define EINA_MALLOC -# define EINA_PURE -# define EINA_PRINTF(fmt, arg) -# define EINA_SCANF(fmt, arg) -# define EINA_FORMAT(fmt) -# define EINA_CONST -# define EINA_NOINSTRUMENT -# define EINA_UNLIKELY(exp) exp -# define EINA_LIKELY(exp) exp - -#elif defined(__SUNPRO_C) -# define EINA_WARN_UNUSED_RESULT -# define EINA_ARG_NONNULL(...) -# define EINA_DEPRECATED -# if __SUNPRO_C >= 0x590 -# define EINA_MALLOC __attribute__ ((malloc)) -# define EINA_PURE __attribute__ ((pure)) -# else -# define EINA_MALLOC -# define EINA_PURE -# endif -# define EINA_PRINTF(fmt, arg) -# define EINA_SCANF(fmt, arg) -# define EINA_FORMAT(fmt) -# if __SUNPRO_C >= 0x590 -# define EINA_CONST __attribute__ ((const)) -# else -# define EINA_CONST -# endif -# define EINA_NOINSTRUMENT -# define EINA_UNLIKELY(exp) exp -# define EINA_LIKELY(exp) exp - -#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */ - -/** - * @def EINA_WARN_UNUSED_RESULT - * Used to warn when the returned value of the function is not used. - */ -# define EINA_WARN_UNUSED_RESULT - -/** - * @def EINA_ARG_NONNULL - * Used to warn when the specified arguments of the function are @c NULL. - */ -# define EINA_ARG_NONNULL(idx, ...) - -/** - * @def EINA_DEPRECATED - * Used to warn when the function is considered as deprecated. - */ -# define EINA_DEPRECATED -# define EINA_MALLOC -# define EINA_PURE -# define EINA_PRINTF(fmt, arg) -# define EINA_SCANF(fmt, arg) -# define EINA_FORMAT(fmt) -# define EINA_CONST -# define EINA_NOINSTRUMENT -# define EINA_UNLIKELY(exp) exp -# define EINA_LIKELY(exp) exp -#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */ - -/** - * @typedef Eina_Bool - * Type to mimic a boolean. - * - * @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 - * also take as few bytes as possible. - */ -typedef unsigned char Eina_Bool; - -/** - * @def EINA_FALSE - * boolean value FALSE (numerical value 0) - */ -#define EINA_FALSE ((Eina_Bool)0) - -/** - * @def EINA_TRUE - * boolean value TRUE (numerical value 1) - */ -#define EINA_TRUE ((Eina_Bool)1) - -EAPI extern const unsigned int eina_prime_table[]; - -/** - * @typedef Eina_Compare_Cb - * Function used in functions using sorting. It compares @p data1 and - * @p data2. If @p data1 is 'less' than @p data2, -1 must be returned, - * if it is 'greater', 1 must be returned, and if they are equal, 0 - * must be returned. - */ -typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2); - -/** - * @def EINA_COMPARE_CB - * Macro to cast to Eina_Compare_Cb. - */ -#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) - -/** - * @typedef Eina_Each_Cb - * A callback type used when iterating over a container. - */ -typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata); - -/** - * @def EINA_EACH_CB - * Macro to cast to Eina_Each. - */ -#define EINA_EACH_CB(Function) ((Eina_Each_Cb)Function) - -/** - * @typedef Eina_Free_Cb - * A callback type used to free data when iterating over a container. - */ -typedef void (*Eina_Free_Cb)(void *data); - -/** - * @def EINA_FREE_CB - * Macro to cast to Eina_Free_Cb. - */ -#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_ */ diff --git a/libraries/eina/src/include/eina_unicode.h b/libraries/eina/src/include/eina_unicode.h deleted file mode 100644 index 2bbfe45..0000000 --- a/libraries/eina/src/include/eina_unicode.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef EINA_UNICODE_H -#define EINA_UNICODE_H - -#include - -#include "eina_config.h" -#include "eina_types.h" - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ -/** - * @addtogroup Eina_Unicode_String Unicode String - * - * @brief These functions provide basic unicode string handling - * - * Eina_Unicode is a type that holds unicode codepoints. - * - * @{ - */ - -/** - * @typedef Eina_Unicode - * A type that holds Unicode codepoints. - */ -#if EINA_SIZEOF_WCHAR_T >= 4 -# include -typedef wchar_t Eina_Unicode; -#elif defined(EINA_HAVE_INTTYPES_H) -# include -typedef uint32_t Eina_Unicode; -#elif defined(EINA_HAVE_STDINT_H) -# include -typedef uint32_t Eina_Unicode; -#else -/* Hope that int is big enough */ -typedef unsigned int Eina_Unicode; -#endif - - -/** - * @brief Same as the standard strlen just with Eina_Unicode instead of char. - */ -EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING; - -EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - -/** - * @brief Returns the length of a Eina_Unicode string, up to a limit. - * - * This function returns the number of characters in string, up to a maximum - * of n. If the terminating character is not found in the string, it returns - * n. - * - * @param ustr String to search - * @param n Max length to search - * @return Number of characters or n. - */ -EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE; - - -/** - * @brief Same as the standard strdup just with Eina_Unicode instead of char. - */ -EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - - -/** - * @brief Same as strdup but cuts on the given size. Assumes n < len - * - * @param text The text to duplicate. - * @param n The maximum size of the text to duplicate. - * @return The duplicated string. - * - * This function duplicates @p text. The resuting string is cut on @p - * n. @p n is assumed to be lesser (<) than the length of @p - * text. When not needed anymore, the returned string must be freed. - * - * @since 1.1.0 - */ -EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - - -/** - * @brief Same as the standard strcmp just with Eina_Unicode instead of char. - */ -EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE; - - -/** - * @brief Same as the standard strcpy just with Eina_Unicode instead of char. - */ -EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source) EINA_ARG_NONNULL(1, 2); - - -/** - * @brief Same as the standard strstr just with Eina_Unicode instead of char. - */ -EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE; - - -/** - * @brief Same as the standard strncpy just with Eina_Unicode instead of char. - */ -EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n) EINA_ARG_NONNULL(1, 2); - - -/** - * @see eina_str_escape() - */ -EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/* UTF-8 Handling */ - - -/** - * Reads UTF8 bytes from @p buf, starting at @p iindex and returns - * the decoded code point at @p iindex offset, and advances @p iindex - * to the next code point after this. @p iindex is always advanced, - * unless if the advancement is after the NULL. - * On error: return a codepoint between DC80 to DCFF where the low 8 bits - * are the byte's value. - * - * @param buf the string - * @param iindex the index to look at and return by. - * @return the codepoint found. - * @since 1.1.0 - */ -EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); - -/** - * Reads UTF8 bytes from @p buf, starting at @p iindex and returns - * the decoded code point at @p iindex offset, and moves Ă p iindex - * to the previous code point. @p iindex is always moved, as long - * as it's not past the start of the string. - * On error: return a codepoint between DC80 to DCFF where the low 8 bits - * are the byte's value. - * - * @param buf the string - * @param iindex the index to look at and return by. - * @return the codepoint found. - * @since 1.1.0 - */ -EAPI Eina_Unicode eina_unicode_utf8_get_prev(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); - -/** - * Returns the number of unicode characters in the string. That is, - * the number of Eina_Unicodes it'll take to store this string in - * an Eina_Unicode string. - * - * @param buf the string - * @return the number of unicode characters (not bytes) in the string - * @since 1.1.0 - */ -EAPI int eina_unicode_utf8_get_len(const char *buf) EINA_ARG_NONNULL(1); - -/** - * Converts a utf-8 string to a newly allocated Eina_Unicode string. - * - * @param utf the string in utf-8 - * @param _len the length of the returned Eina_Unicode string. - * @return the newly allocated Eina_Unicode string. - * @since 1.1.0 - */ -EAPI Eina_Unicode *eina_unicode_utf8_to_unicode(const char *utf, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * Converts an Eina_Unicode string to a newly allocated utf-8 string. - * - * @param uni the Eina_Unicode string - * @param _len the length byte length of the return utf8 string. - * @return the newly allocated utf-8 string. - * @since 1.1.0 - */ -EAPI char * eina_unicode_unicode_to_utf8(const Eina_Unicode *uni, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; - -/** - * @} - */ -/** - * @} - */ - -#endif diff --git a/libraries/eina/src/include/eina_ustrbuf.h b/libraries/eina/src/include/eina_ustrbuf.h deleted file mode 100644 index 9710c42..0000000 --- a/libraries/eina/src/include/eina_ustrbuf.h +++ /dev/null @@ -1,464 +0,0 @@ -#ifndef EINA_USTRBUF_H -#define EINA_USTRBUF_H - -#include - -#include "eina_types.h" -#include "eina_unicode.h" - -/** - * @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer - * - * @brief These functions provide unicode string buffers management. - * - * The Unicode String Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer - * - * @{ - */ - -/** - * @typedef Eina_UStrbuf - * Type for a string buffer. - */ -typedef struct _Eina_Strbuf Eina_UStrbuf; - -/** - * @brief Create a new string buffer. - * - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_ustrbuf_free(). - * - * @see eina_ustrbuf_free() - * @see eina_ustrbuf_append() - * @see eina_ustrbuf_string_get() - */ -EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_ustrbuf_string_steal . The passed string must be malloced. - * - * @param str the string to manage - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_strbuf_free(). - * - * @see eina_ustrbuf_free() - * @see eina_ustrbuf_append() - * @see eina_ustrbuf_string_get() - * @since 1.1.0 - */ -EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Create a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_ustrbuf_string_steal . The passed string must be malloced. - * - * @param str the string to manage - * @param length the length of the string. - * @return Newly allocated string buffer instance. - * - * This function creates a new string buffer. On error, @c NULL is - * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To - * free the resources, use eina_ustrbuf_free(). - * - * @see eina_ustrbuf_manage_new() - * @since 1.2.0 - */ -EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free a string buffer. - * - * @param buf The string buffer to free. - * - * This function frees the memory of @p buf. @p buf must have been - * created by eina_ustrbuf_new(). - */ -EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Reset a string buffer. - * - * @param buf The string buffer to reset. - * - * This function reset @p buf: the buffer len is set to 0, and the - * string is set to '\\0'. No memory is free'd. - */ -EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Append a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends @p str to @p buf. It computes the length of - * @p str, so is slightly slower than eina_ustrbuf_append_length(). If - * the length is known beforehand, consider using that variant. If - * @p buf can't append it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - * - * @see eina_ustrbuf_append() - * @see eina_ustrbuf_append_length() - */ -EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append an escaped string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends the escaped string @p str to @p buf. If @p - * str can not be appended, #EINA_FALSE is returned, otherwise, - * #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a string to a buffer, reallocating as necessary, - * limited by the given length. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @param maxlen The maximum number of characters to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends at most @p maxlen characters of @p str to - * @p buf. It can't appends more than the length of @p str. It - * computes the length of @p str, so is slightly slower than - * eina_ustrbuf_append_length(). If the length is known beforehand, - * consider using that variant (@p maxlen should then be checked so - * that it is greater than the size of @p str). If @p str can not be - * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. - * - * @see eina_ustrbuf_append() - * @see eina_ustrbuf_append_length() - */ -EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to append to. - * @param str The string to append. - * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function appends @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_ustrbuf_append() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_ustrbuf_append() - * @see eina_ustrbuf_append_n() - */ -EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Append a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to append to. - * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf. If it can not insert it, - * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert. - * @param str The string to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf at position @p pos. It - * computes the length of @p str, so is slightly slower than - * eina_ustrbuf_insert_length(). If the length is known beforehand, - * consider using that variant. If @p buf can't insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert an escaped string to a buffer, reallocating as - * necessary. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts the escaped string @p str to @p buf at - * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is - * returned, otherwise #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param maxlen The maximum number of chars to insert. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str ot @p buf at position @p pos, with at - * most @p maxlen bytes. The number of inserted characters can not be - * greater than the length of @p str. It computes the length of - * @p str, so is slightly slower than eina_ustrbuf_insert_length(). If the - * length is known beforehand, consider using that variant (@p maxlen - * should then be checked so that it is greater than the size of - * @p str). If @p str can not be inserted, #EINA_FALSE is returned, - * otherwise, #EINA_TRUE is returned. - */ -EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a string of exact length to a buffer, reallocating as necessary. - * - * @param buf The string buffer to insert to. - * @param str The string to insert. - * @param length The exact length to use. - * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_ustrbuf_insert() as - * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - * - * @see eina_stringshare_length() - * @see eina_ustrbuf_insert() - * @see eina_ustrbuf_insert_n() - */ -EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Insert a character to a string buffer, reallocating as - * necessary. - * - * @param buf The string buffer to insert to. - * @param c The char to insert. - * @param pos The position to insert the char. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function inserts @p c to @p buf at position @p pos. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1); - -/** - * @def eina_ustrbuf_prepend(buf, str) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0) - -/** - * @def eina_ustrbuf_prepend_escaped(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_escaped() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0) - -/** - * @def eina_ustrbuf_prepend_n(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @param maxlen The maximum number of Eina_Unicode *s to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_n() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0) - -/** - * @def eina_ustrbuf_prepend_length(buf, str) - * @brief Prepend the given escaped string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param str The string to prepend. - * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_length() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0) - -/** - * @def eina_ustrbuf_prepend_char(buf, c) - * @brief Prepend the given unicode character to the given buffer - * - * @param buf The string buffer to prepend to. - * @param c The Eina_Unicode character to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise - * #EINA_TRUE is returned. - */ -#define eina_ustrbuf_prepend_char(buf, c) eina_ustrbuf_insert_char(buf, c, 0) - -/** - * @def eina_ustrbuf_prepend_printf(buf, fmt, ...) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param fmt The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__) - -/** - * @def eina_ustrbuf_prepend_vprintf(buf, fmt, args) - * @brief Prepend the given string to the given buffer - * - * @param buf The string buffer to prepend to. - * @param fmt The string to prepend. - * @param args The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This macro is calling eina_ustrbuf_insert_vprintf() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. - */ -#define eina_ustrbuf_prepend_vprintf(buf, fmt, args) eina_ustrbuf_insert_vprintf(buf, fmt, 0, args) - -/** - * @brief Remove a slice of the given string buffer. - * - * @param buf The string buffer to remove a slice. - * @param start The initial (inclusive) slice position to start - * removing, in bytes. - * @param end The final (non-inclusive) slice position to finish - * removing, in bytes. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. - * - * This function removes a slice of @p buf, starting at @p start - * (inclusive) and ending at @p end (non-inclusive). Both values are - * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. - */ -EAPI Eina_Bool -eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve a pointer to the contents of a string buffer - * - * @param buf The string buffer. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. The returned - * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_ustrbuf_append() or similar will - * make that pointer invalid. - * - * @see eina_ustrbuf_string_steal() - */ -EAPI const Eina_Unicode * -eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Steal the contents of a string buffer. - * - * @param buf The string buffer to steal. - * @return The current string in the string buffer. - * - * This function returns the string contained in @p buf. @p buf is - * then initialized and does not own the returned string anymore. The - * caller must release the memory of the returned string by calling - * free(). - * - * @see eina_ustrbuf_string_get() - */ -EAPI Eina_Unicode * -eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - -/** - * @brief Free the contents of a string buffer but not the buffer. - * - * @param buf The string buffer to free the string of. - * - * This function frees the string contained in @p buf without freeing - * @p buf. - */ -EAPI void -eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieve the length of the string buffer content. - * - * @param buf The string buffer. - * @return The current length of the string, in bytes. - * - * This function returns the length of @p buf. - */ -EAPI size_t -eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRBUF_H */ diff --git a/libraries/eina/src/include/eina_ustringshare.h b/libraries/eina/src/include/eina_ustringshare.h deleted file mode 100644 index 1036573..0000000 --- a/libraries/eina/src/include/eina_ustringshare.h +++ /dev/null @@ -1,200 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright (C) 2008 Peter Wehrfritz - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies of the Software and its Copyright notices. In addition publicly - * documented acknowledgment must be given that this software has been used if no - * source code of this software is made available publicly. This includes - * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing - * documents or any documentation provided with any product containing this - * software. This License does not apply to any software that links to the - * libraries provided by this software (statically or dynamically), but only to - * the software provided. - * - * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice - * and it's intent. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef EINA_USTRINGSHARE_H_ -#define EINA_USTRINGSHARE_H_ - -#include "eina_types.h" -#include "eina_unicode.h" - -/** - * @addtogroup Eina_UStringshare_Group Unicode Stringshare - * - * These functions allow you to store one copy of a string, and use it - * throughout your program. - * - * This is a method to reduce the number of duplicated strings kept in - * memory. It's pretty common for the same strings to be dynamically - * allocated repeatedly between applications and libraries, especially in - * circumstances where you could have multiple copies of a structure that - * allocates the string. So rather than duplicating and freeing these - * strings, you request a read-only pointer to an existing string and - * only incur the overhead of a hash lookup. - * - * 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 - * string creation/destruction speed, reduces memory use and decreases - * memory fragmentation, so a win all-around. - * - * For more information, you can look at the @ref tutorial_ustringshare_page. - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @{ - */ - -/** - * @defgroup Eina_UStringshare_Group Unicode Stringshare - * - * @{ - */ - - -/** - * @brief Retrieve an instance of a string for use in a program. - * - * @param str The string to retrieve an instance of. - * @param slen The string size (<= strlen(str)). - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * 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 - * is just returned and its reference counter is increased. Otherwise - * it is added to the strings to be searched and a duplicated string - * of @p str is returned. - * - * This function does not check string size, but uses the - * exact given size. This can be used to share_common part of a larger - * buffer or substring. - * - * @see eina_ustringshare_add() - */ -EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Retrieve an instance of a string for use in a program. - * - * @param str The NULL terminated string to retrieve an instance of. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * 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 - * is just returned and its reference counter is increased. Otherwise - * it is added to the strings to be searched and a duplicated string - * of @p str is returned. - * - * 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 - * terminated, use eina_stringshare_add_length() instead. - * - * @see eina_ustringshare_add_length() - */ -EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT; - -/** - * Increment references of the given shared string. - * - * @param str The shared string. - * @return A pointer to an instance of the string on success. - * @c NULL on failure. - * - * This is similar to eina_share_common_add(), but it's faster since it will - * avoid lookups if possible, but on the down side it requires the parameter - * to be shared before, in other words, it must be the return of a previous - * eina_ustringshare_add(). - * - * There is no unref since this is the work of eina_ustringshare_del(). - */ -EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str); - -/** - * @brief Note that the given string has lost an instance. - * - * @param str string The given string. - * - * This function decreases the reference counter associated to @p str - * if it exists. If that counter reaches 0, the memory associated to - * @p str is freed. If @p str is NULL, the function returns - * immediately. - * - * Note that if the given pointer is not shared or NULL, bad things - * will happen, likely a segmentation fault. - */ -EAPI void eina_ustringshare_del(const Eina_Unicode *str); - -/** - * @brief Note that the given string @b must be shared. - * - * @param str the shared string to know the length. It is safe to - * give NULL, in that case -1 is returned. - * - * This function is a cheap way to known the length of a shared - * string. Note that if the given pointer is not shared, bad - * things will happen, likely a segmentation fault. If in doubt, try - * strlen(). - */ -EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT; - -/** - * @brief Dump the contents of the share_common. - * - * This function dumps all strings in the share_common to stdout with a - * DDD: prefix per line and a memory usage summary. - */ -EAPI void eina_ustringshare_dump(void); - -static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1); -static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1); - -#include "eina_inline_ustringshare.x" - -/** - * @} - */ - -/** - * @} - */ - -#endif /* EINA_STRINGSHARE_H_ */ diff --git a/libraries/eina/src/include/eina_value.h b/libraries/eina/src/include/eina_value.h deleted file mode 100644 index 341781f..0000000 --- a/libraries/eina/src/include/eina_value.h +++ /dev/null @@ -1,3533 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2012 ProFUSION embedded systems - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_VALUE_H_ -#define EINA_VALUE_H_ - -#include - -#include "eina_types.h" -#include "eina_fp.h" /* defines int64_t and uint64_t */ -#include "eina_inarray.h" -#include "eina_list.h" -#include "eina_hash.h" - -/** - * @page eina_value_example_01_page Eina_Value usage - * @dontinclude eina_value_01.c - * - * This very simple example shows how to use some of the basic features of eina - * value: setting and getting values, converting between types and printing a - * value as a string. - * - * Our main function starts out with the basic, declaring some variables and - * initializing eina: - * @until eina_init - * - * Now we can jump into using eina value. We set a value, get this value and - * then print it: - * @until printf - * - * In the above snippet of code we printed an @c int value, we can however print - * the value as a string: - * @until free - * - * And once done with a value it's good practice to destroy it: - * @until eina_value_flush - * - * We now reuse @c v to store a string, get its value and print it: - * @until printf - * @note Since @c s is the value and not returned by @c eina_value_to_string() - * we don't need to free it. - * - * Just because we stored a string doesn't mean we can't use the @c - * eina_value_to_string() function, we can and it's important to note that it - * will return not the stored string but rather a copy of it(one we have to - * free): - * @until eina_value_flush - * - * And now to explore conversions between two type we'll create another value: - * @until eina_value_setup - * - * And make sure @c v and @c otherv have different types: - * @until eina_value_setup - * - * We then set a value to @c v and have it converted, to do this we don't need - * to tell to which type we want to convert, we just say were we want to store - * the converted value and eina value will figure out what to convert to, and - * how: - * @until eina_value_convert - * - * And now let's check the conversion worked: - * @until printf - * - * But converting to strings is not particularly exciting, @c - * eina_value_to_string() already did that, so now let's make the conversion the - * other way around, from string to @c int: - * @until printf - * - * And once done, destroy the values: - * @until } - * - * Full source code: @ref eina_value_01_c - */ - -/** - * @page eina_value_01_c eina_value_01.c - * @include eina_value_01.c - * @example eina_value_01.c - */ - -/** - * @page eina_value_example_02_page Eina_Value struct usage - * @dontinclude eina_value_02.c - * - * This example will examine a hypothetical situation in which we had a - * structure(which represented parameters) with two fields, and then need to add - * a third field to our structure. If using structs directly we'd need to - * rewrite every piece of code that touches the struct, by using eina value, and - * thus having the compiler not even know the struct, we can reduce the amount - * of changes needed and retain interoperability between the old and new format. - * - * Our example will start with a function that creates descriptions of both of - * our structs for eina value usage. The first step is to create a struct and - * describe its members: - * @until v1_members[1] - * @note We can't pass the types of the members to EINA_VALUE_STRUCT_MEMBER - * macro because they are not constant initializers. - * - * So far it should be pretty easy to understand, we said @c My_Struct_V1 has - * two members, one of type @c int and another of type @c char. We now create - * the description of the actual struct, again nothing overly complex, we signal - * which version of EINA_VALUE_STRUCT we're using, we declare no special - * operations, our members and our size: - * @until V1_DESC - * - * We now repeat the process for the second version of our struct, the only - * difference is the addition of a third parameter of type @c int : - * @until V2_DESC - * @until } - * - * We'll now look at a function that sets the values of our structs. For - * simplicity's sake we initialize it we random values, a real world case would - * read these values from a file, a database or even from the network. The - * fundamental detail here is that this function works for both V1 and V2 - * structs, this is because setting a parameter that a struct that doesn't have - * does nothing without throwing any errors: - * @until } - * @note While using eina_value_struct_set() with an in-existing parameter - * causes no error, it does return #EINA_FALSE, to notify it was not possible - * to set the value. This could be used to determine that we're handling a V1 - * struct and take some action based on that. - * - * The next thing is to do is see what a function that uses the values of the - * struct looks like. We'll again be very simplistic in our usage, we'll just - * print the values, but a real world case, might send these values to another - * process use them to open a network/database connection or anything else. - * Since all versions of the struct have @c param1 and @c param2 we'll - * unconditionally use them: - * @until printf - * - * The next step is to conditionally use @c param3, which can fortunately be - * done in the same step in which we get it's value: - * @until } - * - * There we've now got functions that can both populate and use values from both - * our structs, so now let's actually use them in our main function by creating - * a struct of each type, initializing them and them using them: - * @until } - * - * This concludes our example. For the full source code see @ref - * eina_value_02_c. - */ - -/** - * @page eina_value_02_c eina_value_02.c - * @include eina_value_02.c - * @example eina_value_02.c - */ - -/** - * @page eina_value_example_03_page Eina value custom type example - * @dontinclude eina_value_03.c - * - * For this example we'll be creating our own custom type of eina value. Eina - * value can already store struct timeval(man gettimeofday for more information) - * but it has no type to store struct timezone, so that's what this example will - * do. - * @note struct timezone is actually obsolete, so using it in real world - * programs is probably not a good idea, but this is an example so, bear with - * us. - * - * To create our own custom eina value type we need to define functions to - * do the following operations on it: - * @li Setup - * @li Flush - * @li Copy - * @li Compare - * @li Set - * @li Get - * @li Conversion - * - * Most of this functions are very simple, so let's look at them, starting with - * setup which only clear the memory so that we can be certain we won't be using - * stale data: - * @until } - * - * Now the flush function, which is even simpler, it does nothing, that's - * because there is nothing we need to do, all the necessary steps are taken by - * eina value itself: - * @until } - * - * Our next function, copy, is a bit more interesting, but not much, it just - * casts our void pointers to struct timezone pointers and does the copy: - * @until } - * @note By now you might be wondering why our functions receive void pointers - * instead of pointers to struct timezone, and this is a good point. The reason - * for this is that eina value doesn't know anything about our type so it must - * use a generic void pointer, casting that pointer into a proper value is the - * job of the implementor of the new type. - * - * Next we have the comparison function, which compares the @c tz_minuteswest - * field of struct timezone, we don't compare @c tz_dsttime because that field - * is not used in linux: - * @until } - * - * Next we have setting, this however requires not one but rather two functions, - * the reason for this is because to be able to receive arguments of any type - * eina value uses @ref https://wikipedia.org/wiki/Variadic_functions "variadic - * functions", so we need a function to get the argument from a va_list and - * another to actually to the setting. - * - * Lets first look at the pset function which sets the received value to a - * pointer: - * @until } - * - * Next we have the vset function which get the argument from the va_list and - * passes it to the pset function: - * @until } - * - * And now the function to get the value, a very simple copying of the value to - * the given pointer: - * @until } - * - * And finally our conversion function, this is our longest and most interesting - * one. For numeric type we simply assign the value of @c tz_minuteswest to the - * new type and call a set function using it: - * @until EINA_VALUE_TYPE_DOUBLE - * @until return - * @note It would be a good idea to add checks for over and underflow for these - * types and return #EINA_FALSE in thoses cases, we omit this here for brevity. - * - * For string types we use @c snprintf() to format our @c tz_minuteswest field - * and put it in a string(again @c tz_dsttime is ignored because it's not used): - * @until } - * - * Finally we handle any other types by returning an error in that case: - * @until } - * - * Now that we have all the functions, we can populate an @c Eina_Value_Type to - * later use it with @c eina_value_setup(): - * @until } - * - * We can now finally use our new TZ_TYPE with eina value, so lets conclude our - * example by practicing that by setting its value and printing it: - * @until } - * - * For the full source code see @ref eina_value_03_c. - */ - -/** - * @page eina_value_03_c eina_value_03.c - * @include eina_value_03.c - * @example eina_value_03.c - */ - -/** - * @addtogroup Eina_Data_Types_Group Data Types - * - * @since 1.2 - * - * @{ - */ - -/** - * @addtogroup Eina_Containers_Group Containers - * - * @{ - */ - -/** - * @defgroup Eina_Value_Group Generic Value Storage - * - * Abstracts generic data storage and access to it in an extensible - * and efficient way. - * - * It comes with pre-defined types for numbers, array, list, hash, - * blob and structs. It is able to convert between data types, - * including to string. - * - * It is meant for simple data types, providing uniform access and - * release functions, useful to exchange data preserving their - * types. For more complex hierarchical data, with properties and - * children, reference counting, inheritance and interfaces, see @ref - * Eina_Model_Group. - * - * Examples of usage of the Eina_Value API: - * @li @ref eina_value_example_01_page - * @li @ref eina_value_example_02_page - * @li @ref eina_value_example_03_page - * - * @{ - */ - - -/** - * @typedef Eina_Value - * Store generic values. - * - * @since 1.2 - */ -typedef struct _Eina_Value Eina_Value; - -/** - * @typedef Eina_Value_Type - * Describes the data contained by the value - * - * @since 1.2 - */ -typedef struct _Eina_Value_Type Eina_Value_Type; - -/** - * @typedef Eina_Value_Union - * Union of all known value types. - * - * This is only used to specify the minimum payload memory for #Eina_Value. - * - * @internal - * @since 1.2 - */ -typedef union _Eina_Value_Union Eina_Value_Union; - -/** - * @union _Eina_Value_Union - * All possible value types. - * - * This is only used to specify the minimum payload memory for #Eina_Value. - * - * @internal - * @since 1.2 - */ -union _Eina_Value_Union -{ - unsigned char buf[8]; /**< just hold 8-bytes, more goes into ptr */ - void *ptr; /**< used as generic pointer */ - uint64_t _guarantee; /**< guarantees 8-byte alignment */ -}; - -/** - * @var EINA_VALUE_TYPE_UCHAR - * manages unsigned char type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR; - -/** - * @var EINA_VALUE_TYPE_USHORT - * manages unsigned short type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_USHORT; - -/** - * @var EINA_VALUE_TYPE_UINT - * manages unsigned int type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT; - -/** - * @var EINA_VALUE_TYPE_ULONG - * manages unsigned long type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG; - -/** - * @var EINA_VALUE_TYPE_TIMESTAMP - * manages unsigned long type used for timestamps. - * @note this is identical in function to EINA_VALUE_TYPE_ULONG - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMESTAMP; - -/** - * @var EINA_VALUE_TYPE_UINT64 - * manages unsigned integer of 64 bits type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT64; - -/** - * @var EINA_VALUE_TYPE_CHAR - * manages char type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_CHAR; - -/** - * @var EINA_VALUE_TYPE_SHORT - * manages short type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_SHORT; - -/** - * @var EINA_VALUE_TYPE_INT - * manages int type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT; - -/** - * @var EINA_VALUE_TYPE_LONG - * manages long type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LONG; - -/** - * @var EINA_VALUE_TYPE_INT64 - * manages integer of 64 bits type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT64; - -/** - * @var EINA_VALUE_TYPE_FLOAT - * manages float type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT; - -/** - * @var EINA_VALUE_TYPE_DOUBLE - * manages double type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE; - -/** - * @var EINA_VALUE_TYPE_STRINGSHARE - * manages stringshared string type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE; - -/** - * @var EINA_VALUE_TYPE_STRING - * manages string type. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING; - - -/** - * @var EINA_VALUE_TYPE_ARRAY - * - * manages array type. Use the value get/set for arrays: - * @li eina_value_array_get() and eina_value_array_set() - * @li eina_value_array_vget() and eina_value_array_vset() - * @li eina_value_array_pget() and eina_value_array_pset() - * - * eina_value_set() takes an #Eina_Value_Array where just @c subtype - * and @c step are used. If there is an @c array, it will be copied - * (including each item) and its contents must be properly - * configurable as @c subtype expects. eina_value_pset() takes a - * pointer to an #Eina_Value_Array. For your convenience, use - * eina_value_array_setup(). - * - * eina_value_get() and eina_value_pget() takes a pointer to - * #Eina_Value_Array, it's an exact copy of the current structure in - * use by value, no copies are done. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY; - -/** - * @var EINA_VALUE_TYPE_LIST - * - * manages list type. Use the value get/set for lists: - * @li eina_value_list_get() and eina_value_list_set() - * @li eina_value_list_vget() and eina_value_list_vset() - * @li eina_value_list_pget() and eina_value_list_pset() - * - * eina_value_set() takes an #Eina_Value_List where just @c subtype is - * used. If there is an @c list, it will be copied (including each - * item) and its contents must be properly configurable as @c - * subtype expects. eina_value_pset() takes a pointer to an - * #Eina_Value_List. For your convenience, use - * eina_value_list_setup(). - * - * eina_value_get() and eina_value_pget() takes a pointer to - * #Eina_Value_List, it's an exact copy of the current structure in - * use by value, no copies are done. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST; - -/** - * @var EINA_VALUE_TYPE_HASH - * - * manages hash type. Use the value get/set for hashes: - * @li eina_value_hash_get() and eina_value_hash_set() - * @li eina_value_hash_vget() and eina_value_hash_vset() - * @li eina_value_hash_pget() and eina_value_hash_pset() - * - * eina_value_set() takes an #Eina_Value_Hash where just @c subtype - * and @c buckets_power_size are used. If there is an @c hash, it will - * be copied (including each item) and its contents must be - * properly configurable as @c subtype expects. eina_value_pset() - * takes a pointer to an #Eina_Value_Hash. For your convenience, use - * eina_value_hash_setup(). - * - * eina_value_get() and eina_value_pget() takes a pointer to - * #Eina_Value_Hash, it's an exact copy of the current structure in - * use by value, no copies are done. - * - * @note be aware that hash data is always an allocated memory of size - * defined by @c subtype->value_size. If your @c subtype is an - * integer, add as data malloc(sizeof(int)). If your @c subtype - * is an string, add as data malloc(sizeof(char*)) and this data - * value must point to strdup(string)! - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_HASH; - -/** - * @var EINA_VALUE_TYPE_TIMEVAL - * manages 'struct timeval' type - * - * eina_value_set() takes a "struct timeval" from sys/time.h. - * eina_value_pset() takes a pointer to "struct timeval". - * - * eina_value_get() and eina_value_pget() takes a pointer to "struct - * timeval" and it's an exact copy of value. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL; - -/** - * @var EINA_VALUE_TYPE_BLOB - * manages blob of bytes type, see @ref Eina_Value_Blob - * - * eina_value_set() takes an #Eina_Value_Blob - * eina_value_pset() takes a pointer to #Eina_Value_Blob. - * - * eina_value_get() and eina_value_pget() takes a pointer to - * #Eina_Value_Blob and it's an exact copy of value, no allocations - * are made. - * - * Memory is untouched unless you provide @c ops (operations) pointer. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB; - -/** - * @var EINA_VALUE_TYPE_STRUCT - * - * manages struct type. Use the value get/set for structs: - * @li eina_value_struct_get() and eina_value_struct_set() - * @li eina_value_struct_vget() and eina_value_struct_vset() - * @li eina_value_struct_pget() and eina_value_struct_pset() - * - * eina_value_set() takes an #Eina_Value_Struct where just @c desc is - * used. If there is an @c memory, it will be copied (including each - * member) and its contents must be properly configurable as @c desc - * expects. eina_value_pset() takes a pointer to an - * #Eina_Value_Struct. For your convenience, use - * eina_value_struct_setup(). - * - * eina_value_get() and eina_value_pget() takes a pointer to - * #Eina_Value_Struct, it's an exact copy of the current structure in - * use by value, no copies are done. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT; - -/** - * @var EINA_VALUE_TYPE_MODEL - * - * manages Eina_Model type. Use the value get/set to change the model - * in use, it will increase the reference while in use by the value. - * - * eina_value_set() takes a pointer to #Eina_Model, increasing the - * reference. - * - * eina_value_get() takes a pointer to pointer to #Eina_Model, it's an - * exact copy of the current model, no copies are done, no references - * are increased. - * - * @since 1.2 - */ -EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_MODEL; - -/** - * @var EINA_ERROR_VALUE_FAILED - * Error identifier corresponding to value check failure. - * - * @since 1.2 - */ -EAPI extern int EINA_ERROR_VALUE_FAILED; - -/** - * @defgroup Eina_Value_Value_Group Generic Value management - * - * @{ - */ - -/** - * @struct _Eina_Value - * defines the contents of a value - * - * @since 1.2 - */ -struct _Eina_Value -{ - const Eina_Value_Type *type; /**< how to access values */ - Eina_Value_Union value; /**< to be accessed with type descriptor */ -}; - -/** - * @brief Create generic value storage. - * @param type how to manage this value. - * @return The new value or @c NULL on failure. - * - * Create a new generic value storage. The members are managed using - * the description specified by @a type. - * - * Some types may specify more operations: - * eg. #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(), - * eina_value_array_get() and so on. - * - * On failure, @c NULL is returned and either #EINA_ERROR_OUT_OF_MEMORY or - * #EINA_ERROR_VALUE_FAILED is set. - * - * @note this calls creates from mempool and then uses - * eina_value_setup(). Consider using eina_value_flush() and - * eina_value_setup() instead to avoid memory allocations. - * - * @see eina_value_free() - * - * @since 1.2 - */ -EAPI Eina_Value *eina_value_new(const Eina_Value_Type *type) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT; - -/** - * @brief Free value and its data. - * @param value value object - * - * @see eina_value_flush() - * - * @since 1.2 - */ -EAPI void eina_value_free(Eina_Value *value) EINA_ARG_NONNULL(1); - - -/** - * @brief Initialize generic value storage. - * @param value value object - * @param type how to manage this value. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Initializes existing generic value storage. The members are managed using the - * description specified by @a type. - * - * Some types may specify more operations, as an example - * #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(), - * eina_value_array_get() and so on. - * - * @note Existing contents are ignored! If the value was previously used, then - * use eina_value_flush() first. - * - * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY - * or #EINA_ERROR_VALUE_FAILED is set. - * - * @see eina_value_flush() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_setup(Eina_Value *value, - const Eina_Value_Type *type) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Create generic value storage. - * @param value value object - * - * Releases all the resources associated with an #Eina_Value. The - * value must be already set with eina_value_setup() or - * eina_value_new(). - * - * After this call returns, the contents of the value are undefined, - * but the value can be reused by calling eina_value_setup() again. - * - * @see eina_value_setup() - * @see eina_value_free() - * - * @since 1.2 - */ -static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1); - -/** - * @brief Copy generic value storage. - * @param value source value object - * @param copy destination value object - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The @a copy object is considered uninitialized and its existing - * contents are overwritten (just as if eina_value_flush() was called on - * it). - * - * The copy happens by calling eina_value_setup() on @a copy, followed - * by getting the contents of @a value and setting it to @a copy. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_value_copy(const Eina_Value *value, - Eina_Value *copy) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Compare generic value storage. - * @param a left side of comparison - * @param b right side of comparison - * @return less than zero if a < b, greater than zero if a > b, zero - * if a == b - * - * @since 1.2 - */ -static inline int eina_value_compare(const Eina_Value *a, - const Eina_Value *b) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Set the generic value. - * @param value source value object - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); - * int x = 567; - * eina_value_set(value, 1234); - * eina_value_set(value, x); - * - * eina_value_flush(value); - * - * eina_value_setup(value, EINA_VALUE_TYPE_STRING); - * eina_value_set(value, "hello world!"); - * - * eina_value_free(value); - * @endcode - * - * @note for array member see eina_value_array_set() - * @note for list member see eina_value_list_set() - * @note for hash member see eina_value_hash_set() - * - * @see eina_value_get() - * @see eina_value_vset() - * @see eina_value_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_set(Eina_Value *value, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value. - * @param value source value object - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * The variable argument is dependent on chosen type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); - * int x; - * const char *s; - * - * eina_value_set(value, 1234); - * eina_value_get(value, &x); - * - * eina_value_flush(value); - * - * eina_value_setup(value, EINA_VALUE_TYPE_STRING); - * eina_value_set(value, "hello world!"); - * eina_value_get(value, &s); - * - * eina_value_free(value); - * @endcode - * - * @note for array member see eina_value_array_get() - * @note for list member see eina_value_list_get() - * @note for hash member see eina_value_hash_get() - * - * @see eina_value_set() - * @see eina_value_vset() - * @see eina_value_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_get(const Eina_Value *value, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value. - * @param value source value object - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * @note for array member see eina_value_array_vset() - * @note for list member see eina_value_list_vset() - * @note for hash member see eina_value_hash_vset() - * - * @see eina_value_vget() - * @see eina_value_set() - * @see eina_value_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_vset(Eina_Value *value, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value. - * @param value source value object - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * @note for array member see eina_value_array_vget() - * @note for list member see eina_value_list_vget() - * @note for hash member see eina_value_hash_vget() - * - * @see eina_value_vset() - * @see eina_value_get() - * @see eina_value_pget() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_vget(const Eina_Value *value, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value from pointer. - * @param value source value object - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); - * int x = 567; - * const char *s = "hello world!"; - * - * eina_value_pset(value, &x); - * - * eina_value_flush(value); - * - * eina_value_setup(value, EINA_VALUE_TYPE_STRING); - * eina_value_pset(value, &s); - * - * eina_value_free(value); - * @endcode - * - * @note for array member see eina_value_array_pset() - * @note for list member see eina_value_list_pset() - * @note for hash member see eina_value_hash_pset() - * - * @see eina_value_pget() - * @see eina_value_set() - * @see eina_value_vset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_pset(Eina_Value *value, - const void *ptr) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Get the generic value to pointer. - * @param value source value object - * @param ptr pointer to receive the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in pointer contents, the actual value is - * type-dependent, but usually it will be what is stored inside the - * object. There shouldn't be any memory allocation, thus the contents - * should @b not be freed. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * - * @code - * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); - * int x; - * const char *s; - * - * eina_value_set(value, 1234); - * eina_value_pget(value, &x); - * - * eina_value_flush(value); - * - * eina_value_setup(value, EINA_VALUE_TYPE_STRING); - * eina_value_set(value, "hello world!"); - * eina_value_pget(value, &s); - * - * eina_value_free(value); - * @endcode - * - * @note for array member see eina_value_array_get() - * @note for list member see eina_value_list_get() - * @note for hash member see eina_value_hash_get() - * - * @see eina_value_set() - * @see eina_value_vset() - * @see eina_value_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_pget(const Eina_Value *value, - void *ptr) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Convert one value to another type. - * @param value source value object. - * @param convert destination value object. - * @return #EINA_TRUE if converted, #EINA_FALSE otherwise. - * - * Converts one value to another trying first @a value type - * @c convert_to() function. If unsuccessful, tries using @c convert_from() - * function in @a convert. - * - * Conversion functions are type defined, and the basic types can convert - * between themselves, but conversion is strict! That is, if - * converting from negative value to unsigned type, it will fail. It - * also fails on value overflow. - * - * It is recommended that all types implement at least convert to - * string, used by eina_value_to_string(). - * - * @note Both objects must have eina_value_setup() called on them beforehand! - * - * @since 1.2 - */ -EAPI Eina_Bool eina_value_convert(const Eina_Value *value, - Eina_Value *convert) EINA_ARG_NONNULL(1, 2); - - -/** - * @brief Convert value to string. - * @param value value object. - * @return newly allocated memory or @c NULL on failure. - * - * @see eina_value_convert() - * @since 1.2 - */ -EAPI char *eina_value_to_string(const Eina_Value *value) EINA_ARG_NONNULL(1); - -/** - * @brief Query value type. - * @param value value object. - * @return type instance or @c NULL if type is invalid. - * - * Check if value type is valid and returns it. A type is invalid if - * it does not exist or if it is using a different version field. - * - * @see eina_value_type_check() - * - * @since 1.2 - */ -static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @} - */ - - -/** - * @defgroup Eina_Value_Array_Group Generic Value Array management - * - * @{ - */ - - -/** - * @typedef Eina_Value_Array - * Value type for #EINA_VALUE_TYPE_ARRAY. - * - * @see #_Eina_Value_Array explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Array Eina_Value_Array; - -/** - * @struct _Eina_Value_Array - * Used to store the array and its subtype. - * @since 1.2 - */ -struct _Eina_Value_Array -{ - const Eina_Value_Type *subtype; /**< how to allocate and access items */ - unsigned int step; /**< how to grow the members array */ - Eina_Inarray *array; /**< the array that holds data, members are of subtype->value_size bytes. */ -}; - -/** - * @brief Create generic value storage of type array. - * @param subtype how to manage this array members. - * @param step how to grow the members array. - * @return The new value or @c NULL on failure. - * - * Create a new generic value storage of type array. The members are - * managed using the description specified by @a subtype. - * - * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or - * #EINA_ERROR_VALUE_FAILED is set. - * - * @note this creates from mempool and then uses - * eina_value_array_setup(). @see eina_value_free() @see - * eina_value_array_setup() - * - * @since 1.2 - */ -EAPI Eina_Value *eina_value_array_new(const Eina_Value_Type *subtype, - unsigned int step) EINA_ARG_NONNULL(1); - -/** - * @brief Initialize generic value storage of type array. - * @param value value object - * @param subtype how to manage array members. - * @param step how to grow the members array. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Initializes new generic value storage of type array with the given - * @a subtype. - * - * This is the same as calling eina_value_set() with - * #EINA_VALUE_TYPE_ARRAY followed by eina_value_pset() with the - * #Eina_Value_Array description configured. - * - * @note Existing contents are ignored! If the value was previously used, then - * use eina_value_flush() first. - * - * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY - * or #EINA_ERROR_VALUE_FAILED is set. - * - * @see eina_value_flush() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_setup(Eina_Value *value, - const Eina_Value_Type *subtype, - unsigned int step) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Query number of elements in value of array type. - * @param value value object. - * @return number of child elements. - * @since 1.2 - */ -static inline unsigned int eina_value_array_count(const Eina_Value *value); - -/** - * @brief Remove element at given position in value of array type. - * @param value value object. - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_remove(Eina_Value *value, - unsigned int position) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an array member. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_array_append(value, 1234); - * eina_value_array_set(value, 0, 5678); - * eina_value_array_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_set(Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an array member. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, and the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation; - * thus the contents should @b not be freed. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_array_append(value, 1234); - * eina_value_array_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_get(const Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Insert a generic value in an array member position. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_array_insert(value, 0, 1234); - * eina_value_array_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_insert(Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - - -/** - * @brief Append a generic value in an array. - * @param value source value object - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_array_append(value, 1234); - * eina_value_array_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_append(Eina_Value *value, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Set a generic value to an array member. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_pset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_vset(Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an array member. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * @see eina_value_array_vset() - * @see eina_value_array_get() - * @see eina_value_array_pget() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_vget(const Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); -/** - * @brief Insert a generic value to an array member position. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * @see eina_value_array_insert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_vinsert(Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Append a generic value to an array. - * @param value source value object - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vget() - * @see eina_value_array_pset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_vappend(Eina_Value *value, - va_list args) EINA_ARG_NONNULL(1); - - -/** - * @brief Set a generic value to an array member from a pointer. - * @param value source value object - * @param position index of the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x = 1234; - * - * eina_value_array_append(value, 1234); - * eina_value_array_pset(value, 0, &x); - * eina_value_array_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_pset(Eina_Value *value, - unsigned int position, - const void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Retrieve a generic value into a pointer from an array member. - * @param value source value object - * @param position index of the member - * @param ptr pointer to receive the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in pointer contents, the actual value is - * type-dependent, but usually it will be what is stored inside the - * object. There shouldn't be any memory allocation, thus the contents - * should @b not be freed. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_array_append(value, 1234); - * eina_value_array_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_vset() - * @see eina_value_array_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_pget(const Eina_Value *value, - unsigned int position, - void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Insert a generic value to an array member position from a pointer. - * @param value source value object - * @param position index of the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x = 1234; - * - * eina_value_array_pinsert(value, 0, &x); - * eina_value_array_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_pinsert(Eina_Value *value, - unsigned int position, - const void *ptr) EINA_ARG_NONNULL(1); - -/** - * @brief Append a generic value to an array from a pointer. - * @param value source value object - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); - * int x = 1234; - * - * eina_value_array_pappend(value, &x); - * eina_value_array_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_array_set() - * @see eina_value_array_get() - * @see eina_value_array_vset() - * @see eina_value_array_insert() - * @see eina_value_array_vinsert() - * @see eina_value_array_pinsert() - * @see eina_value_array_append() - * @see eina_value_array_vappend() - * @see eina_value_array_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_pappend(Eina_Value *value, - const void *ptr) EINA_ARG_NONNULL(1); - -/** - * @brief Retrieves a value from the array as an Eina_Value copy. - * @param value source value object - * @param position index of the member - * @param dst where to return the array member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The argument @a dst is considered uninitialized and it's setup to - * the type of the member. - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src, - unsigned int position, - Eina_Value *dst) EINA_ARG_NONNULL(1, 3); - -/** - * @} - */ - - -/** - * @defgroup Eina_Value_List_Group Generic Value List management - * - * @{ - */ - - -/** - * @typedef Eina_Value_List - * Value type for #EINA_VALUE_TYPE_LIST. - * - * @see #_Eina_Value_List explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_List Eina_Value_List; - -/** - * @struct _Eina_Value_List - * Used to store the list and its subtype. - * @since 1.2 - */ -struct _Eina_Value_List -{ - const Eina_Value_Type *subtype; /**< how to allocate and access items */ - Eina_List *list; /**< the list that holds data, members are of subtype->value_size bytes. */ -}; - -/** - * @brief Create generic value storage of type list. - * @param subtype how to manage this list members. - * @return The new value or @c NULL on failure. - * - * Create a new generic value storage of type list. The members are - * managed using the description specified by @a subtype. - * - * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or - * #EINA_ERROR_VALUE_FAILED is set. - * - * @note this creates from mempool and then uses - * eina_value_list_setup(). - * - * @see eina_value_free() - * @see eina_value_list_setup() - * - * @since 1.2 - */ -EAPI Eina_Value *eina_value_list_new(const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1); - -/** - * @brief Initialize generic value storage of type list. - * @param value value object - * @param subtype how to manage this list members. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Initializes new generic value storage of type list with the given - * @a subtype. - * - * This is the same as calling eina_value_set() with - * #EINA_VALUE_TYPE_LIST followed by eina_value_pset() with the - * #Eina_Value_List description configured. - * - * @note Existing contents are ignored! If the value was previously used, then - * use eina_value_flush() first. - * - * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY - * or #EINA_ERROR_VALUE_FAILED is set. - * - * @see eina_value_flush() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_setup(Eina_Value *value, - const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Query number of elements in value of list type. - * @param value value object. - * @return number of child elements. - * @since 1.2 - */ -static inline unsigned int eina_value_list_count(const Eina_Value *value); - -/** - * @brief Remove element at given position in value of list type. - * @param value value object. - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_remove(Eina_Value *value, - unsigned int position) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an list member. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x; - * - * eina_value_list_append(value, 1234); - * eina_value_list_set(value, 0, 5678); - * eina_value_list_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_set(Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an list member. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x; - * - * eina_value_list_append(value, 1234); - * eina_value_list_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_get(const Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Insert the generic value in an list member position. - * @param value source value object - * @param position index of the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x; - * - * eina_value_list_insert(value, 0, 1234); - * eina_value_list_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_insert(Eina_Value *value, - unsigned int position, - ...) EINA_ARG_NONNULL(1); - - -/** - * @brief Append the generic value in an list. - * @param value source value object - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x; - * - * eina_value_list_append(value, 1234); - * eina_value_list_get(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_append(Eina_Value *value, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an list member. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_pset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_vset(Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an list member. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * @see eina_value_list_vset() - * @see eina_value_list_get() - * @see eina_value_list_pget() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_vget(const Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); -/** - * @brief Insert the generic value in an list member position. - * @param value source value object - * @param position index of the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * @see eina_value_list_insert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_vinsert(Eina_Value *value, - unsigned int position, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Append the generic value in an list. - * @param value source value object - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vget() - * @see eina_value_list_pset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_vappend(Eina_Value *value, - va_list args) EINA_ARG_NONNULL(1); - - -/** - * @brief Set the generic value in an list member from pointer. - * @param value source value object - * @param position index of the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x = 1234; - * - * eina_value_list_append(value, 1234); - * eina_value_list_pset(value, 0, &x); - * eina_value_list_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_pset(Eina_Value *value, - unsigned int position, - const void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Get the generic value to pointer from an list member. - * @param value source value object - * @param position index of the member - * @param ptr pointer to receive the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in pointer contents, the actual value is - * type-dependent, but usually it will be what is stored inside the - * object. There shouldn't be any memory allocation, thus the contents - * should @b not be freed. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x; - * - * eina_value_list_append(value, 1234); - * eina_value_list_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_vset() - * @see eina_value_list_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_pget(const Eina_Value *value, - unsigned int position, - void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Insert the generic value in an list member position from pointer. - * @param value source value object - * @param position index of the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x = 1234; - * - * eina_value_list_pinsert(value, 0, &x); - * eina_value_list_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_pinsert(Eina_Value *value, - unsigned int position, - const void *ptr) EINA_ARG_NONNULL(1); - -/** - * @brief Append the generic value in an list from pointer. - * @param value source value object - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); - * int x = 1234; - * - * eina_value_list_pappend(value, &x); - * eina_value_list_pget(value, 0, &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_list_set() - * @see eina_value_list_get() - * @see eina_value_list_vset() - * @see eina_value_list_insert() - * @see eina_value_list_vinsert() - * @see eina_value_list_pinsert() - * @see eina_value_list_append() - * @see eina_value_list_vappend() - * @see eina_value_list_pappend() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_list_pappend(Eina_Value *value, - const void *ptr) EINA_ARG_NONNULL(1); - -/** - * @} - */ - -/** - * @defgroup Eina_Value_Hash_Group Generic Value Hash management - * - * @{ - */ - -/** - * @typedef Eina_Value_Hash - * Value type for #EINA_VALUE_TYPE_HASH. - * - * @see #_Eina_Value_Hash explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Hash Eina_Value_Hash; - -/** - * @struct _Eina_Value_Hash - * Used to store the hash and its subtype. - * @since 1.2 - */ -struct _Eina_Value_Hash -{ - const Eina_Value_Type *subtype; /**< how to allocate and access items */ - unsigned int buckets_power_size; /**< how to allocate hash buckets, if zero a sane default is chosen. */ - Eina_Hash *hash; /**< the hash that holds data, members are of subtype->value_size bytes. */ -}; - -/** - * @brief Create generic value storage of type hash. - * @param subtype how to manage this hash members. - * @param buckets_power_size how to allocate hash buckets (2 ^ - * buckets_power_size), if zero then a sane value is chosen. - * @return The new value or @c NULL on failure. - * - * Create a new generic value storage of type hash. The members are - * managed using the description specified by @a subtype. - * - * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or - * #EINA_ERROR_VALUE_FAILED is set. - * - * @note this creates from mempool and then uses - * eina_value_hash_setup(). - * - * @see eina_value_free() - * @see eina_value_hash_setup() - * - * @since 1.2 - */ -EAPI Eina_Value *eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size) EINA_ARG_NONNULL(1); - -/** - * @brief Initialize generic value storage of type hash. - * @param value value object - * @param subtype how to manage this hash members. - * @param buckets_power_size how to allocate hash buckets (2 ^ - * buckets_power_size), if zero then a sane value is chosen. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Initializes new generic value storage of type hash with the given - * @a subtype. - * - * This is the same as calling eina_value_set() with - * #EINA_VALUE_TYPE_HASH followed by eina_value_pset() with the - * #Eina_Value_Hash description configured. - * - * @note Existing contents are ignored! If the value was previously used, then - * use eina_value_flush() first. - * - * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY - * or #EINA_ERROR_VALUE_FAILED is set. - * - * @see eina_value_flush() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_setup(Eina_Value *value, - const Eina_Value_Type *subtype, - unsigned int buckets_power_size) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Query number of elements in value of hash type. - * @param value value object. - * @return number of child elements. - * @since 1.2 - */ -static inline unsigned int eina_value_hash_population(const Eina_Value *value); - -/** - * @brief Remove element at given position in value of hash type. - * @param value value object. - * @param key key to find the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_del(Eina_Value *value, - const char *key) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an hash member. - * @param value source value object - * @param key key to find the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_hash_set(value, "abc", 5678); - * eina_value_hash_get(value, "abc", &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_hash_get() - * @see eina_value_hash_vset() - * @see eina_value_hash_pset() - * @see eina_value_hash_del() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_set(Eina_Value *value, - const char *key, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an hash member. - * @param value source value object - * @param key key to find the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * The variable argument is dependent on chosen subtype. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_hash_set(value, "abc", 1234); - * eina_value_hash_get(value, "abc", &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_hash_set() - * @see eina_value_hash_vset() - * @see eina_value_hash_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_get(const Eina_Value *value, - const char *key, - ...) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an hash member. - * @param value source value object - * @param key key to find the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_hash_set() - * @see eina_value_hash_get() - * @see eina_value_hash_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_vset(Eina_Value *value, - const char *key, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Get the generic value from an hash member. - * @param value source value object - * @param key key to find the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * @see eina_value_hash_vset() - * @see eina_value_hash_get() - * @see eina_value_hash_pget() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_vget(const Eina_Value *value, - const char *key, - va_list args) EINA_ARG_NONNULL(1); - -/** - * @brief Set the generic value in an hash member from pointer. - * @param value source value object - * @param key key to find the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); - * int x = 1234; - * - * eina_value_hash_pset(value, "abc", &x); - * eina_value_hash_pget(value, "abc", &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_hash_set() - * @see eina_value_hash_get() - * @see eina_value_hash_vset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_pset(Eina_Value *value, - const char *key, - const void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @brief Get the generic value to pointer from an hash member. - * @param value source value object - * @param key key to find the member - * @param ptr pointer to receive the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in pointer contents, the actual value is - * type-dependent, but usually it will be what is stored inside the - * object. There shouldn't be any memory allocation, thus the contents - * should @b not be freed. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); - * int x; - * - * eina_value_hash_set(value, "abc", 1234); - * eina_value_hash_pget(value, "abc", &x); - * eina_value_free(value); - * @endcode - * - * @see eina_value_hash_set() - * @see eina_value_hash_vset() - * @see eina_value_hash_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value, - const char *key, - void *ptr) EINA_ARG_NONNULL(1, 3); - -/** - * @} - */ - -/** - * @defgroup Eina_Value_Blob_Group Generic Value Blob management - * - * @{ - */ - -/** - * @typedef Eina_Value_Blob_Operations - * How to manage blob. Any @c NULL callback is ignored. - * @see #_Eina_Value_Blob_Operations explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations; - -/** - * @def EINA_VALUE_BLOB_OPERATIONS_VERSION - * Current API version, used to validate #_Eina_Value_Blob_Operations. - */ -#define EINA_VALUE_BLOB_OPERATIONS_VERSION (1) - -/** - * @struct _Eina_Value_Blob_Operations - * How to manage blob. Any @c NULL callback is ignored. - * @since 1.2 - */ -struct _Eina_Value_Blob_Operations -{ - unsigned int version; /**< must be #EINA_VALUE_BLOB_OPERATIONS_VERSION */ - void (*free)(const Eina_Value_Blob_Operations *ops, void *memory, size_t size); - void *(*copy)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size); - int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2); - char *(*to_string)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size); -}; - -/** - * @var EINA_VALUE_BLOB_OPERATIONS_MALLOC - * - * Assumes @c memory was create with malloc() and applies free() to it - * during flush (Eina_Value_Blob_Operations::free). Copy is done with - * malloc() as well. - * - * No compare or to_string are provided, defaults will be used. - */ -EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC; - -/** - * @typedef Eina_Value_Blob - * Value type for #EINA_VALUE_TYPE_BLOB. - * - * @see #_Eina_Value_Blob explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Blob Eina_Value_Blob; - -/** - * @struct _Eina_Value_Blob - * Used to store the blob information and management operations. - * @since 1.2 - */ -struct _Eina_Value_Blob -{ - const Eina_Value_Blob_Operations *ops; /**< if @c NULL, nothing is freed, copy will just copy the memory pointer, not its value. */ - const void *memory; - unsigned int size; -}; - -/** - * @} - */ - -/** - * @defgroup Eina_Value_Struct_Group Generic Value Struct management - * - * @{ - */ - -/** - * @typedef Eina_Value_Struct_Operations - * How to manage struct. Any @c NULL callback is ignored. - * - * A structure can specify alternative methods to allocate, free and - * copy itself. See structure definition for all methods. - * - * @see #_Eina_Value_Struct_Operations explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations; - -/** - * @typedef Eina_Value_Struct_Member - * Describes a single member of struct. - * - * The member holds a name, type and its byte offset within the struct - * memory. Most Eina_Value_Struct functions takes the member name as - * parameter, as in eina_value_struct_set(). - * - * @see #_Eina_Value_Struct_Member explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member; - -/** - * @typedef Eina_Value_Struct_Desc - * Describes the struct by listing its size, members and operations. - * @see #_Eina_Value_Struct_Desc explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc; - -/** - * @typedef Eina_Value_Struct - * Value type for #EINA_VALUE_TYPE_STRUCT. - * - * @see #_Eina_Value_Struct explains fields. - * @since 1.2 - */ -typedef struct _Eina_Value_Struct Eina_Value_Struct; - -/** - * @def EINA_VALUE_STRUCT_OPERATIONS_VERSION - * Current API version, used to validate #_Eina_Value_Struct_Operations. - */ -#define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1) - -/** - * @struct _Eina_Value_Struct_Operations - * How to manage struct. Any @c NULL callback is ignored. - * @since 1.2 - */ -struct _Eina_Value_Struct_Operations -{ - unsigned int version; /**< must be #EINA_VALUE_STRUCT_OPERATIONS_VERSION */ - void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc); /**< How to allocate struct memory to be managed by the Eina_Value */ - void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory); /**< How to release memory managed by the Eina_Value */ - void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory); /**< How to copy struct memory from an existing Eina_Value, if not provided alloc() will be used, then every member is copied using eina_value_type_copy() with member's type. */ - int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2); /**< How to compare two struct memories */ - const Eina_Value_Struct_Member *(*find_member)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const char *name); /**< How to find description for member. For huge structures consider using binary search, stringshared, hash or gperf. The default function does linear search using strcmp(). */ -}; - -/** - * @var EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH - * - * Assumes @c members is sorted by name and applies binary search for - * names. - * - * Ideally the @c member_count field is set to speed it up. - * - * No other methods are set (alloc, free, copy, compare), then it uses - * the default operations. - */ -EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH; - -/** - * @var EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE - * - * Assumes @c members name are stringshared and can be compared for - * equality without using its contents (simple pointer comparison). - * - * Ideally the search @c name will be stringshared as well, but it - * will do a second loop with a forced stringshare if it did not find - * the member. - * - * No other methods are set (alloc, free, copy, compare), then it uses - * the default operations. - */ -EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE; - -/** - * @struct _Eina_Value_Struct_Member - * Describes a single member of struct. - * - * The name is used to lookup the member description. This is done as - * specified as _Eina_Value_Struct_Operations::find_member(). For - * structures with huge number of members, consider using a better - * find_member function to quickly finding it! There are two helper - * operations provided to help this: - * #EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH and - * #EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE, both depend on properly - * set #_Eina_Value_Struct_Desc and #_Eina_Value_Struct_Member. - * - * @see #EINA_VALUE_STRUCT_MEMBER - * @see #EINA_VALUE_STRUCT_MEMBER_SENTINEL - * - * @since 1.2 - */ -struct _Eina_Value_Struct_Member -{ - const char *name; /**< member name, used in lookups such as eina_value_struct_get() */ - const Eina_Value_Type *type; /**< how to use this member */ - unsigned int offset; /**< where this member is located within the structure memory */ -}; - -/** - * @def EINA_VALUE_STRUCT_DESC_VERSION - * Current API version, used to validate #_Eina_Value_Struct_Desc. - */ -#define EINA_VALUE_STRUCT_DESC_VERSION (1) - -/** - * @struct _Eina_Value_Struct_Desc - * Describes the struct by listing its size, members and operations. - * - * This is the root of Eina_Value knowledge about the memory it's - * handling as a structure. It adds introspection, saying the byte - * size of the structure, its members and how to manage such members. - * - * @since 1.2 - */ -struct _Eina_Value_Struct_Desc -{ - unsigned int version; /**< must be #EINA_VALUE_STRUCT_DESC_VERSION */ - const Eina_Value_Struct_Operations *ops; /**< operations, if @c NULL defaults will be used. You may use operations to optimize member lookup using binary search or gperf hash. */ - const Eina_Value_Struct_Member *members; /**< array of member descriptions, if @c member_count is zero, then it must be @c NULL terminated. */ - unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */ - unsigned int size; /**< byte size to allocate, may be bigger than sum of members */ -}; - -/** - * @def EINA_VALUE_STRUCT_MEMBER - * - * Helper to define Eina_Value_Struct_Member fields, uses offsetof() - * with type and member. - * - * @since 1.2 - */ -#define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member) \ - {#member, eina_value_type, offsetof(type, member)} - -/** - * @def EINA_VALUE_STRUCT_MEMBER_SENTINEL - * - * Helper to define Eina_Value_Struct_Member fields for sentinel (last - * item), useful if you did not define @c member_count. - * - * @since 1.2 - */ -#define EINA_VALUE_STRUCT_MEMBER_SENTINEL {NULL, NULL, 0} - - -/** - * @struct _Eina_Value_Struct - * Used to store the memory and its description. - * @since 1.2 - */ -struct _Eina_Value_Struct -{ - const Eina_Value_Struct_Desc *desc; /**< How to manage the structure */ - void *memory; /**< The managed structure memory */ -}; - -/** - * @brief Create generic value storage of type struct. - * @param desc how to manage this struct members. - * @return The new value or @c NULL on failure. - * - * Create a new generic value storage of type struct. The members are - * managed using the description specified by @a desc. - * - * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or - * #EINA_ERROR_VALUE_FAILED is set. - * - * @note this creates from mempool and then uses - * eina_value_struct_setup(). - * - * @see eina_value_free() - * @see eina_value_struct_setup() - * - * @since 1.2 - */ -EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1); - -/** - * @brief Initialize generic value storage of type struct. - * @param value value object - * @param desc how to manage this struct members. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * Initializes new generic value storage of type struct with the given - * @a desc. - * - * This is the same as calling eina_value_set() with - * #EINA_VALUE_TYPE_STRUCT followed by eina_value_pset() with the - * #Eina_Value_Struct description configured. - * - * @note Existing contents are ignored! If the value was previously used, then - * use eina_value_flush() first. - * - * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY - * or #EINA_ERROR_VALUE_FAILED is set. - * - * @see eina_value_flush() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_setup(Eina_Value *value, - const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Set the generic value in an struct member. - * @param value source value object - * @param name name to find the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The variable argument is dependent on chosen member type. The list - * for basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char - * @li EINA_VALUE_TYPE_USHORT: unsigned short - * @li EINA_VALUE_TYPE_UINT: unsigned int - * @li EINA_VALUE_TYPE_ULONG: unsigned long - * @li EINA_VALUE_TYPE_UINT64: uint64_t - * @li EINA_VALUE_TYPE_CHAR: char - * @li EINA_VALUE_TYPE_SHORT: short - * @li EINA_VALUE_TYPE_INT: int - * @li EINA_VALUE_TYPE_LONG: long - * @li EINA_VALUE_TYPE_INT64: int64_t - * @li EINA_VALUE_TYPE_FLOAT: float - * @li EINA_VALUE_TYPE_DOUBLE: double - * @li EINA_VALUE_TYPE_STRINGSHARE: const char * - * @li EINA_VALUE_TYPE_STRING: const char * - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * struct myst { - * int i; - * char c; - * }; - * const Eina_Value_Struct_Member myst_members[] = { - * {"i", EINA_VALUE_TYPE_INT, 0}, - * {"c", EINA_VALUE_TYPE_CHAR, 4}, - * {NULL, NULL, 0} - * }; - * const Eina_Value_Struct_Desc myst_desc = { - * EINA_VALUE_STRUCT_DESC_VERSION, - * NULL, myst_members, 2, sizeof(struct myst) - * }; - * Eina_Value *value = eina_value_struct_new(&my_desc); - * int x; - * char y; - * - * eina_value_struct_set(value, "i", 5678); - * eina_value_struct_get(value, "i", &x); - * eina_value_struct_set(value, "c", 0xf); - * eina_value_struct_get(value, "c", &y); - * eina_value_free(value); - * @endcode - * - * @see eina_value_struct_get() - * @see eina_value_struct_vset() - * @see eina_value_struct_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_set(Eina_Value *value, - const char *name, - ...) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Get the generic value from an struct member. - * @param value source value object - * @param name name to find the member - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * The variable argument is dependent on chosen member type. The list - * for basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * struct myst { - * int i; - * char c; - * }; - * const Eina_Value_Struct_Member myst_members[] = { - * {"i", EINA_VALUE_TYPE_INT, 0}, - * {"c", EINA_VALUE_TYPE_CHAR, 4}, - * {NULL, NULL, 0} - * }; - * const Eina_Value_Struct_Desc myst_desc = { - * EINA_VALUE_STRUCT_DESC_VERSION, - * NULL, myst_members, 2, sizeof(struct myst) - * }; - * Eina_Value *value = eina_value_struct_new(&my_desc); - * int x; - * char y; - * - * eina_value_struct_set(value, "i", 5678); - * eina_value_struct_get(value, "i", &x); - * eina_value_struct_set(value, "c", 0xf); - * eina_value_struct_get(value, "c", &y); - * eina_value_free(value); - * @endcode - * - * @see eina_value_struct_set() - * @see eina_value_struct_vset() - * @see eina_value_struct_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_get(const Eina_Value *value, - const char *name, - ...) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Set the generic value in an struct member. - * @param value source value object - * @param name name to find the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @see eina_value_struct_set() - * @see eina_value_struct_get() - * @see eina_value_struct_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_vset(Eina_Value *value, - const char *name, - va_list args) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Get the generic value from an struct member. - * @param value source value object - * @param name name to find the member - * @param args variable argument - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in the variable argument parameter, the - * actual value is type-dependent, but usually it will be what is - * stored inside the object. There shouldn't be any memory allocation, - * thus the contents should @b not be freed. - * - * @see eina_value_struct_vset() - * @see eina_value_struct_get() - * @see eina_value_struct_pget() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value, - const char *name, - va_list args) EINA_ARG_NONNULL(1, 2); - -/** - * @brief Set the generic value in an struct member from pointer. - * @param value source value object - * @param name name to find the member - * @param ptr pointer to specify the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @note the pointer contents are written using the size defined by - * type. It can be larger than void* or uint64_t. - * - * @code - * struct myst { - * int i; - * char c; - * }; - * const Eina_Value_Struct_Member myst_members[] = { - * {"i", EINA_VALUE_TYPE_INT, 0}, - * {"c", EINA_VALUE_TYPE_CHAR, 4}, - * {NULL, NULL, 0} - * }; - * const Eina_Value_Struct_Desc myst_desc = { - * EINA_VALUE_STRUCT_DESC_VERSION, - * NULL, myst_members, 2, sizeof(struct myst) - * }; - * Eina_Value *value = eina_value_struct_new(&my_desc); - * int x = 5678; - * char y = 0xf; - * - * eina_value_struct_pset(value, "i", &); - * eina_value_struct_pget(value, "i", &x); - * eina_value_struct_pset(value, "c", &y); - * eina_value_struct_pget(value, "c", &y); - * eina_value_free(value); - * @endcode - * - * @see eina_value_struct_set() - * @see eina_value_struct_get() - * @see eina_value_struct_vset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_pset(Eina_Value *value, - const char *name, - const void *ptr) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Get the generic value to pointer from an struct member. - * @param value source value object - * @param name name to find the member - * @param ptr pointer to receive the contents. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * - * The value is returned in pointer contents, the actual value is - * type-dependent, but usually it will be what is stored inside the - * object. There shouldn't be any memory allocation, thus the contents - * should @b not be freed. - * - * The pointer type is dependent on chosen value type. The list for - * basic types: - * - * @li EINA_VALUE_TYPE_UCHAR: unsigned char* - * @li EINA_VALUE_TYPE_USHORT: unsigned short* - * @li EINA_VALUE_TYPE_UINT: unsigned int* - * @li EINA_VALUE_TYPE_ULONG: unsigned long* - * @li EINA_VALUE_TYPE_UINT64: uint64_t* - * @li EINA_VALUE_TYPE_CHAR: char* - * @li EINA_VALUE_TYPE_SHORT: short* - * @li EINA_VALUE_TYPE_INT: int* - * @li EINA_VALUE_TYPE_LONG: long* - * @li EINA_VALUE_TYPE_INT64: int64_t* - * @li EINA_VALUE_TYPE_FLOAT: float* - * @li EINA_VALUE_TYPE_DOUBLE: double* - * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** - * @li EINA_VALUE_TYPE_STRING: const char ** - * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* - * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* - * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* - * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* - * - * @code - * struct myst { - * int i; - * char c; - * }; - * const Eina_Value_Struct_Member myst_members[] = { - * {"i", EINA_VALUE_TYPE_INT, 0}, - * {"c", EINA_VALUE_TYPE_CHAR, 4}, - * {NULL, NULL, 0} - * }; - * const Eina_Value_Struct_Desc myst_desc = { - * EINA_VALUE_STRUCT_DESC_VERSION, - * NULL, myst_members, 2, sizeof(struct myst) - * }; - * Eina_Value *value = eina_value_struct_new(&my_desc); - * int x = 5678; - * char y = 0xf; - * - * eina_value_struct_pset(value, "i", &); - * eina_value_struct_pget(value, "i", &x); - * eina_value_struct_pset(value, "c", &y); - * eina_value_struct_pget(value, "c", &y); - * eina_value_free(value); - * @endcode - * - * @see eina_value_struct_set() - * @see eina_value_struct_vset() - * @see eina_value_struct_pset() - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value, - const char *name, - void *ptr) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Get the member as Eina_Value copy - * @param src source value object - * @param name name to find the member - * @param dst where to return the member value. - * - * The argument @a dst is considered uninitialized and it's setup to - * the type of the member. - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_value_get(const Eina_Value *src, - const char *name, - Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Set the member from Eina_Value source - * @param dst destination value object - * @param name name to find the member - * @param src source value - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_value_set(Eina_Value *dst, - const char *name, - const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Get the member as Eina_Value copy given its member description. - * @param src source value object - * @param member the member description to use - * @param dst where to return the member value. - * - * The argument @a dst is considered uninitialized and it's setup to - * the type of the member. - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_member_value_get(const Eina_Value *src, - const Eina_Value_Struct_Member *member, - Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3); - -/** - * @brief Set the member from Eina_Value source - * @param dst destination value object - * @param member the member description to use - * @param src source value - * - * @since 1.2 - */ -static inline Eina_Bool eina_value_struct_member_value_set(Eina_Value *dst, - const Eina_Value_Struct_Member *member, - const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3); - - -/** - * @} - */ - - -/** - * @defgroup Eina_Value_Type_Group Generic Value Type management - * - * @{ - */ - -/** - * @def EINA_VALUE_TYPE_VERSION - * Current API version, used to validate type. - */ -#define EINA_VALUE_TYPE_VERSION (1) - -/** - * @struct _Eina_Value_Type - * API to access values. - * - * @since 1.2 - */ -struct _Eina_Value_Type -{ - unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */ - unsigned int value_size; /**< byte size of value */ - const char *name; /**< name for debug and introspection */ - Eina_Bool (*setup)(const Eina_Value_Type *type, void *mem); /**< mem will be malloc(value_size) and should be configured */ - Eina_Bool (*flush)(const Eina_Value_Type *type, void *mem); /**< clear any values from mem */ - Eina_Bool (*copy)(const Eina_Value_Type *type, const void *src, void *dst); /**< how to copy values, both memory are @c value_size */ - int (*compare)(const Eina_Value_Type *type, const void *a, const void *b); /**< how to compare values, both memory are @c value_size */ - Eina_Bool (*convert_to)(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); /**< how to convert values, both memory are @c value_size */ - Eina_Bool (*convert_from)(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); /**< how to convert values, both memory are @c value_size */ - Eina_Bool (*vset)(const Eina_Value_Type *type, void *mem, va_list args); /**< how to set memory from variable argument */ - Eina_Bool (*pset)(const Eina_Value_Type *type, void *mem, const void *ptr); /**< how to set memory from pointer */ - Eina_Bool (*pget)(const Eina_Value_Type *type, const void *mem, void *ptr); /**< how to read memory */ -}; - -/** - * @brief Query type name. - * @param type type reference. - * @return string or @c NULL if type is invalid. - * @since 1.2 - */ -EAPI const char *eina_value_type_name_get(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Check if type is valid. - * @param type type reference. - * @return #EINA_TRUE if valid, #EINA_FALSE otherwise. - * - * A type is invalid if it's NULL or if version field is not the same - * as runtime #EINA_VALUE_TYPE_VERSION. - * - * @since 1.2 - */ -EAPI Eina_Bool eina_value_type_check(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - -/** - * @brief Initialize memory using type descriptor. - * @param type type reference. - * @param mem memory to operate, must be of size @c type->value_size. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_setup(const Eina_Value_Type *type, void *mem); - -/** - * @brief Flush (clear) memory using type descriptor. - * @param type type reference. - * @param mem memory to operate, must be of size @c type->value_size. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_flush(const Eina_Value_Type *type, void *mem); - -/** - * @brief Copy memory using type descriptor. - * @param type type reference. - * @param src memory to operate, must be of size @c type->value_size. - * @param dst memory to operate, must be of size @c type->value_size. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst); - -/** - * @brief Compare memory using type descriptor. - * @param type type reference. - * @param a memory to operate, must be of size @c type->value_size. - * @param b memory to operate, must be of size @c type->value_size. - * @return less than zero if a < b, greater than zero if a > b, zero if equal. - * @since 1.2 - */ -static inline int eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b); - -/** - * @brief Convert memory using type descriptor. - * @param type type reference of the source. - * @param convert type reference of the destination. - * @param type_mem memory to operate, must be of size @c type->value_size. - * @param convert_mem memory to operate, must be of size @c convert->value_size. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); - -/** - * @brief Convert memory using type descriptor. - * @param type type reference of the destination. - * @param convert type reference of the source. - * @param type_mem memory to operate, must be of size @c type->value_size. - * @param convert_mem memory to operate, must be of size @c convert->value_size. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); - -/** - * @brief Set memory using type descriptor and variable argument. - * @param type type reference of the source. - * @param mem memory to operate, must be of size @c type->value_size. - * @param args input value. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args); - -/** - * @brief Set memory using type descriptor and pointer. - * @param type type reference of the source. - * @param mem memory to operate, must be of size @c type->value_size. - * @param ptr pointer to input value. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr); - -/** - * @brief Get memory using type descriptor. - * @param type type reference of the source. - * @param mem memory to operate, must be of size @c type->value_size. - * @param ptr pointer to output. - * @return #EINA_TRUE on success, #EINA_FALSE otherwise. - * @since 1.2 - */ -static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr); - -/** - * @} - */ - -#include "eina_inline_value.x" - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -#endif diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h deleted file mode 100644 index 0f89cc3..0000000 --- a/libraries/eina/src/include/eina_xattr.h +++ /dev/null @@ -1,215 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2011 Cedric Bail - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * 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, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; - * if not, see . - */ - -#ifndef EINA_XATTR_H_ -#define EINA_XATTR_H_ - -#include "eina_types.h" - -/** - * @addtogroup Eina_Tools_Group Tools - * - * @{ - */ - -/** - * @typedef Eina_Xattr_Flags - * define extended attribute creation - * - * @since 1.1 - */ -typedef enum { - EINA_XATTR_INSERT, /**< This is the default behaviour, it will either create or replace the extended attribute */ - EINA_XATTR_REPLACE, /**< This will only succeed if the extended attribute previously existed */ - EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */ -} Eina_Xattr_Flags; - -typedef struct _Eina_Xattr Eina_Xattr; -struct _Eina_Xattr -{ - const char *name; /**< The eXtended attribute name @since 1.2 */ - const char *value; /**< The eXtended attribute value @since 1.2 */ - - size_t length; /**< The length of the eXtended attribute value @since 1.2 */ -}; - -/** - * @brief Get an iterator that list all extended attribute of a file. - * - * @param file The filename to retrieve the extended attribute list from. - * @return an iterator. - * - * The iterator will not allocate any data during the iteration step, so you need to copy them yourself - * if you need. - * - * @since 1.1 - */ -EAPI Eina_Iterator *eina_xattr_ls(const char *file); - -/** - * @brief Get an iterator that list all extended attribute value related to a fd. - * - * @param file The filename to retrieve the extended attribute list from. - * @return an iterator. - * - * The iterator will not allocate any data during the iteration step, so you need to copy them yourself - * if you need. The iterator will provide an Eina_Xattr structure. - * - * @since 1.2 - */ -EAPI Eina_Iterator *eina_xattr_value_ls(const char *file); - -/** - * @brief Get an iterator that list all extended attribute related to a fd. - * - * @param fd The file descriptor to retrieve the extended attribute list from. - * @return an iterator. - * - * The iterator will not allocate any data during the iteration step, so you need to copy them yourself - * if you need. - * - * @since 1.2 - */ -EAPI Eina_Iterator *eina_xattr_fd_ls(int fd); - -/** - * @brief Get an iterator that list all extended attribute value related to a fd. - * - * @param fd The file descriptor to retrieve the extended attribute list from. - * @return an iterator. - * - * The iterator will not allocate any data during the iteration step, so you need to copy them yourself - * if you need. The iterator will provide an Eina_Xattr structure. - * - * @since 1.2 - */ -EAPI Eina_Iterator *eina_xattr_value_fd_ls(int fd); - -/** - * @brief Retrieve an extended attribute from a file. - * - * @param file The file to retrieve the extended attribute from. - * @param attribute The extended attribute name to retrieve. - * @param size The size of the retrieved extended attribute. - * @return the allocated data that hold the extended attribute value. - * - * It will return NULL and *size will be @c 0 if it fails. - * - * @since 1.1 - */ -EAPI void *eina_xattr_get(const char *file, const char *attribute, ssize_t *size); - -/** - * @brief Set an extended attribute on a file. - * - * @param file The file to set the extended attribute to. - * @param attribute The attribute to set. - * @param data The data to set. - * @param length The length of the data to set. - * @param flags Define the set policy. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags); - -/** - * @brief Set a string as a extended attribute properties. - * - * @param file The file to set the string to. - * @param attribute The attribute to set. - * @param data The NULL terminated string to set. - * @param flags Define the set policy. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_string_set(const char *file, const char *attribute, const char *data, Eina_Xattr_Flags flags); - -/** - * @brief Get a string from an extended attribute properties. - * - * @param file The file to get the string from. - * @param attribute The attribute to get. - * @return a valid string on success, NULL otherwise. - * - * This call check that the string is properly NULL-terminated before returning it. - * - * @since 1.1 - */ -EAPI char *eina_xattr_string_get(const char *file, const char *attribute); - -/** - * @brief Set a double as a extended attribute properties. - * - * @param file The file to set the double to. - * @param attribute The attribute to set. - * @param value The NULL terminated double to set. - * @param flags Define the set policy. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_double_set(const char *file, const char *attribute, double value, Eina_Xattr_Flags flags); - -/** - * @brief Get a double from an extended attribute properties. - * - * @param file The file to get the string from. - * @param attribute The attribute to get. - * @param value Where to put the extracted value - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * This call check that the double is correctly set. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, double *value); - -/** - * @brief Set an int as a extended attribute properties. - * - * @param file The file to set the int to. - * @param attribute The attribute to set. - * @param value The NULL terminated int to set. - * @param flags Define the set policy. - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_int_set(const char *file, const char *attribute, int value, Eina_Xattr_Flags flags); - -/** - * @brief Get a int from an extended attribute properties. - * - * @param file The file to get the string from. - * @param attribute The attribute to get. - * @param value Where to put the extracted value - * @return EINA_TRUE on success, EINA_FALSE otherwise. - * - * This call check that the int is correctly set. - * - * @since 1.1 - */ -EAPI Eina_Bool eina_xattr_int_get(const char *file, const char *attribute, int *value); - -/** - * @} - */ - -#endif -- cgit v1.1