aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src')
-rw-r--r--libraries/eina/src/Makefile.in4
-rw-r--r--libraries/eina/src/examples/Makefile.am10
-rw-r--r--libraries/eina/src/examples/Makefile.in68
-rw-r--r--libraries/eina/src/examples/eina_array_01.c4
-rw-r--r--libraries/eina/src/include/Eina.h9
-rw-r--r--libraries/eina/src/include/Makefile.am6
-rw-r--r--libraries/eina/src/include/Makefile.in52
-rw-r--r--libraries/eina/src/include/eina_array.h17
-rw-r--r--libraries/eina/src/include/eina_benchmark.h8
-rw-r--r--libraries/eina/src/include/eina_binbuf.h18
-rw-r--r--libraries/eina/src/include/eina_clist.h160
-rw-r--r--libraries/eina/src/include/eina_config.h10
-rw-r--r--libraries/eina/src/include/eina_config.h.in10
-rw-r--r--libraries/eina/src/include/eina_file.h40
-rw-r--r--libraries/eina/src/include/eina_hash.h4
-rw-r--r--libraries/eina/src/include/eina_inarray.h572
-rw-r--r--libraries/eina/src/include/eina_inline_array.x20
-rw-r--r--libraries/eina/src/include/eina_inline_clist.x135
-rw-r--r--libraries/eina/src/include/eina_inline_hash.x2
-rw-r--r--libraries/eina/src/include/eina_inline_lock_posix.x51
-rw-r--r--libraries/eina/src/include/eina_inline_lock_void.x62
-rw-r--r--libraries/eina/src/include/eina_inline_lock_win32.x46
-rw-r--r--libraries/eina/src/include/eina_inline_lock_wince.x34
-rw-r--r--libraries/eina/src/include/eina_inline_log.x4
-rw-r--r--libraries/eina/src/include/eina_inline_mempool.x49
-rw-r--r--libraries/eina/src/include/eina_inline_value.x1705
-rw-r--r--libraries/eina/src/include/eina_inlist.h101
-rw-r--r--libraries/eina/src/include/eina_iterator.h8
-rw-r--r--libraries/eina/src/include/eina_list.h26
-rw-r--r--libraries/eina/src/include/eina_lock.h4
-rw-r--r--libraries/eina/src/include/eina_log.h51
-rw-r--r--libraries/eina/src/include/eina_magic.h8
-rw-r--r--libraries/eina/src/include/eina_main.h5
-rw-r--r--libraries/eina/src/include/eina_module.h47
-rw-r--r--libraries/eina/src/include/eina_simple_xml_parser.h62
-rw-r--r--libraries/eina/src/include/eina_str.h16
-rw-r--r--libraries/eina/src/include/eina_strbuf.h18
-rw-r--r--libraries/eina/src/include/eina_stringshare.h1
-rw-r--r--libraries/eina/src/include/eina_types.h4
-rw-r--r--libraries/eina/src/include/eina_unicode.h23
-rw-r--r--libraries/eina/src/include/eina_ustrbuf.h20
-rw-r--r--libraries/eina/src/include/eina_value.h3114
-rw-r--r--libraries/eina/src/include/eina_xattr.h53
-rw-r--r--libraries/eina/src/lib/Makefile.am10
-rw-r--r--libraries/eina/src/lib/Makefile.in68
-rw-r--r--libraries/eina/src/lib/eina_array.c4
-rw-r--r--libraries/eina/src/lib/eina_binbuf_template_c.x9
-rw-r--r--libraries/eina/src/lib/eina_cpu.c4
-rw-r--r--libraries/eina/src/lib/eina_file.c128
-rw-r--r--libraries/eina/src/lib/eina_hash.c6
-rw-r--r--libraries/eina/src/lib/eina_inarray.c777
-rw-r--r--libraries/eina/src/lib/eina_log.c145
-rw-r--r--libraries/eina/src/lib/eina_magic.c11
-rw-r--r--libraries/eina/src/lib/eina_main.c16
-rw-r--r--libraries/eina/src/lib/eina_mmap.c5
-rw-r--r--libraries/eina/src/lib/eina_module.c1
-rw-r--r--libraries/eina/src/lib/eina_prefix.c37
-rw-r--r--libraries/eina/src/lib/eina_private.h6
-rw-r--r--libraries/eina/src/lib/eina_rbtree.c10
-rw-r--r--libraries/eina/src/lib/eina_simple_xml_parser.c19
-rw-r--r--libraries/eina/src/lib/eina_strbuf.c6
-rw-r--r--libraries/eina/src/lib/eina_value.c4977
-rw-r--r--libraries/eina/src/lib/eina_xattr.c191
-rw-r--r--libraries/eina/src/modules/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/buddy/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/buddy/eina_buddy.c20
-rw-r--r--libraries/eina/src/modules/mp/chained_pool/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c31
-rw-r--r--libraries/eina/src/modules/mp/ememoa_fixed/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/ememoa_unknown/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/fixed_bitmap/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/one_big/Makefile.in4
-rw-r--r--libraries/eina/src/modules/mp/pass_through/Makefile.in4
-rw-r--r--libraries/eina/src/tests/Makefile.am9
-rw-r--r--libraries/eina/src/tests/Makefile.in77
-rw-r--r--libraries/eina/src/tests/cxx_compile_test.cxx34
-rw-r--r--libraries/eina/src/tests/eina_bench.c3
-rw-r--r--libraries/eina/src/tests/eina_bench_hash.c2
-rw-r--r--libraries/eina/src/tests/eina_bench_quad.c2
-rw-r--r--libraries/eina/src/tests/eina_bench_stringshare.c8
-rw-r--r--libraries/eina/src/tests/eina_suite.c2
-rw-r--r--libraries/eina/src/tests/eina_suite.h2
-rw-r--r--libraries/eina/src/tests/eina_test_array.c6
-rw-r--r--libraries/eina/src/tests/eina_test_binbuf.c36
-rw-r--r--libraries/eina/src/tests/eina_test_file.c4
-rw-r--r--libraries/eina/src/tests/eina_test_inarray.c401
-rw-r--r--libraries/eina/src/tests/eina_test_value.c1799
-rw-r--r--libraries/eina/src/tests/evas_list.c2
-rw-r--r--libraries/eina/src/tests/evas_mempool.c2
90 files changed, 15026 insertions, 541 deletions
diff --git a/libraries/eina/src/Makefile.in b/libraries/eina/src/Makefile.in
index c954fc5..eb3a2c0 100644
--- a/libraries/eina/src/Makefile.in
+++ b/libraries/eina/src/Makefile.in
@@ -147,7 +147,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
147EGREP = @EGREP@ 147EGREP = @EGREP@
148EINA_CFLAGS = @EINA_CFLAGS@ 148EINA_CFLAGS = @EINA_CFLAGS@
149EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 149EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
150EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
150EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 151EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
152EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
151EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 153EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
152EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 154EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
153EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 155EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -199,8 +201,6 @@ PACKAGE_URL = @PACKAGE_URL@
199PACKAGE_VERSION = @PACKAGE_VERSION@ 201PACKAGE_VERSION = @PACKAGE_VERSION@
200PATH_SEPARATOR = @PATH_SEPARATOR@ 202PATH_SEPARATOR = @PATH_SEPARATOR@
201PKG_CONFIG = @PKG_CONFIG@ 203PKG_CONFIG = @PKG_CONFIG@
202PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
203PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
204RANLIB = @RANLIB@ 204RANLIB = @RANLIB@
205SED = @SED@ 205SED = @SED@
206SET_MAKE = @SET_MAKE@ 206SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/examples/Makefile.am b/libraries/eina/src/examples/Makefile.am
index ea5ca6a..45b72f0 100644
--- a/libraries/eina/src/examples/Makefile.am
+++ b/libraries/eina/src/examples/Makefile.am
@@ -1,6 +1,6 @@
1MAINTAINERCLEANFILES = Makefile.in 1MAINTAINERCLEANFILES = Makefile.in
2 2
3pkglibdir = $(datadir)/$(PACKAGE)/examples 3examplesdir = $(datadir)/$(PACKAGE)/examples
4 4
5AM_CPPFLAGS = \ 5AM_CPPFLAGS = \
6-I. \ 6-I. \
@@ -39,7 +39,7 @@ SRCS = \
39 eina_strbuf_01.c \ 39 eina_strbuf_01.c \
40 eina_tiler_01.c 40 eina_tiler_01.c
41 41
42pkglib_PROGRAMS = 42examples_PROGRAMS =
43 43
44if EFL_INSTALL_EXAMPLES 44if EFL_INSTALL_EXAMPLES
45filesdir = $(datadir)/$(PACKAGE)/examples 45filesdir = $(datadir)/$(PACKAGE)/examples
@@ -47,9 +47,9 @@ files_DATA = $(SRCS)
47endif 47endif
48 48
49if EFL_BUILD_EXAMPLES 49if EFL_BUILD_EXAMPLES
50pkglib_PROGRAMS += \ 50examples_PROGRAMS += \
51 eina_accessor_01 \ 51 eina_accessor_01 \
52 eina_array_01 \ 52 eina_array_01 \
53 eina_array_02 \ 53 eina_array_02 \
54 eina_error_01 \ 54 eina_error_01 \
55 eina_file_01 \ 55 eina_file_01 \
@@ -77,7 +77,7 @@ pkglib_PROGRAMS += \
77 77
78if BUILD_TILER_EXAMPLE 78if BUILD_TILER_EXAMPLE
79AM_CPPFLAGS += @ECORE_EVAS_CFLAGS@ 79AM_CPPFLAGS += @ECORE_EVAS_CFLAGS@
80pkglib_PROGRAMS += eina_tiler_01 80examples_PROGRAMS += eina_tiler_01
81eina_tiler_01_LDADD = $(top_builddir)/src/lib/libeina.la @ECORE_EVAS_LIBS@ 81eina_tiler_01_LDADD = $(top_builddir)/src/lib/libeina.la @ECORE_EVAS_LIBS@
82endif 82endif
83 83
diff --git a/libraries/eina/src/examples/Makefile.in b/libraries/eina/src/examples/Makefile.in
index 3379e55..6e432bb 100644
--- a/libraries/eina/src/examples/Makefile.in
+++ b/libraries/eina/src/examples/Makefile.in
@@ -19,6 +19,7 @@
19VPATH = @srcdir@ 19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@ 20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@ 21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@ 23pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644 25install_sh_DATA = $(install_sh) -c -m 644
@@ -34,10 +35,10 @@ PRE_UNINSTALL = :
34POST_UNINSTALL = : 35POST_UNINSTALL = :
35build_triplet = @build@ 36build_triplet = @build@
36host_triplet = @host@ 37host_triplet = @host@
37pkglib_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) 38examples_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
38@EFL_BUILD_EXAMPLES_TRUE@am__append_1 = \ 39@EFL_BUILD_EXAMPLES_TRUE@am__append_1 = \
39@EFL_BUILD_EXAMPLES_TRUE@ eina_accessor_01 \ 40@EFL_BUILD_EXAMPLES_TRUE@ eina_accessor_01 \
40@EFL_BUILD_EXAMPLES_TRUE@ eina_array_01 \ 41@EFL_BUILD_EXAMPLES_TRUE@ eina_array_01 \
41@EFL_BUILD_EXAMPLES_TRUE@ eina_array_02 \ 42@EFL_BUILD_EXAMPLES_TRUE@ eina_array_02 \
42@EFL_BUILD_EXAMPLES_TRUE@ eina_error_01 \ 43@EFL_BUILD_EXAMPLES_TRUE@ eina_error_01 \
43@EFL_BUILD_EXAMPLES_TRUE@ eina_file_01 \ 44@EFL_BUILD_EXAMPLES_TRUE@ eina_file_01 \
@@ -115,8 +116,8 @@ CONFIG_CLEAN_VPATH_FILES =
115@EFL_BUILD_EXAMPLES_TRUE@ eina_str_01$(EXEEXT) \ 116@EFL_BUILD_EXAMPLES_TRUE@ eina_str_01$(EXEEXT) \
116@EFL_BUILD_EXAMPLES_TRUE@ eina_strbuf_01$(EXEEXT) 117@EFL_BUILD_EXAMPLES_TRUE@ eina_strbuf_01$(EXEEXT)
117@BUILD_TILER_EXAMPLE_TRUE@@EFL_BUILD_EXAMPLES_TRUE@am__EXEEXT_2 = eina_tiler_01$(EXEEXT) 118@BUILD_TILER_EXAMPLE_TRUE@@EFL_BUILD_EXAMPLES_TRUE@am__EXEEXT_2 = eina_tiler_01$(EXEEXT)
118am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)" 119am__installdirs = "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)"
119PROGRAMS = $(pkglib_PROGRAMS) 120PROGRAMS = $(examples_PROGRAMS)
120eina_accessor_01_SOURCES = eina_accessor_01.c 121eina_accessor_01_SOURCES = eina_accessor_01.c
121eina_accessor_01_OBJECTS = eina_accessor_01.$(OBJEXT) 122eina_accessor_01_OBJECTS = eina_accessor_01.$(OBJEXT)
122eina_accessor_01_LDADD = $(LDADD) 123eina_accessor_01_LDADD = $(LDADD)
@@ -294,7 +295,6 @@ DATA = $(files_DATA)
294ETAGS = etags 295ETAGS = etags
295CTAGS = ctags 296CTAGS = ctags
296DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 297DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
297pkglibdir = $(datadir)/$(PACKAGE)/examples
298ACLOCAL = @ACLOCAL@ 298ACLOCAL = @ACLOCAL@
299ALLOCA = @ALLOCA@ 299ALLOCA = @ALLOCA@
300AMTAR = @AMTAR@ 300AMTAR = @AMTAR@
@@ -337,7 +337,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
337EGREP = @EGREP@ 337EGREP = @EGREP@
338EINA_CFLAGS = @EINA_CFLAGS@ 338EINA_CFLAGS = @EINA_CFLAGS@
339EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 339EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
340EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
340EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 341EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
342EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
341EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 343EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
342EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 344EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
343EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 345EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -389,8 +391,6 @@ PACKAGE_URL = @PACKAGE_URL@
389PACKAGE_VERSION = @PACKAGE_VERSION@ 391PACKAGE_VERSION = @PACKAGE_VERSION@
390PATH_SEPARATOR = @PATH_SEPARATOR@ 392PATH_SEPARATOR = @PATH_SEPARATOR@
391PKG_CONFIG = @PKG_CONFIG@ 393PKG_CONFIG = @PKG_CONFIG@
392PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
393PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
394RANLIB = @RANLIB@ 394RANLIB = @RANLIB@
395SED = @SED@ 395SED = @SED@
396SET_MAKE = @SET_MAKE@ 396SET_MAKE = @SET_MAKE@
@@ -465,6 +465,7 @@ top_builddir = @top_builddir@
465top_srcdir = @top_srcdir@ 465top_srcdir = @top_srcdir@
466version_info = @version_info@ 466version_info = @version_info@
467MAINTAINERCLEANFILES = Makefile.in 467MAINTAINERCLEANFILES = Makefile.in
468examplesdir = $(datadir)/$(PACKAGE)/examples
468AM_CPPFLAGS = -I. -I$(top_srcdir)/src/include \ 469AM_CPPFLAGS = -I. -I$(top_srcdir)/src/include \
469 -I$(top_builddir)/src/include $(am__append_2) 470 -I$(top_builddir)/src/include $(am__append_2)
470LDADD = \ 471LDADD = \
@@ -536,10 +537,10 @@ $(top_srcdir)/configure: $(am__configure_deps)
536$(ACLOCAL_M4): $(am__aclocal_m4_deps) 537$(ACLOCAL_M4): $(am__aclocal_m4_deps)
537 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 538 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
538$(am__aclocal_m4_deps): 539$(am__aclocal_m4_deps):
539install-pkglibPROGRAMS: $(pkglib_PROGRAMS) 540install-examplesPROGRAMS: $(examples_PROGRAMS)
540 @$(NORMAL_INSTALL) 541 @$(NORMAL_INSTALL)
541 test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" 542 test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)"
542 @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ 543 @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \
543 for p in $$list; do echo "$$p $$p"; done | \ 544 for p in $$list; do echo "$$p $$p"; done | \
544 sed 's/$(EXEEXT)$$//' | \ 545 sed 's/$(EXEEXT)$$//' | \
545 while read p p1; do if test -f $$p || test -f $$p1; \ 546 while read p p1; do if test -f $$p || test -f $$p1; \
@@ -556,23 +557,23 @@ install-pkglibPROGRAMS: $(pkglib_PROGRAMS)
556 while read type dir files; do \ 557 while read type dir files; do \
557 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 558 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
558 test -z "$$files" || { \ 559 test -z "$$files" || { \
559 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibdir)$$dir'"; \ 560 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(examplesdir)$$dir'"; \
560 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibdir)$$dir" || exit $$?; \ 561 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(examplesdir)$$dir" || exit $$?; \
561 } \ 562 } \
562 ; done 563 ; done
563 564
564uninstall-pkglibPROGRAMS: 565uninstall-examplesPROGRAMS:
565 @$(NORMAL_UNINSTALL) 566 @$(NORMAL_UNINSTALL)
566 @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ 567 @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \
567 files=`for p in $$list; do echo "$$p"; done | \ 568 files=`for p in $$list; do echo "$$p"; done | \
568 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 569 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
569 -e 's/$$/$(EXEEXT)/' `; \ 570 -e 's/$$/$(EXEEXT)/' `; \
570 test -n "$$list" || exit 0; \ 571 test -n "$$list" || exit 0; \
571 echo " ( cd '$(DESTDIR)$(pkglibdir)' && rm -f" $$files ")"; \ 572 echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \
572 cd "$(DESTDIR)$(pkglibdir)" && rm -f $$files 573 cd "$(DESTDIR)$(examplesdir)" && rm -f $$files
573 574
574clean-pkglibPROGRAMS: 575clean-examplesPROGRAMS:
575 @list='$(pkglib_PROGRAMS)'; test -n "$$list" || exit 0; \ 576 @list='$(examples_PROGRAMS)'; test -n "$$list" || exit 0; \
576 echo " rm -f" $$list; \ 577 echo " rm -f" $$list; \
577 rm -f $$list || exit $$?; \ 578 rm -f $$list || exit $$?; \
578 test -n "$(EXEEXT)" || exit 0; \ 579 test -n "$(EXEEXT)" || exit 0; \
@@ -831,7 +832,7 @@ check-am: all-am
831check: check-am 832check: check-am
832all-am: Makefile $(PROGRAMS) $(DATA) 833all-am: Makefile $(PROGRAMS) $(DATA)
833installdirs: 834installdirs:
834 for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)"; do \ 835 for dir in "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)"; do \
835 test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 836 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
836 done 837 done
837install: install-am 838install: install-am
@@ -862,7 +863,7 @@ maintainer-clean-generic:
862 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) 863 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
863clean: clean-am 864clean: clean-am
864 865
865clean-am: clean-generic clean-libtool clean-pkglibPROGRAMS \ 866clean-am: clean-examplesPROGRAMS clean-generic clean-libtool \
866 mostlyclean-am 867 mostlyclean-am
867 868
868distclean: distclean-am 869distclean: distclean-am
@@ -883,13 +884,13 @@ info: info-am
883 884
884info-am: 885info-am:
885 886
886install-data-am: install-filesDATA 887install-data-am: install-examplesPROGRAMS install-filesDATA
887 888
888install-dvi: install-dvi-am 889install-dvi: install-dvi-am
889 890
890install-dvi-am: 891install-dvi-am:
891 892
892install-exec-am: install-pkglibPROGRAMS 893install-exec-am:
893 894
894install-html: install-html-am 895install-html: install-html-am
895 896
@@ -929,24 +930,25 @@ ps: ps-am
929 930
930ps-am: 931ps-am:
931 932
932uninstall-am: uninstall-filesDATA uninstall-pkglibPROGRAMS 933uninstall-am: uninstall-examplesPROGRAMS uninstall-filesDATA
933 934
934.MAKE: install-am install-strip 935.MAKE: install-am install-strip
935 936
936.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ 937.PHONY: CTAGS GTAGS all all-am check check-am clean \
937 clean-libtool clean-pkglibPROGRAMS ctags distclean \ 938 clean-examplesPROGRAMS clean-generic clean-libtool ctags \
938 distclean-compile distclean-generic distclean-libtool \ 939 distclean distclean-compile distclean-generic \
939 distclean-tags distdir dvi dvi-am html html-am info info-am \ 940 distclean-libtool distclean-tags distdir dvi dvi-am html \
940 install install-am install-data install-data-am install-dvi \ 941 html-am info info-am install install-am install-data \
941 install-dvi-am install-exec install-exec-am install-filesDATA \ 942 install-data-am install-dvi install-dvi-am \
942 install-html install-html-am install-info install-info-am \ 943 install-examplesPROGRAMS install-exec install-exec-am \
943 install-man install-pdf install-pdf-am install-pkglibPROGRAMS \ 944 install-filesDATA install-html install-html-am install-info \
945 install-info-am install-man install-pdf install-pdf-am \
944 install-ps install-ps-am install-strip installcheck \ 946 install-ps install-ps-am install-strip installcheck \
945 installcheck-am installdirs maintainer-clean \ 947 installcheck-am installdirs maintainer-clean \
946 maintainer-clean-generic mostlyclean mostlyclean-compile \ 948 maintainer-clean-generic mostlyclean mostlyclean-compile \
947 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ 949 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
948 tags uninstall uninstall-am uninstall-filesDATA \ 950 tags uninstall uninstall-am uninstall-examplesPROGRAMS \
949 uninstall-pkglibPROGRAMS 951 uninstall-filesDATA
950 952
951 953
952# Tell versions [3.59,3.63) of GNU make to not export all variables. 954# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/libraries/eina/src/examples/eina_array_01.c b/libraries/eina/src/examples/eina_array_01.c
index 25e0944..d93eb35 100644
--- a/libraries/eina/src/examples/eina_array_01.c
+++ b/libraries/eina/src/examples/eina_array_01.c
@@ -35,12 +35,12 @@ main(int argc, char **argv)
35 for (i = 0; i < 20; i++) 35 for (i = 0; i < 20; i++)
36 eina_array_push(array, strdup(strings[i])); 36 eina_array_push(array, strdup(strings[i]));
37 37
38 printf("array count: %d\n", eina_array_count_get(array)); 38 printf("array count: %d\n", eina_array_count(array));
39 eina_array_foreach(array, _print, NULL); 39 eina_array_foreach(array, _print, NULL);
40 40
41 printf("Top gun: %s\n", (char*)eina_array_data_get(array, 2)); 41 printf("Top gun: %s\n", (char*)eina_array_data_get(array, 2));
42 42
43 while (eina_array_count_get(array)) 43 while (eina_array_count(array))
44 free(eina_array_pop(array)); 44 free(eina_array_pop(array));
45 45
46 eina_array_free(array); 46 eina_array_free(array);
diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h
index 68c41f5..721a991 100644
--- a/libraries/eina/src/include/Eina.h
+++ b/libraries/eina/src/include/Eina.h
@@ -47,7 +47,7 @@
47 * 47 *
48 * @version 1.1 48 * @version 1.1
49 * @date 2008-2011 49 * @date 2008-2011
50 * 50 *
51 * @section eina_intro_sec Introduction 51 * @section eina_intro_sec Introduction
52 * 52 *
53 * The Eina library is a library that implements an API for data types 53 * The Eina library is a library that implements an API for data types
@@ -59,10 +59,11 @@
59 * Linux, BSD, Opensolaris and Windows (XP and CE). 59 * Linux, BSD, Opensolaris and Windows (XP and CE).
60 * 60 *
61 * The data types that are available are (see @ref Eina_Data_Types_Group): 61 * The data types that are available are (see @ref Eina_Data_Types_Group):
62 * @li @ref Eina_Inline_Array_Group standard array of inlined members.
62 * @li @ref Eina_Array_Group standard array of @c void* data. 63 * @li @ref Eina_Array_Group standard array of @c void* data.
63 * @li @ref Eina_Hash_Group standard hash of @c void* data. 64 * @li @ref Eina_Hash_Group standard hash of @c void* data.
64 * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. 65 * @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
65 * @li @ref Eina_CList_Group compact inlined list. 66 * @li @ref Eina_CList_Group Compact List.
66 * @li @ref Eina_List_Group standard list of @c void* data. 67 * @li @ref Eina_List_Group standard list of @c void* data.
67 * @li @ref Eina_Iterator_Group Iterator functions. 68 * @li @ref Eina_Iterator_Group Iterator functions.
68 * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. 69 * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
@@ -89,7 +90,7 @@
89 * 90 *
90 * Please see the @ref authors page for contact details. 91 * Please see the @ref authors page for contact details.
91 * 92 *
92 * @defgroup Eina_Data_Types_Group Data types 93 * @defgroup Eina_Data_Types_Group Data Types
93 * 94 *
94 * Eina provide easy to use and optimized data types and structures. 95 * Eina provide easy to use and optimized data types and structures.
95 * 96 *
@@ -158,6 +159,7 @@ extern "C" {
158#include "eina_mempool.h" 159#include "eina_mempool.h"
159#include "eina_error.h" 160#include "eina_error.h"
160#include "eina_log.h" 161#include "eina_log.h"
162#include "eina_inarray.h"
161#include "eina_array.h" 163#include "eina_array.h"
162#include "eina_binshare.h" 164#include "eina_binshare.h"
163#include "eina_stringshare.h" 165#include "eina_stringshare.h"
@@ -186,6 +188,7 @@ extern "C" {
186#include "eina_refcount.h" 188#include "eina_refcount.h"
187#include "eina_mmap.h" 189#include "eina_mmap.h"
188#include "eina_xattr.h" 190#include "eina_xattr.h"
191#include "eina_value.h"
189 192
190#ifdef __cplusplus 193#ifdef __cplusplus
191} 194}
diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am
index 41a37cb..a818d5f 100644
--- a/libraries/eina/src/include/Makefile.am
+++ b/libraries/eina/src/include/Makefile.am
@@ -14,6 +14,8 @@ eina_hash.h \
14eina_inline_hash.x \ 14eina_inline_hash.x \
15eina_lalloc.h \ 15eina_lalloc.h \
16eina_clist.h \ 16eina_clist.h \
17eina_inline_clist.x \
18eina_inarray.h \
17eina_inlist.h \ 19eina_inlist.h \
18eina_list.h \ 20eina_list.h \
19eina_file.h \ 21eina_file.h \
@@ -60,7 +62,9 @@ eina_lock.h \
60eina_prefix.h \ 62eina_prefix.h \
61eina_refcount.h \ 63eina_refcount.h \
62eina_mmap.h \ 64eina_mmap.h \
63eina_xattr.h 65eina_xattr.h \
66eina_value.h \
67eina_inline_value.x
64 68
65# Will be back for developper after 1.1. 69# Will be back for developper after 1.1.
66# eina_object.h 70# eina_object.h
diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in
index f6e0074..ea922e5 100644
--- a/libraries/eina/src/include/Makefile.in
+++ b/libraries/eina/src/include/Makefile.in
@@ -78,23 +78,24 @@ am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \
78 eina_error.h eina_log.h eina_inline_log.x eina_fp.h \ 78 eina_error.h eina_log.h eina_inline_log.x eina_fp.h \
79 eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \ 79 eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \
80 eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \ 80 eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \
81 eina_clist.h eina_inlist.h eina_list.h eina_file.h \ 81 eina_clist.h eina_inline_clist.x eina_inarray.h eina_inlist.h \
82 eina_mempool.h eina_module.h eina_rectangle.h eina_types.h \ 82 eina_list.h eina_file.h eina_mempool.h eina_module.h \
83 eina_array.h eina_counter.h eina_inline_array.x eina_magic.h \ 83 eina_rectangle.h eina_types.h eina_array.h eina_counter.h \
84 eina_stringshare.h eina_binshare.h eina_binbuf.h \ 84 eina_inline_array.x eina_magic.h eina_stringshare.h \
85 eina_ustringshare.h eina_inline_stringshare.x \ 85 eina_binshare.h eina_binbuf.h eina_ustringshare.h \
86 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ 86 eina_inline_stringshare.x eina_inline_ustringshare.x \
87 eina_convert.h eina_rbtree.h eina_benchmark.h \ 87 eina_inline_list.x eina_accessor.h eina_convert.h \
88 eina_inline_rbtree.x eina_inline_mempool.x \ 88 eina_rbtree.h eina_benchmark.h eina_inline_rbtree.x \
89 eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \ 89 eina_inline_mempool.x eina_inline_rectangle.x \
90 eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \ 90 eina_inline_trash.x eina_trash.h eina_iterator.h eina_main.h \
91 eina_tiler.h eina_hamster.h eina_matrixsparse.h \ 91 eina_cpu.h eina_sched.h eina_tiler.h eina_hamster.h \
92 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ 92 eina_matrixsparse.h eina_inline_tiler.x eina_str.h \
93 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ 93 eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \
94 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ 94 eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \
95 eina_refcount.h eina_mmap.h eina_xattr.h \ 95 eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \
96 eina_inline_lock_wince.x eina_inline_lock_win32.x \ 96 eina_value.h eina_inline_value.x eina_inline_lock_wince.x \
97 eina_inline_lock_posix.x eina_inline_lock_void.x 97 eina_inline_lock_win32.x eina_inline_lock_posix.x \
98 eina_inline_lock_void.x
98am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 99am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
99am__vpath_adj = case $$p in \ 100am__vpath_adj = case $$p in \
100 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 101 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -163,7 +164,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 164EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 165EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 166EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
167EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 168EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
169EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 170EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 171EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 172EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +218,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 218PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 219PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 220PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 221RANLIB = @RANLIB@
221SED = @SED@ 222SED = @SED@
222SET_MAKE = @SET_MAKE@ 223SET_MAKE = @SET_MAKE@
@@ -295,10 +296,10 @@ EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \
295 eina_inline_log.x eina_fp.h eina_inline_f32p32.x \ 296 eina_inline_log.x eina_fp.h eina_inline_f32p32.x \
296 eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \ 297 eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \
297 eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \ 298 eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \
298 eina_inlist.h eina_list.h eina_file.h eina_mempool.h \ 299 eina_inline_clist.x eina_inarray.h eina_inlist.h eina_list.h \
299 eina_module.h eina_rectangle.h eina_types.h eina_array.h \ 300 eina_file.h eina_mempool.h eina_module.h eina_rectangle.h \
300 eina_counter.h eina_inline_array.x eina_magic.h \ 301 eina_types.h eina_array.h eina_counter.h eina_inline_array.x \
301 eina_stringshare.h eina_binshare.h eina_binbuf.h \ 302 eina_magic.h eina_stringshare.h eina_binshare.h eina_binbuf.h \
302 eina_ustringshare.h eina_inline_stringshare.x \ 303 eina_ustringshare.h eina_inline_stringshare.x \
303 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ 304 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \
304 eina_convert.h eina_rbtree.h eina_benchmark.h \ 305 eina_convert.h eina_rbtree.h eina_benchmark.h \
@@ -309,8 +310,9 @@ EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \
309 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ 310 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \
310 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ 311 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \
311 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ 312 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \
312 eina_refcount.h eina_mmap.h eina_xattr.h $(am__append_1) \ 313 eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \
313 $(am__append_2) $(am__append_3) $(am__append_4) 314 eina_inline_value.x $(am__append_1) $(am__append_2) \
315 $(am__append_3) $(am__append_4)
314installed_mainheaderdir = $(includedir)/eina-@VMAJ@ 316installed_mainheaderdir = $(includedir)/eina-@VMAJ@
315dist_installed_mainheader_DATA = Eina.h eina_config.h 317dist_installed_mainheader_DATA = Eina.h eina_config.h
316installed_headersdir = $(includedir)/eina-@VMAJ@/eina 318installed_headersdir = $(includedir)/eina-@VMAJ@/eina
diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h
index d33f5e9..53183b4 100644
--- a/libraries/eina/src/include/eina_array.h
+++ b/libraries/eina/src/include/eina_array.h
@@ -31,7 +31,7 @@
31 31
32 32
33/** 33/**
34 * @page array_01_example_page Basic array usage 34 * @page eina_array_01_example_page Basic array usage
35 * @dontinclude eina_array_01.c 35 * @dontinclude eina_array_01.c
36 * 36 *
37 * For this example we add stdlib.h, stdio.h and string.h for some 37 * For this example we add stdlib.h, stdio.h and string.h for some
@@ -94,7 +94,7 @@
94 */ 94 */
95 95
96/** 96/**
97 * @page array_02_example_page Removing array elements 97 * @page eina_array_02_example_page Removing array elements
98 * @dontinclude eina_array_02.c 98 * @dontinclude eina_array_02.c
99 * 99 *
100 * Just the usual includes: 100 * Just the usual includes:
@@ -169,7 +169,7 @@
169 * element, use eina_array_push() and to remove the last element, use 169 * element, use eina_array_push() and to remove the last element, use
170 * eina_array_pop(). To retrieve the element at a given position, use 170 * eina_array_pop(). To retrieve the element at a given position, use
171 * eina_array_data_get(). The number of elements can be retrieved with 171 * eina_array_data_get(). The number of elements can be retrieved with
172 * eina_array_count_get(). 172 * eina_array_count().
173 * 173 *
174 * Eina_Array is different from a conventional C array in a number of ways, most 174 * Eina_Array is different from a conventional C array in a number of ways, most
175 * importantly they grow and shrink dynamically, this means that if you add an 175 * importantly they grow and shrink dynamically, this means that if you add an
@@ -191,8 +191,8 @@
191 * of void pointers. 191 * of void pointers.
192 * 192 *
193 * See here some examples: 193 * See here some examples:
194 * @li @ref array_01_example_page 194 * @li @ref eina_array_01_example_page
195 * @li @ref array_02_example_page 195 * @li @ref eina_array_02_example_page
196 */ 196 */
197 197
198/** 198/**
@@ -351,7 +351,8 @@ static inline void *eina_array_data_get(const Eina_Array *array,
351static inline void eina_array_data_set(const Eina_Array *array, 351static inline void eina_array_data_set(const Eina_Array *array,
352 unsigned int idx, 352 unsigned int idx,
353 const void *data) EINA_ARG_NONNULL(1); 353 const void *data) EINA_ARG_NONNULL(1);
354static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1); 354static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_DEPRECATED;
355static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
355 356
356/** 357/**
357 * @brief Returned a new iterator associated to an array. 358 * @brief Returned a new iterator associated to an array.
@@ -394,7 +395,7 @@ EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA
394 */ 395 */
395static inline Eina_Bool eina_array_foreach(Eina_Array *array, 396static inline Eina_Bool eina_array_foreach(Eina_Array *array,
396 Eina_Each_Cb cb, 397 Eina_Each_Cb cb,
397 void *data); 398 void *fdata);
398/** 399/**
399 * @def EINA_ARRAY_ITER_NEXT 400 * @def EINA_ARRAY_ITER_NEXT
400 * @brief Macro to iterate over an array easily. 401 * @brief Macro to iterate over an array easily.
@@ -429,7 +430,7 @@ static inline Eina_Bool eina_array_foreach(Eina_Array *array,
429 */ 430 */
430#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \ 431#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
431 for (index = 0, iterator = (array)->data; \ 432 for (index = 0, iterator = (array)->data; \
432 (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \ 433 (index < eina_array_count(array)) && ((item = *((iterator)++))); \
433 ++(index)) 434 ++(index))
434 435
435#include "eina_inline_array.x" 436#include "eina_inline_array.x"
diff --git a/libraries/eina/src/include/eina_benchmark.h b/libraries/eina/src/include/eina_benchmark.h
index 721e1c0..9e96d64 100644
--- a/libraries/eina/src/include/eina_benchmark.h
+++ b/libraries/eina/src/include/eina_benchmark.h
@@ -398,9 +398,9 @@ EAPI void eina_benchmark_free(Eina_Benchmark *bench);
398 * 398 *
399 * This function adds the test named @p name to @p benchmark. @p 399 * This function adds the test named @p name to @p benchmark. @p
400 * bench_cb is the function called when the test is executed. That 400 * bench_cb is the function called when the test is executed. That
401 * test can be executed a certain amount of time. @p start, @p end and 401 * test can be executed a certain amount of time. @p count_start, @p count_end and
402 * @p step define a loop with a step increment. The integer that is 402 * @p count_step define a loop with a step increment. The integer that is
403 * increasing by @p step from @p start to @p end is passed to @p 403 * increasing by @p count_step from @p count_start to @p count_end is passed to @p
404 * bench_cb when eina_benchmark_run() is called. 404 * bench_cb when eina_benchmark_run() is called.
405 * 405 *
406 * If @p bench is @c NULL, this function returns imediatly. If the 406 * If @p bench is @c NULL, this function returns imediatly. If the
@@ -413,7 +413,7 @@ EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench,
413 Eina_Benchmark_Specimens bench_cb, 413 Eina_Benchmark_Specimens bench_cb,
414 int count_start, 414 int count_start,
415 int count_end, 415 int count_end,
416 int count_set); 416 int count_step);
417 417
418/** 418/**
419 * @brief Run the benchmark tests that have been registered. 419 * @brief Run the benchmark tests that have been registered.
diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h
index 92f788e..7c3524b 100644
--- a/libraries/eina/src/include/eina_binbuf.h
+++ b/libraries/eina/src/include/eina_binbuf.h
@@ -49,6 +49,24 @@ typedef struct _Eina_Strbuf Eina_Binbuf;
49EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 49EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
50 50
51/** 51/**
52 * @brief Create a new string buffer using the passed string. The passed
53 * string is used directly as the buffer, it's somehow the opposite function of
54 * @ref eina_binbuf_string_steal . The passed string must be malloced.
55 *
56 * @param str the string to manage
57 * @param length the length of the string.
58 * @return Newly allocated string buffer instance.
59 *
60 * This function creates a new string buffer. On error, @c NULL is
61 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
62 * free the resources, use eina_binbuf_free().
63 *
64 * @see eina_binbuf_manage_new()
65 * @since 1.2.0
66 */
67EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
68
69/**
52 * @brief Free a string buffer. 70 * @brief Free a string buffer.
53 * 71 *
54 * @param buf The string buffer to free. 72 * @param buf The string buffer to free.
diff --git a/libraries/eina/src/include/eina_clist.h b/libraries/eina/src/include/eina_clist.h
index 68f15df..096a4b7 100644
--- a/libraries/eina/src/include/eina_clist.h
+++ b/libraries/eina/src/include/eina_clist.h
@@ -23,7 +23,22 @@
23#define __EINA_CLIST_H__ 23#define __EINA_CLIST_H__
24 24
25/** 25/**
26 * @addtogroup Eina_CList_Group Compact inline list 26 * @addtogroup Eina_Data_Types_Group Data Types
27 *
28 * @{
29 */
30
31/**
32 * @addtogroup Eina_Containers_Group Containers
33 *
34 * @{
35 */
36
37/**
38 * @defgroup Eina_CList_Group Compact List
39 *
40 * @{
41 *
27 * @brief Eina_Clist is a compact (inline) list implementation 42 * @brief Eina_Clist is a compact (inline) list implementation
28 * 43 *
29 * Elements of this list are members of the structs stored in the list 44 * Elements of this list are members of the structs stored in the list
@@ -42,9 +57,8 @@
42 * @note There's no NULL at the end of the list, the last item points to the head. 57 * @note There's no NULL at the end of the list, the last item points to the head.
43 * 58 *
44 * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init 59 * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init
45 */ 60 *
46 61 * Define a list like so:
47/* Define a list like so:
48 * 62 *
49 * @code 63 * @code
50 * struct gadget 64 * struct gadget
@@ -88,24 +102,6 @@
88 */ 102 */
89 103
90/** 104/**
91 * @addtogroup Eina_Data_Types_Group Data Types
92 *
93 * @{
94 */
95
96/**
97 * @addtogroup Eina_Containers_Group Containers
98 *
99 * @{
100 */
101
102/**
103 * @defgroup Eina_CList_Group Compact list
104 *
105 * @{
106 */
107
108/**
109 * @typedef Eina_Clist 105 * @typedef Eina_Clist
110 * This is the list head and the list entry. 106 * This is the list head and the list entry.
111 * @since 1.1.0 107 * @since 1.1.0
@@ -135,13 +131,7 @@ struct _Eina_Clist
135 * @note There's no need to initialize an element before adding it to the list. 131 * @note There's no need to initialize an element before adding it to the list.
136 * @since 1.1.0 132 * @since 1.1.0
137 */ 133 */
138static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add) 134static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add);
139{
140 to_add->next = elem->next;
141 to_add->prev = elem;
142 elem->next->prev = to_add;
143 elem->next = to_add;
144}
145 135
146/** 136/**
147 * Add an element before the specified one. 137 * Add an element before the specified one.
@@ -154,13 +144,7 @@ static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
154 * @note There's no need to initialize an element before adding it to the list. 144 * @note There's no need to initialize an element before adding it to the list.
155 * @since 1.1.0 145 * @since 1.1.0
156 */ 146 */
157static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add) 147static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add);
158{
159 to_add->next = elem;
160 to_add->prev = elem->prev;
161 elem->prev->next = to_add;
162 elem->prev = to_add;
163}
164 148
165/** 149/**
166 * Add element at the head of the list. 150 * Add element at the head of the list.
@@ -173,10 +157,7 @@ static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
173 * @note There's no need to initialize an element before adding it to the list. 157 * @note There's no need to initialize an element before adding it to the list.
174 * @since 1.1.0 158 * @since 1.1.0
175 */ 159 */
176static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) 160static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem);
177{
178 eina_clist_add_after(list, elem);
179}
180 161
181/** 162/**
182 * Add element at the tail of the list. 163 * Add element at the tail of the list.
@@ -189,10 +170,7 @@ static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
189 * @note There's no need to initialize an element before adding it to the list. 170 * @note There's no need to initialize an element before adding it to the list.
190 * @since 1.1.0 171 * @since 1.1.0
191 */ 172 */
192static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) 173static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem);
193{
194 eina_clist_add_before(list, elem);
195}
196 174
197/** 175/**
198 * Init an (unlinked) element. 176 * Init an (unlinked) element.
@@ -207,11 +185,7 @@ static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
207 * @note It is not necessary to call this before adding an element to this list. 185 * @note It is not necessary to call this before adding an element to this list.
208 * @since 1.1.0 186 * @since 1.1.0
209 */ 187 */
210static inline void eina_clist_element_init(Eina_Clist *elem) 188static inline void eina_clist_element_init(Eina_Clist *elem);
211{
212 elem->next = NULL;
213 elem->prev = NULL;
214}
215 189
216/** 190/**
217 * Check if an element is in a list or not. 191 * Check if an element is in a list or not.
@@ -222,10 +196,7 @@ static inline void eina_clist_element_init(Eina_Clist *elem)
222 * it has been added to a list or remove from a list. 196 * it has been added to a list or remove from a list.
223 * @since 1.1.0 197 * @since 1.1.0
224 */ 198 */
225static inline int eina_clist_element_is_linked(Eina_Clist *elem) 199static inline int eina_clist_element_is_linked(Eina_Clist *elem);
226{
227 return (elem->next != NULL && elem->prev != NULL);
228}
229 200
230/** 201/**
231 * Remove an element from its list. 202 * Remove an element from its list.
@@ -235,12 +206,7 @@ static inline int eina_clist_element_is_linked(Eina_Clist *elem)
235 * @post The element is marked as not being in any list 206 * @post The element is marked as not being in any list
236 * @since 1.1.0 207 * @since 1.1.0
237 */ 208 */
238static inline void eina_clist_remove(Eina_Clist *elem) 209static inline void eina_clist_remove(Eina_Clist *elem);
239{
240 elem->next->prev = elem->prev;
241 elem->prev->next = elem->next;
242 eina_clist_element_init(elem);
243}
244 210
245/** 211/**
246 * Get the next element. 212 * Get the next element.
@@ -248,15 +214,10 @@ static inline void eina_clist_remove(Eina_Clist *elem)
248 * @param list The list 214 * @param list The list
249 * @param elem An element 215 * @param elem An element
250 * @pre @a elem is in @a list 216 * @pre @a elem is in @a list
251 * @return The element after @elem in @list or NULL if @a elem is last in @a list 217 * @return The element after @a elem in @a list or @c NULL if @a elem is last in @a list
252 * @since 1.1.0 218 * @since 1.1.0
253 */ 219 */
254static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem) 220static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem);
255{
256 Eina_Clist *ret = elem->next;
257 if (elem->next == list) ret = NULL;
258 return ret;
259}
260 221
261/** 222/**
262 * Get the previous element. 223 * Get the previous element.
@@ -267,12 +228,7 @@ static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Cli
267 * @return The element before @a elem or NULL if @a elem is the first in the list 228 * @return The element before @a elem or NULL if @a elem is the first in the list
268 * @since 1.1.0 229 * @since 1.1.0
269 */ 230 */
270static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem) 231static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem);
271{
272 Eina_Clist *ret = elem->prev;
273 if (elem->prev == list) ret = NULL;
274 return ret;
275}
276 232
277/** 233/**
278 * Get the first element. 234 * Get the first element.
@@ -281,22 +237,16 @@ static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Cli
281 * @returns The first element in @a list or NULL if @a list is empty 237 * @returns The first element in @a list or NULL if @a list is empty
282 * @since 1.1.0 238 * @since 1.1.0
283 */ 239 */
284static inline Eina_Clist *eina_clist_head(const Eina_Clist *list) 240static inline Eina_Clist *eina_clist_head(const Eina_Clist *list);
285{
286 return eina_clist_next(list, list);
287}
288 241
289/** 242/**
290 * Get the last element. 243 * Get the last element.
291 * 244 *
292 * @param list The list 245 * @param list The list
293 * @returns The last element in @a list or NULL if @list is empty 246 * @returns The last element in @a list or NULL if @a list is empty
294 * @since 1.1.0 247 * @since 1.1.0
295 */ 248 */
296static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) 249static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list);
297{
298 return eina_clist_prev(list, list);
299}
300 250
301/** 251/**
302 * Check if a list is empty. 252 * Check if a list is empty.
@@ -305,10 +255,7 @@ static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
305 * @returns non-zero if @a list is empty, zero if it is not 255 * @returns non-zero if @a list is empty, zero if it is not
306 * @since 1.1.0 256 * @since 1.1.0
307 */ 257 */
308static inline int eina_clist_empty(const Eina_Clist *list) 258static inline int eina_clist_empty(const Eina_Clist *list);
309{
310 return list->next == list;
311}
312 259
313/** 260/**
314 * Initialize a list 261 * Initialize a list
@@ -322,10 +269,7 @@ static inline int eina_clist_empty(const Eina_Clist *list)
322 * initialize the list by zero'ing out the list head. 269 * initialize the list by zero'ing out the list head.
323 * @since 1.1.0 270 * @since 1.1.0
324 */ 271 */
325static inline void eina_clist_init(Eina_Clist *list) 272static inline void eina_clist_init(Eina_Clist *list);
326{
327 list->next = list->prev = list;
328}
329 273
330/** 274/**
331 * Count the elements of a list 275 * Count the elements of a list
@@ -334,13 +278,7 @@ static inline void eina_clist_init(Eina_Clist *list)
334 * @returns The number of items in the list 278 * @returns The number of items in the list
335 * @since 1.1.0 279 * @since 1.1.0
336 */ 280 */
337static inline unsigned int eina_clist_count(const Eina_Clist *list) 281static inline unsigned int eina_clist_count(const Eina_Clist *list);
338{
339 unsigned count = 0;
340 const Eina_Clist *ptr;
341 for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
342 return count;
343}
344 282
345/** 283/**
346 * Move all elements from src to the tail of dst 284 * Move all elements from src to the tail of dst
@@ -351,16 +289,7 @@ static inline unsigned int eina_clist_count(const Eina_Clist *list)
351 * @post @a src is initialized but empty after this operation 289 * @post @a src is initialized but empty after this operation
352 * @since 1.1.0 290 * @since 1.1.0
353 */ 291 */
354static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src) 292static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src);
355{
356 if (eina_clist_empty(src)) return;
357
358 dst->prev->next = src->next;
359 src->next->prev = dst->prev;
360 dst->prev = src->prev;
361 src->prev->next = dst;
362 eina_clist_init(src);
363}
364 293
365/** 294/**
366 * move all elements from src to the head of dst 295 * move all elements from src to the head of dst
@@ -371,16 +300,7 @@ static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
371 * @post @a src is initialized but empty after this operation 300 * @post @a src is initialized but empty after this operation
372 * @since 1.1.0 301 * @since 1.1.0
373 */ 302 */
374static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src) 303static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src);
375{
376 if (eina_clist_empty(src)) return;
377
378 dst->next->prev = src->prev;
379 src->prev->next = dst->next;
380 dst->next = src->next;
381 src->next->prev = dst;
382 eina_clist_init(src);
383}
384 304
385/** 305/**
386 * iterate through the list 306 * iterate through the list
@@ -441,15 +361,17 @@ static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
441#define EINA_CLIST_ENTRY(elem, type, field) \ 361#define EINA_CLIST_ENTRY(elem, type, field) \
442 ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) 362 ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
443 363
444/* 364#include "eina_inline_clist.x"
365
366/**
445 * @} 367 * @}
446 */ 368 */
447 369
448/* 370/**
449 * @} 371 * @}
450 */ 372 */
451 373
452/* 374/**
453 * @} 375 * @}
454 */ 376 */
455 377
diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h
index 3341731..474edaa 100644
--- a/libraries/eina/src/include/eina_config.h
+++ b/libraries/eina/src/include/eina_config.h
@@ -64,4 +64,14 @@
64#endif 64#endif
65 65
66 66
67#ifdef EINA_CONFIGURE_HAVE_DIRENT_H
68# undef EINA_CONFIGURE_HAVE_DIRENT_H
69#endif
70#define EINA_HAVE_DIRENT_H
71
72#ifdef EINA_CONFIGURE_ENABLE_LOG
73# undef EINA_CONFIGURE_ENABLE_LOG
74#endif
75#define EINA_ENABLE_LOG
76
67#endif /* EINA_CONFIG_H_ */ 77#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in
index be328cd..2459ace 100644
--- a/libraries/eina/src/include/eina_config.h.in
+++ b/libraries/eina/src/include/eina_config.h.in
@@ -64,4 +64,14 @@
64#endif 64#endif
65@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 65@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
66 66
67#ifdef EINA_CONFIGURE_HAVE_DIRENT_H
68# undef EINA_CONFIGURE_HAVE_DIRENT_H
69#endif
70@EINA_CONFIGURE_HAVE_DIRENT_H@
71
72#ifdef EINA_CONFIGURE_ENABLE_LOG
73# undef EINA_CONFIGURE_ENABLE_LOG
74#endif
75@EINA_CONFIGURE_ENABLE_LOG@
76
67#endif /* EINA_CONFIG_H_ */ 77#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h
index 01ef8f5..422fb65 100644
--- a/libraries/eina/src/include/eina_file.h
+++ b/libraries/eina/src/include/eina_file.h
@@ -94,6 +94,9 @@ typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
94 * @typedef Eina_File_Dir_List_Cb 94 * @typedef Eina_File_Dir_List_Cb
95 * Type for a callback to be called when iterating over the files of a 95 * Type for a callback to be called when iterating over the files of a
96 * directory. 96 * directory.
97 * @param The file name EXCLUDING the path
98 * @param path The path passed to eina_file_dir_list()
99 * @param data The data passed to eina_file_dir_list()
97 */ 100 */
98typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data); 101typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
99 102
@@ -345,6 +348,33 @@ EAPI time_t eina_file_mtime_get(Eina_File *file);
345EAPI const char *eina_file_filename_get(Eina_File *file); 348EAPI const char *eina_file_filename_get(Eina_File *file);
346 349
347/** 350/**
351 * @brief Get the eXtended attribute of an open file.
352 *
353 * @param file The file handler to request the eXtended attribute from.
354 * @return an iterator.
355 *
356 * The iterator will list all eXtended attribute name without allocating
357 * them, so you need to copy them yourself if needed.
358 *
359 * @since 1.2
360 */
361EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file);
362
363/**
364 * @brief Get the eXtended attribute of an open file.
365 *
366 * @param file The file handler to request the eXtended attribute from.
367 * @return an iterator.
368 *
369 * The iterator will list all eXtended attribute without allocating
370 * them, so you need to copy them yourself if needed. It is returning
371 * Eina_Xattr structure.
372 *
373 * @since 1.2
374 */
375EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file);
376
377/**
348 * @brief Map all the file to a buffer. 378 * @brief Map all the file to a buffer.
349 * 379 *
350 * @param file The file handler to map in memory 380 * @param file The file handler to map in memory
@@ -382,6 +412,16 @@ EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
382EAPI void eina_file_map_free(Eina_File *file, void *map); 412EAPI void eina_file_map_free(Eina_File *file, void *map);
383 413
384/** 414/**
415 * @brief Tell if their was an IO error during the life of a mmaped file
416 *
417 * @param file The file handler to the mmaped file.
418 * @param map Memory map to check if an error occured on it.
419 *
420 * @since 1.2
421 */
422EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map);
423
424/**
385 * @} 425 * @}
386 */ 426 */
387 427
diff --git a/libraries/eina/src/include/eina_hash.h b/libraries/eina/src/include/eina_hash.h
index c8eb048..57316b2 100644
--- a/libraries/eina/src/include/eina_hash.h
+++ b/libraries/eina/src/include/eina_hash.h
@@ -578,7 +578,7 @@ EAPI Eina_Bool eina_hash_del(Eina_Hash *hash,
578 * otherwise. 578 * otherwise.
579 */ 579 */
580EAPI void *eina_hash_find(const Eina_Hash *hash, 580EAPI void *eina_hash_find(const Eina_Hash *hash,
581 const void *key) EINA_ARG_NONNULL(1, 2); 581 const void *key) EINA_ARG_NONNULL(2);
582 582
583/** 583/**
584 * @brief Modify the entry pointer at the specified key and return the old 584 * @brief Modify the entry pointer at the specified key and return the old
@@ -1005,7 +1005,7 @@ EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MAL
1005 * @endcode 1005 * @endcode
1006 */ 1006 */
1007EAPI void eina_hash_foreach(const Eina_Hash *hash, 1007EAPI void eina_hash_foreach(const Eina_Hash *hash,
1008 Eina_Hash_Foreach cb, 1008 Eina_Hash_Foreach func,
1009 const void *fdata) EINA_ARG_NONNULL(1, 2); 1009 const void *fdata) EINA_ARG_NONNULL(1, 2);
1010/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */ 1010/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
1011EAPI int eina_hash_superfast(const char *key, 1011EAPI int eina_hash_superfast(const char *key,
diff --git a/libraries/eina/src/include/eina_inarray.h b/libraries/eina/src/include/eina_inarray.h
new file mode 100644
index 0000000..d37c76b
--- /dev/null
+++ b/libraries/eina/src/include/eina_inarray.h
@@ -0,0 +1,572 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INARRAY_H_
20#define EINA_INARRAY_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_accessor.h"
25
26/**
27 * @addtogroup Eina_Data_Types_Group Data Types
28 *
29 * @since 1.2
30 *
31 * @{
32 */
33
34/**
35 * @addtogroup Eina_Containers_Group Containers
36 *
37 * @{
38 */
39
40/**
41 * @defgroup Eina_Inline_Array_Group Inline Array
42 *
43 * @{
44 */
45
46
47/**
48 * @typedef Eina_Inarray
49 * Inlined array type.
50 *
51 * @since 1.2
52 */
53typedef struct _Eina_Inarray Eina_Inarray;
54
55/**
56 * Inline array structure, use #Eina_Inarray typedef instead.
57 *
58 * Do not modify these fields directly, use eina_inarray_setup() or
59 * eina_inarray_new() instead.
60 *
61 * @since 1.2
62 */
63struct _Eina_Inarray
64{
65 unsigned int member_size; /**< byte size of each entry in members */
66 unsigned int len; /**< number of elements used in members */
67 unsigned int max; /**< number of elements allocated in members */
68 unsigned int step; /**< amount to grow number of members allocated */
69 void *members; /**< actual array of elements */
70 EINA_MAGIC
71};
72
73/**
74 * @brief Create new inline array.
75 *
76 * @param member_size size of each member in the array.
77 * @param step when resizing the array, do this using the following
78 * extra amount.
79 * @return The new inline array table or @c NULL on failure.
80 *
81 * Create a new array where members are inlined in a sequence. Each
82 * member has @a member_size bytes.
83 *
84 * If the @a step is 0, then a safe default is chosen.
85 *
86 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
87 * set. If @a member_size is zero, then @c NULL is returned.
88 *
89 * @see eina_inarray_free()
90 *
91 * @since 1.2
92 */
93EAPI Eina_Inarray *eina_inarray_new(unsigned int member_size,
94 unsigned int step) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
95
96/**
97 * @brief Free array and its members.
98 * @param array array object
99 *
100 * @see eina_inarray_flush()
101 *
102 * @since 1.2
103 */
104EAPI void eina_inarray_free(Eina_Inarray *array) EINA_ARG_NONNULL(1);
105
106/**
107 * @brief Initialize inline array.
108 * @param array array object to initialize.
109 * @param member_size size of each member in the array.
110 * @param step when resizing the array, do this using the following
111 * extra amount.
112 *
113 * Initialize array. If the @a step is 0, then a safe default is
114 * chosen.
115 *
116 * This is useful for arrays inlined into other structures or
117 * allocated at stack.
118 *
119 * @see eina_inarray_flush()
120 *
121 * @since 1.2
122 */
123EAPI void eina_inarray_setup(Eina_Inarray *array,
124 unsigned int member_size,
125 unsigned int step) EINA_ARG_NONNULL(1);
126
127/**
128 * @brief Remove every member from array.
129 * @param array array object
130 *
131 * @since 1.2
132 */
133EAPI void eina_inarray_flush(Eina_Inarray *array) EINA_ARG_NONNULL(1);
134
135/**
136 * @brief Copy the data as the last member of the array.
137 * @param array array object
138 * @param data data to be copied at the end
139 * @return the index of the new member or -1 on errors.
140 *
141 * Copies the given pointer contents at the end of the array. The
142 * pointer is not referenced, instead it's contents is copied to the
143 * members array using the previously defined @c member_size.
144 *
145 * @see eina_inarray_insert_at().
146 *
147 * @since 1.2
148 */
149EAPI int eina_inarray_append(Eina_Inarray *array,
150 const void *data) EINA_ARG_NONNULL(1, 2);
151
152/**
153 * @brief Copy the data to array at position found by comparison function
154 * @param array array object
155 * @param data data to be copied
156 * @param compare compare function
157 * @return the index of the new member or -1 on errors.
158 *
159 * Copies the given pointer contents at the array position defined by
160 * given @a compare function. The pointer is not referenced, instead
161 * it's contents is copied to the members array using the previously
162 * defined @c member_size.
163 *
164 * The data given to @a compare function are the pointer to member
165 * memory itself, do no change it.
166 *
167 * @see eina_inarray_insert_sorted()
168 * @see eina_inarray_insert_at()
169 * @see eina_inarray_append()
170 *
171 * @since 1.2
172 */
173EAPI int eina_inarray_insert(Eina_Inarray *array,
174 const void *data,
175 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
176
177/**
178 * @brief Copy the data to array at position found by comparison function
179 * @param array array object
180 * @param data data to be copied
181 * @param compare compare function
182 * @return the index of the new member or -1 on errors.
183 *
184 * Copies the given pointer contents at the array position defined by
185 * given @a compare function. The pointer is not referenced, instead
186 * it's contents is copied to the members array using the previously
187 * defined @c member_size.
188 *
189 * The data given to @a compare function are the pointer to member
190 * memory itself, do no change it.
191 *
192 * This variation will optimize insertion position assuming the array
193 * is already sorted by doing binary search.
194 *
195 * @see eina_inarray_sort()
196 *
197 * @since 1.2
198 */
199EAPI int eina_inarray_insert_sorted(Eina_Inarray *array,
200 const void *data,
201 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
202
203/**
204 * @brief Find data and remove matching member
205 * @param array array object
206 * @param data data to be found and removed
207 * @return the index of the removed member or -1 on errors.
208 *
209 * Find data in the array and remove it. Data may be an existing
210 * member of array (then optimized) or the contents will be matched
211 * using memcmp().
212 *
213 * @see eina_inarray_pop()
214 * @see eina_inarray_remove_at()
215 *
216 * @since 1.2
217 */
218EAPI int eina_inarray_remove(Eina_Inarray *array,
219 const void *data) EINA_ARG_NONNULL(1, 2);
220
221/**
222 * @brief Removes the last member of the array
223 * @param array array object
224 * @return the index of the removed member or -1 on errors.
225 *
226 * @since 1.2
227 */
228EAPI int eina_inarray_pop(Eina_Inarray *array) EINA_ARG_NONNULL(1);
229
230/**
231 * @brief Get the member at given position
232 * @param array array object
233 * @param position member position
234 * @return pointer to current member memory.
235 *
236 * Gets the member given its position in the array. It is a pointer to
237 * its current memory, then it can be invalidated with functions that
238 * changes the array such as eina_inarray_append(),
239 * eina_inarray_insert_at() or eina_inarray_remove_at() or variants.
240 *
241 * See also eina_inarray_lookup() and eina_inarray_lookup_sorted().
242 *
243 * @since 1.2
244 */
245EAPI void *eina_inarray_nth(const Eina_Inarray *array,
246 unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
247
248/**
249 * @brief Copy the data at given position in the array
250 * @param array array object
251 * @param position where to insert the member
252 * @param data data to be copied at position
253 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
254 *
255 * Copies the given pointer contents at the given @a position in the
256 * array. The pointer is not referenced, instead it's contents is
257 * copied to the members array using the previously defined
258 * @c member_size.
259 *
260 * All the members from @a position to the end of the array are
261 * shifted to the end.
262 *
263 * If @a position is equal to the end of the array (equals to
264 * eina_inarray_count()), then the member is appended.
265 *
266 * If @a position is bigger than the array length, it will fail.
267 *
268 * @since 1.2
269 */
270EAPI Eina_Bool eina_inarray_insert_at(Eina_Inarray *array,
271 unsigned int position,
272 const void *data) EINA_ARG_NONNULL(1, 3);
273
274/**
275 * @brief Opens a space at given position, returning its pointer.
276 * @param array array object
277 * @param position where to insert first member (open/allocate space)
278 * @param member_count how many times member_size bytes will be allocated.
279 * @return pointer to first member memory allocated or @c NULL on errors.
280 *
281 * This is similar to eina_inarray_insert_at(), but useful if the
282 * members contents are still unknown or unallocated. It will make
283 * room for the required number of items and return the pointer to the
284 * first item, similar to malloc(member_count * member_size), with the
285 * guarantee all memory is within members array.
286 *
287 * The new member memory is undefined, it's not automatically zeroed.
288 *
289 * All the members from @a position to the end of the array are
290 * shifted to the end.
291 *
292 * If @a position is equal to the end of the array (equals to
293 * eina_inarray_count()), then the member is appended.
294 *
295 * If @a position is bigger than the array length, it will fail.
296 *
297 * @since 1.2
298 */
299EAPI void *eina_inarray_alloc_at(Eina_Inarray *array,
300 unsigned int position,
301 unsigned int member_count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
302
303/**
304 * @brief Copy the data over the given position.
305 * @param array array object
306 * @param position where to replace the member
307 * @param data data to be copied at position
308 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
309 *
310 * Copies the given pointer contents at the given @a position in the
311 * array. The pointer is not referenced, instead it's contents is
312 * copied to the members array using the previously defined
313 * @c member_size.
314 *
315 * If @a position does not exist, it will fail.
316 *
317 * @since 1.2
318 */
319EAPI Eina_Bool eina_inarray_replace_at(Eina_Inarray *array,
320 unsigned int position,
321 const void *data) EINA_ARG_NONNULL(1, 3);
322
323/**
324 * @brief Remove member at given position
325 * @param array array object
326 * @param position position to be removed
327 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
328 *
329 * The member is removed from array and any members after it are moved
330 * towards the array head.
331 *
332 * See also eina_inarray_pop() and eina_inarray_remove().
333 *
334 * @since 1.2
335 */
336EAPI Eina_Bool eina_inarray_remove_at(Eina_Inarray *array,
337 unsigned int position) EINA_ARG_NONNULL(1);
338
339/**
340 * @brief Reverse members in the array.
341 * @param array array object
342 *
343 * If you do not want to change the array, just walk its elements
344 * backwards, then use EINA_INARRAY_REVERSE_FOREACH() macro.
345 *
346 * @see EINA_INARRAY_REVERSE_FOREACH()
347 *
348 * @since 1.2
349 */
350EAPI void eina_inarray_reverse(Eina_Inarray *array) EINA_ARG_NONNULL(1);
351
352/**
353 * @brief Applies quick sort to array
354 * @param array array object
355 * @param compare compare function
356 *
357 * Applies quick sort to the @a array.
358 *
359 * The data given to @a compare function are the pointer to member
360 * memory itself, do no change it.
361 *
362 * @see eina_inarray_insert_sorted()
363 *
364 * @since 1.2
365 */
366EAPI void eina_inarray_sort(Eina_Inarray *array,
367 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2);
368
369/**
370 * @brief Search member (linear walk)
371 * @param array array object
372 * @param data member to search using @a compare function.
373 * @param compare compare function
374 * @return the member index or -1 if not found.
375 *
376 * Walks array linearly looking for given data as compared by
377 * @a compare function.
378 *
379 * The data given to @a compare function are the pointer to member
380 * memory itself, do no change it.
381 *
382 * See also eina_inarray_lookup_sorted().
383 *
384 * @since 1.2
385 */
386EAPI int eina_inarray_search(const Eina_Inarray *array,
387 const void *data,
388 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
389
390/**
391 * @brief Search member (binary search walk)
392 * @param array array object
393 * @param data member to search using @a compare function.
394 * @param compare compare function
395 * @return the member index or -1 if not found.
396 *
397 * Uses binary search for given data as compared by @a compare function.
398 *
399 * The data given to @a compare function are the pointer to member
400 * memory itself, do no change it.
401 *
402 * @since 1.2
403 */
404EAPI int eina_inarray_search_sorted(const Eina_Inarray *array,
405 const void *data,
406 Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3);
407
408/**
409 * @brief Call function for each array member
410 * @param array array object
411 * @param function callback function
412 * @param user_data user data given to callback @a function
413 * @return #EINA_TRUE if it successfully iterate all items of the array.
414 *
415 * Call @a function for every given data in @a array.
416 *
417 * Safe way to iterate over an array. @p function should return
418 * #EINA_TRUE as long as you want the function to continue iterating,
419 * by returning #EINA_FALSE it will stop and return #EINA_FALSE as a
420 * result.
421 *
422 * The data given to @a function are the pointer to member memory
423 * itself.
424 *
425 * @see EINA_INARRAY_FOREACH()
426 *
427 * @since 1.2
428 */
429EAPI Eina_Bool eina_inarray_foreach(const Eina_Inarray *array,
430 Eina_Each_Cb function,
431 const void *user_data) EINA_ARG_NONNULL(1, 2);
432
433/**
434 * @brief Remove all members that matched.
435 * @param array array object
436 * @param match match function
437 * @param user_data user data given to callback @a match.
438 * @return number of removed entries or -1 on error.
439 *
440 * Remove all entries in the @a array where @a match function
441 * returns #EINA_TRUE.
442 *
443 * @since 1.2
444 */
445EAPI int eina_inarray_foreach_remove(Eina_Inarray *array,
446 Eina_Each_Cb match,
447 const void *user_data) EINA_ARG_NONNULL(1, 2);
448
449/**
450 * @brief number of members in array.
451 * @param array array object
452 * @return number of members in array.
453 *
454 * @since 1.2
455 */
456EAPI unsigned int eina_inarray_count(const Eina_Inarray *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
457
458/**
459 * @brief Returned a new iterator associated to an array.
460 * @param array array object
461 * @return A new iterator.
462 *
463 * This function returns a newly allocated iterator associated to
464 * @p array.
465 *
466 * If the memory can not be allocated, NULL is returned and
467 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
468 * returned.
469 *
470 * @warning if the array structure changes then the iterator becomes
471 * invalid! That is, if you add or remove members this
472 * iterator behavior is undefined and your program may crash!
473 *
474 * @since 1.2
475 */
476EAPI Eina_Iterator *eina_inarray_iterator_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
477
478/**
479 * @brief Returned a new reversed iterator associated to an array.
480 * @param array array object
481 * @return A new iterator.
482 *
483 * This function returns a newly allocated iterator associated to
484 * @p array.
485 *
486 * Unlike eina_inarray_iterator_new(), this will walk the array backwards.
487 *
488 * If the memory can not be allocated, NULL is returned and
489 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
490 * returned.
491 *
492 * @warning if the array structure changes then the iterator becomes
493 * invalid! That is, if you add or remove nodes this iterator
494 * behavior is undefined and your program may crash!
495 *
496 * @since 1.2
497 */
498EAPI Eina_Iterator *eina_inarray_iterator_reversed_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
499
500/**
501 * @brief Returned a new accessor associated to an array.
502 * @param array array object
503 * @return A new accessor.
504 *
505 * This function returns a newly allocated accessor associated to
506 * @p array.
507 *
508 * If the memory can not be allocated, NULL is returned and
509 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid accessor is
510 * returned.
511 *
512 * @since 1.2
513 */
514EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
515
516/**
517 * @def EINA_INARRAY_FOREACH
518 * @brief walks array linearly from head to tail
519 * @param array array object
520 * @param itr the iterator pointer
521 *
522 * @a itr must be a pointer with sizeof(itr*) == array->member_size.
523 *
524 * @warning This is fast as it does direct pointer access, but it will
525 * not check for @c NULL pointers or invalid array object!
526 * See eina_inarray_foreach() to do that.
527 *
528 * @warning Do not modify array as you walk it! If that is desired,
529 * then use eina_inarray_foreach_remove()
530 *
531 * @since 1.2
532 */
533#define EINA_INARRAY_FOREACH(array, itr) \
534 for ((itr) = array->members; \
535 (itr) < (((typeof(*itr)*)array->members) + array->len); \
536 (itr)++)
537
538/**
539 * @def EINA_INARRAY_REVERSE_FOREACH
540 * @brief walks array linearly from tail to head
541 * @param array array object
542 * @param itr the iterator pointer
543 *
544 * @a itr must be a pointer with sizeof(itr*) == array->member_size.
545 *
546 * @warning This is fast as it does direct pointer access, but it will
547 * not check for @c NULL pointers or invalid array object!
548 *
549 * @warning Do not modify array as you walk it! If that is desired,
550 * then use eina_inarray_foreach_remove()
551 *
552 * @since 1.2
553 */
554#define EINA_INARRAY_REVERSE_FOREACH(array, itr) \
555 for ((itr) = ((((typeof(*(itr))*)array->members) + array->len) - 1); \
556 (((itr) >= (typeof(*(itr))*)array->members) \
557 && (array->members != NULL)); \
558 (itr)--)
559
560/**
561 * @}
562 */
563
564/**
565 * @}
566 */
567
568/**
569 * @}
570 */
571
572#endif /*EINA_INARRAY_H_*/
diff --git a/libraries/eina/src/include/eina_inline_array.x b/libraries/eina/src/include/eina_inline_array.x
index f9f6026..a635ee2 100644
--- a/libraries/eina/src/include/eina_inline_array.x
+++ b/libraries/eina/src/include/eina_inline_array.x
@@ -19,6 +19,8 @@
19#ifndef EINA_INLINE_ARRAY_X_ 19#ifndef EINA_INLINE_ARRAY_X_
20#define EINA_INLINE_ARRAY_X_ 20#define EINA_INLINE_ARRAY_X_
21 21
22#include <stddef.h>
23
22#include <stdio.h> 24#include <stdio.h>
23 25
24/** 26/**
@@ -126,6 +128,8 @@ eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data)
126 * This function returns the number of elements in @p array. For 128 * This function returns the number of elements in @p array. For
127 * performance reasons, there is no check of @p array. If it is 129 * performance reasons, there is no check of @p array. If it is
128 * @c NULL or invalid, the program may crash. 130 * @c NULL or invalid, the program may crash.
131 *
132 * @deprecated use eina_array_count()
129 */ 133 */
130static inline unsigned int 134static inline unsigned int
131eina_array_count_get(const Eina_Array *array) 135eina_array_count_get(const Eina_Array *array)
@@ -133,6 +137,22 @@ eina_array_count_get(const Eina_Array *array)
133 return array->count; 137 return array->count;
134} 138}
135 139
140/**
141 * @brief Return the number of elements in an array.
142 *
143 * @param array The array.
144 * @return The number of elements.
145 *
146 * This function returns the number of elements in @p array. For
147 * performance reasons, there is no check of @p array. If it is
148 * @c NULL or invalid, the program may crash.
149 */
150static inline unsigned int
151eina_array_count(const Eina_Array *array)
152{
153 return array->count;
154}
155
136static inline Eina_Bool 156static inline Eina_Bool
137eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata) 157eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
138{ 158{
diff --git a/libraries/eina/src/include/eina_inline_clist.x b/libraries/eina/src/include/eina_inline_clist.x
new file mode 100644
index 0000000..66223fe
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_clist.x
@@ -0,0 +1,135 @@
1/*
2 * Linked lists support
3 *
4 * Copyright (C) 2002 Alexandre Julliard
5 * Copyright (C) 2011 Mike McCormack (adapted for Eina)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifndef __EINA_CLIST_INLINE_H__
23#define __EINA_CLIST_INLINE_H__
24
25#include <stddef.h>
26
27static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
28{
29 to_add->next = elem->next;
30 to_add->prev = elem;
31 elem->next->prev = to_add;
32 elem->next = to_add;
33}
34
35static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
36{
37 to_add->next = elem;
38 to_add->prev = elem->prev;
39 elem->prev->next = to_add;
40 elem->prev = to_add;
41}
42
43static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
44{
45 eina_clist_add_after(list, elem);
46}
47
48static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
49{
50 eina_clist_add_before(list, elem);
51}
52
53static inline void eina_clist_element_init(Eina_Clist *elem)
54{
55 elem->next = NULL;
56 elem->prev = NULL;
57}
58
59static inline int eina_clist_element_is_linked(Eina_Clist *elem)
60{
61 return (elem->next != NULL && elem->prev != NULL);
62}
63
64static inline void eina_clist_remove(Eina_Clist *elem)
65{
66 elem->next->prev = elem->prev;
67 elem->prev->next = elem->next;
68 eina_clist_element_init(elem);
69}
70
71static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem)
72{
73 Eina_Clist *ret = elem->next;
74 if (elem->next == list) ret = NULL;
75 return ret;
76}
77
78static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem)
79{
80 Eina_Clist *ret = elem->prev;
81 if (elem->prev == list) ret = NULL;
82 return ret;
83}
84
85static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
86{
87 return eina_clist_next(list, list);
88}
89
90static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
91{
92 return eina_clist_prev(list, list);
93}
94
95static inline int eina_clist_empty(const Eina_Clist *list)
96{
97 return list->next == list;
98}
99
100static inline void eina_clist_init(Eina_Clist *list)
101{
102 list->next = list->prev = list;
103}
104
105static inline unsigned int eina_clist_count(const Eina_Clist *list)
106{
107 unsigned count = 0;
108 const Eina_Clist *ptr;
109 for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
110 return count;
111}
112
113static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
114{
115 if (eina_clist_empty(src)) return;
116
117 dst->prev->next = src->next;
118 src->next->prev = dst->prev;
119 dst->prev = src->prev;
120 src->prev->next = dst;
121 eina_clist_init(src);
122}
123
124static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
125{
126 if (eina_clist_empty(src)) return;
127
128 dst->next->prev = src->prev;
129 src->prev->next = dst->next;
130 dst->next = src->next;
131 src->next->prev = dst;
132 eina_clist_init(src);
133}
134
135#endif
diff --git a/libraries/eina/src/include/eina_inline_hash.x b/libraries/eina/src/include/eina_inline_hash.x
index f27060f..be20e8f 100644
--- a/libraries/eina/src/include/eina_inline_hash.x
+++ b/libraries/eina/src/include/eina_inline_hash.x
@@ -101,7 +101,7 @@ static inline unsigned int _fmix32(unsigned int h)
101 return h; 101 return h;
102} 102}
103 103
104int 104static inline int
105eina_hash_murmur3(const char *key, int len) 105eina_hash_murmur3(const char *key, int len)
106{ 106{
107 const unsigned char * data = (const unsigned char*)key; 107 const unsigned char * data = (const unsigned char*)key;
diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x
index 77f5b8b..64e049a 100644
--- a/libraries/eina/src/include/eina_inline_lock_posix.x
+++ b/libraries/eina/src/include/eina_inline_lock_posix.x
@@ -19,6 +19,15 @@
19#ifndef EINA_INLINE_LOCK_POSIX_X_ 19#ifndef EINA_INLINE_LOCK_POSIX_X_
20#define EINA_INLINE_LOCK_POSIX_X_ 20#define EINA_INLINE_LOCK_POSIX_X_
21 21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
22#include <errno.h> 31#include <errno.h>
23#ifndef __USE_UNIX98 32#ifndef __USE_UNIX98
24# define __USE_UNIX98 33# define __USE_UNIX98
@@ -28,7 +37,10 @@
28# include <pthread.h> 37# include <pthread.h>
29#endif 38#endif
30 39
40#include <semaphore.h>
41
31#include <sys/time.h> 42#include <sys/time.h>
43#include <stdio.h>
32 44
33#ifdef EINA_HAVE_DEBUG_THREADS 45#ifdef EINA_HAVE_DEBUG_THREADS
34#include <stdlib.h> 46#include <stdlib.h>
@@ -45,6 +57,7 @@ typedef struct _Eina_Lock Eina_Lock;
45typedef struct _Eina_RWLock Eina_RWLock; 57typedef struct _Eina_RWLock Eina_RWLock;
46typedef struct _Eina_Condition Eina_Condition; 58typedef struct _Eina_Condition Eina_Condition;
47typedef pthread_key_t Eina_TLS; 59typedef pthread_key_t Eina_TLS;
60typedef sem_t Eina_Semaphore;
48 61
49struct _Eina_Lock 62struct _Eina_Lock
50{ 63{
@@ -77,8 +90,6 @@ struct _Eina_RWLock
77EAPI extern Eina_Bool _eina_threads_activated; 90EAPI extern Eina_Bool _eina_threads_activated;
78 91
79#ifdef EINA_HAVE_DEBUG_THREADS 92#ifdef EINA_HAVE_DEBUG_THREADS
80# include <sys/time.h>
81
82EAPI extern int _eina_threads_debug; 93EAPI extern int _eina_threads_debug;
83EAPI extern pthread_t _eina_main_loop; 94EAPI extern pthread_t _eina_main_loop;
84EAPI extern pthread_mutex_t _eina_tracking_lock; 95EAPI extern pthread_mutex_t _eina_tracking_lock;
@@ -506,4 +517,40 @@ eina_tls_set(Eina_TLS key, const void *data)
506 return EINA_TRUE; 517 return EINA_TRUE;
507} 518}
508 519
520static inline Eina_Bool
521eina_semaphore_new(Eina_Semaphore *sem, int count_init)
522{
523 if (!sem || (count_init <= 0))
524 return EINA_FALSE;
525
526 return (sem_init(sem, count_init, 1) == 0) ? EINA_TRUE : EINA_FALSE;
527}
528
529static inline Eina_Bool
530eina_semaphore_free(Eina_Semaphore *sem)
531{
532 if (!sem)
533 return EINA_FALSE;
534
535 return (sem_destroy(sem) == 0) ? EINA_TRUE : EINA_FALSE;
536}
537
538static inline Eina_Bool
539eina_semaphore_lock(Eina_Semaphore *sem)
540{
541 if (!sem)
542 return EINA_FALSE;
543
544 return (sem_wait(sem) == 0) ? EINA_TRUE : EINA_FALSE;
545}
546
547static inline Eina_Bool
548eina_semaphore_release(Eina_Semaphore *sem, int count_release EINA_UNUSED)
549{
550 if (!sem)
551 return EINA_FALSE;
552
553 return (sem_post(sem) == 0) ? EINA_TRUE : EINA_FALSE;
554}
555
509#endif 556#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_void.x b/libraries/eina/src/include/eina_inline_lock_void.x
index 8cb9a49..2f5209f 100644
--- a/libraries/eina/src/include/eina_inline_lock_void.x
+++ b/libraries/eina/src/include/eina_inline_lock_void.x
@@ -47,6 +47,7 @@ typedef void *Eina_Lock;
47typedef void *Eina_RWLock; 47typedef void *Eina_RWLock;
48typedef void *Eina_Condition; 48typedef void *Eina_Condition;
49typedef void *Eina_TLS; 49typedef void *Eina_TLS;
50typedef void *Eina_Semaphore;
50 51
51/** 52/**
52 * @brief Create a new #Eina_Lock. 53 * @brief Create a new #Eina_Lock.
@@ -63,7 +64,7 @@ typedef void *Eina_TLS;
63static inline Eina_Bool 64static inline Eina_Bool
64eina_lock_new(Eina_Lock *mutex EINA_UNUSED) 65eina_lock_new(Eina_Lock *mutex EINA_UNUSED)
65{ 66{
66 return EINA_FALSE; 67 return EINA_TRUE;
67} 68}
68 69
69/** 70/**
@@ -94,7 +95,7 @@ eina_lock_free(Eina_Lock *mutex EINA_UNUSED)
94static inline Eina_Lock_Result 95static inline Eina_Lock_Result
95eina_lock_take(Eina_Lock *mutex EINA_UNUSED) 96eina_lock_take(Eina_Lock *mutex EINA_UNUSED)
96{ 97{
97 return EINA_LOCK_FAIL; 98 return EINA_LOCK_SUCCEED;
98} 99}
99 100
100/** 101/**
@@ -115,7 +116,7 @@ eina_lock_take(Eina_Lock *mutex EINA_UNUSED)
115static inline Eina_Lock_Result 116static inline Eina_Lock_Result
116eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED) 117eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED)
117{ 118{
118 return EINA_LOCK_FAIL; 119 return EINA_LOCK_SUCCEED;
119} 120}
120 121
121/** 122/**
@@ -132,7 +133,7 @@ eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED)
132static inline Eina_Lock_Result 133static inline Eina_Lock_Result
133eina_lock_release(Eina_Lock *mutex EINA_UNUSED) 134eina_lock_release(Eina_Lock *mutex EINA_UNUSED)
134{ 135{
135 return EINA_LOCK_FAIL; 136 return EINA_LOCK_SUCCEED;
136} 137}
137 138
138static inline void 139static inline void
@@ -143,7 +144,7 @@ eina_lock_debug(const Eina_Lock *mutex EINA_UNUSED)
143static inline Eina_Bool 144static inline Eina_Bool
144eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED) 145eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED)
145{ 146{
146 return EINA_FALSE; 147 return EINA_TRUE;
147} 148}
148 149
149static inline void 150static inline void
@@ -154,72 +155,72 @@ eina_condition_free(Eina_Condition *cond EINA_UNUSED)
154static inline Eina_Bool 155static inline Eina_Bool
155eina_condition_wait(Eina_Condition *cond EINA_UNUSED) 156eina_condition_wait(Eina_Condition *cond EINA_UNUSED)
156{ 157{
157 return EINA_FALSE; 158 return EINA_TRUE;
158} 159}
159 160
160static inline Eina_Bool 161static inline Eina_Bool
161eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED) 162eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED)
162{ 163{
163 return EINA_FALSE; 164 return EINA_TRUE;
164} 165}
165 166
166static inline Eina_Bool 167static inline Eina_Bool
167eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED) 168eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED)
168{ 169{
169 return EINA_FALSE; 170 return EINA_TRUE;
170} 171}
171 172
172static inline Eina_Bool 173static inline Eina_Bool
173eina_condition_signal(Eina_Condition *cond EINA_UNUSED) 174eina_condition_signal(Eina_Condition *cond EINA_UNUSED)
174{ 175{
175 return EINA_FALSE; 176 return EINA_TRUE;
176} 177}
177 178
178static inline Eina_Bool 179static inline Eina_Bool
179eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED) 180eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED)
180{ 181{
181 return EINA_FALSE; 182 return EINA_TRUE;
182} 183}
183 184
184static inline void 185static inline void
185 eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED) 186eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED)
186{ 187{
187} 188}
188 189
189static inline Eina_Lock_Result 190static inline Eina_Lock_Result
190eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED) 191eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED)
191{ 192{
192 return EINA_LOCK_FAIL; 193 return EINA_LOCK_SUCCEED;
193} 194}
194 195
195static inline Eina_Lock_Result 196static inline Eina_Lock_Result
196eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED) 197eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED)
197{ 198{
198 return EINA_LOCK_FAIL; 199 return EINA_LOCK_SUCCEED;
199} 200}
200 201
201static inline Eina_Lock_Result 202static inline Eina_Lock_Result
202eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED) 203eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED)
203{ 204{
204 return EINA_LOCK_FAIL; 205 return EINA_LOCK_SUCCEED;
205} 206}
206 207
207static inline Eina_Lock_Result 208static inline Eina_Lock_Result
208eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED) 209eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED)
209{ 210{
210 return EINA_LOCK_FAIL; 211 return EINA_LOCK_SUCCEED;
211} 212}
212 213
213static inline Eina_Lock_Result 214static inline Eina_Lock_Result
214eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED) 215eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED)
215{ 216{
216 return EINA_LOCK_FAIL; 217 return EINA_LOCK_SUCCEED;
217} 218}
218 219
219static inline Eina_Bool 220static inline Eina_Bool
220eina_tls_new(Eina_TLS *key EINA_UNUSED) 221eina_tls_new(Eina_TLS *key EINA_UNUSED)
221{ 222{
222 return EINA_FALSE; 223 return EINA_TRUE;
223} 224}
224 225
225static inline void 226static inline void
@@ -236,9 +237,34 @@ eina_tls_get(Eina_TLS key EINA_UNUSED)
236static inline Eina_Bool 237static inline Eina_Bool
237eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED) 238eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED)
238{ 239{
239 return EINA_FALSE; 240 return EINA_TRUE;
240} 241}
241 242
243static inline Eina_Bool
244eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED,
245 int count_init EINA_UNUSED)
246{
247 return EINA_TRUE;
248}
249
250static inline Eina_Bool
251eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED)
252{
253 return EINA_TRUE;
254}
255
256static inline Eina_Bool
257eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED)
258{
259 return EINA_TRUE;
260}
261
262static inline Eina_Bool
263eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED,
264 int count_release EINA_UNUSED)
265{
266 return EINA_TRUE;
267}
242 268
243/** 269/**
244 * @} 270 * @}
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x
index 072095c..e8363d5 100644
--- a/libraries/eina/src/include/eina_inline_lock_win32.x
+++ b/libraries/eina/src/include/eina_inline_lock_win32.x
@@ -58,6 +58,8 @@ struct _Eina_Win32_RWLock
58 58
59typedef DWORD Eina_TLS; 59typedef DWORD Eina_TLS;
60 60
61typedef HANDLE Eina_Semaphore;
62
61EAPI extern Eina_Bool _eina_threads_activated; 63EAPI extern Eina_Bool _eina_threads_activated;
62 64
63static inline Eina_Bool 65static inline Eina_Bool
@@ -463,4 +465,48 @@ eina_tls_set(Eina_TLS key, const void *data)
463 return EINA_TRUE; 465 return EINA_TRUE;
464} 466}
465 467
468static inline Eina_Bool
469eina_semaphore_new(Eina_Semaphore *sem, int count_init)
470{
471 if (!sem || (count_init <= 0))
472 return EINA_FALSE;
473
474 *sem = CreateSemaphore(NULL, count_init, 32767, NULL);
475 if (!*sem)
476 return EINA_FALSE;
477}
478
479static inline Eina_Bool
480eina_semaphore_free(Eina_Semaphore *sem)
481{
482 if (!sem)
483 return EINA_FALSE;
484
485 CloseHandle(*sem);
486}
487
488static inline Eina_Bool
489eina_semaphore_lock(Eina_Semaphore *sem)
490{
491 DWORD res;
492
493 if (!sem)
494 return EINA_FALSE;
495
496 res = WaitForSingleObject(*sem, 0L);
497 if (res == WAIT_OBJECT_0)
498 return EINA_TRUE;
499
500 return EINA_FALSE;
501}
502
503static inline Eina_Bool
504eina_semaphore_release(Eina_Semaphore *sem, int count_release)
505{
506 if (!sem)
507 return EINA_FALSE;
508
509 return ReleaseSemaphore(*sem, count_release, NULL) ? EINA_TRUE : EINA_FALSE;
510}
511
466#endif 512#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x
index 965d475..1af1aac 100644
--- a/libraries/eina/src/include/eina_inline_lock_wince.x
+++ b/libraries/eina/src/include/eina_inline_lock_wince.x
@@ -19,6 +19,15 @@
19#ifndef EINA_INLINE_LOCK_WIN32_X_ 19#ifndef EINA_INLINE_LOCK_WIN32_X_
20#define EINA_INLINE_LOCK_WIN32_X_ 20#define EINA_INLINE_LOCK_WIN32_X_
21 21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
22#include <windows.h> 31#include <windows.h>
23 32
24EAPI extern Eina_Bool _threads_activated; 33EAPI extern Eina_Bool _threads_activated;
@@ -26,6 +35,7 @@ EAPI extern Eina_Bool _threads_activated;
26typedef HANDLE Eina_Lock; 35typedef HANDLE Eina_Lock;
27typedef Eina_Lock Eina_RWLock; 36typedef Eina_Lock Eina_RWLock;
28typedef DWORD Eina_TLS; 37typedef DWORD Eina_TLS;
38typedef void * Eina_Semaphore;
29 39
30static inline Eina_Bool 40static inline Eina_Bool
31eina_lock_new(Eina_Lock *mutex) 41eina_lock_new(Eina_Lock *mutex)
@@ -173,6 +183,30 @@ eina_tls_set(Eina_TLS key, const void *data)
173 return EINA_TRUE; 183 return EINA_TRUE;
174} 184}
175 185
186static inline Eina_Bool
187eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED,
188 int count_init EINA_UNUSED)
189{
190 return EINA_FALSE;
191}
176 192
193static inline Eina_Bool
194eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED)
195{
196 return EINA_FALSE;
197}
198
199static inline Eina_Bool
200eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED)
201{
202 return EINA_FALSE;
203}
204
205static inline Eina_Bool
206eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED,
207 int count_release EINA_UNUSED)
208{
209 return EINA_FALSE;
210}
177 211
178#endif 212#endif
diff --git a/libraries/eina/src/include/eina_inline_log.x b/libraries/eina/src/include/eina_inline_log.x
index 4cdd7d8..53d8afb 100644
--- a/libraries/eina/src/include/eina_inline_log.x
+++ b/libraries/eina/src/include/eina_inline_log.x
@@ -49,7 +49,7 @@
49static inline Eina_Bool 49static inline Eina_Bool
50eina_log_level_check(int level) 50eina_log_level_check(int level)
51{ 51{
52 return eina_log_level_get() <= level; 52 return eina_log_level_get() >= level;
53} 53}
54 54
55/** 55/**
@@ -81,7 +81,7 @@ eina_log_domain_level_check(int domain, int level)
81 int dom_level = eina_log_domain_registered_level_get(domain); 81 int dom_level = eina_log_domain_registered_level_get(domain);
82 if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN)) 82 if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN))
83 return EINA_FALSE; 83 return EINA_FALSE;
84 return dom_level <= level; 84 return dom_level >= level;
85} 85}
86 86
87/** 87/**
diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x
index a67ec3d..729a669 100644
--- a/libraries/eina/src/include/eina_inline_mempool.x
+++ b/libraries/eina/src/include/eina_inline_mempool.x
@@ -19,6 +19,8 @@
19#ifndef EINA_INLINE_MEMPOOL_X_ 19#ifndef EINA_INLINE_MEMPOOL_X_
20#define EINA_INLINE_MEMPOOL_X_ 20#define EINA_INLINE_MEMPOOL_X_
21 21
22#include <string.h>
23
22/** 24/**
23 * @addtogroup Eina_Memory_Pool_Group Memory Pool 25 * @addtogroup Eina_Memory_Pool_Group Memory Pool
24 * 26 *
@@ -67,17 +69,16 @@ struct _Eina_Mempool
67}; 69};
68 70
69/** 71/**
70 * @brief Re-allocate a amount memory by the given mempool. 72 * @brief Re-allocate an amount memory by the given mempool.
71 * 73 *
72 * @param mp The mempool. 74 * @param mp The mempool.
73 * @param element The element to re-allocate. 75 * @param element The element to re-allocate.
74 * @param size The size in bytes to re-allocate. 76 * @param size The size in bytes to re-allocate.
75 * @return The newly re-allocated data. 77 * @return The newly re-allocated data.
76 * 78 *
77 * This function re-allocates @p element with @p size bytes, using the 79 * This function re-allocates and returns @p element with @p size bytes using the
78 * mempool @p mp and returns the allocated data. If not used anymore, 80 * mempool @p mp. If not used anymore, the data must be freed with eina_mempool_free().
79 * the data must be freed with eina_mempool_free(). No check is done 81 * @warning No checks are done for @p mp.
80 * on @p mp, so it must be a valid mempool.
81 */ 82 */
82static inline void * 83static inline void *
83eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) 84eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
@@ -86,16 +87,15 @@ eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
86} 87}
87 88
88/** 89/**
89 * @brief Allocate a amount memory by the given mempool. 90 * @brief Allocate memory using the given mempool.
90 * 91 *
91 * @param mp The mempool. 92 * @param mp The mempool.
92 * @param size The size in bytes to allocate. 93 * @param size The size in bytes to allocate.
93 * @return The newly allocated data. 94 * @return The newly allocated data.
94 * 95 *
95 * This function allocates @p size bytes, using the mempool @p mp and 96 * This function allocates and returns @p size bytes using the mempool @p mp.
96 * returns the allocated data. If not used anymore, the data must be 97 * If not used anymore, the data must be freed with eina_mempool_free().
97 * freed with eina_mempool_free(). No check is done on @p mp, so it 98 * @warning No checks are done for @p mp.
98 * must be a valid mempool.
99 */ 99 */
100static inline void * 100static inline void *
101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) 101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
@@ -104,15 +104,36 @@ eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
104} 104}
105 105
106/** 106/**
107 * @brief Free the allocated ressources by the given mempool. 107 * @brief Allocate and zero memory using the given mempool.
108 *
109 * @param mp The mempool.
110 * @param size The size in bytes to allocate.
111 * @return The newly allocated data.
112 *
113 * This function allocates, zeroes, and returns @p size bytes using the mempool @p mp.
114 * If not used anymore, the data must be freed with eina_mempool_free().
115 * @warning No checks are done for @p mp.
116 * @since 1.2
117 */
118static inline void *
119eina_mempool_calloc(Eina_Mempool *mp, unsigned int size)
120{
121 void *r = mp->backend.alloc(mp->backend_data, size);
122 if (!r) return NULL;
123 memset(r, 0, size);
124 return r;
125}
126
127/**
128 * @brief Free resources previously allocated by the given mempool.
108 * 129 *
109 * @param mp The mempool. 130 * @param mp The mempool.
110 * @param element The data to free. 131 * @param element The data to free.
111 * 132 *
112 * This function frees @p element allocated by @p mp. @p element must 133 * This function frees @p element allocated by @p mp. @p element must
113 * have been obtained by eina_mempool_malloc() or 134 * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or
114 * eina_mempool_realloc(). No check is done on @p mp, so it must be a 135 * eina_mempool_realloc().
115 * valid mempool. 136 * @warning No checks are done for @p mp.
116 */ 137 */
117static inline void 138static inline void
118eina_mempool_free(Eina_Mempool *mp, void *element) 139eina_mempool_free(Eina_Mempool *mp, void *element)
diff --git a/libraries/eina/src/include/eina_inline_value.x b/libraries/eina/src/include/eina_inline_value.x
new file mode 100644
index 0000000..59ec315
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_value.x
@@ -0,0 +1,1705 @@
1/* Eina - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_VALUE_X_
20#define EINA_INLINE_VALUE_X_
21
22#include <string.h>
23#include <alloca.h>
24
25#include "eina_stringshare.h"
26
27/* NOTE: most of value is implemented here for performance reasons */
28
29//#define EINA_VALUE_NO_OPTIMIZE 1
30#ifdef EINA_VALUE_NO_OPTIMIZE
31#define EINA_VALUE_TYPE_DEFAULT(type) (0)
32#else
33
34/**
35 * @var _EINA_VALUE_TYPE_BASICS_START
36 * pointer to the first basic type.
37 * @since 1.2
38 * @private
39 */
40EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START;
41
42/**
43 * @var _EINA_VALUE_TYPE_BASICS_END
44 * pointer to the last (inclusive) basic type.
45 * @since 1.2
46 * @private
47 */
48EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END;
49#define EINA_VALUE_TYPE_DEFAULT(type) \
50 ((_EINA_VALUE_TYPE_BASICS_START <= type) && \
51 (type <= _EINA_VALUE_TYPE_BASICS_END))
52#endif
53
54#define EINA_VALUE_TYPE_CHECK_RETURN(value) \
55 EINA_SAFETY_ON_NULL_RETURN(value); \
56 EINA_SAFETY_ON_FALSE_RETURN(eina_value_type_check(value->type))
57
58#define EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, retval) \
59 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
60 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), retval)
61
62#define EINA_VALUE_TYPE_DISPATCH(type, method, no_method_err, ...) \
63 do \
64 { \
65 if (type->method) \
66 type->method(type, ##__VA_ARGS__); \
67 else \
68 eina_error_set(no_method_err); \
69 } \
70 while (0)
71
72#define EINA_VALUE_TYPE_DISPATCH_RETURN(value, method, no_method_err, def_ret, ...) \
73 do \
74 { \
75 if (type->method) \
76 return type->method(type, ##__VA_ARGS__); \
77 eina_error_set(no_method_err); \
78 return def_ret; \
79 } \
80 while (0)
81
82/**
83 * @brief Get memory for given value (inline or allocated buffer).
84 * @since 1.2
85 * @private
86 */
87static inline void *
88eina_value_memory_get(const Eina_Value *value)
89{
90 if (value->type->value_size <= 8)
91 return (void *)value->value.buf;
92 return value->value.ptr;
93}
94
95/**
96 * @brief Allocate memory for internal value types.
97 * @since 1.2
98 * @private
99 */
100EAPI void *eina_value_inner_alloc(size_t size);
101/**
102 * @brief Releases memory for internal value types.
103 * @since 1.2
104 * @private
105 */
106EAPI void eina_value_inner_free(size_t size, void *mem);
107
108static inline Eina_Bool
109eina_value_setup(Eina_Value *value, const Eina_Value_Type *type)
110{
111 void *mem;
112
113 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
114 EINA_SAFETY_ON_FALSE_RETURN_VAL(type->value_size > 0, EINA_FALSE);
115
116 value->type = type;
117
118 if (type->value_size <= 8) mem = &value->value;
119 else
120 {
121 mem = value->value.ptr = eina_value_inner_alloc(type->value_size);
122 EINA_SAFETY_ON_NULL_RETURN_VAL(mem, EINA_FALSE);
123 }
124
125 memset(mem, 0, type->value_size);
126
127 if (EINA_VALUE_TYPE_DEFAULT(type))
128 {
129 eina_error_set(0);
130 return EINA_TRUE;
131 }
132
133 EINA_VALUE_TYPE_DISPATCH_RETURN(type, setup,
134 EINA_ERROR_VALUE_FAILED, EINA_FALSE, mem);
135}
136
137static inline void
138eina_value_flush(Eina_Value *value)
139{
140 const Eina_Value_Type *type;
141 void *mem;
142
143 EINA_VALUE_TYPE_CHECK_RETURN(value);
144
145 type = value->type;
146 mem = eina_value_memory_get(value);
147
148 if (EINA_VALUE_TYPE_DEFAULT(type))
149 {
150 if (type == EINA_VALUE_TYPE_STRINGSHARE)
151 {
152 if (value->value.ptr) eina_stringshare_del((const char*) value->value.ptr);
153 }
154 else if (type == EINA_VALUE_TYPE_STRING)
155 {
156 if (value->value.ptr) free(value->value.ptr);
157 }
158 else if (type->value_size > 8)
159 eina_value_inner_free(type->value_size, mem);
160 eina_error_set(0);
161 return;
162 }
163
164 EINA_VALUE_TYPE_DISPATCH(type, flush, EINA_ERROR_VALUE_FAILED, mem);
165 if (type->value_size > 8)
166 eina_value_inner_free(type->value_size, mem);
167 value->type = NULL;
168}
169
170static inline int
171eina_value_compare(const Eina_Value *a, const Eina_Value *b)
172{
173 const Eina_Value_Type *type;
174 void *pa, *pb;
175
176 EINA_VALUE_TYPE_CHECK_RETURN_VAL(a, -1);
177 EINA_SAFETY_ON_NULL_RETURN_VAL(b, -1);
178 EINA_SAFETY_ON_FALSE_RETURN_VAL(a->type == b->type, -1);
179
180 eina_error_set(0);
181 type = a->type;
182 pa = eina_value_memory_get(a);
183 pb = eina_value_memory_get(b);
184
185#ifndef EINA_VALUE_NO_OPTIMIZE
186 if (type == EINA_VALUE_TYPE_UCHAR)
187 {
188 unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *) pb;
189 if (*ta < *tb)
190 return -1;
191 else if (*ta > *tb)
192 return 1;
193 return 0;
194 }
195 else if (type == EINA_VALUE_TYPE_USHORT)
196 {
197 unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short *) pb;
198 if (*ta < *tb)
199 return -1;
200 else if (*ta > *tb)
201 return 1;
202 return 0;
203 }
204 else if (type == EINA_VALUE_TYPE_UINT)
205 {
206 unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb;
207 if (*ta < *tb)
208 return -1;
209 else if (*ta > *tb)
210 return 1;
211 return 0;
212 }
213 else if (type == EINA_VALUE_TYPE_ULONG)
214 {
215 unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb;
216 if (*ta < *tb)
217 return -1;
218 else if (*ta > *tb)
219 return 1;
220 return 0;
221 }
222 else if (type == EINA_VALUE_TYPE_UINT64)
223 {
224 uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb;
225 if (*ta < *tb)
226 return -1;
227 else if (*ta > *tb)
228 return 1;
229 return 0;
230 }
231 else if (type == EINA_VALUE_TYPE_CHAR)
232 {
233 char *ta = (char *) pa, *tb = (char *) pb;
234 if (*ta < *tb)
235 return -1;
236 else if (*ta > *tb)
237 return 1;
238 return 0;
239 }
240 else if (type == EINA_VALUE_TYPE_SHORT)
241 {
242 short *ta = (short *) pa, *tb = (short *) pb;
243 if (*ta < *tb)
244 return -1;
245 else if (*ta > *tb)
246 return 1;
247 return 0;
248 }
249 else if (type == EINA_VALUE_TYPE_INT)
250 {
251 int *ta = (int *) pa, *tb = (int *) pb;
252 if (*ta < *tb)
253 return -1;
254 else if (*ta > *tb)
255 return 1;
256 return 0;
257 }
258 else if (type == EINA_VALUE_TYPE_LONG)
259 {
260 long *ta = (long *) pa, *tb = (long *) pb;
261 if (*ta < *tb)
262 return -1;
263 else if (*ta > *tb)
264 return 1;
265 return 0;
266 }
267 else if (type == EINA_VALUE_TYPE_INT64)
268 {
269 int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb;
270 if (*ta < *tb)
271 return -1;
272 else if (*ta > *tb)
273 return 1;
274 return 0;
275 }
276 else if (type == EINA_VALUE_TYPE_FLOAT)
277 {
278 float *ta = (float *) pa, *tb = (float *) pb;
279 if (*ta < *tb)
280 return -1;
281 else if (*ta > *tb)
282 return 1;
283 return 0;
284 }
285 else if (type == EINA_VALUE_TYPE_DOUBLE)
286 {
287 double *ta = (double *) pa, *tb = (double *) pb;
288 if (*ta < *tb)
289 return -1;
290 else if (*ta > *tb)
291 return 1;
292 return 0;
293 }
294 else if (type == EINA_VALUE_TYPE_STRINGSHARE ||
295 type == EINA_VALUE_TYPE_STRING)
296 {
297 const char *sa = *(const char **)pa;
298 const char *sb = *(const char **)pb;
299 if (sa == sb)
300 return 0;
301 if (sa == NULL)
302 return -1;
303 if (sb == NULL)
304 return 1;
305 return strcmp(sa, sb);
306 }
307#endif
308
309 EINA_VALUE_TYPE_DISPATCH_RETURN(type, compare, EINA_ERROR_VALUE_FAILED,
310 EINA_FALSE, pa, pb);
311}
312
313static inline Eina_Bool
314eina_value_set(Eina_Value *value, ...)
315{
316 va_list args;
317 Eina_Bool ret;
318 va_start(args, value);
319 ret = eina_value_vset(value, args);
320 va_end(args);
321 return ret;
322}
323
324static inline Eina_Bool
325eina_value_get(const Eina_Value *value, ...)
326{
327 va_list args;
328 Eina_Bool ret;
329 va_start(args, value);
330 ret = eina_value_vget(value, args);
331 va_end(args);
332 return ret;
333}
334
335static inline Eina_Bool
336eina_value_vset(Eina_Value *value, va_list args)
337{
338 const Eina_Value_Type *type;
339 void *mem;
340
341 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
342
343 type = value->type;
344 mem = eina_value_memory_get(value);
345 eina_error_set(0);
346#ifndef EINA_VALUE_NO_OPTIMIZE
347 if (type == EINA_VALUE_TYPE_UCHAR)
348 {
349 unsigned char *tmem = (unsigned char *) mem;
350 *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
351 return EINA_TRUE;
352 }
353 else if (type == EINA_VALUE_TYPE_USHORT)
354 {
355 unsigned short *tmem = (unsigned short *) mem;
356 *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
357 return EINA_TRUE;
358 }
359 else if (type == EINA_VALUE_TYPE_UINT)
360 {
361 unsigned int *tmem = (unsigned int *) mem;
362 *tmem = va_arg(args, unsigned int);
363 return EINA_TRUE;
364 }
365 else if (type == EINA_VALUE_TYPE_ULONG)
366 {
367 unsigned long *tmem = (unsigned long *) mem;
368 *tmem = va_arg(args, unsigned long);
369 return EINA_TRUE;
370 }
371 else if (type == EINA_VALUE_TYPE_UINT64)
372 {
373 uint64_t *tmem = (uint64_t *) mem;
374 *tmem = va_arg(args, uint64_t);
375 return EINA_TRUE;
376 }
377 else if (type == EINA_VALUE_TYPE_CHAR)
378 {
379 char *tmem = (char *) mem;
380 *tmem = va_arg(args, int); /* promoted by va_arg */
381 return EINA_TRUE;
382 }
383 else if (type == EINA_VALUE_TYPE_SHORT)
384 {
385 short *tmem = (short *) mem;
386 *tmem = va_arg(args, int); /* promoted by va_arg */
387 return EINA_TRUE;
388 }
389 else if (type == EINA_VALUE_TYPE_INT)
390 {
391 int *tmem = (int *) mem;
392 *tmem = va_arg(args, int);
393 return EINA_TRUE;
394 }
395 else if (type == EINA_VALUE_TYPE_LONG)
396 {
397 long *tmem = (long *) mem;
398 *tmem = va_arg(args, long);
399 return EINA_TRUE;
400 }
401 else if (type == EINA_VALUE_TYPE_INT64)
402 {
403 int64_t *tmem = (int64_t *) mem;
404 *tmem = va_arg(args, int64_t);
405 return EINA_TRUE;
406 }
407 else if (type == EINA_VALUE_TYPE_FLOAT)
408 {
409 float *tmem = (float *) mem;
410 *tmem = va_arg(args, double); /* promoted by va_arg */
411 return EINA_TRUE;
412 }
413 else if (type == EINA_VALUE_TYPE_DOUBLE)
414 {
415 double *tmem = (double *) mem;
416 *tmem = va_arg(args, double);
417 return EINA_TRUE;
418 }
419 else if (type == EINA_VALUE_TYPE_STRINGSHARE)
420 {
421 const char *str = (const char *) va_arg(args, const char *);
422 return eina_stringshare_replace((const char **)&value->value.ptr, str);
423 }
424 else if (type == EINA_VALUE_TYPE_STRING)
425 {
426 const char *str = (const char *) va_arg(args, const char *);
427 free(value->value.ptr);
428 if (!str)
429 value->value.ptr = NULL;
430 else
431 {
432 value->value.ptr = strdup(str);
433 if (!value->value.ptr)
434 {
435 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
436 return EINA_FALSE;
437 }
438 }
439 return EINA_TRUE;
440 }
441#endif
442
443 EINA_VALUE_TYPE_DISPATCH_RETURN(value, vset, EINA_ERROR_VALUE_FAILED,
444 EINA_FALSE, mem, args);
445}
446
447static inline Eina_Bool
448eina_value_vget(const Eina_Value *value, va_list args)
449{
450 const Eina_Value_Type *type;
451 const void *mem;
452 void *ptr;
453
454 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
455
456 type = value->type;
457 mem = eina_value_memory_get(value);
458 ptr = va_arg(args, void *);
459 eina_error_set(0);
460 if (EINA_VALUE_TYPE_DEFAULT(type))
461 {
462 memcpy(ptr, mem, type->value_size);
463 return EINA_TRUE;
464 }
465
466 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED,
467 EINA_FALSE, mem, ptr);
468}
469
470static inline Eina_Bool
471eina_value_pset(Eina_Value *value, const void *ptr)
472{
473 const Eina_Value_Type *type;
474 void *mem;
475
476 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
477 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
478
479 type = value->type;
480 mem = eina_value_memory_get(value);
481 eina_error_set(0);
482
483 if (EINA_VALUE_TYPE_DEFAULT(type))
484 {
485 if (type == EINA_VALUE_TYPE_STRINGSHARE)
486 {
487 const char * const *pstr = (const char * const *) ptr;
488 const char *str = *pstr;
489
490 return eina_stringshare_replace((const char **)&value->value.ptr,
491 str);
492 }
493 else if (type == EINA_VALUE_TYPE_STRING)
494 {
495 const char * const * pstr = (const char * const *) ptr;
496 const char *str = *pstr;
497
498 free(value->value.ptr);
499 if (!str)
500 value->value.ptr = NULL;
501 else
502 {
503 value->value.ptr = strdup(str);
504 if (!value->value.ptr)
505 {
506 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
507 return EINA_FALSE;
508 }
509 }
510 return EINA_TRUE;
511 }
512 else
513 memcpy(mem, ptr, type->value_size);
514 return EINA_TRUE;
515 }
516
517 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pset, EINA_ERROR_VALUE_FAILED,
518 EINA_FALSE, mem, ptr);
519}
520
521static inline Eina_Bool
522eina_value_pget(const Eina_Value *value, void *ptr)
523{
524 const Eina_Value_Type *type;
525 const void *mem;
526
527 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
528 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
529
530 type = value->type;
531 mem = eina_value_memory_get(value);
532 eina_error_set(0);
533 if (EINA_VALUE_TYPE_DEFAULT(type))
534 {
535 memcpy(ptr, mem, type->value_size);
536 return EINA_TRUE;
537 }
538
539 EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED,
540 EINA_FALSE, mem, ptr);
541}
542
543static inline const Eina_Value_Type *
544eina_value_type_get(const Eina_Value *value)
545{
546 EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, NULL);
547 return value->type;
548}
549
550#define EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, retval) \
551 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
552 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_ARRAY, retval)
553
554static inline Eina_Bool
555eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int step)
556{
557 Eina_Value_Array desc = { subtype, step, NULL };
558 if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY))
559 return EINA_FALSE;
560 if (!eina_value_pset(value, &desc))
561 {
562 eina_value_flush(value);
563 return EINA_FALSE;
564 }
565 return EINA_TRUE;
566}
567
568static inline unsigned int
569eina_value_array_count(const Eina_Value *value)
570{
571 Eina_Value_Array desc;
572 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
573 if (!eina_value_pget(value, &desc))
574 return 0;
575 return eina_inarray_count(desc.array);
576}
577
578static inline Eina_Bool
579eina_value_array_remove(Eina_Value *value, unsigned int position)
580{
581 Eina_Value_Array desc;
582 void *mem;
583
584 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
585 if (!eina_value_pget(value, &desc))
586 return EINA_FALSE;
587
588 mem = eina_inarray_nth(desc.array, position);
589 if (!mem)
590 return EINA_FALSE;
591
592 eina_value_type_flush(desc.subtype, mem);
593 return eina_inarray_remove_at(desc.array, position);
594}
595
596static inline Eina_Bool
597eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args)
598{
599 Eina_Value_Array desc;
600 void *mem;
601
602 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
603 if (!eina_value_pget(value, &desc))
604 return EINA_FALSE;
605
606 mem = eina_inarray_nth(desc.array, position);
607 if (!mem)
608 return EINA_FALSE;
609
610 eina_value_type_flush(desc.subtype, mem);
611
612 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
613 if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
614 return EINA_TRUE;
615
616 error_set:
617 eina_value_type_flush(desc.subtype, mem);
618 error_setup:
619 return EINA_FALSE;
620}
621
622static inline Eina_Bool
623eina_value_array_vget(const Eina_Value *value, unsigned int position, va_list args)
624{
625 Eina_Value_Array desc;
626 const void *mem;
627 void *ptr;
628 Eina_Bool ret;
629
630 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
631 if (!eina_value_pget(value, &desc))
632 return EINA_FALSE;
633
634 mem = eina_inarray_nth(desc.array, position);
635 if (!mem)
636 return EINA_FALSE;
637
638 ptr = va_arg(args, void *);
639 ret = eina_value_type_pget(desc.subtype, mem, ptr);
640 return ret;
641}
642
643static inline Eina_Bool
644eina_value_array_vinsert(Eina_Value *value, unsigned int position, va_list args)
645{
646 Eina_Value_Array desc;
647 void *mem;
648
649 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
650 if (!eina_value_pget(value, &desc))
651 return EINA_FALSE;
652
653 mem = eina_inarray_alloc_at(desc.array, position, 1);
654 if (!mem)
655 return EINA_FALSE;
656
657 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
658 if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
659 return EINA_TRUE;
660
661 error_set:
662 eina_value_type_flush(desc.subtype, mem);
663 error_setup:
664 eina_inarray_remove_at(desc.array, position);
665 return EINA_FALSE;
666}
667
668static inline Eina_Bool
669eina_value_array_vappend(Eina_Value *value, va_list args)
670{
671 Eina_Value_Array desc;
672 void *mem;
673 int position;
674
675 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
676 if (!eina_value_pget(value, &desc))
677 return EINA_FALSE;
678
679 position = eina_inarray_count(desc.array);
680 mem = eina_inarray_alloc_at(desc.array, position, 1);
681 if (!mem)
682 return EINA_FALSE;
683
684 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
685 if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
686 return EINA_TRUE;
687
688 error_set:
689 eina_value_type_flush(desc.subtype, mem);
690 error_setup:
691 eina_inarray_remove_at(desc.array, position);
692 return EINA_FALSE;
693}
694
695static inline Eina_Bool
696eina_value_array_set(Eina_Value *value, unsigned int position, ...)
697{
698 va_list args;
699 Eina_Bool ret;
700 va_start(args, position);
701 ret = eina_value_array_vset(value, position, args);
702 va_end(args);
703 return ret;
704}
705
706static inline Eina_Bool
707eina_value_array_get(const Eina_Value *value, unsigned int position, ...)
708{
709 va_list args;
710 Eina_Bool ret;
711 va_start(args, position);
712 ret = eina_value_array_vget(value, position, args);
713 va_end(args);
714 return ret;
715}
716
717static inline Eina_Bool
718eina_value_array_insert(Eina_Value *value, unsigned int position, ...)
719{
720 va_list args;
721 Eina_Bool ret;
722 va_start(args, position);
723 ret = eina_value_array_vinsert(value, position, args);
724 va_end(args);
725 return ret;
726}
727
728static inline Eina_Bool eina_value_array_append(Eina_Value *value, ...)
729{
730 va_list args;
731 Eina_Bool ret;
732 va_start(args, value);
733 ret = eina_value_array_vappend(value, args);
734 va_end(args);
735 return ret;
736}
737
738static inline Eina_Bool
739eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr)
740{
741 Eina_Value_Array desc;
742 void *mem;
743
744 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
745 if (!eina_value_pget(value, &desc))
746 return EINA_FALSE;
747
748 mem = eina_inarray_nth(desc.array, position);
749 if (!mem)
750 return EINA_FALSE;
751
752 eina_value_type_flush(desc.subtype, mem);
753
754 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
755 if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
756 return EINA_TRUE;
757
758 error_set:
759 eina_value_type_flush(desc.subtype, mem);
760 error_setup:
761 return EINA_FALSE;
762}
763
764static inline Eina_Bool
765eina_value_array_pget(const Eina_Value *value, unsigned int position, void *ptr)
766{
767 Eina_Value_Array desc;
768 const void *mem;
769 Eina_Bool ret;
770
771 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
772 if (!eina_value_pget(value, &desc))
773 return EINA_FALSE;
774
775 mem = eina_inarray_nth(desc.array, position);
776 if (!mem)
777 return EINA_FALSE;
778
779 ret = eina_value_type_pget(desc.subtype, mem, ptr);
780 return ret;
781}
782
783static inline Eina_Bool
784eina_value_array_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
785{
786 Eina_Value_Array desc;
787 void *mem;
788
789 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
790 if (!eina_value_pget(value, &desc))
791 return EINA_FALSE;
792
793 mem = eina_inarray_alloc_at(desc.array, position, 1);
794 if (!mem)
795 return EINA_FALSE;
796
797 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
798 if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
799 return EINA_TRUE;
800
801 error_set:
802 eina_value_type_flush(desc.subtype, mem);
803 error_setup:
804 eina_inarray_remove_at(desc.array, position);
805 return EINA_FALSE;
806}
807
808static inline Eina_Bool
809eina_value_array_pappend(Eina_Value *value, const void *ptr)
810{
811 Eina_Value_Array desc;
812 void *mem;
813 int position;
814
815 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
816 if (!eina_value_pget(value, &desc))
817 return EINA_FALSE;
818
819 position = eina_inarray_count(desc.array);
820 mem = eina_inarray_alloc_at(desc.array, position, 1);
821 if (!mem)
822 return EINA_FALSE;
823
824 if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
825 if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
826 return EINA_TRUE;
827
828 error_set:
829 eina_value_type_flush(desc.subtype, mem);
830 error_setup:
831 eina_inarray_remove_at(desc.array, position);
832 return EINA_FALSE;
833}
834
835#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL
836
837#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \
838 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
839 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_LIST, retval)
840
841static inline void *
842eina_value_list_node_memory_get(const Eina_Value_Type *type, const Eina_List *node)
843{
844 if (node == NULL) return NULL;
845 if (type->value_size <= sizeof(void*))
846 return (void *)&(node->data);
847 return node->data;
848}
849
850static inline void *
851eina_value_list_node_memory_setup(const Eina_Value_Type *type, Eina_List *node)
852{
853 if (type->value_size <= sizeof(void*))
854 return (void *)&(node->data);
855 node->data = malloc(type->value_size);
856 return node->data;
857}
858
859static inline void
860eina_value_list_node_memory_flush(const Eina_Value_Type *type, Eina_List *node)
861{
862 if (type->value_size <= sizeof(void*))
863 return;
864 free(node->data);
865}
866
867static inline Eina_Bool
868eina_value_list_setup(Eina_Value *value, const Eina_Value_Type *subtype)
869{
870 Eina_Value_List desc = { subtype, NULL };
871 if (!eina_value_setup(value, EINA_VALUE_TYPE_LIST))
872 return EINA_FALSE;
873 if (!eina_value_pset(value, &desc))
874 {
875 eina_value_flush(value);
876 return EINA_FALSE;
877 }
878 return EINA_TRUE;
879}
880
881static inline unsigned int
882eina_value_list_count(const Eina_Value *value)
883{
884 Eina_Value_List *desc;
885 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
886 desc = (Eina_Value_List *)eina_value_memory_get(value);
887 if (!desc)
888 return 0;
889 return eina_list_count(desc->list);
890}
891
892static inline Eina_Bool
893eina_value_list_remove(Eina_Value *value, unsigned int position)
894{
895 Eina_Value_List *desc;
896 Eina_List *node;
897 void *mem;
898
899 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
900 desc = (Eina_Value_List *)eina_value_memory_get(value);
901 if (!desc)
902 return EINA_FALSE;
903
904 node = eina_list_nth_list(desc->list, position);
905 mem = eina_value_list_node_memory_get(desc->subtype, node);
906 if (!mem)
907 return EINA_FALSE;
908
909 eina_value_type_flush(desc->subtype, mem);
910 eina_value_list_node_memory_flush(desc->subtype, node);
911 desc->list = eina_list_remove_list(desc->list, node);
912 return EINA_TRUE;
913}
914
915static inline Eina_Bool
916eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args)
917{
918 Eina_Value_List *desc;
919 Eina_List *node;
920 void *mem;
921
922 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
923 desc = (Eina_Value_List *)eina_value_memory_get(value);
924 if (!desc)
925 return EINA_FALSE;
926
927 node = eina_list_nth_list(desc->list, position);
928 mem = eina_value_list_node_memory_get(desc->subtype, node);
929 if (!mem)
930 return EINA_FALSE;
931
932 eina_value_type_flush(desc->subtype, mem);
933
934 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
935 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
936 return EINA_TRUE;
937
938 error_set:
939 eina_value_type_flush(desc->subtype, mem);
940 error_setup:
941 return EINA_FALSE;
942}
943
944static inline Eina_Bool
945eina_value_list_vget(const Eina_Value *value, unsigned int position, va_list args)
946{
947 const Eina_Value_List *desc;
948 const Eina_List *node;
949 const void *mem;
950 void *ptr;
951 Eina_Bool ret;
952
953 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
954 desc = (const Eina_Value_List *)eina_value_memory_get(value);
955 if (!desc)
956 return EINA_FALSE;
957
958 node = eina_list_nth_list(desc->list, position);
959 mem = eina_value_list_node_memory_get(desc->subtype, node);
960 if (!mem)
961 return EINA_FALSE;
962
963 ptr = va_arg(args, void *);
964 ret = eina_value_type_pget(desc->subtype, mem, ptr);
965 return ret;
966}
967
968static inline Eina_Bool
969eina_value_list_vinsert(Eina_Value *value, unsigned int position, va_list args)
970{
971 Eina_Value_List *desc;
972 Eina_List *node;
973 void *mem;
974
975 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
976 desc = (Eina_Value_List *)eina_value_memory_get(value);
977 if (!desc)
978 return EINA_FALSE;
979
980 if (!desc->list)
981 node = desc->list = eina_list_append(NULL, (void*)1L);
982 else if (position == 0)
983 node = desc->list = eina_list_prepend(desc->list, (void*)1L);
984 else
985 {
986 Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
987 desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
988 node = rel->next;
989 }
990 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
991 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
992
993 mem = eina_value_list_node_memory_setup(desc->subtype, node);
994 if (!mem)
995 {
996 desc->list = eina_list_remove_list(desc->list, node);
997 return EINA_FALSE;
998 }
999
1000 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1001 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
1002 return EINA_TRUE;
1003
1004 error_set:
1005 eina_value_type_flush(desc->subtype, mem);
1006 error_setup:
1007 eina_value_list_node_memory_flush(desc->subtype, node);
1008 desc->list = eina_list_remove_list(desc->list, node);
1009 return EINA_FALSE;
1010}
1011
1012static inline Eina_Bool
1013eina_value_list_vappend(Eina_Value *value, va_list args)
1014{
1015 Eina_Value_List *desc;
1016 Eina_List *node;
1017 void *mem;
1018
1019 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1020 desc = (Eina_Value_List *)eina_value_memory_get(value);
1021 if (!desc)
1022 return EINA_FALSE;
1023
1024 desc->list = eina_list_append(desc->list, (void*)1L);
1025 node = eina_list_last(desc->list);
1026 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1027 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1028
1029 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1030 if (!mem)
1031 {
1032 desc->list = eina_list_remove_list(desc->list, node);
1033 return EINA_FALSE;
1034 }
1035
1036 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1037 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
1038 return EINA_TRUE;
1039
1040 error_set:
1041 eina_value_type_flush(desc->subtype, mem);
1042 error_setup:
1043 eina_value_list_node_memory_flush(desc->subtype, node);
1044 desc->list = eina_list_remove_list(desc->list, node);
1045 return EINA_FALSE;
1046}
1047
1048static inline Eina_Bool
1049eina_value_list_set(Eina_Value *value, unsigned int position, ...)
1050{
1051 va_list args;
1052 Eina_Bool ret;
1053 va_start(args, position);
1054 ret = eina_value_list_vset(value, position, args);
1055 va_end(args);
1056 return ret;
1057}
1058
1059static inline Eina_Bool
1060eina_value_list_get(const Eina_Value *value, unsigned int position, ...)
1061{
1062 va_list args;
1063 Eina_Bool ret;
1064 va_start(args, position);
1065 ret = eina_value_list_vget(value, position, args);
1066 va_end(args);
1067 return ret;
1068}
1069
1070static inline Eina_Bool
1071eina_value_list_insert(Eina_Value *value, unsigned int position, ...)
1072{
1073 va_list args;
1074 Eina_Bool ret;
1075 va_start(args, position);
1076 ret = eina_value_list_vinsert(value, position, args);
1077 va_end(args);
1078 return ret;
1079}
1080
1081static inline Eina_Bool eina_value_list_append(Eina_Value *value, ...)
1082{
1083 va_list args;
1084 Eina_Bool ret;
1085 va_start(args, value);
1086 ret = eina_value_list_vappend(value, args);
1087 va_end(args);
1088 return ret;
1089}
1090
1091static inline Eina_Bool
1092eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr)
1093{
1094 Eina_Value_List *desc;
1095 Eina_List *node;
1096 void *mem;
1097
1098 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1099 desc = (Eina_Value_List *)eina_value_memory_get(value);
1100 if (!desc)
1101 return EINA_FALSE;
1102
1103 node = eina_list_nth_list(desc->list, position);
1104 mem = eina_value_list_node_memory_get(desc->subtype, node);
1105 if (!mem)
1106 return EINA_FALSE;
1107
1108 eina_value_type_flush(desc->subtype, mem);
1109
1110 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1111 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1112 return EINA_TRUE;
1113
1114 error_set:
1115 eina_value_type_flush(desc->subtype, mem);
1116 error_setup:
1117 return EINA_FALSE;
1118}
1119
1120static inline Eina_Bool
1121eina_value_list_pget(const Eina_Value *value, unsigned int position, void *ptr)
1122{
1123 const Eina_Value_List *desc;
1124 const Eina_List *node;
1125 const void *mem;
1126 Eina_Bool ret;
1127
1128 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1129 desc = (const Eina_Value_List *)eina_value_memory_get(value);
1130 if (!desc)
1131 return EINA_FALSE;
1132
1133 node = eina_list_nth_list(desc->list, position);
1134 mem = eina_value_list_node_memory_get(desc->subtype, node);
1135 if (!mem)
1136 return EINA_FALSE;
1137
1138 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1139 return ret;
1140}
1141
1142static inline Eina_Bool
1143eina_value_list_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
1144{
1145 Eina_Value_List *desc;
1146 Eina_List *node;
1147 void *mem;
1148
1149 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1150 desc = (Eina_Value_List *)eina_value_memory_get(value);
1151 if (!desc)
1152 return EINA_FALSE;
1153
1154 if (!desc->list)
1155 node = desc->list = eina_list_append(NULL, (void*)1L);
1156 else if (position == 0)
1157 node = desc->list = eina_list_prepend(desc->list, (void*)1L);
1158 else
1159 {
1160 Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
1161 desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
1162 node = rel->next;
1163 }
1164 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1165 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1166
1167 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1168 if (!mem)
1169 {
1170 desc->list = eina_list_remove_list(desc->list, node);
1171 return EINA_FALSE;
1172 }
1173
1174 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1175 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1176 return EINA_TRUE;
1177
1178 error_set:
1179 eina_value_type_flush(desc->subtype, mem);
1180 error_setup:
1181 eina_value_list_node_memory_flush(desc->subtype, node);
1182 desc->list = eina_list_remove_list(desc->list, node);
1183 return EINA_FALSE;
1184}
1185
1186static inline Eina_Bool
1187eina_value_list_pappend(Eina_Value *value, const void *ptr)
1188{
1189 Eina_Value_List *desc;
1190 Eina_List *node;
1191 void *mem;
1192
1193 EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
1194 desc = (Eina_Value_List *)eina_value_memory_get(value);
1195 if (!desc)
1196 return EINA_FALSE;
1197
1198 desc->list = eina_list_append(desc->list, (void*)1L);
1199 node = eina_list_last(desc->list);
1200 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
1201 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
1202
1203 mem = eina_value_list_node_memory_setup(desc->subtype, node);
1204 if (!mem)
1205 {
1206 desc->list = eina_list_remove_list(desc->list, node);
1207 return EINA_FALSE;
1208 }
1209
1210 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1211 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1212 return EINA_TRUE;
1213
1214 error_set:
1215 eina_value_type_flush(desc->subtype, mem);
1216 error_setup:
1217 eina_value_list_node_memory_flush(desc->subtype, node);
1218 desc->list = eina_list_remove_list(desc->list, node);
1219 return EINA_FALSE;
1220}
1221#undef EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL
1222
1223#define EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, retval) \
1224 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
1225 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_HASH, retval)
1226
1227static inline Eina_Bool
1228eina_value_hash_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size)
1229{
1230 Eina_Value_Hash desc = { subtype, buckets_power_size, NULL };
1231 if (!eina_value_setup(value, EINA_VALUE_TYPE_HASH))
1232 return EINA_FALSE;
1233 if (!eina_value_pset(value, &desc))
1234 {
1235 eina_value_flush(value);
1236 return EINA_FALSE;
1237 }
1238 return EINA_TRUE;
1239}
1240
1241static inline unsigned int
1242eina_value_hash_population(const Eina_Value *value)
1243{
1244 Eina_Value_Hash *desc;
1245 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1246 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1247 if (!desc)
1248 return 0;
1249 return eina_hash_population(desc->hash);
1250}
1251
1252static inline Eina_Bool
1253eina_value_hash_del(Eina_Value *value, const char *key)
1254{
1255 Eina_Value_Hash *desc;
1256 void *mem;
1257
1258 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1259 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1260 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1261 if (!desc)
1262 return EINA_FALSE;
1263
1264 mem = eina_hash_find(desc->hash, key);
1265 if (!mem)
1266 return EINA_FALSE;
1267
1268 eina_value_type_flush(desc->subtype, mem);
1269 free(mem);
1270 eina_hash_del_by_key(desc->hash, key);
1271 return EINA_TRUE;
1272}
1273
1274static inline Eina_Bool
1275eina_value_hash_vset(Eina_Value *value, const char *key, va_list args)
1276{
1277 Eina_Value_Hash *desc;
1278 void *mem;
1279
1280 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1281 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1282 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1283 if (!desc)
1284 return EINA_FALSE;
1285
1286 mem = eina_hash_find(desc->hash, key);
1287 if (mem)
1288 eina_value_type_flush(desc->subtype, mem);
1289 else
1290 {
1291 mem = malloc(desc->subtype->value_size);
1292 if (!mem)
1293 {
1294 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
1295 return EINA_FALSE;
1296 }
1297 if (!eina_hash_add(desc->hash, key, mem))
1298 {
1299 free(mem);
1300 return EINA_FALSE;
1301 }
1302 }
1303
1304 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1305 if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
1306 return EINA_TRUE;
1307
1308 error_set:
1309 eina_value_type_flush(desc->subtype, mem);
1310 error_setup:
1311 eina_hash_del_by_key(desc->hash, key);
1312 free(mem);
1313 return EINA_FALSE;
1314}
1315
1316static inline Eina_Bool
1317eina_value_hash_vget(const Eina_Value *value, const char *key, va_list args)
1318{
1319 const Eina_Value_Hash *desc;
1320 const void *mem;
1321 void *ptr;
1322 Eina_Bool ret;
1323
1324 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
1325 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1326 desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
1327 if (!desc)
1328 return EINA_FALSE;
1329
1330 mem = eina_hash_find(desc->hash, key);
1331 if (!mem)
1332 return EINA_FALSE;
1333
1334 ptr = va_arg(args, void *);
1335 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1336 return ret;
1337}
1338
1339static inline Eina_Bool
1340eina_value_hash_set(Eina_Value *value, const char *key, ...)
1341{
1342 va_list args;
1343 Eina_Bool ret;
1344 va_start(args, key);
1345 ret = eina_value_hash_vset(value, key, args);
1346 va_end(args);
1347 return ret;
1348}
1349
1350static inline Eina_Bool
1351eina_value_hash_get(const Eina_Value *value, const char *key, ...)
1352{
1353 va_list args;
1354 Eina_Bool ret;
1355 va_start(args, key);
1356 ret = eina_value_hash_vget(value, key, args);
1357 va_end(args);
1358 return ret;
1359}
1360
1361static inline Eina_Bool
1362eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr)
1363{
1364 Eina_Value_Hash *desc;
1365 void *mem;
1366
1367 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1368 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1369 desc = (Eina_Value_Hash *)eina_value_memory_get(value);
1370 if (!desc)
1371 return EINA_FALSE;
1372
1373 mem = eina_hash_find(desc->hash, key);
1374 if (mem)
1375 eina_value_type_flush(desc->subtype, mem);
1376 else
1377 {
1378 mem = malloc(desc->subtype->value_size);
1379 if (!mem)
1380 {
1381 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
1382 return EINA_FALSE;
1383 }
1384 if (!eina_hash_add(desc->hash, key, mem))
1385 {
1386 free(mem);
1387 return EINA_FALSE;
1388 }
1389 }
1390
1391 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
1392 if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
1393 return EINA_TRUE;
1394
1395 error_set:
1396 eina_value_type_flush(desc->subtype, mem);
1397 error_setup:
1398 eina_hash_del_by_key(desc->hash, key);
1399 free(mem);
1400 return EINA_FALSE;
1401}
1402
1403static inline Eina_Bool
1404eina_value_hash_pget(const Eina_Value *value, const char *key, void *ptr)
1405{
1406 const Eina_Value_Hash *desc;
1407 const void *mem;
1408 Eina_Bool ret;
1409
1410 EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
1411 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
1412 desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
1413 if (!desc)
1414 return EINA_FALSE;
1415
1416 mem = eina_hash_find(desc->hash, key);
1417 if (!mem)
1418 return EINA_FALSE;
1419
1420 ret = eina_value_type_pget(desc->subtype, mem, ptr);
1421 return ret;
1422}
1423#undef EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL
1424
1425#define EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, retval) \
1426 EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
1427 EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_STRUCT, retval)
1428
1429/**
1430 * @brief Find member of struct
1431 * @since 1.2
1432 * @internal
1433 */
1434EAPI const Eina_Value_Struct_Member *eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
1435
1436static inline Eina_Bool
1437eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc)
1438{
1439 Eina_Value_Struct desc = {sdesc, NULL};
1440 if (!eina_value_setup(value, EINA_VALUE_TYPE_STRUCT))
1441 return EINA_FALSE;
1442 if (!eina_value_pset(value, &desc))
1443 {
1444 eina_value_flush(value);
1445 return EINA_FALSE;
1446 }
1447 return EINA_TRUE;
1448}
1449
1450static inline void *
1451eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
1452{
1453 unsigned char *base = (unsigned char *)st->memory;
1454 if (!base) return NULL;
1455 return base + member->offset;
1456}
1457
1458static inline Eina_Bool
1459eina_value_struct_vset(Eina_Value *value, const char *name, va_list args)
1460{
1461 const Eina_Value_Struct_Member *member;
1462 Eina_Value_Struct *st;
1463 void *mem;
1464
1465 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1466 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1467 st = (Eina_Value_Struct *)eina_value_memory_get(value);
1468 if (!st)
1469 return EINA_FALSE;
1470 member = eina_value_struct_member_find(st, name);
1471 if (!member)
1472 return EINA_FALSE;
1473 mem = eina_value_struct_member_memory_get(st, member);
1474 if (!mem)
1475 return EINA_FALSE;
1476
1477 eina_value_type_flush(member->type, mem);
1478 if (!eina_value_type_setup(member->type, mem)) goto error_setup;
1479 if (!eina_value_type_vset(member->type, mem, args)) goto error_set;
1480 return EINA_TRUE;
1481
1482 error_set:
1483 eina_value_type_flush(member->type, mem);
1484 error_setup:
1485 return EINA_FALSE;
1486}
1487
1488static inline Eina_Bool
1489eina_value_struct_vget(const Eina_Value *value, const char *name, va_list args)
1490{
1491 const Eina_Value_Struct_Member *member;
1492 const Eina_Value_Struct *st;
1493 const void *mem;
1494 void *ptr;
1495 Eina_Bool ret;
1496
1497 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1498 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1499 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1500 if (!st)
1501 return EINA_FALSE;
1502 member = eina_value_struct_member_find(st, name);
1503 if (!member)
1504 return EINA_FALSE;
1505 mem = eina_value_struct_member_memory_get(st, member);
1506 if (!mem)
1507 return EINA_FALSE;
1508
1509 ptr = va_arg(args, void *);
1510 ret = eina_value_type_pget(member->type, mem, ptr);
1511 return ret;
1512}
1513
1514static inline Eina_Bool
1515eina_value_struct_set(Eina_Value *value, const char *name, ...)
1516{
1517 va_list args;
1518 Eina_Bool ret;
1519 va_start(args, name);
1520 ret = eina_value_struct_vset(value, name, args);
1521 va_end(args);
1522 return ret;
1523}
1524
1525static inline Eina_Bool
1526eina_value_struct_get(const Eina_Value *value, const char *name, ...)
1527{
1528 va_list args;
1529 Eina_Bool ret;
1530 va_start(args, name);
1531 ret = eina_value_struct_vget(value, name, args);
1532 va_end(args);
1533 return ret;
1534}
1535
1536static inline Eina_Bool
1537eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr)
1538{
1539 const Eina_Value_Struct_Member *member;
1540 Eina_Value_Struct *st;
1541 void *mem;
1542
1543 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0);
1544 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1545 st = (Eina_Value_Struct *)eina_value_memory_get(value);
1546 if (!st)
1547 return EINA_FALSE;
1548 member = eina_value_struct_member_find(st, name);
1549 if (!member)
1550 return EINA_FALSE;
1551 mem = eina_value_struct_member_memory_get(st, member);
1552 if (!mem)
1553 return EINA_FALSE;
1554
1555 eina_value_type_flush(member->type, mem);
1556 if (!eina_value_type_setup(member->type, mem)) goto error_setup;
1557 if (!eina_value_type_pset(member->type, mem, ptr)) goto error_set;
1558 return EINA_TRUE;
1559
1560 error_set:
1561 eina_value_type_flush(member->type, mem);
1562 error_setup:
1563 return EINA_FALSE;
1564}
1565
1566static inline Eina_Bool
1567eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr)
1568{
1569 const Eina_Value_Struct_Member *member;
1570 const Eina_Value_Struct *st;
1571 const void *mem;
1572 Eina_Bool ret;
1573
1574 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0);
1575 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1576 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1577 if (!st)
1578 return EINA_FALSE;
1579 member = eina_value_struct_member_find(st, name);
1580 if (!member)
1581 return EINA_FALSE;
1582 mem = eina_value_struct_member_memory_get(st, member);
1583 if (!mem)
1584 return EINA_FALSE;
1585
1586 ret = eina_value_type_pget(member->type, mem, ptr);
1587 return ret;
1588}
1589#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
1590
1591
1592static inline Eina_Bool
1593eina_value_type_setup(const Eina_Value_Type *type, void *mem)
1594{
1595 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1596 if (!type->setup)
1597 {
1598 eina_error_set(EINA_ERROR_VALUE_FAILED);
1599 return EINA_FALSE;
1600 }
1601 return type->setup(type, mem);
1602}
1603
1604static inline Eina_Bool
1605eina_value_type_flush(const Eina_Value_Type *type, void *mem)
1606{
1607 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1608 if (!type->flush)
1609 {
1610 eina_error_set(EINA_ERROR_VALUE_FAILED);
1611 return EINA_FALSE;
1612 }
1613 return type->flush(type, mem);
1614}
1615
1616static inline Eina_Bool
1617eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst)
1618{
1619 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1620 if (!type->copy)
1621 {
1622 eina_error_set(EINA_ERROR_VALUE_FAILED);
1623 return EINA_FALSE;
1624 }
1625 return type->copy(type, src, dst);
1626}
1627
1628static inline int
1629eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b)
1630{
1631 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1632 if (!type->compare)
1633 {
1634 eina_error_set(EINA_ERROR_VALUE_FAILED);
1635 return EINA_FALSE;
1636 }
1637 return type->compare(type, a, b);
1638}
1639
1640static inline Eina_Bool
1641eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1642{
1643 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1644 if (!type->convert_to)
1645 {
1646 eina_error_set(EINA_ERROR_VALUE_FAILED);
1647 return EINA_FALSE;
1648 }
1649 return type->convert_to(type, convert, type_mem, convert_mem);
1650}
1651
1652static inline Eina_Bool
1653eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
1654{
1655 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1656 if (!type->convert_from)
1657 {
1658 eina_error_set(EINA_ERROR_VALUE_FAILED);
1659 return EINA_FALSE;
1660 }
1661 return type->convert_from(type, convert, type_mem, convert_mem);
1662}
1663
1664static inline Eina_Bool
1665eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args)
1666{
1667 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1668 if (!type->vset)
1669 {
1670 eina_error_set(EINA_ERROR_VALUE_FAILED);
1671 return EINA_FALSE;
1672 }
1673 return type->vset(type, mem, args);
1674}
1675
1676static inline Eina_Bool
1677eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr)
1678{
1679 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1680 if (!type->pset)
1681 {
1682 eina_error_set(EINA_ERROR_VALUE_FAILED);
1683 return EINA_FALSE;
1684 }
1685 return type->pset(type, mem, ptr);
1686}
1687
1688static inline Eina_Bool
1689eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr)
1690{
1691 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
1692 if (!type->pget)
1693 {
1694 eina_error_set(EINA_ERROR_VALUE_FAILED);
1695 return EINA_FALSE;
1696 }
1697 return type->pget(type, mem, ptr);
1698}
1699
1700#undef EINA_VALUE_TYPE_DEFAULT
1701#undef EINA_VALUE_TYPE_CHECK_RETURN
1702#undef EINA_VALUE_TYPE_CHECK_RETURN_VAL
1703#undef EINA_VALUE_TYPE_DISPATCH
1704#undef EINA_VALUE_TYPE_DISPATCH_RETURN
1705#endif
diff --git a/libraries/eina/src/include/eina_inlist.h b/libraries/eina/src/include/eina_inlist.h
index 1b3ab27..cfb3159 100644
--- a/libraries/eina/src/include/eina_inlist.h
+++ b/libraries/eina/src/include/eina_inlist.h
@@ -25,7 +25,7 @@
25#include <stddef.h> 25#include <stddef.h>
26 26
27/** 27/**
28 * @page inlist_01_example_page Eina_Inlist basic usage 28 * @page eina_inlist_01_example_page Eina_Inlist basic usage
29 * @dontinclude eina_inlist_01.c 29 * @dontinclude eina_inlist_01.c
30 * 30 *
31 * To see the full source for this example, click here: @ref 31 * To see the full source for this example, click here: @ref
@@ -111,7 +111,7 @@
111 */ 111 */
112 112
113/** 113/**
114 * @page inlist_02_example_page Eina_Inlist advanced usage - lists and inlists 114 * @page eina_inlist_02_example_page Eina_Inlist advanced usage - lists and inlists
115 * @dontinclude eina_inlist_02.c 115 * @dontinclude eina_inlist_02.c
116 * 116 *
117 * This example describes the usage of @ref Eina_Inlist mixed with @ref 117 * This example describes the usage of @ref Eina_Inlist mixed with @ref
@@ -120,7 +120,7 @@
120 * from this normal list. 120 * from this normal list.
121 * 121 *
122 * The struct that is going to be used is the same used in @ref 122 * The struct that is going to be used is the same used in @ref
123 * inlist_01_example_page , since we still need the @ref EINA_INLIST macro to 123 * eina_inlist_01_example_page , since we still need the @ref EINA_INLIST macro to
124 * declare the inlist node info: 124 * declare the inlist node info:
125 * 125 *
126 * @skip struct 126 * @skip struct
@@ -184,7 +184,7 @@
184 */ 184 */
185 185
186/** 186/**
187 * @page inlist_03_example_page Eina_Inlist advanced usage - multi-inlists 187 * @page eina_inlist_03_example_page Eina_Inlist advanced usage - multi-inlists
188 * @dontinclude eina_inlist_03.c 188 * @dontinclude eina_inlist_03.c
189 * 189 *
190 * This example describes the usage of multiple inlists storing the same data. 190 * This example describes the usage of multiple inlists storing the same data.
@@ -315,7 +315,7 @@
315 * exactly what type this list is. 315 * exactly what type this list is.
316 * 316 *
317 * A simple example demonstrating the basic usage of an inlist can be found 317 * A simple example demonstrating the basic usage of an inlist can be found
318 * here: @ref inlist_01_example_page 318 * here: @ref eina_inlist_01_example_page
319 * 319 *
320 * @section inlist_algo Algorithm 320 * @section inlist_algo Algorithm
321 * 321 *
@@ -368,9 +368,9 @@
368 * @ref inlist_03_example_page 368 * @ref inlist_03_example_page
369 * 369 *
370 * List of examples: 370 * List of examples:
371 * @li @ref inlist_01_example_page 371 * @li @ref eina_inlist_01_example_page
372 * @li @ref inlist_02_example_page 372 * @li @ref eina_inlist_02_example_page
373 * @li @ref inlist_03_example_page 373 * @li @ref eina_inlist_03_example_page
374 */ 374 */
375 375
376/** 376/**
@@ -428,17 +428,17 @@ struct _Eina_Inlist
428 * Add a new node to end of a list. 428 * Add a new node to end of a list.
429 * 429 *
430 * @note this code is meant to be fast: appends are O(1) and do not 430 * @note this code is meant to be fast: appends are O(1) and do not
431 * walk @a list. 431 * walk @a in_list.
432 * 432 *
433 * @note @a new_l is considered to be in no list. If it was in another 433 * @note @a in_item is considered to be in no list. If it was in another
434 * list before, eina_inlist_remove() it before adding. No 434 * list before, eina_inlist_remove() it before adding. No
435 * check of @a new_l prev and next pointers is done, so it's safe 435 * check of @a new_l prev and next pointers is done, so it's safe
436 * to have them uninitialized. 436 * to have them uninitialized.
437 * 437 *
438 * @param list existing list head or NULL to create a new list. 438 * @param in_list existing list head or NULL to create a new list.
439 * @param new_l new list node, must not be NULL. 439 * @param in_item new list node, must not be NULL.
440 * 440 *
441 * @return the new list head. Use it and not @a list anymore. 441 * @return the new list head. Use it and not @a in_list anymore.
442 */ 442 */
443EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, 443EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list,
444 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; 444 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
@@ -447,17 +447,17 @@ EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list,
447 * Add a new node to beginning of list. 447 * Add a new node to beginning of list.
448 * 448 *
449 * @note this code is meant to be fast: appends are O(1) and do not 449 * @note this code is meant to be fast: appends are O(1) and do not
450 * walk @a list. 450 * walk @a in_list.
451 * 451 *
452 * @note @a new_l is considered to be in no list. If it was in another 452 * @note @a new_l is considered to be in no list. If it was in another
453 * list before, eina_inlist_remove() it before adding. No 453 * list before, eina_inlist_remove() it before adding. No
454 * check of @a new_l prev and next pointers is done, so it's safe 454 * check of @a new_l prev and next pointers is done, so it's safe
455 * to have them uninitialized. 455 * to have them uninitialized.
456 * 456 *
457 * @param list existing list head or NULL to create a new list. 457 * @param in_list existing list head or NULL to create a new list.
458 * @param new_l new list node, must not be NULL. 458 * @param in_item new list node, must not be NULL.
459 * 459 *
460 * @return the new list head. Use it and not @a list anymore. 460 * @return the new list head. Use it and not @a in_list anymore.
461 */ 461 */
462EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, 462EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list,
463 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; 463 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
@@ -466,21 +466,21 @@ EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list,
466 * Add a new node after the given relative item in list. 466 * Add a new node after the given relative item in list.
467 * 467 *
468 * @note this code is meant to be fast: appends are O(1) and do not 468 * @note this code is meant to be fast: appends are O(1) and do not
469 * walk @a list. 469 * walk @a in_list.
470 * 470 *
471 * @note @a new_l is considered to be in no list. If it was in another 471 * @note @a in_item_l is considered to be in no list. If it was in another
472 * list before, eina_inlist_remove() it before adding. No 472 * list before, eina_inlist_remove() it before adding. No
473 * check of @a new_l prev and next pointers is done, so it's safe 473 * check of @a in_item prev and next pointers is done, so it's safe
474 * to have them uninitialized. 474 * to have them uninitialized.
475 * 475 *
476 * @note @a relative is considered to be inside @a list, no checks are 476 * @note @a in_relative is considered to be inside @a in_list, no checks are
477 * done to confirm that and giving nodes from different lists 477 * done to confirm that and giving nodes from different lists
478 * will lead to problems. Giving NULL @a relative is the same as 478 * will lead to problems. Giving NULL @a in_relative is the same as
479 * eina_list_append(). 479 * eina_list_append().
480 * 480 *
481 * @param list existing list head or NULL to create a new list. 481 * @param in_list existing list head or NULL to create a new list.
482 * @param new_l new list node, must not be NULL. 482 * @param in_item new list node, must not be NULL.
483 * @param relative reference node, @a new_l will be added after it. 483 * @param in_relative reference node, @a in_item will be added after it.
484 * 484 *
485 * @return the new list head. Use it and not @a list anymore. 485 * @return the new list head. Use it and not @a list anymore.
486 */ 486 */
@@ -492,23 +492,23 @@ EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list,
492 * Add a new node before the given relative item in list. 492 * Add a new node before the given relative item in list.
493 * 493 *
494 * @note this code is meant to be fast: appends are O(1) and do not 494 * @note this code is meant to be fast: appends are O(1) and do not
495 * walk @a list. 495 * walk @a in_list.
496 * 496 *
497 * @note @a new_l is considered to be in no list. If it was in another 497 * @note @a in_item is considered to be in no list. If it was in another
498 * list before, eina_inlist_remove() it before adding. No 498 * list before, eina_inlist_remove() it before adding. No
499 * check of @a new_l prev and next pointers is done, so it's safe 499 * check of @a in_item prev and next pointers is done, so it's safe
500 * to have them uninitialized. 500 * to have them uninitialized.
501 * 501 *
502 * @note @a relative is considered to be inside @a list, no checks are 502 * @note @a in_relative is considered to be inside @a in_list, no checks are
503 * done to confirm that and giving nodes from different lists 503 * done to confirm that and giving nodes from different lists
504 * will lead to problems. Giving NULL @a relative is the same as 504 * will lead to problems. Giving NULL @a in_relative is the same as
505 * eina_list_prepend(). 505 * eina_list_prepend().
506 * 506 *
507 * @param list existing list head or NULL to create a new list. 507 * @param in_list existing list head or NULL to create a new list.
508 * @param new_l new list node, must not be NULL. 508 * @param in_item new list node, must not be NULL.
509 * @param relative reference node, @a new_l will be added before it. 509 * @param in_relative reference node, @a in_item will be added before it.
510 * 510 *
511 * @return the new list head. Use it and not @a list anymore. 511 * @return the new list head. Use it and not @a in_list anymore.
512 */ 512 */
513EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, 513EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list,
514 Eina_Inlist *in_item, 514 Eina_Inlist *in_item,
@@ -520,14 +520,14 @@ EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list,
520 * @note this code is meant to be fast: appends are O(1) and do not 520 * @note this code is meant to be fast: appends are O(1) and do not
521 * walk @a list. 521 * walk @a list.
522 * 522 *
523 * @note @a item is considered to be inside @a list, no checks are 523 * @note @a in_item is considered to be inside @a in_list, no checks are
524 * done to confirm that and giving nodes from different lists 524 * done to confirm that and giving nodes from different lists
525 * will lead to problems, especially if @a item is the head since 525 * will lead to problems, especially if @a in_item is the head since
526 * it will be different from @a list and the wrong new head will 526 * it will be different from @a list and the wrong new head will
527 * be returned. 527 * be returned.
528 * 528 *
529 * @param list existing list head, must not be NULL. 529 * @param in_list existing list head, must not be NULL.
530 * @param item existing list node, must not be NULL. 530 * @param in_item existing list node, must not be NULL.
531 * 531 *
532 * @return the new list head. Use it and not @a list anymore. 532 * @return the new list head. Use it and not @a list anymore.
533 */ 533 */
@@ -540,10 +540,10 @@ EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list,
540 * @warning this is an expensive call and has O(n) cost, possibly 540 * @warning this is an expensive call and has O(n) cost, possibly
541 * walking the whole list. 541 * walking the whole list.
542 * 542 *
543 * @param list existing list to search @a item in, must not be NULL. 543 * @param in_list existing list to search @a in_item in, must not be NULL.
544 * @param item what to search for, must not be NULL. 544 * @param in_item what to search for, must not be NULL.
545 * 545 *
546 * @return @a item if found, NULL if not. 546 * @return @a in_item if found, NULL if not.
547 */ 547 */
548EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list, 548EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list,
549 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; 549 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
@@ -603,11 +603,11 @@ EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_
603/** 603/**
604 * @brief Returns a new iterator associated to @a list. 604 * @brief Returns a new iterator associated to @a list.
605 * 605 *
606 * @param list The list. 606 * @param in_list The list.
607 * @return A new iterator. 607 * @return A new iterator.
608 * 608 *
609 * This function returns a newly allocated iterator associated to @p 609 * This function returns a newly allocated iterator associated to @p
610 * list. If @p list is @c NULL or the count member of @p list is less 610 * in_list. If @p in_list is @c NULL or the count member of @p in_list is less
611 * or equal than 0, this function still returns a valid iterator that 611 * or equal than 0, this function still returns a valid iterator that
612 * will always return false on eina_iterator_next(), thus keeping API 612 * will always return false on eina_iterator_next(), thus keeping API
613 * sane. 613 * sane.
@@ -625,13 +625,13 @@ EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MA
625/** 625/**
626 * @brief Returns a new accessor associated to a list. 626 * @brief Returns a new accessor associated to a list.
627 * 627 *
628 * @param list The list. 628 * @param in_list The list.
629 * @return A new accessor. 629 * @return A new accessor.
630 * 630 *
631 * This function returns a newly allocated accessor associated to 631 * This function returns a newly allocated accessor associated to
632 * @p list. If @p list is @c NULL or the count member of @p list is 632 * @p in_list. If @p in_list is @c NULL or the count member of @p in_list is
633 * less or equal than 0, this function returns NULL. If the memory can 633 * less or equal than 0, this function returns @c NULL. If the memory can
634 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is 634 * not be allocated, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
635 * set. Otherwise, a valid accessor is returned. 635 * set. Otherwise, a valid accessor is returned.
636 */ 636 */
637EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 637EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
@@ -728,13 +728,13 @@ EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list,
728/** 728/**
729 * @brief Sort a list according to the ordering func will return. 729 * @brief Sort a list according to the ordering func will return.
730 * 730 *
731 * @param list The list handle to sort. 731 * @param head The list handle to sort.
732 * @param func A function pointer that can handle comparing the list data 732 * @param func A function pointer that can handle comparing the list data
733 * nodes. 733 * nodes.
734 * @return the new head of list. 734 * @return the new head of list.
735 * 735 *
736 * This function sorts all the elements of @p list. @p func is used to 736 * This function sorts all the elements of @p head. @p func is used to
737 * compare two elements of @p list. If @p list or @p func are @c NULL, 737 * compare two elements of @p head. If @p head or @p func are @c NULL,
738 * this function returns @c NULL. 738 * this function returns @c NULL.
739 * 739 *
740 * @note @b in-place: this will change the given list, so you should 740 * @note @b in-place: this will change the given list, so you should
@@ -787,6 +787,7 @@ EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func);
787 _EINA_INLIST_OFFSET(ref)) 787 _EINA_INLIST_OFFSET(ref))
788#endif 788#endif
789 789
790/** Macro to iterate over an inlist */
790#define EINA_INLIST_FOREACH(list, l) \ 791#define EINA_INLIST_FOREACH(list, l) \
791 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ 792 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \
792 l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL)) 793 l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
diff --git a/libraries/eina/src/include/eina_iterator.h b/libraries/eina/src/include/eina_iterator.h
index 1c8e6ce..10a9ece 100644
--- a/libraries/eina/src/include/eina_iterator.h
+++ b/libraries/eina/src/include/eina_iterator.h
@@ -25,7 +25,7 @@
25#include "eina_magic.h" 25#include "eina_magic.h"
26 26
27/** 27/**
28 * @page eina_iterator_example Eina_Iterator usage 28 * @page eina_iterator_example_page Eina_Iterator usage
29 * @dontinclude eina_iterator_01.c 29 * @dontinclude eina_iterator_01.c
30 * 30 *
31 * As always when using eina we need to include it: 31 * As always when using eina we need to include it:
@@ -48,7 +48,7 @@
48 * @until eina_init 48 * @until eina_init
49 * 49 *
50 * Next we populate both an array and a list with our strings, for more details 50 * Next we populate both an array and a list with our strings, for more details
51 * see @ref eina_list_01_example and @ref eina_array_01_example: 51 * see @ref eina_list_01_example_page and @ref eina_array_01_example_page :
52 * @until } 52 * @until }
53 * 53 *
54 * And now we create an array and because the first element of the container 54 * And now we create an array and because the first element of the container
@@ -63,7 +63,7 @@
63 * iterator itself: 63 * iterator itself:
64 * @until eina_iterator_free 64 * @until eina_iterator_free
65 * 65 *
66 * But so far you're not impressed in @ref eina_array_01_example an array is 66 * But so far you're not impressed in @ref eina_array_01_example_page an array is
67 * also printed, so now we go to the cool stuff and use an iterator to do same 67 * also printed, so now we go to the cool stuff and use an iterator to do same
68 * stuff to a list: 68 * stuff to a list:
69 * @until eina_iterator_free 69 * @until eina_iterator_free
@@ -99,7 +99,7 @@
99 * eina_iterator_next(). To call a function on all the elements of a 99 * eina_iterator_next(). To call a function on all the elements of a
100 * container, use eina_iterator_foreach(). 100 * container, use eina_iterator_foreach().
101 * 101 *
102 * Here an @ref eina_iterator_example "example" 102 * Here an @ref eina_iterator_example_page "example"
103 */ 103 */
104 104
105/** 105/**
diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h
index 8a8f25e..db65e17 100644
--- a/libraries/eina/src/include/eina_list.h
+++ b/libraries/eina/src/include/eina_list.h
@@ -29,7 +29,7 @@
29#include "eina_magic.h" 29#include "eina_magic.h"
30 30
31/** 31/**
32 * @page list_01_example_page Adding elements to Eina_List 32 * @page eina_list_01_example_page Adding elements to Eina_List
33 * @dontinclude eina_list_01.c 33 * @dontinclude eina_list_01.c
34 * 34 *
35 * Creating an @ref Eina_List and adding elements to it is very easy and can be 35 * Creating an @ref Eina_List and adding elements to it is very easy and can be
@@ -99,11 +99,11 @@
99 */ 99 */
100 100
101/** 101/**
102 * @page list_02_example_page Sorting Eina_List elements 102 * @page eina_list_02_example_page Sorting Eina_List elements
103 * @dontinclude eina_list_02.c 103 * @dontinclude eina_list_02.c
104 * 104 *
105 * If you don't know how to create lists see 105 * If you don't know how to create lists see
106 * @ref list_01_example_page. 106 * @ref eina_list_01_example_page.
107 * 107 *
108 * @skip #include 108 * @skip #include
109 * @until boomer 109 * @until boomer
@@ -151,11 +151,11 @@
151 */ 151 */
152 152
153/** 153/**
154 * @page list_03_example_page Reordering Eina_List elments 154 * @page eina_list_03_example_page Reordering Eina_List elments
155 * @dontinclude eina_list_03.c 155 * @dontinclude eina_list_03.c
156 * 156 *
157 * If you don't know how to create lists see 157 * If you don't know how to create lists see
158 * @ref list_01_example_page. 158 * @ref eina_list_01_example_page.
159 * 159 *
160 * We start out with code that should be familiar by now: 160 * We start out with code that should be familiar by now:
161 * @skip #include 161 * @skip #include
@@ -197,12 +197,12 @@
197 */ 197 */
198 198
199/** 199/**
200 * @page list_04_example_page Eina_List and memory allocation 200 * @page eina_list_04_example_page Eina_List and memory allocation
201 * @dontinclude eina_list_04.c 201 * @dontinclude eina_list_04.c
202 * 202 *
203 * If you don't know how to create lists see 203 * If you don't know how to create lists see
204 * @ref list_01_example_page. In this example we also use 204 * @ref eina_list_01_example_page. In this example we also use
205 * @ref eina_stringshare, however it should be possible to understand the code 205 * @ref Eina_Stringshare_Group, however it should be possible to understand the code
206 * regardless of previous knowledge about it. 206 * regardless of previous knowledge about it.
207 * 207 *
208 * Here we have the usual list creation code with a twist, now we are using as 208 * Here we have the usual list creation code with a twist, now we are using as
@@ -276,10 +276,10 @@
276 * list as the list! 276 * list as the list!
277 * 277 *
278 * Here are some examples of @ref Eina_List usage: 278 * Here are some examples of @ref Eina_List usage:
279 * @li @ref list_01_example_page 279 * @li @ref eina_list_01_example_page
280 * @li @ref list_02_example_page 280 * @li @ref eina_list_02_example_page
281 * @li @ref list_03_example_page 281 * @li @ref eina_list_03_example_page
282 * @li @ref list_04_example_page 282 * @li @ref eina_list_04_example_page
283 */ 283 */
284 284
285/** 285/**
@@ -582,7 +582,7 @@ EAPI Eina_List *eina_list_remove(Eina_List *list, const void *data) E
582 582
583 583
584/** 584/**
585 * @brief Remove the specified data. 585 * @brief Remove the specified list node.
586 * 586 *
587 * @param list The given linked list. 587 * @param list The given linked list.
588 * @param remove_list The list node which is to be removed. 588 * @param remove_list The list node which is to be removed.
diff --git a/libraries/eina/src/include/eina_lock.h b/libraries/eina/src/include/eina_lock.h
index 7c26dc0..16f4314 100644
--- a/libraries/eina/src/include/eina_lock.h
+++ b/libraries/eina/src/include/eina_lock.h
@@ -81,6 +81,10 @@ static inline void eina_tls_free(Eina_TLS key);
81static inline void *eina_tls_get(Eina_TLS key); 81static inline void *eina_tls_get(Eina_TLS key);
82static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); 82static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data);
83 83
84static inline Eina_Bool eina_semaphore_new(Eina_Semaphore *sem, int count_init);
85static inline Eina_Bool eina_semaphore_free(Eina_Semaphore *sem);
86static inline Eina_Bool eina_semaphore_lock(Eina_Semaphore *sem);
87static inline Eina_Bool eina_semaphore_release(Eina_Semaphore *sem, int count_release);
84 88
85#ifdef EINA_HAVE_DEBUG_THREADS 89#ifdef EINA_HAVE_DEBUG_THREADS
86# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ 90# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \
diff --git a/libraries/eina/src/include/eina_log.h b/libraries/eina/src/include/eina_log.h
index 5cd7c59..186397d 100644
--- a/libraries/eina/src/include/eina_log.h
+++ b/libraries/eina/src/include/eina_log.h
@@ -21,6 +21,7 @@
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <stdarg.h> 23#include <stdarg.h>
24#include <sys/types.h>
24 25
25#include "eina_types.h" 26#include "eina_types.h"
26 27
@@ -297,22 +298,27 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
297 * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public 298 * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public
298 * header files. 299 * header files.
299 */ 300 */
300#ifdef EINA_LOG_LEVEL_MAXIMUM 301#ifdef EINA_ENABLE_LOG
301#define EINA_LOG(DOM, LEVEL, fmt, ...) \ 302# ifdef EINA_LOG_LEVEL_MAXIMUM
302 do { \ 303# define EINA_LOG(DOM, LEVEL, fmt, ...) \
303 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ 304 do { \
304 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ 305 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \
305 fmt, ## __VA_ARGS__); } \ 306 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
306 } while (0) 307 fmt, ## __VA_ARGS__); } \
307#else 308 } while (0)
308#define EINA_LOG(DOM, LEVEL, fmt, ...) \ 309# else
309 eina_log_print(DOM, \ 310# define EINA_LOG(DOM, LEVEL, fmt, ...) \
310 LEVEL, \ 311 eina_log_print(DOM, \
311 __FILE__, \ 312 LEVEL, \
312 __FUNCTION__, \ 313 __FILE__, \
313 __LINE__, \ 314 __FUNCTION__, \
314 fmt, \ 315 __LINE__, \
316 fmt, \
315 ## __VA_ARGS__) 317 ## __VA_ARGS__)
318# endif
319#else
320#define EINA_LOG(DOM, LEVEL, fmt, ...) \
321 do { (void) DOM; (void) LEVEL; (void) fmt; } while (0)
316#endif 322#endif
317 323
318/** 324/**
@@ -726,7 +732,7 @@ EAPI void eina_log_domain_unregister(int domain);
726 * specified value (eina_log_level_set() or environment 732 * specified value (eina_log_level_set() or environment
727 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored. 733 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
728 * @param file filename that originated the call, must @b not be @c NULL. 734 * @param file filename that originated the call, must @b not be @c NULL.
729 * @param fnc function that originated the call, must @b not be @c NULL. 735 * @param function function that originated the call, must @b not be @c NULL.
730 * @param line originating line in @a file. 736 * @param line originating line in @a file.
731 * @param fmt printf-like format to use. Should not provide trailing 737 * @param fmt printf-like format to use. Should not provide trailing
732 * '\n' as it is automatically included. 738 * '\n' as it is automatically included.
@@ -780,7 +786,7 @@ EAPI void eina_log_vprint(int domain,
780 */ 786 */
781 787
782/** 788/**
783 * Alternative logging method, this will output to standard output stream. 789 * @brief Alternative logging method, this will output to standard output stream.
784 * 790 *
785 * @param d The domain. 791 * @param d The domain.
786 * @param level The level. 792 * @param level The level.
@@ -815,7 +821,16 @@ EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d,
815 va_list args); 821 va_list args);
816 822
817/** 823/**
818 * Default logging method, this will output to standard error stream. 824 * @brief Default logging method, this will output to standard error stream.
825 *
826 * @param d The domain.
827 * @param level The level.
828 * @param file The file which is logged.
829 * @param fnc The function which is logged.
830 * @param line The line which is logged.
831 * @param fmt The ouptut format to use.
832 * @param data Not used.
833 * @param args The arguments needed by the format.
819 * 834 *
820 * This method will colorize output based on domain provided color and 835 * This method will colorize output based on domain provided color and
821 * message logging level. 836 * message logging level.
diff --git a/libraries/eina/src/include/eina_magic.h b/libraries/eina/src/include/eina_magic.h
index 44cd4e9..d4909d8 100644
--- a/libraries/eina/src/include/eina_magic.h
+++ b/libraries/eina/src/include/eina_magic.h
@@ -21,6 +21,7 @@
21 21
22#include "eina_config.h" 22#include "eina_config.h"
23#include "eina_types.h" 23#include "eina_types.h"
24#include "eina_error.h"
24 25
25/** 26/**
26 * @page eina_magic_example_01_page 27 * @page eina_magic_example_01_page
@@ -200,6 +201,13 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
200 */ 201 */
201#define EINA_MAGIC_NONE 0x1234fedc 202#define EINA_MAGIC_NONE 0x1234fedc
202 203
204/**
205 * @var EINA_ERROR_MAGIC_FAILED
206 * Error identifier corresponding to magic check failure.
207 */
208EAPI extern Eina_Error EINA_ERROR_MAGIC_FAILED;
209
210
203#ifdef EINA_MAGIC_DEBUG 211#ifdef EINA_MAGIC_DEBUG
204 212
205/** 213/**
diff --git a/libraries/eina/src/include/eina_main.h b/libraries/eina/src/include/eina_main.h
index fa34d59..4baf40e 100644
--- a/libraries/eina/src/include/eina_main.h
+++ b/libraries/eina/src/include/eina_main.h
@@ -50,7 +50,7 @@
50 * @def EINA_VERSION_MINOR 50 * @def EINA_VERSION_MINOR
51 * @brief Minor version of Eina 51 * @brief Minor version of Eina
52 */ 52 */
53#define EINA_VERSION_MINOR 0 53#define EINA_VERSION_MINOR 2
54 54
55/** 55/**
56 * @typedef Eina_Version 56 * @typedef Eina_Version
@@ -134,6 +134,9 @@ EAPI int eina_threads_shutdown(void);
134 134
135/** 135/**
136 * @brief Check if you are calling this function from the same thread Eina was initialized or not 136 * @brief Check if you are calling this function from the same thread Eina was initialized or not
137 *
138 * @return #EINA_TRUE is the calling function is the same thread, #EINA_FALSE otherwise.
139 *
137 * @since 1.1.0 140 * @since 1.1.0
138 * 141 *
139 * Most EFL function are not thread safe and all the call need to happen in 142 * Most EFL function are not thread safe and all the call need to happen in
diff --git a/libraries/eina/src/include/eina_module.h b/libraries/eina/src/include/eina_module.h
index 58e38f9..178fa9a 100644
--- a/libraries/eina/src/include/eina_module.h
+++ b/libraries/eina/src/include/eina_module.h
@@ -67,6 +67,10 @@
67 */ 67 */
68typedef struct _Eina_Module Eina_Module; 68typedef struct _Eina_Module Eina_Module;
69 69
70/**
71 * @typedef Eina_Module_Cb
72 * Dynamic module loader callback.
73 */
70typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data); 74typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data);
71 75
72/** 76/**
@@ -135,21 +139,21 @@ EAPI Eina_Module *
135/** 139/**
136 * @brief Delete a module. 140 * @brief Delete a module.
137 * 141 *
138 * @param m The module to delete. 142 * @param module The module to delete.
139 * @return EINA_TRUE on success, EINA_FALSE otherwise. 143 * @return EINA_TRUE on success, EINA_FALSE otherwise.
140 * 144 *
141 * This function calls eina_module_unload() if @p m has been previously 145 * This function calls eina_module_unload() if @p module has been previously
142 * loaded and frees the allocated memory. On success this function 146 * loaded and frees the allocated memory. On success this function
143 * returns EINA_TRUE and EINA_FALSE otherwise. If @p m is @c NULL, the 147 * returns EINA_TRUE and EINA_FALSE otherwise. If @p module is @c NULL, the
144 * function returns immediately. 148 * function returns immediately.
145 */ 149 */
146EAPI Eina_Bool 150EAPI Eina_Bool
147 eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1); 151 eina_module_free(Eina_Module *module) EINA_ARG_NONNULL(1);
148 152
149/** 153/**
150 * @brief Load a module. 154 * @brief Load a module.
151 * 155 *
152 * @param m The module to load. 156 * @param module The module to load.
153 * @return EINA_TRUE on success, EINA_FALSE otherwise. 157 * @return EINA_TRUE on success, EINA_FALSE otherwise.
154 * 158 *
155 * This function load the shared file object passed in 159 * This function load the shared file object passed in
@@ -160,7 +164,7 @@ EAPI Eina_Bool
160 * module can not be initialized, the error 164 * module can not be initialized, the error
161 * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is 165 * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is
162 * returned. If the module has already been loaded, it's refeence 166 * returned. If the module has already been loaded, it's refeence
163 * counter is increased by one and #EINA_TRUE is returned. If @p m is 167 * counter is increased by one and #EINA_TRUE is returned. If @p module is
164 * @c NULL, the function returns immediately #EINA_FALSE. 168 * @c NULL, the function returns immediately #EINA_FALSE.
165 * 169 *
166 * When the symbols of the shared file objetcts are not needed 170 * When the symbols of the shared file objetcts are not needed
@@ -172,29 +176,29 @@ EAPI Eina_Bool
172/** 176/**
173 * @brief Unload a module. 177 * @brief Unload a module.
174 * 178 *
175 * @param m The module to load. 179 * @param module The module to load.
176 * @return EINA_TRUE on success, EINA_FALSE otherwise. 180 * @return EINA_TRUE on success, EINA_FALSE otherwise.
177 * 181 *
178 * This function unload the module @p m that has been previously 182 * This function unload the module @p module that has been previously
179 * loaded by eina_module_load(). If the reference counter of @p m is 183 * loaded by eina_module_load(). If the reference counter of @p module is
180 * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the 184 * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the
181 * shared object file is closed and if it is a internal Eina module, it 185 * shared object file is closed and if it is a internal Eina module, it
182 * is shutted down just before. In that case, #EINA_TRUE is 186 * is shutted down just before. In that case, #EINA_TRUE is
183 * returned. In all case, the reference counter is decreased. If @p m 187 * returned. In all case, the reference counter is decreased. If @p module
184 * is @c NULL, the function returns immediately #EINA_FALSE. 188 * is @c NULL, the function returns immediately #EINA_FALSE.
185 */ 189 */
186EAPI Eina_Bool 190EAPI Eina_Bool
187 eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1); 191 eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1);
188 192
189/** 193/**
190 * @brief Retrive the data associated to a symbol. 194 * @brief Retrive the data associated to a symbol.
191 * 195 *
192 * @param m The module. 196 * @param module The module.
193 * @param symbol The symbol. 197 * @param symbol The symbol.
194 * @return The data associated to the symbol, or @c NULL on failure. 198 * @return The data associated to the symbol, or @c NULL on failure.
195 * 199 *
196 * This function returns the data associated to @p symbol of @p m. @p 200 * This function returns the data associated to @p symbol of @p module. @p
197 * m must have been loaded before with eina_module_load(). If @p m 201 * module must have been loaded before with eina_module_load(). If @p module
198 * is @c NULL, or if it has not been correctly loaded before, the 202 * is @c NULL, or if it has not been correctly loaded before, the
199 * function returns immediately @c NULL. 203 * function returns immediately @c NULL.
200 */ 204 */
@@ -204,15 +208,15 @@ EAPI void *
204/** 208/**
205 * @brief Return the file name associated to the module. 209 * @brief Return the file name associated to the module.
206 * 210 *
207 * @param m The module. 211 * @param module The module.
208 * @return The file name. 212 * @return The file name.
209 * 213 *
210 * This function returns the file name passed in eina_module_new(). If 214 * This function returns the file name passed in eina_module_new(). If
211 * @p m is @c NULL, the function returns immediately @c NULL. The 215 * @p module is @c NULL, the function returns immediately @c NULL. The
212 * returned value must no be freed. 216 * returned value must no be freed.
213 */ 217 */
214EAPI const char * 218EAPI const char *
215 eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); 219 eina_module_file_get(const Eina_Module *module) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
216 220
217 221
218/** 222/**
@@ -256,6 +260,7 @@ EAPI char *
256 * @param array The array that stores the list of the modules. 260 * @param array The array that stores the list of the modules.
257 * @param path The directory's path to search for modules. 261 * @param path The directory's path to search for modules.
258 * @param arch The architecture string. 262 * @param arch The architecture string.
263 * @return The array of modules found in @p path matching @p arch.
259 * 264 *
260 * This function adds to @p array the module names found in @p path 265 * This function adds to @p array the module names found in @p path
261 * which match the cpu architecture @p arch. If @p path or @p arch is 266 * which match the cpu architecture @p arch. If @p path or @p arch is
@@ -273,6 +278,7 @@ EAPI Eina_Array *
273 * @param recursive Iterate recursively on the path. 278 * @param recursive Iterate recursively on the path.
274 * @param cb Callback function to call on each module. 279 * @param cb Callback function to call on each module.
275 * @param data Data passed to the callback function. 280 * @param data Data passed to the callback function.
281 * @return The array of modules found in @p path.
276 * 282 *
277 * This function adds to @p array the list of modules found in 283 * This function adds to @p array the list of modules found in
278 * @p path. If @p recursive is #EINA_TRUE, then recursive search is 284 * @p path. If @p recursive is #EINA_TRUE, then recursive search is
@@ -295,7 +301,7 @@ EAPI Eina_Array *
295 * @p array. If @p array is @c NULL, this function does nothing. 301 * @p array. If @p array is @c NULL, this function does nothing.
296 */ 302 */
297EAPI void 303EAPI void
298 eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1); 304 eina_module_list_load(Eina_Array *array) EINA_ARG_NONNULL(1);
299 305
300/** 306/**
301 * @brief Unload every module on the list of modules. 307 * @brief Unload every module on the list of modules.
@@ -306,7 +312,7 @@ EAPI void
306 * @p array. If @p array is @c NULL, this function does nothing. 312 * @p array. If @p array is @c NULL, this function does nothing.
307 */ 313 */
308EAPI void 314EAPI void
309 eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1); 315 eina_module_list_unload(Eina_Array *array) EINA_ARG_NONNULL(1);
310 316
311/** 317/**
312 * @p Free every module on the list of modules. 318 * @p Free every module on the list of modules.
@@ -317,13 +323,14 @@ EAPI void
317 * @p array. If @p array is @c NULL, this function does nothing. 323 * @p array. If @p array is @c NULL, this function does nothing.
318 */ 324 */
319EAPI void 325EAPI void
320 eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1); 326 eina_module_list_free(Eina_Array *array) EINA_ARG_NONNULL(1);
321 327
322/** 328/**
323 * @brief Find an module in array. 329 * @brief Find an module in array.
324 * 330 *
325 * @param array The array to find the module. 331 * @param array The array to find the module.
326 * @param module The name of module to be searched. 332 * @param module The name of module to be searched.
333 * @return The module to find on success, @c NULL otherwise.
327 * 334 *
328 * This function finds an @p module in @p array. 335 * This function finds an @p module in @p array.
329 * If the element is found the function returns the module, else 336 * If the element is found the function returns the module, else
diff --git a/libraries/eina/src/include/eina_simple_xml_parser.h b/libraries/eina/src/include/eina_simple_xml_parser.h
index db9a4e1..78660ef 100644
--- a/libraries/eina/src/include/eina_simple_xml_parser.h
+++ b/libraries/eina/src/include/eina_simple_xml_parser.h
@@ -119,16 +119,16 @@ struct _Eina_Simple_XML_Node_Data
119 119
120typedef enum _Eina_Simple_XML_Type 120typedef enum _Eina_Simple_XML_Type
121{ 121{
122 EINA_SIMPLE_XML_OPEN = 0, /* <tag attribute="value"> */ 122 EINA_SIMPLE_XML_OPEN = 0, /*!< <tag attribute="value"> */
123 EINA_SIMPLE_XML_OPEN_EMPTY, /* <tag attribute="value" /> */ 123 EINA_SIMPLE_XML_OPEN_EMPTY, /*!< <tag attribute="value" /> */
124 EINA_SIMPLE_XML_CLOSE, /* </tag> */ 124 EINA_SIMPLE_XML_CLOSE, /*!< </tag> */
125 EINA_SIMPLE_XML_DATA, /* tag text data */ 125 EINA_SIMPLE_XML_DATA, /*!< tag text data */
126 EINA_SIMPLE_XML_CDATA, /* <![CDATA[something]]> */ 126 EINA_SIMPLE_XML_CDATA, /*!< <![CDATA[something]]> */
127 EINA_SIMPLE_XML_ERROR, /* error contents */ 127 EINA_SIMPLE_XML_ERROR, /*!< error contents */
128 EINA_SIMPLE_XML_PROCESSING, /* <?xml ... ?> <?php .. ?> */ 128 EINA_SIMPLE_XML_PROCESSING, /*!< <?xml ... ?> <?php .. ?> */
129 EINA_SIMPLE_XML_DOCTYPE, /* <!DOCTYPE html */ 129 EINA_SIMPLE_XML_DOCTYPE, /*!< <!DOCTYPE html */
130 EINA_SIMPLE_XML_COMMENT, /* <!-- something --> */ 130 EINA_SIMPLE_XML_COMMENT, /*!< <!-- something --> */
131 EINA_SIMPLE_XML_IGNORED /* whatever is ignored by parser, like whitespace */ 131 EINA_SIMPLE_XML_IGNORED /*!< whatever is ignored by parser, like whitespace */
132} Eina_Simple_XML_Type; 132} Eina_Simple_XML_Type;
133 133
134typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length); 134typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length);
@@ -137,7 +137,7 @@ typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *key, c
137 137
138/** 138/**
139 * Parse a section of XML string text 139 * Parse a section of XML string text
140 * 140 *
141 * @param buf the input string. May not contain \0 terminator. 141 * @param buf the input string. May not contain \0 terminator.
142 * @param buflen the input string size. 142 * @param buflen the input string size.
143 * @param strip whenever this parser should strip leading and trailing 143 * @param strip whenever this parser should strip leading and trailing
@@ -164,12 +164,15 @@ EAPI Eina_Bool eina_simple_xml_parse(const char *buf, unsigned buflen,
164/** 164/**
165 * Given the contents of a tag, find where the attributes start. 165 * Given the contents of a tag, find where the attributes start.
166 * 166 *
167 * The tag contents is returned by eina_simple_xml_parse() when 167 * @param buf the input string. May not contain \0 terminator.
168 * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY. 168 * @param buflen the input string size.
169 *
170 * @return pointer to the start of attributes, it can be used 169 * @return pointer to the start of attributes, it can be used
171 * to feed eina_simple_xml_attributes_parse(). NULL is returned 170 * to feed eina_simple_xml_attributes_parse(). NULL is returned
172 * if no attributes were found. 171 * if no attributes were found.
172 *
173 * The tag contents is returned by eina_simple_xml_parse() when
174 * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY.
175 *
173 */ 176 */
174EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen); 177EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen);
175 178
@@ -183,6 +186,7 @@ EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned
183 * key (null-terminated) and the last is the value (null 186 * key (null-terminated) and the last is the value (null
184 * terminated). These strings should not be modified and 187 * terminated). These strings should not be modified and
185 * reference is just valid until the function return. 188 * reference is just valid until the function return.
189 * @param data data to pass to the callback function.
186 * 190 *
187 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or 191 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or
188 * parsing error. 192 * parsing error.
@@ -238,8 +242,8 @@ EAPI void eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag);
238 * 242 *
239 * @param parent if provided, will be set in the resulting structure 243 * @param parent if provided, will be set in the resulting structure
240 * as well as the data will be appended to children list. 244 * as well as the data will be appended to children list.
241 * @param content string to be used. Must not be NULL. 245 * @param contents string to be used. Must not be NULL.
242 * @param length size in bytes of @a content. 246 * @param length size in bytes of @a contents.
243 * 247 *
244 * @return newly allocated memory or NULL on error. This memory should be 248 * @return newly allocated memory or NULL on error. This memory should be
245 * released with eina_simple_xml_node_data_free() or indirectly 249 * released with eina_simple_xml_node_data_free() or indirectly
@@ -250,7 +254,7 @@ EAPI Eina_Simple_XML_Node_Data * eina_simple_xml_node_data_new(Eina_Simple_XML_N
250/** 254/**
251 * Remove data from parent and delete it. 255 * Remove data from parent and delete it.
252 * 256 *
253 * @param data to release memory. 257 * @param node to release memory.
254 */ 258 */
255EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node); 259EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node);
256 260
@@ -260,7 +264,7 @@ EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node);
260 * 264 *
261 * @param parent if provided, will be set in the resulting structure 265 * @param parent if provided, will be set in the resulting structure
262 * as well as the cdata will be appended to children list. 266 * as well as the cdata will be appended to children list.
263 * @param content string to be used. Must not be NULL. 267 * @param contents string to be used. Must not be NULL.
264 * @param length size in bytes of @a content. 268 * @param length size in bytes of @a content.
265 * 269 *
266 * @return newly allocated memory or NULL on error. This memory should be 270 * @return newly allocated memory or NULL on error. This memory should be
@@ -272,7 +276,7 @@ EAPI Eina_Simple_XML_Node_CData * eina_simple_xml_node_cdata_new(Eina_Simple_XML
272/** 276/**
273 * Remove cdata from parent and delete it. 277 * Remove cdata from parent and delete it.
274 * 278 *
275 * @param cdata to release memory. 279 * @param node to release memory.
276 */ 280 */
277EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node); 281EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node);
278 282
@@ -282,8 +286,8 @@ EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node);
282 * 286 *
283 * @param parent if provided, will be set in the resulting structure 287 * @param parent if provided, will be set in the resulting structure
284 * as well as the processing will be appended to children list. 288 * as well as the processing will be appended to children list.
285 * @param content string to be used. Must not be NULL. 289 * @param contents string to be used. Must not be NULL.
286 * @param length size in bytes of @a content. 290 * @param length size in bytes of @a contents.
287 * 291 *
288 * @return newly allocated memory or NULL on error. This memory should be 292 * @return newly allocated memory or NULL on error. This memory should be
289 * released with eina_simple_xml_node_processing_free() or indirectly 293 * released with eina_simple_xml_node_processing_free() or indirectly
@@ -294,7 +298,7 @@ EAPI Eina_Simple_XML_Node_Processing * eina_simple_xml_node_processing_new(Eina_
294/** 298/**
295 * Remove processing from parent and delete it. 299 * Remove processing from parent and delete it.
296 * 300 *
297 * @param processing to release memory. 301 * @param node processing to release memory.
298 */ 302 */
299EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node); 303EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node);
300 304
@@ -304,8 +308,8 @@ EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node);
304 * 308 *
305 * @param parent if provided, will be set in the resulting structure 309 * @param parent if provided, will be set in the resulting structure
306 * as well as the doctype will be appended to children list. 310 * as well as the doctype will be appended to children list.
307 * @param content string to be used. Must not be NULL. 311 * @param contents string to be used. Must not be NULL.
308 * @param length size in bytes of @a content. 312 * @param length size in bytes of @a contents.
309 * 313 *
310 * @return newly allocated memory or NULL on error. This memory should be 314 * @return newly allocated memory or NULL on error. This memory should be
311 * released with eina_simple_xml_node_doctype_free() or indirectly 315 * released with eina_simple_xml_node_doctype_free() or indirectly
@@ -316,7 +320,7 @@ EAPI Eina_Simple_XML_Node_Doctype * eina_simple_xml_node_doctype_new(Eina_Simple
316/** 320/**
317 * Remove doctype from parent and delete it. 321 * Remove doctype from parent and delete it.
318 * 322 *
319 * @param doctype to release memory. 323 * @param node doctype to release memory.
320 */ 324 */
321EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node); 325EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node);
322 326
@@ -326,8 +330,8 @@ EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node);
326 * 330 *
327 * @param parent if provided, will be set in the resulting structure 331 * @param parent if provided, will be set in the resulting structure
328 * as well as the comment will be appended to children list. 332 * as well as the comment will be appended to children list.
329 * @param content string to be used. Must not be NULL. 333 * @param contents string to be used. Must not be NULL.
330 * @param length size in bytes of @a content. 334 * @param length size in bytes of @a contents.
331 * 335 *
332 * @return newly allocated memory or NULL on error. This memory should be 336 * @return newly allocated memory or NULL on error. This memory should be
333 * released with eina_simple_xml_node_comment_free() or indirectly 337 * released with eina_simple_xml_node_comment_free() or indirectly
@@ -338,7 +342,7 @@ EAPI Eina_Simple_XML_Node_Comment * eina_simple_xml_node_comment_new(Eina_Simple
338/** 342/**
339 * Remove comment from parent and delete it. 343 * Remove comment from parent and delete it.
340 * 344 *
341 * @param comment to release memory. 345 * @param node comment to release memory.
342 */ 346 */
343EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node); 347EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node);
344 348
@@ -370,7 +374,7 @@ EAPI void eina_simple_xml_node_root_free(Eina_Simple_XML_Node_Root *root);
370 * @param node the base node to convert. 374 * @param node the base node to convert.
371 * @param indent indentation string, or NULL to disable it. 375 * @param indent indentation string, or NULL to disable it.
372 * 376 *
373 * @param NULL on errors or a newly allocated string on success. 377 * @return NULL on errors or a newly allocated string on success.
374 */ 378 */
375EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent); 379EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent);
376 380
diff --git a/libraries/eina/src/include/eina_str.h b/libraries/eina/src/include/eina_str.h
index 8b52ab2..2913fbf 100644
--- a/libraries/eina/src/include/eina_str.h
+++ b/libraries/eina/src/include/eina_str.h
@@ -161,14 +161,14 @@ EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EI
161/** 161/**
162 * @brief Split a string using a delimiter. 162 * @brief Split a string using a delimiter.
163 * 163 *
164 * @param str The string to split. 164 * @param string The string to split.
165 * @param delim The string which specifies the places at which to split the string. 165 * @param delimiter The string which specifies the places at which to split the string.
166 * @param max_tokens The maximum number of strings to split string into. 166 * @param max_tokens The maximum number of strings to split string into.
167 * @return A newly-allocated NULL-terminated array of strings or NULL if it 167 * @return A newly-allocated NULL-terminated array of strings or NULL if it
168 * fails to allocate the array. 168 * fails to allocate the array.
169 * 169 *
170 * This functin splits @p str into a maximum of @p max_tokens pieces, 170 * This functin splits @p string into a maximum of @p max_tokens pieces,
171 * using the given delimiter @p delim. @p delim is not included in any 171 * using the given delimiter @p delimiter. @p delimiter is not included in any
172 * of the resulting strings, unless @p max_tokens is reached. If 172 * of the resulting strings, unless @p max_tokens is reached. If
173 * @p max_tokens is less than @c 1, the string is splitted completely. If 173 * @p max_tokens is less than @c 1, the string is splitted completely. If
174 * @p max_tokens is reached, the last string in the returned string 174 * @p max_tokens is reached, the last string in the returned string
@@ -185,16 +185,16 @@ EAPI char **eina_str_split(const char *string, const char *delimiter, i
185/** 185/**
186 * @brief Split a string using a delimiter and returns number of elements. 186 * @brief Split a string using a delimiter and returns number of elements.
187 * 187 *
188 * @param str The string to split. 188 * @param string The string to split.
189 * @param delim The string which specifies the places at which to split the string. 189 * @param delimiter The string which specifies the places at which to split the string.
190 * @param max_tokens The maximum number of strings to split string into. 190 * @param max_tokens The maximum number of strings to split string into.
191 * @param elements Where to return the number of elements in returned 191 * @param elements Where to return the number of elements in returned
192 * array (not counting the terminating @c NULL). May be @c NULL. 192 * array (not counting the terminating @c NULL). May be @c NULL.
193 * @return A newly-allocated NULL-terminated array of strings or NULL if it 193 * @return A newly-allocated NULL-terminated array of strings or NULL if it
194 * fails to allocate the array. 194 * fails to allocate the array.
195 * 195 *
196 * This functin splits @p str into a maximum of @p max_tokens pieces, 196 * This function splits @p string into a maximum of @p max_tokens pieces,
197 * using the given delimiter @p delim. @p delim is not included in any 197 * using the given delimiter @p delimiter. @p delimiter is not included in any
198 * of the resulting strings, unless @p max_tokens is reached. If 198 * of the resulting strings, unless @p max_tokens is reached. If
199 * @p max_tokens is less than @c 1, the string is splitted completely. If 199 * @p max_tokens is less than @c 1, the string is splitted completely. If
200 * @p max_tokens is reached, the last string in the returned string 200 * @p max_tokens is reached, the last string in the returned string
diff --git a/libraries/eina/src/include/eina_strbuf.h b/libraries/eina/src/include/eina_strbuf.h
index 7043575..34c200f 100644
--- a/libraries/eina/src/include/eina_strbuf.h
+++ b/libraries/eina/src/include/eina_strbuf.h
@@ -99,6 +99,24 @@ EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
99EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 99EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
100 100
101/** 101/**
102 * @brief Create a new string buffer using the passed string. The passed
103 * string is used directly as the buffer, it's somehow the opposite function of
104 * @ref eina_strbuf_string_steal . The passed string must be malloced.
105 *
106 * @param str the string to manage
107 * @param length the length of the string.
108 * @return Newly allocated string buffer instance.
109 *
110 * This function creates a new string buffer. On error, @c NULL is
111 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
112 * free the resources, use eina_strbuf_free().
113 *
114 * @see eina_strbuf_manage_new()
115 * @since 1.2.0
116 */
117EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
118
119/**
102 * @brief Free a string buffer. 120 * @brief Free a string buffer.
103 * 121 *
104 * @param buf The string buffer to free. 122 * @param buf The string buffer to free.
diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h
index af58add..862b2b2 100644
--- a/libraries/eina/src/include/eina_stringshare.h
+++ b/libraries/eina/src/include/eina_stringshare.h
@@ -289,6 +289,7 @@ EAPI void eina_stringshare_del(const char *str);
289 * 289 *
290 * @param str the shared string to know the length. It is safe to 290 * @param str the shared string to know the length. It is safe to
291 * give NULL, in that case -1 is returned. 291 * give NULL, in that case -1 is returned.
292 * @return The length of a shared string.
292 * 293 *
293 * This function is a cheap way to known the length of a shared 294 * This function is a cheap way to known the length of a shared
294 * string. Note that if the given pointer is not shared, bad 295 * string. Note that if the given pointer is not shared, bad
diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h
index 8c77cdf..1653949 100644
--- a/libraries/eina/src/include/eina_types.h
+++ b/libraries/eina/src/include/eina_types.h
@@ -251,6 +251,10 @@ typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
251 */ 251 */
252#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) 252#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
253 253
254/**
255 * @typedef Eina_Each_Cb
256 * A callback type used when iterating over a container.
257 */
254typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata); 258typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata);
255 259
256/** 260/**
diff --git a/libraries/eina/src/include/eina_unicode.h b/libraries/eina/src/include/eina_unicode.h
index aed59af..2bbfe45 100644
--- a/libraries/eina/src/include/eina_unicode.h
+++ b/libraries/eina/src/include/eina_unicode.h
@@ -68,7 +68,16 @@ EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSE
68 68
69 69
70/** 70/**
71 * @brief Same as strdup but cuts on n. Assumes n < len 71 * @brief Same as strdup but cuts on the given size. Assumes n < len
72 *
73 * @param text The text to duplicate.
74 * @param n The maximum size of the text to duplicate.
75 * @return The duplicated string.
76 *
77 * This function duplicates @p text. The resuting string is cut on @p
78 * n. @p n is assumed to be lesser (<) than the length of @p
79 * text. When not needed anymore, the returned string must be freed.
80 *
72 * @since 1.1.0 81 * @since 1.1.0
73 */ 82 */
74EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; 83EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
@@ -107,9 +116,9 @@ EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL
107 116
108 117
109/** 118/**
110 * Reads UTF8 bytes from @buf, starting at *@index and returns 119 * Reads UTF8 bytes from @p buf, starting at @p iindex and returns
111 * the decoded code point at iindex offset, and advances iindex 120 * the decoded code point at @p iindex offset, and advances @p iindex
112 * to the next code point after this. iindex is always advanced, 121 * to the next code point after this. @p iindex is always advanced,
113 * unless if the advancement is after the NULL. 122 * unless if the advancement is after the NULL.
114 * On error: return a codepoint between DC80 to DCFF where the low 8 bits 123 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
115 * are the byte's value. 124 * are the byte's value.
@@ -122,9 +131,9 @@ EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL
122EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); 131EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2);
123 132
124/** 133/**
125 * Reads UTF8 bytes from @buf, starting at *@iindex and returns 134 * Reads UTF8 bytes from @p buf, starting at @p iindex and returns
126 * the decoded code point at iindex offset, and moves iindex 135 * the decoded code point at @p iindex offset, and moves àp iindex
127 * to the previous code point. iindex is always moved, as long 136 * to the previous code point. @p iindex is always moved, as long
128 * as it's not past the start of the string. 137 * as it's not past the start of the string.
129 * On error: return a codepoint between DC80 to DCFF where the low 8 bits 138 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
130 * are the byte's value. 139 * are the byte's value.
diff --git a/libraries/eina/src/include/eina_ustrbuf.h b/libraries/eina/src/include/eina_ustrbuf.h
index f68cb7b..9710c42 100644
--- a/libraries/eina/src/include/eina_ustrbuf.h
+++ b/libraries/eina/src/include/eina_ustrbuf.h
@@ -65,7 +65,25 @@ EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
65 * @see eina_ustrbuf_string_get() 65 * @see eina_ustrbuf_string_get()
66 * @since 1.1.0 66 * @since 1.1.0
67 */ 67 */
68EAPI Eina_Strbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 68EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
69
70/**
71 * @brief Create a new string buffer using the passed string. The passed
72 * string is used directly as the buffer, it's somehow the opposite function of
73 * @ref eina_ustrbuf_string_steal . The passed string must be malloced.
74 *
75 * @param str the string to manage
76 * @param length the length of the string.
77 * @return Newly allocated string buffer instance.
78 *
79 * This function creates a new string buffer. On error, @c NULL is
80 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
81 * free the resources, use eina_ustrbuf_free().
82 *
83 * @see eina_ustrbuf_manage_new()
84 * @since 1.2.0
85 */
86EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
69 87
70/** 88/**
71 * @brief Free a string buffer. 89 * @brief Free a string buffer.
diff --git a/libraries/eina/src/include/eina_value.h b/libraries/eina/src/include/eina_value.h
new file mode 100644
index 0000000..846c4ef
--- /dev/null
+++ b/libraries/eina/src/include/eina_value.h
@@ -0,0 +1,3114 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_VALUE_H_
20#define EINA_VALUE_H_
21
22#include "eina_types.h"
23#include "eina_fp.h" /* defines int64_t and uint64_t */
24#include "eina_inarray.h"
25#include "eina_list.h"
26#include "eina_hash.h"
27#include <stdarg.h>
28
29/**
30 * @addtogroup Eina_Data_Types_Group Data Types
31 *
32 * @since 1.2
33 *
34 * @{
35 */
36
37/**
38 * @addtogroup Eina_Containers_Group Containers
39 *
40 * @{
41 */
42
43/**
44 * @defgroup Eina_Value_Group Generic Value Storage
45 *
46 * @{
47 */
48
49
50/**
51 * @typedef Eina_Value
52 * Store generic values.
53 *
54 * @since 1.2
55 */
56typedef struct _Eina_Value Eina_Value;
57
58/**
59 * @typedef Eina_Value_Type
60 * Describes the data contained by the value
61 *
62 * @since 1.2
63 */
64typedef struct _Eina_Value_Type Eina_Value_Type;
65
66/**
67 * @typedef Eina_Value_Union
68 * Union of all known value types.
69 *
70 * @since 1.2
71 */
72typedef union _Eina_Value_Union Eina_Value_Union;
73
74/**
75 * @union _Eina_Value_Union
76 * All possible value types.
77 *
78 * @since 1.2
79 */
80union _Eina_Value_Union
81{
82 unsigned char buf[8]; /**< just hold 8-bytes, more goes into ptr */
83 void *ptr; /**< used as generic pointer */
84 uint64_t _guarantee; /**< guarantees 8-byte alignment */
85};
86
87/**
88 * @var EINA_VALUE_TYPE_UCHAR
89 * manages unsigned char type.
90 *
91 * @since 1.2
92 */
93EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR;
94
95/**
96 * @var EINA_VALUE_TYPE_USHORT
97 * manages unsigned short type.
98 *
99 * @since 1.2
100 */
101EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_USHORT;
102
103/**
104 * @var EINA_VALUE_TYPE_UINT
105 * manages unsigned int type.
106 *
107 * @since 1.2
108 */
109EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT;
110
111/**
112 * @var EINA_VALUE_TYPE_ULONG
113 * manages unsigned long type.
114 *
115 * @since 1.2
116 */
117EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG;
118
119/**
120 * @var EINA_VALUE_TYPE_UINT64
121 * manages unsigned integer of 64 bits type.
122 *
123 * @since 1.2
124 */
125EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT64;
126
127/**
128 * @var EINA_VALUE_TYPE_CHAR
129 * manages char type.
130 *
131 * @since 1.2
132 */
133EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_CHAR;
134
135/**
136 * @var EINA_VALUE_TYPE_SHORT
137 * manages short type.
138 *
139 * @since 1.2
140 */
141EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_SHORT;
142
143/**
144 * @var EINA_VALUE_TYPE_INT
145 * manages int type.
146 *
147 * @since 1.2
148 */
149EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT;
150
151/**
152 * @var EINA_VALUE_TYPE_LONG
153 * manages long type.
154 *
155 * @since 1.2
156 */
157EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LONG;
158
159/**
160 * @var EINA_VALUE_TYPE_INT64
161 * manages integer of 64 bits type.
162 *
163 * @since 1.2
164 */
165EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT64;
166
167/**
168 * @var EINA_VALUE_TYPE_FLOAT
169 * manages float type.
170 *
171 * @since 1.2
172 */
173EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT;
174
175/**
176 * @var EINA_VALUE_TYPE_DOUBLE
177 * manages double type.
178 *
179 * @since 1.2
180 */
181EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE;
182
183/**
184 * @var EINA_VALUE_TYPE_STRINGSHARE
185 * manages stringshared string type.
186 *
187 * @since 1.2
188 */
189EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE;
190
191/**
192 * @var EINA_VALUE_TYPE_STRING
193 * manages string type.
194 *
195 * @since 1.2
196 */
197EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING;
198
199
200/**
201 * @var EINA_VALUE_TYPE_ARRAY
202 *
203 * manages array type. Use the value get/set for arrays:
204 * @li eina_value_array_get() and eina_value_array_set()
205 * @li eina_value_array_vget() and eina_value_array_vset()
206 * @li eina_value_array_pget() and eina_value_array_pset()
207 *
208 * eina_value_set() takes an #Eina_Value_Array where just @c subtype
209 * and @c step are used. If there is an @c array, it will be adopted
210 * and its contents must be properly configurable as @c subtype
211 * expects. eina_value_pset() takes a pointer to an #Eina_Value_Array.
212 * For your convenience, use eina_value_array_setup().
213 *
214 * eina_value_get() and eina_value_pget() takes a pointer to
215 * #Eina_Value_Array, it's an exact copy of the current structure in
216 * use by value, no copies are done.
217 *
218 * @since 1.2
219 */
220EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY;
221
222/**
223 * @var EINA_VALUE_TYPE_LIST
224 *
225 * manages list type. Use the value get/set for lists:
226 * @li eina_value_list_get() and eina_value_list_set()
227 * @li eina_value_list_vget() and eina_value_list_vset()
228 * @li eina_value_list_pget() and eina_value_list_pset()
229 *
230 * eina_value_set() takes an #Eina_Value_List where just @c subtype is
231 * used. If there is an @c list, it will be adopted and its contents
232 * must be properly configurable as @c subtype
233 * expects. eina_value_pset() takes a pointer to an #Eina_Value_List.
234 * For your convenience, use eina_value_list_setup().
235 *
236 * eina_value_get() and eina_value_pget() takes a pointer to
237 * #Eina_Value_List, it's an exact copy of the current structure in
238 * use by value, no copies are done.
239 *
240 * @since 1.2
241 */
242EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST;
243
244/**
245 * @var EINA_VALUE_TYPE_HASH
246 *
247 * manages hash type. Use the value get/set for hashes:
248 * @li eina_value_hash_get() and eina_value_hash_set()
249 * @li eina_value_hash_vget() and eina_value_hash_vset()
250 * @li eina_value_hash_pget() and eina_value_hash_pset()
251 *
252 * eina_value_set() takes an #Eina_Value_Hash where just @c subtype
253 * and @c buckets_power_size are used. If there is an @c hash, it will
254 * be adopted and its contents must be properly configurable as @c
255 * subtype expects. eina_value_pset() takes a pointer to an
256 * #Eina_Value_Hash. For your convenience, use
257 * eina_value_hash_setup().
258 *
259 * eina_value_get() and eina_value_pget() takes a pointer to
260 * #Eina_Value_Hash, it's an exact copy of the current structure in
261 * use by value, no copies are done.
262 *
263 * @note be aware that hash data is always an allocated memory of size
264 * defined by @c subtype->value_size. If your @c subtype is an
265 * integer, add as data malloc(sizeof(int)). If your @c subtype
266 * is an string, add as data malloc(sizeof(char*)) and this data
267 * value must point to strdup(string)!
268 *
269 * @since 1.2
270 */
271EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_HASH;
272
273/**
274 * @var EINA_VALUE_TYPE_TIMEVAL
275 * manages 'struct timeval' type
276 *
277 * eina_value_set() takes a "struct timeval" from sys/time.h.
278 * eina_value_pset() takes a pointer to "struct timeval".
279 *
280 * eina_value_get() and eina_value_pget() takes a pointer to "struct
281 * timeval" and it's an exact copy of value.
282 *
283 * @since 1.2
284 */
285EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL;
286
287/**
288 * @var EINA_VALUE_TYPE_BLOB
289 * manages blob of bytes type, see @ref Eina_Value_Blob
290 *
291 * eina_value_set() takes an #Eina_Value_Blob
292 * eina_value_pset() takes a pointer to #Eina_Value_Blob.
293 *
294 * eina_value_get() and eina_value_pget() takes a pointer to
295 * #Eina_Value_Blob and it's an exact copy of value, no allocations
296 * are made.
297 *
298 * Memory is untouched unless you provide @c ops (operations) pointer.
299 *
300 * @since 1.2
301 */
302EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB;
303
304/**
305 * @var EINA_VALUE_TYPE_STRUCT
306 *
307 * manages struct type. Use the value get/set for structs:
308 * @li eina_value_struct_get() and eina_value_struct_set()
309 * @li eina_value_struct_vget() and eina_value_struct_vset()
310 * @li eina_value_struct_pget() and eina_value_struct_pset()
311 *
312 * eina_value_set() takes an #Eina_Value_Struct where just @c desc is
313 * used. If there is an @c memory, it will be adopted and its contents
314 * must be properly configurable as @c desc expects. eina_value_pset()
315 * takes a pointer to an #Eina_Value_Struct. For your convenience, use
316 * eina_value_struct_setup().
317 *
318 * eina_value_get() and eina_value_pget() takes a pointer to
319 * #Eina_Value_Struct, it's an exact copy of the current structure in
320 * use by value, no copies are done.
321 *
322 * @since 1.2
323 */
324EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT;
325
326/**
327 * @var EINA_ERROR_VALUE_FAILED
328 * Error identifier corresponding to value check failure.
329 *
330 * @since 1.2
331 */
332EAPI extern int EINA_ERROR_VALUE_FAILED;
333
334/**
335 * @defgroup Eina_Value_Value_Group Generic Value management
336 *
337 * @{
338 */
339
340/**
341 * @struct _Eina_Value
342 * defines the contents of a value
343 *
344 * @since 1.2
345 */
346struct _Eina_Value
347{
348 const Eina_Value_Type *type; /**< how to access values */
349 Eina_Value_Union value; /**< to be accessed with type descriptor */
350};
351
352/**
353 * @brief Create generic value storage.
354 * @param type how to manage this value.
355 * @return The new value or @c NULL on failure.
356 *
357 * Create a new generic value storage. The members are managed using
358 * the description specified by @a type.
359 *
360 * Some types may specify more operations:
361 * eg. #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(),
362 * eina_value_array_get() and so on.
363 *
364 * On failure, @c NULL is returned and either #EINA_ERROR_OUT_OF_MEMORY or
365 * #EINA_ERROR_VALUE_FAILED is set.
366 *
367 * @note this calls creates from mempool and then uses
368 * eina_value_setup(). Consider using eina_value_flush() and
369 * eina_value_setup() instead to avoid memory allocations.
370 *
371 * @see eina_value_free()
372 *
373 * @since 1.2
374 */
375EAPI Eina_Value *eina_value_new(const Eina_Value_Type *type) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
376
377/**
378 * @brief Free value and its data.
379 * @param value value object
380 *
381 * @see eina_value_flush()
382 *
383 * @since 1.2
384 */
385EAPI void eina_value_free(Eina_Value *value) EINA_ARG_NONNULL(1);
386
387
388/**
389 * @brief Initialize generic value storage.
390 * @param value value object
391 * @param type how to manage this value.
392 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
393 *
394 * Initializes existing generic value storage. The members are managed using the
395 * description specified by @a type.
396 *
397 * Some types may specify more operations, as an example
398 * #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(),
399 * eina_value_array_get() and so on.
400 *
401 * @note Existing contents are ignored! If the value was previously used, then
402 * use eina_value_flush() first.
403 *
404 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
405 * or #EINA_ERROR_VALUE_FAILED is set.
406 *
407 * @see eina_value_flush()
408 *
409 * @since 1.2
410 */
411static inline Eina_Bool eina_value_setup(Eina_Value *value,
412 const Eina_Value_Type *type) EINA_ARG_NONNULL(1, 2);
413
414/**
415 * @brief Create generic value storage.
416 * @param value value object
417 *
418 * Releases all the resources associated with an #Eina_Value. The
419 * value must be already set with eina_value_setup() or
420 * eina_value_new().
421 *
422 * After this call returns, the contents of the value are undefined,
423 * but the value can be reused by calling eina_value_setup() again.
424 *
425 * @see eina_value_setup()
426 * @see eina_value_free()
427 *
428 * @since 1.2
429 */
430static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1);
431
432/**
433 * @brief Copy generic value storage.
434 * @param value source value object
435 * @param copy destination value object
436 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
437 *
438 * The @a copy object is considered internalized and its existing
439 * contents are overwritten (just as if eina_value_flush() was called on
440 * it).
441 *
442 * The copy happens by calling eina_value_setup() on @a copy, followed
443 * by getting the contents of @a value and setting it to @a copy.
444 *
445 * @since 1.2
446 */
447EAPI Eina_Bool eina_value_copy(const Eina_Value *value,
448 Eina_Value *copy) EINA_ARG_NONNULL(1, 2);
449
450/**
451 * @brief Compare generic value storage.
452 * @param a left side of comparison
453 * @param b right side of comparison
454 * @return less than zero if a < b, greater than zero if a > b, zero
455 * if a == b
456 *
457 * @since 1.2
458 */
459static inline int eina_value_compare(const Eina_Value *a,
460 const Eina_Value *b) EINA_ARG_NONNULL(1, 2);
461
462/**
463 * @brief Set the generic value.
464 * @param value source value object
465 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
466 *
467 * The variable argument is dependent on chosen type. The list for
468 * basic types:
469 *
470 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
471 * @li EINA_VALUE_TYPE_USHORT: unsigned short
472 * @li EINA_VALUE_TYPE_UINT: unsigned int
473 * @li EINA_VALUE_TYPE_ULONG: unsigned long
474 * @li EINA_VALUE_TYPE_UINT64: uint64_t
475 * @li EINA_VALUE_TYPE_CHAR: char
476 * @li EINA_VALUE_TYPE_SHORT: short
477 * @li EINA_VALUE_TYPE_INT: int
478 * @li EINA_VALUE_TYPE_LONG: long
479 * @li EINA_VALUE_TYPE_INT64: int64_t
480 * @li EINA_VALUE_TYPE_FLOAT: float
481 * @li EINA_VALUE_TYPE_DOUBLE: double
482 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
483 * @li EINA_VALUE_TYPE_STRING: const char *
484 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
485 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
486 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
487 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
488 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
489 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
490 *
491 * @code
492 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
493 * int x = 567;
494 * eina_value_set(value, 1234);
495 * eina_value_set(value, x);
496 *
497 * eina_value_flush(value);
498 *
499 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
500 * eina_value_set(value, "hello world!");
501 *
502 * eina_value_free(value);
503 * @endcode
504 *
505 * @note for array member see eina_value_array_set()
506 * @note for list member see eina_value_list_set()
507 * @note for hash member see eina_value_hash_set()
508 *
509 * @see eina_value_get()
510 * @see eina_value_vset()
511 * @see eina_value_pset()
512 *
513 * @since 1.2
514 */
515static inline Eina_Bool eina_value_set(Eina_Value *value,
516 ...) EINA_ARG_NONNULL(1);
517
518/**
519 * @brief Get the generic value.
520 * @param value source value object
521 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
522 *
523 * The value is returned in the variable argument parameter, the
524 * actual value is type-dependent, but usually it will be what is
525 * stored inside the object. There shouldn't be any memory allocation,
526 * thus the contents should @b not be freed.
527 *
528 * The variable argument is dependent on chosen type. The list for
529 * basic types:
530 *
531 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
532 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
533 * @li EINA_VALUE_TYPE_UINT: unsigned int*
534 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
535 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
536 * @li EINA_VALUE_TYPE_CHAR: char*
537 * @li EINA_VALUE_TYPE_SHORT: short*
538 * @li EINA_VALUE_TYPE_INT: int*
539 * @li EINA_VALUE_TYPE_LONG: long*
540 * @li EINA_VALUE_TYPE_INT64: int64_t*
541 * @li EINA_VALUE_TYPE_FLOAT: float*
542 * @li EINA_VALUE_TYPE_DOUBLE: double*
543 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
544 * @li EINA_VALUE_TYPE_STRING: const char **
545 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
546 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
547 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
548 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
549 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
550 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
551 *
552 * @code
553 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
554 * int x;
555 * const char *s;
556 *
557 * eina_value_set(value, 1234);
558 * eina_value_get(value, &x);
559 *
560 * eina_value_flush(value);
561 *
562 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
563 * eina_value_set(value, "hello world!");
564 * eina_value_get(value, &s);
565 *
566 * eina_value_free(value);
567 * @endcode
568 *
569 * @note for array member see eina_value_array_get()
570 * @note for list member see eina_value_list_get()
571 * @note for hash member see eina_value_hash_get()
572 *
573 * @see eina_value_set()
574 * @see eina_value_vset()
575 * @see eina_value_pset()
576 *
577 * @since 1.2
578 */
579static inline Eina_Bool eina_value_get(const Eina_Value *value,
580 ...) EINA_ARG_NONNULL(1);
581
582/**
583 * @brief Set the generic value.
584 * @param value source value object
585 * @param args variable argument
586 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
587 *
588 * @note for array member see eina_value_array_vset()
589 * @note for list member see eina_value_list_vset()
590 * @note for hash member see eina_value_hash_vset()
591 *
592 * @see eina_value_vget()
593 * @see eina_value_set()
594 * @see eina_value_pset()
595 *
596 * @since 1.2
597 */
598static inline Eina_Bool eina_value_vset(Eina_Value *value,
599 va_list args) EINA_ARG_NONNULL(1);
600
601/**
602 * @brief Get the generic value.
603 * @param value source value object
604 * @param args variable argument
605 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
606 *
607 * The value is returned in the variable argument parameter, the
608 * actual value is type-dependent, but usually it will be what is
609 * stored inside the object. There shouldn't be any memory allocation,
610 * thus the contents should @b not be freed.
611 *
612 * @note for array member see eina_value_array_vget()
613 * @note for list member see eina_value_list_vget()
614 * @note for hash member see eina_value_hash_vget()
615 *
616 * @see eina_value_vset()
617 * @see eina_value_get()
618 * @see eina_value_pget()
619 *
620 * @since 1.2
621 */
622static inline Eina_Bool eina_value_vget(const Eina_Value *value,
623 va_list args) EINA_ARG_NONNULL(1);
624
625/**
626 * @brief Set the generic value from pointer.
627 * @param value source value object
628 * @param ptr pointer to specify the contents.
629 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
630 *
631 * The pointer type is dependent on chosen value type. The list for
632 * basic types:
633 *
634 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
635 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
636 * @li EINA_VALUE_TYPE_UINT: unsigned int*
637 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
638 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
639 * @li EINA_VALUE_TYPE_CHAR: char*
640 * @li EINA_VALUE_TYPE_SHORT: short*
641 * @li EINA_VALUE_TYPE_INT: int*
642 * @li EINA_VALUE_TYPE_LONG: long*
643 * @li EINA_VALUE_TYPE_INT64: int64_t*
644 * @li EINA_VALUE_TYPE_FLOAT: float*
645 * @li EINA_VALUE_TYPE_DOUBLE: double*
646 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
647 * @li EINA_VALUE_TYPE_STRING: const char **
648 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
649 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
650 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
651 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
652 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
653 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
654 *
655 * @note the pointer contents are written using the size defined by
656 * type. It can be larger than void* or uint64_t.
657 *
658 * @code
659 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
660 * int x = 567;
661 * const char *s = "hello world!";
662 *
663 * eina_value_pset(value, &x);
664 *
665 * eina_value_flush(value);
666 *
667 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
668 * eina_value_pset(value, &s);
669 *
670 * eina_value_free(value);
671 * @endcode
672 *
673 * @note for array member see eina_value_array_pset()
674 * @note for list member see eina_value_list_pset()
675 * @note for hash member see eina_value_hash_pset()
676 *
677 * @see eina_value_pget()
678 * @see eina_value_set()
679 * @see eina_value_vset()
680 *
681 * @since 1.2
682 */
683static inline Eina_Bool eina_value_pset(Eina_Value *value,
684 const void *ptr) EINA_ARG_NONNULL(1, 2);
685
686/**
687 * @brief Get the generic value to pointer.
688 * @param value source value object
689 * @param ptr pointer to receive the contents.
690 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
691 *
692 * The value is returned in pointer contents, the actual value is
693 * type-dependent, but usually it will be what is stored inside the
694 * object. There shouldn't be any memory allocation, thus the contents
695 * should @b not be freed.
696 *
697 * The pointer type is dependent on chosen value type. The list for
698 * basic types:
699 *
700 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
701 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
702 * @li EINA_VALUE_TYPE_UINT: unsigned int*
703 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
704 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
705 * @li EINA_VALUE_TYPE_CHAR: char*
706 * @li EINA_VALUE_TYPE_SHORT: short*
707 * @li EINA_VALUE_TYPE_INT: int*
708 * @li EINA_VALUE_TYPE_LONG: long*
709 * @li EINA_VALUE_TYPE_INT64: int64_t*
710 * @li EINA_VALUE_TYPE_FLOAT: float*
711 * @li EINA_VALUE_TYPE_DOUBLE: double*
712 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
713 * @li EINA_VALUE_TYPE_STRING: const char **
714 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
715 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
716 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
717 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
718 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
719 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
720 *
721 * @code
722 * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT);
723 * int x;
724 * const char *s;
725 *
726 * eina_value_set(value, 1234);
727 * eina_value_pget(value, &x);
728 *
729 * eina_value_flush(value);
730 *
731 * eina_value_setup(value, EINA_VALUE_TYPE_STRING);
732 * eina_value_set(value, "hello world!");
733 * eina_value_pget(value, &s);
734 *
735 * eina_value_free(value);
736 * @endcode
737 *
738 * @note for array member see eina_value_array_get()
739 * @note for list member see eina_value_list_get()
740 * @note for hash member see eina_value_hash_get()
741 *
742 * @see eina_value_set()
743 * @see eina_value_vset()
744 * @see eina_value_pset()
745 *
746 * @since 1.2
747 */
748static inline Eina_Bool eina_value_pget(const Eina_Value *value,
749 void *ptr) EINA_ARG_NONNULL(1, 2);
750
751/**
752 * @brief Convert one value to another type.
753 * @param value source value object.
754 * @param convert destination value object.
755 * @return #EINA_TRUE if converted, #EINA_FALSE otherwise.
756 *
757 * Converts one value to another trying first @a value type
758 * @c convert_to() function. If unsuccessful, tries using @c convert_from()
759 * function in @a convert.
760 *
761 * Conversion functions are type defined, and the basic types can convert
762 * between themselves, but conversion is strict! That is, if
763 * converting from negative value to unsigned type, it will fail. It
764 * also fails on value overflow.
765 *
766 * It is recommended that all types implement at least convert to
767 * string, used by eina_value_to_string().
768 *
769 * @note Both objects must have eina_value_setup() called on them beforehand!
770 *
771 * @since 1.2
772 */
773EAPI Eina_Bool eina_value_convert(const Eina_Value *value,
774 Eina_Value *convert) EINA_ARG_NONNULL(1, 2);
775
776
777/**
778 * @brief Convert value to string.
779 * @param value value object.
780 * @return newly allocated memory or @c NULL on failure.
781 *
782 * @see eina_value_convert()
783 * @since 1.2
784 */
785EAPI char *eina_value_to_string(const Eina_Value *value) EINA_ARG_NONNULL(1);
786
787/**
788 * @brief Query value type.
789 * @param value value object.
790 * @return type instance or @c NULL if type is invalid.
791 *
792 * Check if value type is valid and returns it. A type is invalid if
793 * it does not exist or if it is using a different version field.
794 *
795 * @see eina_value_type_check()
796 *
797 * @since 1.2
798 */
799static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
800
801/**
802 * @}
803 */
804
805
806/**
807 * @defgroup Eina_Value_Array_Group Generic Value Array management
808 *
809 * @{
810 */
811
812
813/**
814 * @typedef Eina_Value_Array
815 * Value type for #EINA_VALUE_TYPE_ARRAY
816 *
817 * @since 1.2
818 */
819typedef struct _Eina_Value_Array Eina_Value_Array;
820
821/**
822 * @struct _Eina_Value_Array
823 * Used to store the array and its subtype.
824 */
825struct _Eina_Value_Array
826{
827 const Eina_Value_Type *subtype; /**< how to allocate and access items */
828 unsigned int step; /**< how to grow the members array */
829 Eina_Inarray *array; /**< the array that holds data, members are of subtype->value_size bytes. */
830};
831
832/**
833 * @brief Create generic value storage of type array.
834 * @param subtype how to manage this array members.
835 * @param step how to grow the members array.
836 * @return The new value or @c NULL on failure.
837 *
838 * Create a new generic value storage of type array. The members are
839 * managed using the description specified by @a subtype.
840 *
841 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
842 * #EINA_ERROR_VALUE_FAILED is set.
843 *
844 * @note this creates from mempool and then uses
845 * eina_value_array_setup(). @see eina_value_free() @see
846 * eina_value_array_setup()
847 *
848 * @since 1.2
849 */
850EAPI Eina_Value *eina_value_array_new(const Eina_Value_Type *subtype,
851 unsigned int step) EINA_ARG_NONNULL(1);
852
853/**
854 * @brief Initialize generic value storage of type array.
855 * @param value value object
856 * @param subtype how to manage array members.
857 * @param step how to grow the members array.
858 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
859 *
860 * Initializes new generic value storage of type array with the given
861 * @a subtype.
862 *
863 * This is the same as calling eina_value_set() with
864 * #EINA_VALUE_TYPE_ARRAY followed by eina_value_pset() with the
865 * #Eina_Value_Array description configured.
866 *
867 * @note Existing contents are ignored! If the value was previously used, then
868 * use eina_value_flush() first.
869 *
870 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
871 * or #EINA_ERROR_VALUE_FAILED is set.
872 *
873 * @see eina_value_flush()
874 *
875 * @since 1.2
876 */
877static inline Eina_Bool eina_value_array_setup(Eina_Value *value,
878 const Eina_Value_Type *subtype,
879 unsigned int step) EINA_ARG_NONNULL(1, 2);
880
881/**
882 * @brief Query number of elements in value of array type.
883 * @param value value object.
884 * @return number of child elements.
885 * @since 1.2
886 */
887static inline unsigned int eina_value_array_count(const Eina_Value *value);
888
889/**
890 * @brief Remove element at given position in value of array type.
891 * @param value value object.
892 * @param position index of the member
893 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
894 * @since 1.2
895 */
896static inline Eina_Bool eina_value_array_remove(Eina_Value *value,
897 unsigned int position) EINA_ARG_NONNULL(1);
898
899/**
900 * @brief Set the generic value in an array member.
901 * @param value source value object
902 * @param position index of the member
903 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
904 *
905 * The variable argument is dependent on chosen subtype. The list for
906 * basic types:
907 *
908 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
909 * @li EINA_VALUE_TYPE_USHORT: unsigned short
910 * @li EINA_VALUE_TYPE_UINT: unsigned int
911 * @li EINA_VALUE_TYPE_ULONG: unsigned long
912 * @li EINA_VALUE_TYPE_UINT64: uint64_t
913 * @li EINA_VALUE_TYPE_CHAR: char
914 * @li EINA_VALUE_TYPE_SHORT: short
915 * @li EINA_VALUE_TYPE_INT: int
916 * @li EINA_VALUE_TYPE_LONG: long
917 * @li EINA_VALUE_TYPE_INT64: int64_t
918 * @li EINA_VALUE_TYPE_FLOAT: float
919 * @li EINA_VALUE_TYPE_DOUBLE: double
920 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
921 * @li EINA_VALUE_TYPE_STRING: const char *
922 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
923 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
924 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
925 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
926 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
927 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
928 *
929 * @code
930 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
931 * int x;
932 *
933 * eina_value_array_append(value, 1234);
934 * eina_value_array_set(value, 0, 5678);
935 * eina_value_array_get(value, 0, &x);
936 * eina_value_free(value);
937 * @endcode
938 *
939 * @see eina_value_array_get()
940 * @see eina_value_array_vset()
941 * @see eina_value_array_pset()
942 * @see eina_value_array_insert()
943 * @see eina_value_array_vinsert()
944 * @see eina_value_array_pinsert()
945 * @see eina_value_array_append()
946 * @see eina_value_array_vappend()
947 * @see eina_value_array_pappend()
948 *
949 * @since 1.2
950 */
951static inline Eina_Bool eina_value_array_set(Eina_Value *value,
952 unsigned int position,
953 ...) EINA_ARG_NONNULL(1);
954
955/**
956 * @brief Get the generic value from an array member.
957 * @param value source value object
958 * @param position index of the member
959 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
960 *
961 * The value is returned in the variable argument parameter, and the
962 * actual value is type-dependent, but usually it will be what is
963 * stored inside the object. There shouldn't be any memory allocation;
964 * thus the contents should @b not be freed.
965 *
966 * The variable argument is dependent on chosen subtype. The list for
967 * basic types:
968 *
969 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
970 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
971 * @li EINA_VALUE_TYPE_UINT: unsigned int*
972 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
973 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
974 * @li EINA_VALUE_TYPE_CHAR: char*
975 * @li EINA_VALUE_TYPE_SHORT: short*
976 * @li EINA_VALUE_TYPE_INT: int*
977 * @li EINA_VALUE_TYPE_LONG: long*
978 * @li EINA_VALUE_TYPE_INT64: int64_t*
979 * @li EINA_VALUE_TYPE_FLOAT: float*
980 * @li EINA_VALUE_TYPE_DOUBLE: double*
981 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
982 * @li EINA_VALUE_TYPE_STRING: const char **
983 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
984 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
985 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
986 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
987 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
988 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
989 *
990 * @code
991 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
992 * int x;
993 *
994 * eina_value_array_append(value, 1234);
995 * eina_value_array_get(value, 0, &x);
996 * eina_value_free(value);
997 * @endcode
998 *
999 * @see eina_value_array_set()
1000 * @see eina_value_array_vset()
1001 * @see eina_value_array_pset()
1002 *
1003 * @since 1.2
1004 */
1005static inline Eina_Bool eina_value_array_get(const Eina_Value *value,
1006 unsigned int position,
1007 ...) EINA_ARG_NONNULL(1);
1008
1009/**
1010 * @brief Insert a generic value in an array member position.
1011 * @param value source value object
1012 * @param position index of the member
1013 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1014 *
1015 * The variable argument is dependent on chosen subtype. The list for
1016 * basic types:
1017 *
1018 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1019 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1020 * @li EINA_VALUE_TYPE_UINT: unsigned int
1021 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1022 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1023 * @li EINA_VALUE_TYPE_CHAR: char
1024 * @li EINA_VALUE_TYPE_SHORT: short
1025 * @li EINA_VALUE_TYPE_INT: int
1026 * @li EINA_VALUE_TYPE_LONG: long
1027 * @li EINA_VALUE_TYPE_INT64: int64_t
1028 * @li EINA_VALUE_TYPE_FLOAT: float
1029 * @li EINA_VALUE_TYPE_DOUBLE: double
1030 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1031 * @li EINA_VALUE_TYPE_STRING: const char *
1032 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1033 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1034 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1035 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1036 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1037 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1038 *
1039 * @code
1040 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1041 * int x;
1042 *
1043 * eina_value_array_insert(value, 0, 1234);
1044 * eina_value_array_get(value, 0, &x);
1045 * eina_value_free(value);
1046 * @endcode
1047 *
1048 * @see eina_value_array_set()
1049 * @see eina_value_array_get()
1050 * @see eina_value_array_vset()
1051 * @see eina_value_array_pset()
1052 * @see eina_value_array_vinsert()
1053 * @see eina_value_array_pinsert()
1054 * @see eina_value_array_append()
1055 * @see eina_value_array_vappend()
1056 * @see eina_value_array_pappend()
1057 *
1058 * @since 1.2
1059 */
1060static inline Eina_Bool eina_value_array_insert(Eina_Value *value,
1061 unsigned int position,
1062 ...) EINA_ARG_NONNULL(1);
1063
1064
1065/**
1066 * @brief Append a generic value in an array.
1067 * @param value source value object
1068 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1069 *
1070 * The variable argument is dependent on chosen subtype. The list for
1071 * basic types:
1072 *
1073 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1074 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1075 * @li EINA_VALUE_TYPE_UINT: unsigned int
1076 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1077 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1078 * @li EINA_VALUE_TYPE_CHAR: char
1079 * @li EINA_VALUE_TYPE_SHORT: short
1080 * @li EINA_VALUE_TYPE_INT: int
1081 * @li EINA_VALUE_TYPE_LONG: long
1082 * @li EINA_VALUE_TYPE_INT64: int64_t
1083 * @li EINA_VALUE_TYPE_FLOAT: float
1084 * @li EINA_VALUE_TYPE_DOUBLE: double
1085 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1086 * @li EINA_VALUE_TYPE_STRING: const char *
1087 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array
1088 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1089 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1090 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1091 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1092 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1093 *
1094 * @code
1095 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1096 * int x;
1097 *
1098 * eina_value_array_append(value, 1234);
1099 * eina_value_array_get(value, 0, &x);
1100 * eina_value_free(value);
1101 * @endcode
1102 *
1103 * @see eina_value_array_set()
1104 * @see eina_value_array_get()
1105 * @see eina_value_array_vset()
1106 * @see eina_value_array_pset()
1107 * @see eina_value_array_vinsert()
1108 * @see eina_value_array_pinsert()
1109 * @see eina_value_array_append()
1110 * @see eina_value_array_vappend()
1111 * @see eina_value_array_pappend()
1112 *
1113 * @since 1.2
1114 */
1115static inline Eina_Bool eina_value_array_append(Eina_Value *value,
1116 ...) EINA_ARG_NONNULL(1);
1117
1118/**
1119 * @brief Set a generic value to an array member.
1120 * @param value source value object
1121 * @param position index of the member
1122 * @param args variable argument
1123 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1124 * @see eina_value_array_set()
1125 * @see eina_value_array_get()
1126 * @see eina_value_array_pset()
1127 * @see eina_value_array_insert()
1128 * @see eina_value_array_vinsert()
1129 * @see eina_value_array_pinsert()
1130 * @see eina_value_array_append()
1131 * @see eina_value_array_vappend()
1132 * @see eina_value_array_pappend()
1133 *
1134 * @since 1.2
1135 */
1136static inline Eina_Bool eina_value_array_vset(Eina_Value *value,
1137 unsigned int position,
1138 va_list args) EINA_ARG_NONNULL(1);
1139
1140/**
1141 * @brief Get the generic value from an array member.
1142 * @param value source value object
1143 * @param position index of the member
1144 * @param args variable argument
1145 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1146 *
1147 * The value is returned in the variable argument parameter, the
1148 * actual value is type-dependent, but usually it will be what is
1149 * stored inside the object. There shouldn't be any memory allocation,
1150 * thus the contents should @b not be freed.
1151 *
1152 * @see eina_value_array_vset()
1153 * @see eina_value_array_get()
1154 * @see eina_value_array_pget()
1155 *
1156 * @since 1.2
1157 */
1158static inline Eina_Bool eina_value_array_vget(const Eina_Value *value,
1159 unsigned int position,
1160 va_list args) EINA_ARG_NONNULL(1);
1161/**
1162 * @brief Insert a generic value to an array member position.
1163 * @param value source value object
1164 * @param position index of the member
1165 * @param args variable argument
1166 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1167 * @see eina_value_array_set()
1168 * @see eina_value_array_get()
1169 * @see eina_value_array_vset()
1170 * @see eina_value_array_pset()
1171 * @see eina_value_array_insert()
1172 * @see eina_value_array_pinsert()
1173 * @see eina_value_array_append()
1174 * @see eina_value_array_vappend()
1175 * @see eina_value_array_pappend()
1176 *
1177 * @since 1.2
1178 */
1179static inline Eina_Bool eina_value_array_vinsert(Eina_Value *value,
1180 unsigned int position,
1181 va_list args) EINA_ARG_NONNULL(1);
1182
1183/**
1184 * @brief Append a generic value to an array.
1185 * @param value source value object
1186 * @param args variable argument
1187 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1188 * @see eina_value_array_set()
1189 * @see eina_value_array_get()
1190 * @see eina_value_array_vget()
1191 * @see eina_value_array_pset()
1192 * @see eina_value_array_insert()
1193 * @see eina_value_array_vinsert()
1194 * @see eina_value_array_pinsert()
1195 * @see eina_value_array_append()
1196 * @see eina_value_array_pappend()
1197 *
1198 * @since 1.2
1199 */
1200static inline Eina_Bool eina_value_array_vappend(Eina_Value *value,
1201 va_list args) EINA_ARG_NONNULL(1);
1202
1203
1204/**
1205 * @brief Set a generic value to an array member from a pointer.
1206 * @param value source value object
1207 * @param position index of the member
1208 * @param ptr pointer to specify the contents.
1209 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1210 *
1211 * The pointer type is dependent on chosen value type. The list for
1212 * basic types:
1213 *
1214 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1215 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1216 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1217 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1218 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1219 * @li EINA_VALUE_TYPE_CHAR: char*
1220 * @li EINA_VALUE_TYPE_SHORT: short*
1221 * @li EINA_VALUE_TYPE_INT: int*
1222 * @li EINA_VALUE_TYPE_LONG: long*
1223 * @li EINA_VALUE_TYPE_INT64: int64_t*
1224 * @li EINA_VALUE_TYPE_FLOAT: float*
1225 * @li EINA_VALUE_TYPE_DOUBLE: double*
1226 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1227 * @li EINA_VALUE_TYPE_STRING: const char **
1228 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1229 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1230 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1231 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1232 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1233 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1234 *
1235 * @note the pointer contents are written using the size defined by
1236 * type. It can be larger than void* or uint64_t.
1237 *
1238 * @code
1239 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1240 * int x = 1234;
1241 *
1242 * eina_value_array_append(value, 1234);
1243 * eina_value_array_pset(value, 0, &x);
1244 * eina_value_array_pget(value, 0, &x);
1245 * eina_value_free(value);
1246 * @endcode
1247 *
1248 * @see eina_value_array_set()
1249 * @see eina_value_array_get()
1250 * @see eina_value_array_vset()
1251 * @see eina_value_array_insert()
1252 * @see eina_value_array_vinsert()
1253 * @see eina_value_array_pinsert()
1254 * @see eina_value_array_append()
1255 * @see eina_value_array_vappend()
1256 * @see eina_value_array_pappend()
1257 *
1258 * @since 1.2
1259 */
1260static inline Eina_Bool eina_value_array_pset(Eina_Value *value,
1261 unsigned int position,
1262 const void *ptr) EINA_ARG_NONNULL(1, 3);
1263
1264/**
1265 * @brief Retrieve a generic value into a pointer from an array member.
1266 * @param value source value object
1267 * @param position index of the member
1268 * @param ptr pointer to receive the contents.
1269 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1270 *
1271 * The value is returned in pointer contents, the actual value is
1272 * type-dependent, but usually it will be what is stored inside the
1273 * object. There shouldn't be any memory allocation, thus the contents
1274 * should @b not be freed.
1275 *
1276 * The pointer type is dependent on chosen value type. The list for
1277 * basic types:
1278 *
1279 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1280 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1281 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1282 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1283 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1284 * @li EINA_VALUE_TYPE_CHAR: char*
1285 * @li EINA_VALUE_TYPE_SHORT: short*
1286 * @li EINA_VALUE_TYPE_INT: int*
1287 * @li EINA_VALUE_TYPE_LONG: long*
1288 * @li EINA_VALUE_TYPE_INT64: int64_t*
1289 * @li EINA_VALUE_TYPE_FLOAT: float*
1290 * @li EINA_VALUE_TYPE_DOUBLE: double*
1291 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1292 * @li EINA_VALUE_TYPE_STRING: const char **
1293 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1294 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1295 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1296 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1297 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1298 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1299 *
1300 * @code
1301 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1302 * int x;
1303 *
1304 * eina_value_array_append(value, 1234);
1305 * eina_value_array_pget(value, 0, &x);
1306 * eina_value_free(value);
1307 * @endcode
1308 *
1309 * @see eina_value_array_set()
1310 * @see eina_value_array_vset()
1311 * @see eina_value_array_pset()
1312 *
1313 * @since 1.2
1314 */
1315static inline Eina_Bool eina_value_array_pget(const Eina_Value *value,
1316 unsigned int position,
1317 void *ptr) EINA_ARG_NONNULL(1, 3);
1318
1319/**
1320 * @brief Insert a generic value to an array member position from a pointer.
1321 * @param value source value object
1322 * @param position index of the member
1323 * @param ptr pointer to specify the contents.
1324 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1325 *
1326 * The pointer type is dependent on chosen value type. The list for
1327 * basic types:
1328 *
1329 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1330 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1331 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1332 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1333 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1334 * @li EINA_VALUE_TYPE_CHAR: char*
1335 * @li EINA_VALUE_TYPE_SHORT: short*
1336 * @li EINA_VALUE_TYPE_INT: int*
1337 * @li EINA_VALUE_TYPE_LONG: long*
1338 * @li EINA_VALUE_TYPE_INT64: int64_t*
1339 * @li EINA_VALUE_TYPE_FLOAT: float*
1340 * @li EINA_VALUE_TYPE_DOUBLE: double*
1341 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1342 * @li EINA_VALUE_TYPE_STRING: const char **
1343 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1344 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1345 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1346 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1347 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1348 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1349 *
1350 * @note the pointer contents are written using the size defined by
1351 * type. It can be larger than void* or uint64_t.
1352 *
1353 * @code
1354 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1355 * int x = 1234;
1356 *
1357 * eina_value_array_pinsert(value, 0, &x);
1358 * eina_value_array_pget(value, 0, &x);
1359 * eina_value_free(value);
1360 * @endcode
1361 *
1362 * @see eina_value_array_set()
1363 * @see eina_value_array_get()
1364 * @see eina_value_array_vset()
1365 * @see eina_value_array_insert()
1366 * @see eina_value_array_vinsert()
1367 * @see eina_value_array_pinsert()
1368 * @see eina_value_array_append()
1369 * @see eina_value_array_vappend()
1370 * @see eina_value_array_pappend()
1371 *
1372 * @since 1.2
1373 */
1374static inline Eina_Bool eina_value_array_pinsert(Eina_Value *value,
1375 unsigned int position,
1376 const void *ptr) EINA_ARG_NONNULL(1);
1377
1378/**
1379 * @brief Append a generic value to an array from a pointer.
1380 * @param value source value object
1381 * @param ptr pointer to specify the contents.
1382 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1383 *
1384 * The pointer type is dependent on chosen value type. The list for
1385 * basic types:
1386 *
1387 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1388 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1389 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1390 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1391 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1392 * @li EINA_VALUE_TYPE_CHAR: char*
1393 * @li EINA_VALUE_TYPE_SHORT: short*
1394 * @li EINA_VALUE_TYPE_INT: int*
1395 * @li EINA_VALUE_TYPE_LONG: long*
1396 * @li EINA_VALUE_TYPE_INT64: int64_t*
1397 * @li EINA_VALUE_TYPE_FLOAT: float*
1398 * @li EINA_VALUE_TYPE_DOUBLE: double*
1399 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1400 * @li EINA_VALUE_TYPE_STRING: const char **
1401 * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array*
1402 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1403 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1404 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1405 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1406 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1407 *
1408 * @note the pointer contents are written using the size defined by
1409 * type. It can be larger than void* or uint64_t.
1410 *
1411 * @code
1412 * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0);
1413 * int x = 1234;
1414 *
1415 * eina_value_array_pappend(value, &x);
1416 * eina_value_array_pget(value, 0, &x);
1417 * eina_value_free(value);
1418 * @endcode
1419 *
1420 * @see eina_value_array_set()
1421 * @see eina_value_array_get()
1422 * @see eina_value_array_vset()
1423 * @see eina_value_array_insert()
1424 * @see eina_value_array_vinsert()
1425 * @see eina_value_array_pinsert()
1426 * @see eina_value_array_append()
1427 * @see eina_value_array_vappend()
1428 * @see eina_value_array_pappend()
1429 *
1430 * @since 1.2
1431 */
1432static inline Eina_Bool eina_value_array_pappend(Eina_Value *value,
1433 const void *ptr) EINA_ARG_NONNULL(1);
1434
1435/**
1436 * @}
1437 */
1438
1439
1440/**
1441 * @defgroup Eina_Value_List_Group Generic Value List management
1442 *
1443 * @{
1444 */
1445
1446
1447/**
1448 * @typedef Eina_Value_List
1449 * Value type for #EINA_VALUE_TYPE_LIST
1450 *
1451 * @since 1.2
1452 */
1453typedef struct _Eina_Value_List Eina_Value_List;
1454
1455/**
1456 * @struct _Eina_Value_List
1457 * Used to store the list and its subtype.
1458 */
1459struct _Eina_Value_List
1460{
1461 const Eina_Value_Type *subtype; /**< how to allocate and access items */
1462 Eina_List *list; /**< the list that holds data, members are of subtype->value_size bytes. */
1463};
1464
1465/**
1466 * @brief Create generic value storage of type list.
1467 * @param subtype how to manage this list members.
1468 * @return The new value or @c NULL on failure.
1469 *
1470 * Create a new generic value storage of type list. The members are
1471 * managed using the description specified by @a subtype.
1472 *
1473 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
1474 * #EINA_ERROR_VALUE_FAILED is set.
1475 *
1476 * @note this creates from mempool and then uses
1477 * eina_value_list_setup().
1478 *
1479 * @see eina_value_free()
1480 * @see eina_value_list_setup()
1481 *
1482 * @since 1.2
1483 */
1484EAPI Eina_Value *eina_value_list_new(const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1);
1485
1486/**
1487 * @brief Initialize generic value storage of type list.
1488 * @param value value object
1489 * @param subtype how to manage this list members.
1490 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1491 *
1492 * Initializes new generic value storage of type list with the given
1493 * @a subtype.
1494 *
1495 * This is the same as calling eina_value_set() with
1496 * #EINA_VALUE_TYPE_LIST followed by eina_value_pset() with the
1497 * #Eina_Value_List description configured.
1498 *
1499 * @note Existing contents are ignored! If the value was previously used, then
1500 * use eina_value_flush() first.
1501 *
1502 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
1503 * or #EINA_ERROR_VALUE_FAILED is set.
1504 *
1505 * @see eina_value_flush()
1506 *
1507 * @since 1.2
1508 */
1509static inline Eina_Bool eina_value_list_setup(Eina_Value *value,
1510 const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1, 2);
1511
1512/**
1513 * @brief Query number of elements in value of list type.
1514 * @param value value object.
1515 * @return number of child elements.
1516 * @since 1.2
1517 */
1518static inline unsigned int eina_value_list_count(const Eina_Value *value);
1519
1520/**
1521 * @brief Remove element at given position in value of list type.
1522 * @param value value object.
1523 * @param position index of the member
1524 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1525 * @since 1.2
1526 */
1527static inline Eina_Bool eina_value_list_remove(Eina_Value *value,
1528 unsigned int position) EINA_ARG_NONNULL(1);
1529
1530/**
1531 * @brief Set the generic value in an list member.
1532 * @param value source value object
1533 * @param position index of the member
1534 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1535 *
1536 * The variable argument is dependent on chosen subtype. The list for
1537 * basic types:
1538 *
1539 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1540 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1541 * @li EINA_VALUE_TYPE_UINT: unsigned int
1542 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1543 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1544 * @li EINA_VALUE_TYPE_CHAR: char
1545 * @li EINA_VALUE_TYPE_SHORT: short
1546 * @li EINA_VALUE_TYPE_INT: int
1547 * @li EINA_VALUE_TYPE_LONG: long
1548 * @li EINA_VALUE_TYPE_INT64: int64_t
1549 * @li EINA_VALUE_TYPE_FLOAT: float
1550 * @li EINA_VALUE_TYPE_DOUBLE: double
1551 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1552 * @li EINA_VALUE_TYPE_STRING: const char *
1553 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1554 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1555 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1556 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1557 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1558 *
1559 * @code
1560 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1561 * int x;
1562 *
1563 * eina_value_list_append(value, 1234);
1564 * eina_value_list_set(value, 0, 5678);
1565 * eina_value_list_get(value, 0, &x);
1566 * eina_value_free(value);
1567 * @endcode
1568 *
1569 * @see eina_value_list_get()
1570 * @see eina_value_list_vset()
1571 * @see eina_value_list_pset()
1572 * @see eina_value_list_insert()
1573 * @see eina_value_list_vinsert()
1574 * @see eina_value_list_pinsert()
1575 * @see eina_value_list_append()
1576 * @see eina_value_list_vappend()
1577 * @see eina_value_list_pappend()
1578 *
1579 * @since 1.2
1580 */
1581static inline Eina_Bool eina_value_list_set(Eina_Value *value,
1582 unsigned int position,
1583 ...) EINA_ARG_NONNULL(1);
1584
1585/**
1586 * @brief Get the generic value from an list member.
1587 * @param value source value object
1588 * @param position index of the member
1589 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1590 *
1591 * The value is returned in the variable argument parameter, the
1592 * actual value is type-dependent, but usually it will be what is
1593 * stored inside the object. There shouldn't be any memory allocation,
1594 * thus the contents should @b not be freed.
1595 *
1596 * The variable argument is dependent on chosen subtype. The list for
1597 * basic types:
1598 *
1599 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1600 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1601 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1602 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1603 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1604 * @li EINA_VALUE_TYPE_CHAR: char*
1605 * @li EINA_VALUE_TYPE_SHORT: short*
1606 * @li EINA_VALUE_TYPE_INT: int*
1607 * @li EINA_VALUE_TYPE_LONG: long*
1608 * @li EINA_VALUE_TYPE_INT64: int64_t*
1609 * @li EINA_VALUE_TYPE_FLOAT: float*
1610 * @li EINA_VALUE_TYPE_DOUBLE: double*
1611 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1612 * @li EINA_VALUE_TYPE_STRING: const char **
1613 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1614 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1615 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1616 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1617 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1618 *
1619 * @code
1620 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1621 * int x;
1622 *
1623 * eina_value_list_append(value, 1234);
1624 * eina_value_list_get(value, 0, &x);
1625 * eina_value_free(value);
1626 * @endcode
1627 *
1628 * @see eina_value_list_set()
1629 * @see eina_value_list_vset()
1630 * @see eina_value_list_pset()
1631 *
1632 * @since 1.2
1633 */
1634static inline Eina_Bool eina_value_list_get(const Eina_Value *value,
1635 unsigned int position,
1636 ...) EINA_ARG_NONNULL(1);
1637
1638/**
1639 * @brief Insert the generic value in an list member position.
1640 * @param value source value object
1641 * @param position index of the member
1642 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1643 *
1644 * The variable argument is dependent on chosen subtype. The list for
1645 * basic types:
1646 *
1647 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1648 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1649 * @li EINA_VALUE_TYPE_UINT: unsigned int
1650 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1651 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1652 * @li EINA_VALUE_TYPE_CHAR: char
1653 * @li EINA_VALUE_TYPE_SHORT: short
1654 * @li EINA_VALUE_TYPE_INT: int
1655 * @li EINA_VALUE_TYPE_LONG: long
1656 * @li EINA_VALUE_TYPE_INT64: int64_t
1657 * @li EINA_VALUE_TYPE_FLOAT: float
1658 * @li EINA_VALUE_TYPE_DOUBLE: double
1659 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1660 * @li EINA_VALUE_TYPE_STRING: const char *
1661 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1662 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1663 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1664 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1665 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1666 *
1667 * @code
1668 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1669 * int x;
1670 *
1671 * eina_value_list_insert(value, 0, 1234);
1672 * eina_value_list_get(value, 0, &x);
1673 * eina_value_free(value);
1674 * @endcode
1675 *
1676 * @see eina_value_list_set()
1677 * @see eina_value_list_get()
1678 * @see eina_value_list_vset()
1679 * @see eina_value_list_pset()
1680 * @see eina_value_list_vinsert()
1681 * @see eina_value_list_pinsert()
1682 * @see eina_value_list_append()
1683 * @see eina_value_list_vappend()
1684 * @see eina_value_list_pappend()
1685 *
1686 * @since 1.2
1687 */
1688static inline Eina_Bool eina_value_list_insert(Eina_Value *value,
1689 unsigned int position,
1690 ...) EINA_ARG_NONNULL(1);
1691
1692
1693/**
1694 * @brief Append the generic value in an list.
1695 * @param value source value object
1696 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1697 *
1698 * The variable argument is dependent on chosen subtype. The list for
1699 * basic types:
1700 *
1701 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
1702 * @li EINA_VALUE_TYPE_USHORT: unsigned short
1703 * @li EINA_VALUE_TYPE_UINT: unsigned int
1704 * @li EINA_VALUE_TYPE_ULONG: unsigned long
1705 * @li EINA_VALUE_TYPE_UINT64: uint64_t
1706 * @li EINA_VALUE_TYPE_CHAR: char
1707 * @li EINA_VALUE_TYPE_SHORT: short
1708 * @li EINA_VALUE_TYPE_INT: int
1709 * @li EINA_VALUE_TYPE_LONG: long
1710 * @li EINA_VALUE_TYPE_INT64: int64_t
1711 * @li EINA_VALUE_TYPE_FLOAT: float
1712 * @li EINA_VALUE_TYPE_DOUBLE: double
1713 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
1714 * @li EINA_VALUE_TYPE_STRING: const char *
1715 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List
1716 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
1717 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval
1718 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob
1719 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct
1720 *
1721 * @code
1722 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1723 * int x;
1724 *
1725 * eina_value_list_append(value, 1234);
1726 * eina_value_list_get(value, 0, &x);
1727 * eina_value_free(value);
1728 * @endcode
1729 *
1730 * @see eina_value_list_set()
1731 * @see eina_value_list_get()
1732 * @see eina_value_list_vset()
1733 * @see eina_value_list_pset()
1734 * @see eina_value_list_vinsert()
1735 * @see eina_value_list_pinsert()
1736 * @see eina_value_list_append()
1737 * @see eina_value_list_vappend()
1738 * @see eina_value_list_pappend()
1739 *
1740 * @since 1.2
1741 */
1742static inline Eina_Bool eina_value_list_append(Eina_Value *value,
1743 ...) EINA_ARG_NONNULL(1);
1744
1745/**
1746 * @brief Set the generic value in an list member.
1747 * @param value source value object
1748 * @param position index of the member
1749 * @param args variable argument
1750 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1751 * @see eina_value_list_set()
1752 * @see eina_value_list_get()
1753 * @see eina_value_list_pset()
1754 * @see eina_value_list_insert()
1755 * @see eina_value_list_vinsert()
1756 * @see eina_value_list_pinsert()
1757 * @see eina_value_list_append()
1758 * @see eina_value_list_vappend()
1759 * @see eina_value_list_pappend()
1760 *
1761 * @since 1.2
1762 */
1763static inline Eina_Bool eina_value_list_vset(Eina_Value *value,
1764 unsigned int position,
1765 va_list args) EINA_ARG_NONNULL(1);
1766
1767/**
1768 * @brief Get the generic value from an list member.
1769 * @param value source value object
1770 * @param position index of the member
1771 * @param args variable argument
1772 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1773 *
1774 * The value is returned in the variable argument parameter, the
1775 * actual value is type-dependent, but usually it will be what is
1776 * stored inside the object. There shouldn't be any memory allocation,
1777 * thus the contents should @b not be freed.
1778 *
1779 * @see eina_value_list_vset()
1780 * @see eina_value_list_get()
1781 * @see eina_value_list_pget()
1782 *
1783 * @since 1.2
1784 */
1785static inline Eina_Bool eina_value_list_vget(const Eina_Value *value,
1786 unsigned int position,
1787 va_list args) EINA_ARG_NONNULL(1);
1788/**
1789 * @brief Insert the generic value in an list member position.
1790 * @param value source value object
1791 * @param position index of the member
1792 * @param args variable argument
1793 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1794 * @see eina_value_list_set()
1795 * @see eina_value_list_get()
1796 * @see eina_value_list_vset()
1797 * @see eina_value_list_pset()
1798 * @see eina_value_list_insert()
1799 * @see eina_value_list_pinsert()
1800 * @see eina_value_list_append()
1801 * @see eina_value_list_vappend()
1802 * @see eina_value_list_pappend()
1803 *
1804 * @since 1.2
1805 */
1806static inline Eina_Bool eina_value_list_vinsert(Eina_Value *value,
1807 unsigned int position,
1808 va_list args) EINA_ARG_NONNULL(1);
1809
1810/**
1811 * @brief Append the generic value in an list.
1812 * @param value source value object
1813 * @param args variable argument
1814 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1815 * @see eina_value_list_set()
1816 * @see eina_value_list_get()
1817 * @see eina_value_list_vget()
1818 * @see eina_value_list_pset()
1819 * @see eina_value_list_insert()
1820 * @see eina_value_list_vinsert()
1821 * @see eina_value_list_pinsert()
1822 * @see eina_value_list_append()
1823 * @see eina_value_list_pappend()
1824 *
1825 * @since 1.2
1826 */
1827static inline Eina_Bool eina_value_list_vappend(Eina_Value *value,
1828 va_list args) EINA_ARG_NONNULL(1);
1829
1830
1831/**
1832 * @brief Set the generic value in an list member from pointer.
1833 * @param value source value object
1834 * @param position index of the member
1835 * @param ptr pointer to specify the contents.
1836 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1837 *
1838 * The pointer type is dependent on chosen value type. The list for
1839 * basic types:
1840 *
1841 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1842 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1843 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1844 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1845 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1846 * @li EINA_VALUE_TYPE_CHAR: char*
1847 * @li EINA_VALUE_TYPE_SHORT: short*
1848 * @li EINA_VALUE_TYPE_INT: int*
1849 * @li EINA_VALUE_TYPE_LONG: long*
1850 * @li EINA_VALUE_TYPE_INT64: int64_t*
1851 * @li EINA_VALUE_TYPE_FLOAT: float*
1852 * @li EINA_VALUE_TYPE_DOUBLE: double*
1853 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1854 * @li EINA_VALUE_TYPE_STRING: const char **
1855 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1856 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1857 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1858 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1859 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1860 *
1861 * @note the pointer contents are written using the size defined by
1862 * type. It can be larger than void* or uint64_t.
1863 *
1864 * @code
1865 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1866 * int x = 1234;
1867 *
1868 * eina_value_list_append(value, 1234);
1869 * eina_value_list_pset(value, 0, &x);
1870 * eina_value_list_pget(value, 0, &x);
1871 * eina_value_free(value);
1872 * @endcode
1873 *
1874 * @see eina_value_list_set()
1875 * @see eina_value_list_get()
1876 * @see eina_value_list_vset()
1877 * @see eina_value_list_insert()
1878 * @see eina_value_list_vinsert()
1879 * @see eina_value_list_pinsert()
1880 * @see eina_value_list_append()
1881 * @see eina_value_list_vappend()
1882 * @see eina_value_list_pappend()
1883 *
1884 * @since 1.2
1885 */
1886static inline Eina_Bool eina_value_list_pset(Eina_Value *value,
1887 unsigned int position,
1888 const void *ptr) EINA_ARG_NONNULL(1, 3);
1889
1890/**
1891 * @brief Get the generic value to pointer from an list member.
1892 * @param value source value object
1893 * @param position index of the member
1894 * @param ptr pointer to receive the contents.
1895 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1896 *
1897 * The value is returned in pointer contents, the actual value is
1898 * type-dependent, but usually it will be what is stored inside the
1899 * object. There shouldn't be any memory allocation, thus the contents
1900 * should @b not be freed.
1901 *
1902 * The pointer type is dependent on chosen value type. The list for
1903 * basic types:
1904 *
1905 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1906 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1907 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1908 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1909 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1910 * @li EINA_VALUE_TYPE_CHAR: char*
1911 * @li EINA_VALUE_TYPE_SHORT: short*
1912 * @li EINA_VALUE_TYPE_INT: int*
1913 * @li EINA_VALUE_TYPE_LONG: long*
1914 * @li EINA_VALUE_TYPE_INT64: int64_t*
1915 * @li EINA_VALUE_TYPE_FLOAT: float*
1916 * @li EINA_VALUE_TYPE_DOUBLE: double*
1917 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1918 * @li EINA_VALUE_TYPE_STRING: const char **
1919 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1920 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1921 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1922 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1923 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1924 *
1925 * @code
1926 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1927 * int x;
1928 *
1929 * eina_value_list_append(value, 1234);
1930 * eina_value_list_pget(value, 0, &x);
1931 * eina_value_free(value);
1932 * @endcode
1933 *
1934 * @see eina_value_list_set()
1935 * @see eina_value_list_vset()
1936 * @see eina_value_list_pset()
1937 *
1938 * @since 1.2
1939 */
1940static inline Eina_Bool eina_value_list_pget(const Eina_Value *value,
1941 unsigned int position,
1942 void *ptr) EINA_ARG_NONNULL(1, 3);
1943
1944/**
1945 * @brief Insert the generic value in an list member position from pointer.
1946 * @param value source value object
1947 * @param position index of the member
1948 * @param ptr pointer to specify the contents.
1949 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1950 *
1951 * The pointer type is dependent on chosen value type. The list for
1952 * basic types:
1953 *
1954 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
1955 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
1956 * @li EINA_VALUE_TYPE_UINT: unsigned int*
1957 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
1958 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
1959 * @li EINA_VALUE_TYPE_CHAR: char*
1960 * @li EINA_VALUE_TYPE_SHORT: short*
1961 * @li EINA_VALUE_TYPE_INT: int*
1962 * @li EINA_VALUE_TYPE_LONG: long*
1963 * @li EINA_VALUE_TYPE_INT64: int64_t*
1964 * @li EINA_VALUE_TYPE_FLOAT: float*
1965 * @li EINA_VALUE_TYPE_DOUBLE: double*
1966 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
1967 * @li EINA_VALUE_TYPE_STRING: const char **
1968 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
1969 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
1970 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
1971 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
1972 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
1973 *
1974 * @note the pointer contents are written using the size defined by
1975 * type. It can be larger than void* or uint64_t.
1976 *
1977 * @code
1978 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
1979 * int x = 1234;
1980 *
1981 * eina_value_list_pinsert(value, 0, &x);
1982 * eina_value_list_pget(value, 0, &x);
1983 * eina_value_free(value);
1984 * @endcode
1985 *
1986 * @see eina_value_list_set()
1987 * @see eina_value_list_get()
1988 * @see eina_value_list_vset()
1989 * @see eina_value_list_insert()
1990 * @see eina_value_list_vinsert()
1991 * @see eina_value_list_pinsert()
1992 * @see eina_value_list_append()
1993 * @see eina_value_list_vappend()
1994 * @see eina_value_list_pappend()
1995 *
1996 * @since 1.2
1997 */
1998static inline Eina_Bool eina_value_list_pinsert(Eina_Value *value,
1999 unsigned int position,
2000 const void *ptr) EINA_ARG_NONNULL(1);
2001
2002/**
2003 * @brief Append the generic value in an list from pointer.
2004 * @param value source value object
2005 * @param ptr pointer to specify the contents.
2006 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2007 *
2008 * The pointer type is dependent on chosen value type. The list for
2009 * basic types:
2010 *
2011 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2012 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2013 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2014 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2015 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2016 * @li EINA_VALUE_TYPE_CHAR: char*
2017 * @li EINA_VALUE_TYPE_SHORT: short*
2018 * @li EINA_VALUE_TYPE_INT: int*
2019 * @li EINA_VALUE_TYPE_LONG: long*
2020 * @li EINA_VALUE_TYPE_INT64: int64_t*
2021 * @li EINA_VALUE_TYPE_FLOAT: float*
2022 * @li EINA_VALUE_TYPE_DOUBLE: double*
2023 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2024 * @li EINA_VALUE_TYPE_STRING: const char **
2025 * @li EINA_VALUE_TYPE_LIST: Eina_Value_List*
2026 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2027 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2028 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2029 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2030 *
2031 * @note the pointer contents are written using the size defined by
2032 * type. It can be larger than void* or uint64_t.
2033 *
2034 * @code
2035 * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT);
2036 * int x = 1234;
2037 *
2038 * eina_value_list_pappend(value, &x);
2039 * eina_value_list_pget(value, 0, &x);
2040 * eina_value_free(value);
2041 * @endcode
2042 *
2043 * @see eina_value_list_set()
2044 * @see eina_value_list_get()
2045 * @see eina_value_list_vset()
2046 * @see eina_value_list_insert()
2047 * @see eina_value_list_vinsert()
2048 * @see eina_value_list_pinsert()
2049 * @see eina_value_list_append()
2050 * @see eina_value_list_vappend()
2051 * @see eina_value_list_pappend()
2052 *
2053 * @since 1.2
2054 */
2055static inline Eina_Bool eina_value_list_pappend(Eina_Value *value,
2056 const void *ptr) EINA_ARG_NONNULL(1);
2057
2058/**
2059 * @}
2060 */
2061
2062/**
2063 * @defgroup Eina_Value_Hash_Group Generic Value Hash management
2064 *
2065 * @{
2066 */
2067
2068/**
2069 * @typedef Eina_Value_Hash
2070 * Value type for #EINA_VALUE_TYPE_HASH
2071 *
2072 * @since 1.2
2073 */
2074typedef struct _Eina_Value_Hash Eina_Value_Hash;
2075
2076/**
2077 * @struct _Eina_Value_Hash
2078 * Used to store the hash and its subtype.
2079 */
2080struct _Eina_Value_Hash
2081{
2082 const Eina_Value_Type *subtype; /**< how to allocate and access items */
2083 unsigned int buckets_power_size; /**< how to allocate hash buckets, if zero a sane default is chosen. */
2084 Eina_Hash *hash; /**< the hash that holds data, members are of subtype->value_size bytes. */
2085};
2086
2087/**
2088 * @brief Create generic value storage of type hash.
2089 * @param subtype how to manage this hash members.
2090 * @param buckets_power_size how to allocate hash buckets (2 ^
2091 * buckets_power_size), if zero then a sane value is chosen.
2092 * @return The new value or @c NULL on failure.
2093 *
2094 * Create a new generic value storage of type hash. The members are
2095 * managed using the description specified by @a subtype.
2096 *
2097 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
2098 * #EINA_ERROR_VALUE_FAILED is set.
2099 *
2100 * @note this creates from mempool and then uses
2101 * eina_value_hash_setup().
2102 *
2103 * @see eina_value_free()
2104 * @see eina_value_hash_setup()
2105 *
2106 * @since 1.2
2107 */
2108EAPI Eina_Value *eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size) EINA_ARG_NONNULL(1);
2109
2110/**
2111 * @brief Initialize generic value storage of type hash.
2112 * @param value value object
2113 * @param subtype how to manage this hash members.
2114 * @param buckets_power_size how to allocate hash buckets (2 ^
2115 * buckets_power_size), if zero then a sane value is chosen.
2116 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2117 *
2118 * Initializes new generic value storage of type hash with the given
2119 * @a subtype.
2120 *
2121 * This is the same as calling eina_value_set() with
2122 * #EINA_VALUE_TYPE_HASH followed by eina_value_pset() with the
2123 * #Eina_Value_Hash description configured.
2124 *
2125 * @note Existing contents are ignored! If the value was previously used, then
2126 * use eina_value_flush() first.
2127 *
2128 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2129 * or #EINA_ERROR_VALUE_FAILED is set.
2130 *
2131 * @see eina_value_flush()
2132 *
2133 * @since 1.2
2134 */
2135static inline Eina_Bool eina_value_hash_setup(Eina_Value *value,
2136 const Eina_Value_Type *subtype,
2137 unsigned int buckets_power_size) EINA_ARG_NONNULL(1, 2);
2138
2139/**
2140 * @brief Query number of elements in value of hash type.
2141 * @param value value object.
2142 * @return number of child elements.
2143 * @since 1.2
2144 */
2145static inline unsigned int eina_value_hash_population(const Eina_Value *value);
2146
2147/**
2148 * @brief Remove element at given position in value of hash type.
2149 * @param value value object.
2150 * @param key key to find the member
2151 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2152 * @since 1.2
2153 */
2154static inline Eina_Bool eina_value_hash_del(Eina_Value *value,
2155 const char *key) EINA_ARG_NONNULL(1);
2156
2157/**
2158 * @brief Set the generic value in an hash member.
2159 * @param value source value object
2160 * @param key key to find the member
2161 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2162 *
2163 * The variable argument is dependent on chosen subtype. The list for
2164 * basic types:
2165 *
2166 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2167 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2168 * @li EINA_VALUE_TYPE_UINT: unsigned int
2169 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2170 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2171 * @li EINA_VALUE_TYPE_CHAR: char
2172 * @li EINA_VALUE_TYPE_SHORT: short
2173 * @li EINA_VALUE_TYPE_INT: int
2174 * @li EINA_VALUE_TYPE_LONG: long
2175 * @li EINA_VALUE_TYPE_INT64: int64_t
2176 * @li EINA_VALUE_TYPE_FLOAT: float
2177 * @li EINA_VALUE_TYPE_DOUBLE: double
2178 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
2179 * @li EINA_VALUE_TYPE_STRING: const char *
2180 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2181 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2182 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2183 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2184 *
2185 * @code
2186 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2187 * int x;
2188 *
2189 * eina_value_hash_set(value, "abc", 5678);
2190 * eina_value_hash_get(value, "abc", &x);
2191 * eina_value_free(value);
2192 * @endcode
2193 *
2194 * @see eina_value_hash_get()
2195 * @see eina_value_hash_vset()
2196 * @see eina_value_hash_pset()
2197 * @see eina_value_hash_del()
2198 *
2199 * @since 1.2
2200 */
2201static inline Eina_Bool eina_value_hash_set(Eina_Value *value,
2202 const char *key,
2203 ...) EINA_ARG_NONNULL(1);
2204
2205/**
2206 * @brief Get the generic value from an hash member.
2207 * @param value source value object
2208 * @param key key to find the member
2209 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2210 *
2211 * The value is returned in the variable argument parameter, the
2212 * actual value is type-dependent, but usually it will be what is
2213 * stored inside the object. There shouldn't be any memory allocation,
2214 * thus the contents should @b not be freed.
2215 *
2216 * The variable argument is dependent on chosen subtype. The list for
2217 * basic types:
2218 *
2219 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2220 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2221 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2222 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2223 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2224 * @li EINA_VALUE_TYPE_CHAR: char*
2225 * @li EINA_VALUE_TYPE_SHORT: short*
2226 * @li EINA_VALUE_TYPE_INT: int*
2227 * @li EINA_VALUE_TYPE_LONG: long*
2228 * @li EINA_VALUE_TYPE_INT64: int64_t*
2229 * @li EINA_VALUE_TYPE_FLOAT: float*
2230 * @li EINA_VALUE_TYPE_DOUBLE: double*
2231 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2232 * @li EINA_VALUE_TYPE_STRING: const char **
2233 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2234 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2235 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2236 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2237 *
2238 * @code
2239 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2240 * int x;
2241 *
2242 * eina_value_hash_set(value, "abc", 1234);
2243 * eina_value_hash_get(value, "abc", &x);
2244 * eina_value_free(value);
2245 * @endcode
2246 *
2247 * @see eina_value_hash_set()
2248 * @see eina_value_hash_vset()
2249 * @see eina_value_hash_pset()
2250 *
2251 * @since 1.2
2252 */
2253static inline Eina_Bool eina_value_hash_get(const Eina_Value *value,
2254 const char *key,
2255 ...) EINA_ARG_NONNULL(1);
2256
2257/**
2258 * @brief Set the generic value in an hash member.
2259 * @param value source value object
2260 * @param key key to find the member
2261 * @param args variable argument
2262 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2263 * @see eina_value_hash_set()
2264 * @see eina_value_hash_get()
2265 * @see eina_value_hash_pset()
2266 *
2267 * @since 1.2
2268 */
2269static inline Eina_Bool eina_value_hash_vset(Eina_Value *value,
2270 const char *key,
2271 va_list args) EINA_ARG_NONNULL(1);
2272
2273/**
2274 * @brief Get the generic value from an hash member.
2275 * @param value source value object
2276 * @param key key to find the member
2277 * @param args variable argument
2278 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2279 *
2280 * The value is returned in the variable argument parameter, the
2281 * actual value is type-dependent, but usually it will be what is
2282 * stored inside the object. There shouldn't be any memory allocation,
2283 * thus the contents should @b not be freed.
2284 *
2285 * @see eina_value_hash_vset()
2286 * @see eina_value_hash_get()
2287 * @see eina_value_hash_pget()
2288 *
2289 * @since 1.2
2290 */
2291static inline Eina_Bool eina_value_hash_vget(const Eina_Value *value,
2292 const char *key,
2293 va_list args) EINA_ARG_NONNULL(1);
2294
2295/**
2296 * @brief Set the generic value in an hash member from pointer.
2297 * @param value source value object
2298 * @param key key to find the member
2299 * @param ptr pointer to specify the contents.
2300 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2301 *
2302 * The pointer type is dependent on chosen value type. The list for
2303 * basic types:
2304 *
2305 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2306 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2307 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2308 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2309 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2310 * @li EINA_VALUE_TYPE_CHAR: char*
2311 * @li EINA_VALUE_TYPE_SHORT: short*
2312 * @li EINA_VALUE_TYPE_INT: int*
2313 * @li EINA_VALUE_TYPE_LONG: long*
2314 * @li EINA_VALUE_TYPE_INT64: int64_t*
2315 * @li EINA_VALUE_TYPE_FLOAT: float*
2316 * @li EINA_VALUE_TYPE_DOUBLE: double*
2317 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2318 * @li EINA_VALUE_TYPE_STRING: const char **
2319 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2320 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2321 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2322 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2323 *
2324 * @note the pointer contents are written using the size defined by
2325 * type. It can be larger than void* or uint64_t.
2326 *
2327 * @code
2328 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2329 * int x = 1234;
2330 *
2331 * eina_value_hash_pset(value, "abc", &x);
2332 * eina_value_hash_pget(value, "abc", &x);
2333 * eina_value_free(value);
2334 * @endcode
2335 *
2336 * @see eina_value_hash_set()
2337 * @see eina_value_hash_get()
2338 * @see eina_value_hash_vset()
2339 *
2340 * @since 1.2
2341 */
2342static inline Eina_Bool eina_value_hash_pset(Eina_Value *value,
2343 const char *key,
2344 const void *ptr) EINA_ARG_NONNULL(1, 3);
2345
2346/**
2347 * @brief Get the generic value to pointer from an hash member.
2348 * @param value source value object
2349 * @param key key to find the member
2350 * @param ptr pointer to receive the contents.
2351 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2352 *
2353 * The value is returned in pointer contents, the actual value is
2354 * type-dependent, but usually it will be what is stored inside the
2355 * object. There shouldn't be any memory allocation, thus the contents
2356 * should @b not be freed.
2357 *
2358 * The pointer type is dependent on chosen value type. The list for
2359 * basic types:
2360 *
2361 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2362 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2363 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2364 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2365 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2366 * @li EINA_VALUE_TYPE_CHAR: char*
2367 * @li EINA_VALUE_TYPE_SHORT: short*
2368 * @li EINA_VALUE_TYPE_INT: int*
2369 * @li EINA_VALUE_TYPE_LONG: long*
2370 * @li EINA_VALUE_TYPE_INT64: int64_t*
2371 * @li EINA_VALUE_TYPE_FLOAT: float*
2372 * @li EINA_VALUE_TYPE_DOUBLE: double*
2373 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2374 * @li EINA_VALUE_TYPE_STRING: const char **
2375 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2376 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2377 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2378 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2379 *
2380 * @code
2381 * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0);
2382 * int x;
2383 *
2384 * eina_value_hash_set(value, "abc", 1234);
2385 * eina_value_hash_pget(value, "abc", &x);
2386 * eina_value_free(value);
2387 * @endcode
2388 *
2389 * @see eina_value_hash_set()
2390 * @see eina_value_hash_vset()
2391 * @see eina_value_hash_pset()
2392 *
2393 * @since 1.2
2394 */
2395static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value,
2396 const char *key,
2397 void *ptr) EINA_ARG_NONNULL(1, 3);
2398
2399/**
2400 * @}
2401 */
2402
2403/**
2404 * @defgroup Eina_Value_Blob_Group Generic Value Blob management
2405 *
2406 * @{
2407 */
2408
2409/**
2410 * @typedef Eina_Value_Blob_Operations
2411 * How to manage blob. Any @c NULL callback is ignored.
2412 * @since 1.2
2413 */
2414typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations;
2415
2416/**
2417 * @struct _Eina_Value_Blob_Operations
2418 * How to manage blob. Any @c NULL callback is ignored.
2419 * @since 1.2
2420 */
2421struct _Eina_Value_Blob_Operations
2422{
2423#define EINA_VALUE_BLOB_OPERATIONS_VERSION (1)
2424 unsigned int version; /**< must be EINA_VALUE_BLOB_OPERATIONS_VERSION */
2425 void (*free)(const Eina_Value_Blob_Operations *ops, void *memory, size_t size);
2426 void *(*copy)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2427 int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2);
2428 char *(*to_string)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size);
2429};
2430
2431/**
2432 * @var EINA_VALUE_BLOB_OPERATIONS_MALLOC
2433 *
2434 * Assumes @c memory was create with malloc() and applies free() to it
2435 * during flush (Eina_Value_Blob_Operations::free). Copy is done with
2436 * malloc() as well.
2437 *
2438 * No compare or to_string are provided, defaults will be used.
2439 */
2440EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC;
2441
2442/**
2443 * @typedef Eina_Value_Blob
2444 * @since 1.2
2445 */
2446typedef struct _Eina_Value_Blob Eina_Value_Blob;
2447
2448/**
2449 * @struct _Eina_Value_Blob
2450 * @since 1.2
2451 */
2452struct _Eina_Value_Blob
2453{
2454 const Eina_Value_Blob_Operations *ops; /**< if @c NULL, nothing is freed, copy will just copy the memory pointer, not its value. */
2455 const void *memory;
2456 unsigned int size;
2457};
2458
2459/**
2460 * @}
2461 */
2462
2463/**
2464 * @defgroup Eina_Value_Struct_Group Generic Value Struct management
2465 *
2466 * @{
2467 */
2468
2469/**
2470 * @typedef Eina_Value_Struct_Operations
2471 * How to manage struct. Any @c NULL callback is ignored.
2472 * @since 1.2
2473 */
2474typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations;
2475
2476/**
2477 * @typedef Eina_Value_Struct_Member
2478 * Describes a single member of struct.
2479 * @since 1.2
2480 */
2481typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member;
2482
2483/**
2484 * @typedef Eina_Value_Struct_Desc
2485 * Describes the struct by listing its size, members and operations.
2486 * @since 1.2
2487 */
2488typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc;
2489
2490/**
2491 * @typedef Eina_Value_Struct
2492 * @since 1.2
2493 */
2494typedef struct _Eina_Value_Struct Eina_Value_Struct;
2495
2496/**
2497 * @struct _Eina_Value_Struct_Operations
2498 * How to manage struct. Any @c NULL callback is ignored.
2499 * @since 1.2
2500 */
2501struct _Eina_Value_Struct_Operations
2502{
2503#define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1)
2504 unsigned int version; /**< must be EINA_VALUE_STRUCT_OPERATIONS_VERSION */
2505 void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc);
2506 void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory);
2507 void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory);
2508 int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2);
2509 const Eina_Value_Struct_Member *(*find_member)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const char *name); /**< replace the function to find description for member. For huge structures consider using binary search, stringshared, hash or gperf. The default function does linear search using strcmp(). */
2510};
2511
2512/**
2513 * @var EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH
2514 *
2515 * Assumes @c members is sorted by name and applies binary search for
2516 * names.
2517 *
2518 * Ideally the @c member_count field is set to speed it up.
2519 *
2520 * No other methods are set (alloc, free, copy, compare), then it uses
2521 * the default operations.
2522 */
2523EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
2524
2525/**
2526 * @var EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE
2527 *
2528 * Assumes @c members name are stringshared and can be compared for
2529 * equality without using its contents (simple pointer comparison).
2530 *
2531 * Ideally the search @c name will be stringshared as well, but it
2532 * will do a second loop with a forced stringshare if it did not find
2533 * the member.
2534 *
2535 * No other methods are set (alloc, free, copy, compare), then it uses
2536 * the default operations.
2537 */
2538EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
2539
2540/**
2541 * @struct _Eina_Value_Struct_Member
2542 * @since 1.2
2543 */
2544struct _Eina_Value_Struct_Member
2545{
2546 const char *name;
2547 const Eina_Value_Type *type;
2548 unsigned int offset;
2549};
2550
2551/**
2552 * @struct _Eina_Value_Struct_Desc
2553 * @since 1.2
2554 */
2555struct _Eina_Value_Struct_Desc
2556{
2557#define EINA_VALUE_STRUCT_DESC_VERSION (1)
2558 unsigned int version; /**< must be EINA_VALUE_STRUCT_DESC_VERSION */
2559 const Eina_Value_Struct_Operations *ops; /**< operations, if @c NULL defaults will be used. You may use operations to optimize member lookup using binary search or gperf hash. */
2560 const Eina_Value_Struct_Member *members; /**< array of member descriptions, if @c member_count is zero, then it must be @c NULL terminated. */
2561 unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */
2562 unsigned int size; /**< byte size to allocate, may be bigger than sum of members */
2563};
2564
2565/**
2566 * @def EINA_VALUE_STRUCT_MEMBER
2567 *
2568 * Helper to define Eina_Value_Struct_Member fields, uses offsetof()
2569 * with type and member.
2570 *
2571 * @since 1.2
2572 */
2573#define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member) \
2574 {#member, eina_value_type, offsetof(type, member)}
2575
2576/**
2577 * @def EINA_VALUE_STRUCT_MEMBER_SENTINEL
2578 *
2579 * Helper to define Eina_Value_Struct_Member fields for sentinel (last
2580 * item), useful if you did not define @c member_count.
2581 *
2582 * @since 1.2
2583 */
2584#define EINA_VALUE_STRUCT_MEMBER_SENTINEL {NULL, NULL, 0}
2585
2586
2587/**
2588 * @struct _Eina_Value_Struct
2589 * @since 1.2
2590 */
2591struct _Eina_Value_Struct
2592{
2593 const Eina_Value_Struct_Desc *desc;
2594 void *memory;
2595};
2596
2597/**
2598 * @brief Create generic value storage of type struct.
2599 * @param desc how to manage this struct members.
2600 * @return The new value or @c NULL on failure.
2601 *
2602 * Create a new generic value storage of type struct. The members are
2603 * managed using the description specified by @a desc.
2604 *
2605 * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or
2606 * #EINA_ERROR_VALUE_FAILED is set.
2607 *
2608 * @note this creates from mempool and then uses
2609 * eina_value_struct_setup().
2610 *
2611 * @see eina_value_free()
2612 * @see eina_value_struct_setup()
2613 *
2614 * @since 1.2
2615 */
2616EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1);
2617
2618/**
2619 * @brief Initialize generic value storage of type struct.
2620 * @param value value object
2621 * @param desc how to manage this struct members.
2622 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2623 *
2624 * Initializes new generic value storage of type struct with the given
2625 * @a desc.
2626 *
2627 * This is the same as calling eina_value_set() with
2628 * #EINA_VALUE_TYPE_STRUCT followed by eina_value_pset() with the
2629 * #Eina_Value_Struct description configured.
2630 *
2631 * @note Existing contents are ignored! If the value was previously used, then
2632 * use eina_value_flush() first.
2633 *
2634 * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY
2635 * or #EINA_ERROR_VALUE_FAILED is set.
2636 *
2637 * @see eina_value_flush()
2638 *
2639 * @since 1.2
2640 */
2641static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
2642 const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2);
2643
2644/**
2645 * @brief Set the generic value in an struct member.
2646 * @param value source value object
2647 * @param name name to find the member
2648 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2649 *
2650 * The variable argument is dependent on chosen member type. The list
2651 * for basic types:
2652 *
2653 * @li EINA_VALUE_TYPE_UCHAR: unsigned char
2654 * @li EINA_VALUE_TYPE_USHORT: unsigned short
2655 * @li EINA_VALUE_TYPE_UINT: unsigned int
2656 * @li EINA_VALUE_TYPE_ULONG: unsigned long
2657 * @li EINA_VALUE_TYPE_UINT64: uint64_t
2658 * @li EINA_VALUE_TYPE_CHAR: char
2659 * @li EINA_VALUE_TYPE_SHORT: short
2660 * @li EINA_VALUE_TYPE_INT: int
2661 * @li EINA_VALUE_TYPE_LONG: long
2662 * @li EINA_VALUE_TYPE_INT64: int64_t
2663 * @li EINA_VALUE_TYPE_FLOAT: float
2664 * @li EINA_VALUE_TYPE_DOUBLE: double
2665 * @li EINA_VALUE_TYPE_STRINGSHARE: const char *
2666 * @li EINA_VALUE_TYPE_STRING: const char *
2667 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash
2668 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2669 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2670 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2671 *
2672 * @code
2673 * struct myst {
2674 * int i;
2675 * char c;
2676 * };
2677 * const Eina_Value_Struct_Member myst_members[] = {
2678 * {"i", EINA_VALUE_TYPE_INT, 0},
2679 * {"c", EINA_VALUE_TYPE_CHAR, 4},
2680 * {NULL, NULL, 0}
2681 * };
2682 * const Eina_Value_Struct_Desc myst_desc = {
2683 * EINA_VALUE_STRUCT_DESC_VERSION,
2684 * NULL, myst_members, 2, sizeof(struct myst)
2685 * };
2686 * Eina_Value *value = eina_value_struct_new(&my_desc);
2687 * int x;
2688 * char y;
2689 *
2690 * eina_value_struct_set(value, "i", 5678);
2691 * eina_value_struct_get(value, "i", &x);
2692 * eina_value_struct_set(value, "c", 0xf);
2693 * eina_value_struct_get(value, "c", &y);
2694 * eina_value_free(value);
2695 * @endcode
2696 *
2697 * @see eina_value_struct_get()
2698 * @see eina_value_struct_vset()
2699 * @see eina_value_struct_pset()
2700 *
2701 * @since 1.2
2702 */
2703static inline Eina_Bool eina_value_struct_set(Eina_Value *value,
2704 const char *name,
2705 ...) EINA_ARG_NONNULL(1);
2706
2707/**
2708 * @brief Get the generic value from an struct member.
2709 * @param value source value object
2710 * @param name name to find the member
2711 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2712 *
2713 * The value is returned in the variable argument parameter, the
2714 * actual value is type-dependent, but usually it will be what is
2715 * stored inside the object. There shouldn't be any memory allocation,
2716 * thus the contents should @b not be freed.
2717 *
2718 * The variable argument is dependent on chosen member type. The list
2719 * for basic types:
2720 *
2721 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2722 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2723 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2724 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2725 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2726 * @li EINA_VALUE_TYPE_CHAR: char*
2727 * @li EINA_VALUE_TYPE_SHORT: short*
2728 * @li EINA_VALUE_TYPE_INT: int*
2729 * @li EINA_VALUE_TYPE_LONG: long*
2730 * @li EINA_VALUE_TYPE_INT64: int64_t*
2731 * @li EINA_VALUE_TYPE_FLOAT: float*
2732 * @li EINA_VALUE_TYPE_DOUBLE: double*
2733 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2734 * @li EINA_VALUE_TYPE_STRING: const char **
2735 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2736 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2737 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2738 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2739 *
2740 * @code
2741 * struct myst {
2742 * int i;
2743 * char c;
2744 * };
2745 * const Eina_Value_Struct_Member myst_members[] = {
2746 * {"i", EINA_VALUE_TYPE_INT, 0},
2747 * {"c", EINA_VALUE_TYPE_CHAR, 4},
2748 * {NULL, NULL, 0}
2749 * };
2750 * const Eina_Value_Struct_Desc myst_desc = {
2751 * EINA_VALUE_STRUCT_DESC_VERSION,
2752 * NULL, myst_members, 2, sizeof(struct myst)
2753 * };
2754 * Eina_Value *value = eina_value_struct_new(&my_desc);
2755 * int x;
2756 * char y;
2757 *
2758 * eina_value_struct_set(value, "i", 5678);
2759 * eina_value_struct_get(value, "i", &x);
2760 * eina_value_struct_set(value, "c", 0xf);
2761 * eina_value_struct_get(value, "c", &y);
2762 * eina_value_free(value);
2763 * @endcode
2764 *
2765 * @see eina_value_struct_set()
2766 * @see eina_value_struct_vset()
2767 * @see eina_value_struct_pset()
2768 *
2769 * @since 1.2
2770 */
2771static inline Eina_Bool eina_value_struct_get(const Eina_Value *value,
2772 const char *name,
2773 ...) EINA_ARG_NONNULL(1);
2774
2775/**
2776 * @brief Set the generic value in an struct member.
2777 * @param value source value object
2778 * @param name name to find the member
2779 * @param args variable argument
2780 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2781 * @see eina_value_struct_set()
2782 * @see eina_value_struct_get()
2783 * @see eina_value_struct_pset()
2784 *
2785 * @since 1.2
2786 */
2787static inline Eina_Bool eina_value_struct_vset(Eina_Value *value,
2788 const char *name,
2789 va_list args) EINA_ARG_NONNULL(1);
2790
2791/**
2792 * @brief Get the generic value from an struct member.
2793 * @param value source value object
2794 * @param name name to find the member
2795 * @param args variable argument
2796 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2797 *
2798 * The value is returned in the variable argument parameter, the
2799 * actual value is type-dependent, but usually it will be what is
2800 * stored inside the object. There shouldn't be any memory allocation,
2801 * thus the contents should @b not be freed.
2802 *
2803 * @see eina_value_struct_vset()
2804 * @see eina_value_struct_get()
2805 * @see eina_value_struct_pget()
2806 *
2807 * @since 1.2
2808 */
2809static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value,
2810 const char *name,
2811 va_list args) EINA_ARG_NONNULL(1);
2812
2813/**
2814 * @brief Set the generic value in an struct member from pointer.
2815 * @param value source value object
2816 * @param name name to find the member
2817 * @param ptr pointer to specify the contents.
2818 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2819 *
2820 * The pointer type is dependent on chosen value type. The list for
2821 * basic types:
2822 *
2823 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2824 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2825 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2826 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2827 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2828 * @li EINA_VALUE_TYPE_CHAR: char*
2829 * @li EINA_VALUE_TYPE_SHORT: short*
2830 * @li EINA_VALUE_TYPE_INT: int*
2831 * @li EINA_VALUE_TYPE_LONG: long*
2832 * @li EINA_VALUE_TYPE_INT64: int64_t*
2833 * @li EINA_VALUE_TYPE_FLOAT: float*
2834 * @li EINA_VALUE_TYPE_DOUBLE: double*
2835 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2836 * @li EINA_VALUE_TYPE_STRING: const char **
2837 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2838 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2839 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2840 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2841 *
2842 * @note the pointer contents are written using the size defined by
2843 * type. It can be larger than void* or uint64_t.
2844 *
2845 * @code
2846 * struct myst {
2847 * int i;
2848 * char c;
2849 * };
2850 * const Eina_Value_Struct_Member myst_members[] = {
2851 * {"i", EINA_VALUE_TYPE_INT, 0},
2852 * {"c", EINA_VALUE_TYPE_CHAR, 4},
2853 * {NULL, NULL, 0}
2854 * };
2855 * const Eina_Value_Struct_Desc myst_desc = {
2856 * EINA_VALUE_STRUCT_DESC_VERSION,
2857 * NULL, myst_members, 2, sizeof(struct myst)
2858 * };
2859 * Eina_Value *value = eina_value_struct_new(&my_desc);
2860 * int x = 5678;
2861 * char y = 0xf;
2862 *
2863 * eina_value_struct_pset(value, "i", &);
2864 * eina_value_struct_pget(value, "i", &x);
2865 * eina_value_struct_pset(value, "c", &y);
2866 * eina_value_struct_pget(value, "c", &y);
2867 * eina_value_free(value);
2868 * @endcode
2869 *
2870 * @see eina_value_struct_set()
2871 * @see eina_value_struct_get()
2872 * @see eina_value_struct_vset()
2873 *
2874 * @since 1.2
2875 */
2876static inline Eina_Bool eina_value_struct_pset(Eina_Value *value,
2877 const char *name,
2878 const void *ptr) EINA_ARG_NONNULL(1, 3);
2879
2880/**
2881 * @brief Get the generic value to pointer from an struct member.
2882 * @param value source value object
2883 * @param name name to find the member
2884 * @param ptr pointer to receive the contents.
2885 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
2886 *
2887 * The value is returned in pointer contents, the actual value is
2888 * type-dependent, but usually it will be what is stored inside the
2889 * object. There shouldn't be any memory allocation, thus the contents
2890 * should @b not be freed.
2891 *
2892 * The pointer type is dependent on chosen value type. The list for
2893 * basic types:
2894 *
2895 * @li EINA_VALUE_TYPE_UCHAR: unsigned char*
2896 * @li EINA_VALUE_TYPE_USHORT: unsigned short*
2897 * @li EINA_VALUE_TYPE_UINT: unsigned int*
2898 * @li EINA_VALUE_TYPE_ULONG: unsigned long*
2899 * @li EINA_VALUE_TYPE_UINT64: uint64_t*
2900 * @li EINA_VALUE_TYPE_CHAR: char*
2901 * @li EINA_VALUE_TYPE_SHORT: short*
2902 * @li EINA_VALUE_TYPE_INT: int*
2903 * @li EINA_VALUE_TYPE_LONG: long*
2904 * @li EINA_VALUE_TYPE_INT64: int64_t*
2905 * @li EINA_VALUE_TYPE_FLOAT: float*
2906 * @li EINA_VALUE_TYPE_DOUBLE: double*
2907 * @li EINA_VALUE_TYPE_STRINGSHARE: const char **
2908 * @li EINA_VALUE_TYPE_STRING: const char **
2909 * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
2910 * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval*
2911 * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
2912 * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
2913 *
2914 * @code
2915 * struct myst {
2916 * int i;
2917 * char c;
2918 * };
2919 * const Eina_Value_Struct_Member myst_members[] = {
2920 * {"i", EINA_VALUE_TYPE_INT, 0},
2921 * {"c", EINA_VALUE_TYPE_CHAR, 4},
2922 * {NULL, NULL, 0}
2923 * };
2924 * const Eina_Value_Struct_Desc myst_desc = {
2925 * EINA_VALUE_STRUCT_DESC_VERSION,
2926 * NULL, myst_members, 2, sizeof(struct myst)
2927 * };
2928 * Eina_Value *value = eina_value_struct_new(&my_desc);
2929 * int x = 5678;
2930 * char y = 0xf;
2931 *
2932 * eina_value_struct_pset(value, "i", &);
2933 * eina_value_struct_pget(value, "i", &x);
2934 * eina_value_struct_pset(value, "c", &y);
2935 * eina_value_struct_pget(value, "c", &y);
2936 * eina_value_free(value);
2937 * @endcode
2938 *
2939 * @see eina_value_struct_set()
2940 * @see eina_value_struct_vset()
2941 * @see eina_value_struct_pset()
2942 *
2943 * @since 1.2
2944 */
2945static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
2946 const char *name,
2947 void *ptr) EINA_ARG_NONNULL(1, 3);
2948
2949/**
2950 * @}
2951 */
2952
2953
2954/**
2955 * @defgroup Eina_Value_Type_Group Generic Value Type management
2956 *
2957 * @{
2958 */
2959
2960/**
2961 * @struct _Eina_Value_Type
2962 * API to access values.
2963 *
2964 * @since 1.2
2965 */
2966struct _Eina_Value_Type
2967{
2968 /**
2969 * @def EINA_VALUE_TYPE_VERSION
2970 * Current API version, used to validate type.
2971 */
2972#define EINA_VALUE_TYPE_VERSION (1)
2973 unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */
2974 unsigned int value_size; /**< byte size of value */
2975 const char *name; /**< name for debug and introspection */
2976 Eina_Bool (*setup)(const Eina_Value_Type *type, void *mem); /**< mem will be malloc(value_size) and should be configured */
2977 Eina_Bool (*flush)(const Eina_Value_Type *type, void *mem); /**< clear any values from mem */
2978 Eina_Bool (*copy)(const Eina_Value_Type *type, const void *src, void *dst); /**< how to copy values, both memory are @c value_size */
2979 int (*compare)(const Eina_Value_Type *type, const void *a, const void *b); /**< how to compare values, both memory are @c value_size */
2980 Eina_Bool (*convert_to)(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); /**< how to convert values, both memory are @c value_size */
2981 Eina_Bool (*convert_from)(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); /**< how to convert values, both memory are @c value_size */
2982 Eina_Bool (*vset)(const Eina_Value_Type *type, void *mem, va_list args); /**< how to set memory from variable argument */
2983 Eina_Bool (*pset)(const Eina_Value_Type *type, void *mem, const void *ptr); /**< how to set memory from pointer */
2984 Eina_Bool (*pget)(const Eina_Value_Type *type, const void *mem, void *ptr); /**< how to read memory */
2985};
2986
2987/**
2988 * @brief Query type name.
2989 * @param type type reference.
2990 * @return string or @c NULL if type is invalid.
2991 * @since 1.2
2992 */
2993EAPI const char *eina_value_type_name_get(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
2994
2995/**
2996 * @brief Check if type is valid.
2997 * @param type type reference.
2998 * @return #EINA_TRUE if valid, #EINA_FALSE otherwise.
2999 *
3000 * A type is invalid if it's NULL or if version field is not the same
3001 * as runtime #EINA_VALUE_TYPE_VERSION.
3002 *
3003 * @since 1.2
3004 */
3005EAPI Eina_Bool eina_value_type_check(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
3006
3007/**
3008 * @brief Initialize memory using type descriptor.
3009 * @param type type reference.
3010 * @param mem memory to operate, must be of size @c type->value_size.
3011 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3012 * @since 1.2
3013 */
3014static inline Eina_Bool eina_value_type_setup(const Eina_Value_Type *type, void *mem);
3015
3016/**
3017 * @brief Flush (clear) memory using type descriptor.
3018 * @param type type reference.
3019 * @param mem memory to operate, must be of size @c type->value_size.
3020 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3021 * @since 1.2
3022 */
3023static inline Eina_Bool eina_value_type_flush(const Eina_Value_Type *type, void *mem);
3024
3025/**
3026 * @brief Copy memory using type descriptor.
3027 * @param type type reference.
3028 * @param src memory to operate, must be of size @c type->value_size.
3029 * @param dst memory to operate, must be of size @c type->value_size.
3030 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3031 * @since 1.2
3032 */
3033static inline Eina_Bool eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst);
3034
3035/**
3036 * @brief Compare memory using type descriptor.
3037 * @param type type reference.
3038 * @param a memory to operate, must be of size @c type->value_size.
3039 * @param b memory to operate, must be of size @c type->value_size.
3040 * @return less than zero if a < b, greater than zero if a > b, zero if equal.
3041 * @since 1.2
3042 */
3043static inline int eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b);
3044
3045/**
3046 * @brief Convert memory using type descriptor.
3047 * @param type type reference of the source.
3048 * @param convert type reference of the destination.
3049 * @param type_mem memory to operate, must be of size @c type->value_size.
3050 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3051 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3052 * @since 1.2
3053 */
3054static inline Eina_Bool eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem);
3055
3056/**
3057 * @brief Convert memory using type descriptor.
3058 * @param type type reference of the destination.
3059 * @param convert type reference of the source.
3060 * @param type_mem memory to operate, must be of size @c type->value_size.
3061 * @param convert_mem memory to operate, must be of size @c convert->value_size.
3062 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3063 * @since 1.2
3064 */
3065static inline Eina_Bool eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem);
3066
3067/**
3068 * @brief Set memory using type descriptor and variable argument.
3069 * @param type type reference of the source.
3070 * @param mem memory to operate, must be of size @c type->value_size.
3071 * @param args input value.
3072 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3073 * @since 1.2
3074 */
3075static inline Eina_Bool eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args);
3076
3077/**
3078 * @brief Set memory using type descriptor and pointer.
3079 * @param type type reference of the source.
3080 * @param mem memory to operate, must be of size @c type->value_size.
3081 * @param ptr pointer to input value.
3082 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3083 * @since 1.2
3084 */
3085static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr);
3086
3087/**
3088 * @brief Get memory using type descriptor.
3089 * @param type type reference of the source.
3090 * @param mem memory to operate, must be of size @c type->value_size.
3091 * @param ptr pointer to output.
3092 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
3093 * @since 1.2
3094 */
3095static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr);
3096
3097/**
3098 * @}
3099 */
3100
3101#include "eina_inline_value.x"
3102
3103/**
3104 * @}
3105 */
3106
3107/**
3108 * @}
3109 */
3110
3111/**
3112 * @}
3113 */
3114#endif
diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h
index 8ddb30a..0f89cc3 100644
--- a/libraries/eina/src/include/eina_xattr.h
+++ b/libraries/eina/src/include/eina_xattr.h
@@ -39,6 +39,14 @@ typedef enum {
39 EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */ 39 EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */
40} Eina_Xattr_Flags; 40} Eina_Xattr_Flags;
41 41
42typedef struct _Eina_Xattr Eina_Xattr;
43struct _Eina_Xattr
44{
45 const char *name; /**< The eXtended attribute name @since 1.2 */
46 const char *value; /**< The eXtended attribute value @since 1.2 */
47
48 size_t length; /**< The length of the eXtended attribute value @since 1.2 */
49};
42 50
43/** 51/**
44 * @brief Get an iterator that list all extended attribute of a file. 52 * @brief Get an iterator that list all extended attribute of a file.
@@ -54,10 +62,49 @@ typedef enum {
54EAPI Eina_Iterator *eina_xattr_ls(const char *file); 62EAPI Eina_Iterator *eina_xattr_ls(const char *file);
55 63
56/** 64/**
65 * @brief Get an iterator that list all extended attribute value related to a fd.
66 *
67 * @param file The filename to retrieve the extended attribute list from.
68 * @return an iterator.
69 *
70 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
71 * if you need. The iterator will provide an Eina_Xattr structure.
72 *
73 * @since 1.2
74 */
75EAPI Eina_Iterator *eina_xattr_value_ls(const char *file);
76
77/**
78 * @brief Get an iterator that list all extended attribute related to a fd.
79 *
80 * @param fd The file descriptor to retrieve the extended attribute list from.
81 * @return an iterator.
82 *
83 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
84 * if you need.
85 *
86 * @since 1.2
87 */
88EAPI Eina_Iterator *eina_xattr_fd_ls(int fd);
89
90/**
91 * @brief Get an iterator that list all extended attribute value related to a fd.
92 *
93 * @param fd The file descriptor to retrieve the extended attribute list from.
94 * @return an iterator.
95 *
96 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
97 * if you need. The iterator will provide an Eina_Xattr structure.
98 *
99 * @since 1.2
100 */
101EAPI Eina_Iterator *eina_xattr_value_fd_ls(int fd);
102
103/**
57 * @brief Retrieve an extended attribute from a file. 104 * @brief Retrieve an extended attribute from a file.
58 * 105 *
59 * @param file The file to retrieve the extended attribute from. 106 * @param file The file to retrieve the extended attribute from.
60 * @param atttribute The extended attribute name to retrieve. 107 * @param attribute The extended attribute name to retrieve.
61 * @param size The size of the retrieved extended attribute. 108 * @param size The size of the retrieved extended attribute.
62 * @return the allocated data that hold the extended attribute value. 109 * @return the allocated data that hold the extended attribute value.
63 * 110 *
@@ -112,7 +159,7 @@ EAPI char *eina_xattr_string_get(const char *file, const char *attribute);
112 * 159 *
113 * @param file The file to set the double to. 160 * @param file The file to set the double to.
114 * @param attribute The attribute to set. 161 * @param attribute The attribute to set.
115 * @param data The NULL terminated double to set. 162 * @param value The NULL terminated double to set.
116 * @param flags Define the set policy. 163 * @param flags Define the set policy.
117 * @return EINA_TRUE on success, EINA_FALSE otherwise. 164 * @return EINA_TRUE on success, EINA_FALSE otherwise.
118 * 165 *
@@ -139,7 +186,7 @@ EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, do
139 * 186 *
140 * @param file The file to set the int to. 187 * @param file The file to set the int to.
141 * @param attribute The attribute to set. 188 * @param attribute The attribute to set.
142 * @param data The NULL terminated int to set. 189 * @param value The NULL terminated int to set.
143 * @param flags Define the set policy. 190 * @param flags Define the set policy.
144 * @return EINA_TRUE on success, EINA_FALSE otherwise. 191 * @return EINA_TRUE on success, EINA_FALSE otherwise.
145 * 192 *
diff --git a/libraries/eina/src/lib/Makefile.am b/libraries/eina/src/lib/Makefile.am
index 0537a61..d8c9d20 100644
--- a/libraries/eina/src/lib/Makefile.am
+++ b/libraries/eina/src/lib/Makefile.am
@@ -22,6 +22,7 @@ eina_error.c \
22eina_fp.c \ 22eina_fp.c \
23eina_hamster.c \ 23eina_hamster.c \
24eina_hash.c \ 24eina_hash.c \
25eina_inarray.c \
25eina_inlist.c \ 26eina_inlist.c \
26eina_iterator.c \ 27eina_iterator.c \
27eina_lalloc.c \ 28eina_lalloc.c \
@@ -130,12 +131,17 @@ eina_amalgamation.c: $(base_sources) Makefile
130 @echo "#include <stdio.h>" >> eina_amalgamation.c 131 @echo "#include <stdio.h>" >> eina_amalgamation.c
131 @echo "#include <stdlib.h>" >> eina_amalgamation.c 132 @echo "#include <stdlib.h>" >> eina_amalgamation.c
132 @echo "#include <string.h>" >> eina_amalgamation.c 133 @echo "#include <string.h>" >> eina_amalgamation.c
133 @echo "#include <dlfcn.h>" >> eina_amalgamation.c 134 @echo "#ifdef HAVE_DLOPEN" >> eina_amalgamation.c
135 @echo "# include <dlfcn.h>" >> eina_amalgamation.c
136 @echo "#endif" >> eina_amalgamation.c
134 @echo "#include <sys/types.h>" >> eina_amalgamation.c 137 @echo "#include <sys/types.h>" >> eina_amalgamation.c
135 @echo "#include <dirent.h>" >> eina_amalgamation.c 138 @echo "#ifdef HAVE_DIRENT_H" >> eina_amalgamation.c
139 @echo "# include <dirent.h>" >> eina_amalgamation.c
140 @echo "#endif" >> eina_amalgamation.c
136 @echo "#include <assert.h>" >> eina_amalgamation.c 141 @echo "#include <assert.h>" >> eina_amalgamation.c
137 @echo "#include <errno.h>" >> eina_amalgamation.c 142 @echo "#include <errno.h>" >> eina_amalgamation.c
138 @echo "#include <fnmatch.h>" >> eina_amalgamation.c 143 @echo "#include <fnmatch.h>" >> eina_amalgamation.c
144 @echo "#include <fcntl.h>" >> eina_amalgamation.c
139 145
140 @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c 146 @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c
141 @echo "# include <Evil.h>" >> eina_amalgamation.c 147 @echo "# include <Evil.h>" >> eina_amalgamation.c
diff --git a/libraries/eina/src/lib/Makefile.in b/libraries/eina/src/lib/Makefile.in
index 359aba0..878bcbe 100644
--- a/libraries/eina/src/lib/Makefile.in
+++ b/libraries/eina/src/lib/Makefile.in
@@ -96,15 +96,16 @@ libeina_la_DEPENDENCIES =
96am__libeina_la_SOURCES_DIST = eina_accessor.c eina_array.c \ 96am__libeina_la_SOURCES_DIST = eina_accessor.c eina_array.c \
97 eina_benchmark.c eina_binbuf.c eina_binshare.c eina_convert.c \ 97 eina_benchmark.c eina_binbuf.c eina_binshare.c eina_convert.c \
98 eina_counter.c eina_cpu.c eina_error.c eina_fp.c \ 98 eina_counter.c eina_cpu.c eina_error.c eina_fp.c \
99 eina_hamster.c eina_hash.c eina_inlist.c eina_iterator.c \ 99 eina_hamster.c eina_hash.c eina_inarray.c eina_inlist.c \
100 eina_lalloc.c eina_list.c eina_log.c eina_magic.c eina_main.c \ 100 eina_iterator.c eina_lalloc.c eina_list.c eina_log.c \
101 eina_matrixsparse.c eina_mempool.c eina_mmap.c eina_module.c \ 101 eina_magic.c eina_main.c eina_matrixsparse.c eina_mempool.c \
102 eina_prefix.c eina_quadtree.c eina_rbtree.c eina_rectangle.c \ 102 eina_mmap.c eina_module.c eina_prefix.c eina_quadtree.c \
103 eina_safety_checks.c eina_sched.c eina_share_common.c \ 103 eina_rbtree.c eina_rectangle.c eina_safety_checks.c \
104 eina_simple_xml_parser.c eina_str.c eina_strbuf.c \ 104 eina_sched.c eina_share_common.c eina_simple_xml_parser.c \
105 eina_strbuf_common.c eina_stringshare.c eina_tiler.c \ 105 eina_str.c eina_strbuf.c eina_strbuf_common.c \
106 eina_unicode.c eina_ustrbuf.c eina_ustringshare.c eina_value.c \ 106 eina_stringshare.c eina_tiler.c eina_unicode.c eina_ustrbuf.c \
107 eina_xattr.c eina_file_win32.c eina_file.c \ 107 eina_ustringshare.c eina_value.c eina_xattr.c \
108 eina_file_win32.c eina_file.c \
108 $(top_srcdir)/src/modules/mp/buddy/eina_buddy.c \ 109 $(top_srcdir)/src/modules/mp/buddy/eina_buddy.c \
109 $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c \ 110 $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c \
110 $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c \ 111 $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c \
@@ -129,15 +130,16 @@ am__objects_10 = libeina_la-eina_accessor.lo libeina_la-eina_array.lo \
129 libeina_la-eina_counter.lo libeina_la-eina_cpu.lo \ 130 libeina_la-eina_counter.lo libeina_la-eina_cpu.lo \
130 libeina_la-eina_error.lo libeina_la-eina_fp.lo \ 131 libeina_la-eina_error.lo libeina_la-eina_fp.lo \
131 libeina_la-eina_hamster.lo libeina_la-eina_hash.lo \ 132 libeina_la-eina_hamster.lo libeina_la-eina_hash.lo \
132 libeina_la-eina_inlist.lo libeina_la-eina_iterator.lo \ 133 libeina_la-eina_inarray.lo libeina_la-eina_inlist.lo \
133 libeina_la-eina_lalloc.lo libeina_la-eina_list.lo \ 134 libeina_la-eina_iterator.lo libeina_la-eina_lalloc.lo \
134 libeina_la-eina_log.lo libeina_la-eina_magic.lo \ 135 libeina_la-eina_list.lo libeina_la-eina_log.lo \
135 libeina_la-eina_main.lo libeina_la-eina_matrixsparse.lo \ 136 libeina_la-eina_magic.lo libeina_la-eina_main.lo \
136 libeina_la-eina_mempool.lo libeina_la-eina_mmap.lo \ 137 libeina_la-eina_matrixsparse.lo libeina_la-eina_mempool.lo \
137 libeina_la-eina_module.lo libeina_la-eina_prefix.lo \ 138 libeina_la-eina_mmap.lo libeina_la-eina_module.lo \
138 libeina_la-eina_quadtree.lo libeina_la-eina_rbtree.lo \ 139 libeina_la-eina_prefix.lo libeina_la-eina_quadtree.lo \
139 libeina_la-eina_rectangle.lo libeina_la-eina_safety_checks.lo \ 140 libeina_la-eina_rbtree.lo libeina_la-eina_rectangle.lo \
140 libeina_la-eina_sched.lo libeina_la-eina_share_common.lo \ 141 libeina_la-eina_safety_checks.lo libeina_la-eina_sched.lo \
142 libeina_la-eina_share_common.lo \
141 libeina_la-eina_simple_xml_parser.lo libeina_la-eina_str.lo \ 143 libeina_la-eina_simple_xml_parser.lo libeina_la-eina_str.lo \
142 libeina_la-eina_strbuf.lo libeina_la-eina_strbuf_common.lo \ 144 libeina_la-eina_strbuf.lo libeina_la-eina_strbuf_common.lo \
143 libeina_la-eina_stringshare.lo libeina_la-eina_tiler.lo \ 145 libeina_la-eina_stringshare.lo libeina_la-eina_tiler.lo \
@@ -231,7 +233,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
231EGREP = @EGREP@ 233EGREP = @EGREP@
232EINA_CFLAGS = @EINA_CFLAGS@ 234EINA_CFLAGS = @EINA_CFLAGS@
233EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 235EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
236EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
234EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 237EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
238EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
235EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 239EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
236EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 240EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
237EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 241EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -283,8 +287,6 @@ PACKAGE_URL = @PACKAGE_URL@
283PACKAGE_VERSION = @PACKAGE_VERSION@ 287PACKAGE_VERSION = @PACKAGE_VERSION@
284PATH_SEPARATOR = @PATH_SEPARATOR@ 288PATH_SEPARATOR = @PATH_SEPARATOR@
285PKG_CONFIG = @PKG_CONFIG@ 289PKG_CONFIG = @PKG_CONFIG@
286PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
287PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
288RANLIB = @RANLIB@ 290RANLIB = @RANLIB@
289SED = @SED@ 291SED = @SED@
290SET_MAKE = @SET_MAKE@ 292SET_MAKE = @SET_MAKE@
@@ -371,10 +373,10 @@ AM_CPPFLAGS = \
371base_sources = eina_accessor.c eina_array.c eina_benchmark.c \ 373base_sources = eina_accessor.c eina_array.c eina_benchmark.c \
372 eina_binbuf.c eina_binshare.c eina_convert.c eina_counter.c \ 374 eina_binbuf.c eina_binshare.c eina_convert.c eina_counter.c \
373 eina_cpu.c eina_error.c eina_fp.c eina_hamster.c eina_hash.c \ 375 eina_cpu.c eina_error.c eina_fp.c eina_hamster.c eina_hash.c \
374 eina_inlist.c eina_iterator.c eina_lalloc.c eina_list.c \ 376 eina_inarray.c eina_inlist.c eina_iterator.c eina_lalloc.c \
375 eina_log.c eina_magic.c eina_main.c eina_matrixsparse.c \ 377 eina_list.c eina_log.c eina_magic.c eina_main.c \
376 eina_mempool.c eina_mmap.c eina_module.c eina_prefix.c \ 378 eina_matrixsparse.c eina_mempool.c eina_mmap.c eina_module.c \
377 eina_quadtree.c eina_rbtree.c eina_rectangle.c \ 379 eina_prefix.c eina_quadtree.c eina_rbtree.c eina_rectangle.c \
378 eina_safety_checks.c eina_sched.c eina_share_common.c \ 380 eina_safety_checks.c eina_sched.c eina_share_common.c \
379 eina_simple_xml_parser.c eina_str.c eina_strbuf.c \ 381 eina_simple_xml_parser.c eina_str.c eina_strbuf.c \
380 eina_strbuf_common.c eina_stringshare.c eina_tiler.c \ 382 eina_strbuf_common.c eina_stringshare.c eina_tiler.c \
@@ -489,6 +491,7 @@ distclean-compile:
489@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_fp.Plo@am__quote@ 491@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_fp.Plo@am__quote@
490@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_hamster.Plo@am__quote@ 492@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_hamster.Plo@am__quote@
491@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_hash.Plo@am__quote@ 493@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_hash.Plo@am__quote@
494@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_inarray.Plo@am__quote@
492@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_inlist.Plo@am__quote@ 495@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_inlist.Plo@am__quote@
493@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_iterator.Plo@am__quote@ 496@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_iterator.Plo@am__quote@
494@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_lalloc.Plo@am__quote@ 497@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeina_la-eina_lalloc.Plo@am__quote@
@@ -641,6 +644,14 @@ libeina_la-eina_hash.lo: eina_hash.c
641@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 644@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
642@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -c -o libeina_la-eina_hash.lo `test -f 'eina_hash.c' || echo '$(srcdir)/'`eina_hash.c 645@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -c -o libeina_la-eina_hash.lo `test -f 'eina_hash.c' || echo '$(srcdir)/'`eina_hash.c
643 646
647libeina_la-eina_inarray.lo: eina_inarray.c
648@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -MT libeina_la-eina_inarray.lo -MD -MP -MF $(DEPDIR)/libeina_la-eina_inarray.Tpo -c -o libeina_la-eina_inarray.lo `test -f 'eina_inarray.c' || echo '$(srcdir)/'`eina_inarray.c
649@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeina_la-eina_inarray.Tpo $(DEPDIR)/libeina_la-eina_inarray.Plo
650@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
651@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eina_inarray.c' object='libeina_la-eina_inarray.lo' libtool=yes @AMDEPBACKSLASH@
652@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
653@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -c -o libeina_la-eina_inarray.lo `test -f 'eina_inarray.c' || echo '$(srcdir)/'`eina_inarray.c
654
644libeina_la-eina_inlist.lo: eina_inlist.c 655libeina_la-eina_inlist.lo: eina_inlist.c
645@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -MT libeina_la-eina_inlist.lo -MD -MP -MF $(DEPDIR)/libeina_la-eina_inlist.Tpo -c -o libeina_la-eina_inlist.lo `test -f 'eina_inlist.c' || echo '$(srcdir)/'`eina_inlist.c 656@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeina_la_CFLAGS) $(CFLAGS) -MT libeina_la-eina_inlist.lo -MD -MP -MF $(DEPDIR)/libeina_la-eina_inlist.Tpo -c -o libeina_la-eina_inlist.lo `test -f 'eina_inlist.c' || echo '$(srcdir)/'`eina_inlist.c
646@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeina_la-eina_inlist.Tpo $(DEPDIR)/libeina_la-eina_inlist.Plo 657@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeina_la-eina_inlist.Tpo $(DEPDIR)/libeina_la-eina_inlist.Plo
@@ -1189,12 +1200,17 @@ uninstall-am: uninstall-libLTLIBRARIES
1189@EINA_AMALGAMATION_TRUE@ @echo "#include <stdio.h>" >> eina_amalgamation.c 1200@EINA_AMALGAMATION_TRUE@ @echo "#include <stdio.h>" >> eina_amalgamation.c
1190@EINA_AMALGAMATION_TRUE@ @echo "#include <stdlib.h>" >> eina_amalgamation.c 1201@EINA_AMALGAMATION_TRUE@ @echo "#include <stdlib.h>" >> eina_amalgamation.c
1191@EINA_AMALGAMATION_TRUE@ @echo "#include <string.h>" >> eina_amalgamation.c 1202@EINA_AMALGAMATION_TRUE@ @echo "#include <string.h>" >> eina_amalgamation.c
1192@EINA_AMALGAMATION_TRUE@ @echo "#include <dlfcn.h>" >> eina_amalgamation.c 1203@EINA_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_DLOPEN" >> eina_amalgamation.c
1204@EINA_AMALGAMATION_TRUE@ @echo "# include <dlfcn.h>" >> eina_amalgamation.c
1205@EINA_AMALGAMATION_TRUE@ @echo "#endif" >> eina_amalgamation.c
1193@EINA_AMALGAMATION_TRUE@ @echo "#include <sys/types.h>" >> eina_amalgamation.c 1206@EINA_AMALGAMATION_TRUE@ @echo "#include <sys/types.h>" >> eina_amalgamation.c
1194@EINA_AMALGAMATION_TRUE@ @echo "#include <dirent.h>" >> eina_amalgamation.c 1207@EINA_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_DIRENT_H" >> eina_amalgamation.c
1208@EINA_AMALGAMATION_TRUE@ @echo "# include <dirent.h>" >> eina_amalgamation.c
1209@EINA_AMALGAMATION_TRUE@ @echo "#endif" >> eina_amalgamation.c
1195@EINA_AMALGAMATION_TRUE@ @echo "#include <assert.h>" >> eina_amalgamation.c 1210@EINA_AMALGAMATION_TRUE@ @echo "#include <assert.h>" >> eina_amalgamation.c
1196@EINA_AMALGAMATION_TRUE@ @echo "#include <errno.h>" >> eina_amalgamation.c 1211@EINA_AMALGAMATION_TRUE@ @echo "#include <errno.h>" >> eina_amalgamation.c
1197@EINA_AMALGAMATION_TRUE@ @echo "#include <fnmatch.h>" >> eina_amalgamation.c 1212@EINA_AMALGAMATION_TRUE@ @echo "#include <fnmatch.h>" >> eina_amalgamation.c
1213@EINA_AMALGAMATION_TRUE@ @echo "#include <fcntl.h>" >> eina_amalgamation.c
1198 1214
1199@EINA_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c 1215@EINA_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c
1200@EINA_AMALGAMATION_TRUE@ @echo "# include <Evil.h>" >> eina_amalgamation.c 1216@EINA_AMALGAMATION_TRUE@ @echo "# include <Evil.h>" >> eina_amalgamation.c
diff --git a/libraries/eina/src/lib/eina_array.c b/libraries/eina/src/lib/eina_array.c
index 5a850ac..4bcab61 100644
--- a/libraries/eina/src/lib/eina_array.c
+++ b/libraries/eina/src/lib/eina_array.c
@@ -119,7 +119,7 @@ eina_array_iterator_next(Eina_Iterator_Array *it, void **data)
119{ 119{
120 EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE); 120 EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE);
121 121
122 if (!(it->index < eina_array_count_get(it->array))) 122 if (!(it->index < eina_array_count(it->array)))
123 return EINA_FALSE; 123 return EINA_FALSE;
124 124
125 if (data) 125 if (data)
@@ -150,7 +150,7 @@ eina_array_accessor_get_at(Eina_Accessor_Array *it,
150{ 150{
151 EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE); 151 EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE);
152 152
153 if (!(idx < eina_array_count_get(it->array))) 153 if (!(idx < eina_array_count(it->array)))
154 return EINA_FALSE; 154 return EINA_FALSE;
155 155
156 if (data) 156 if (data)
diff --git a/libraries/eina/src/lib/eina_binbuf_template_c.x b/libraries/eina/src/lib/eina_binbuf_template_c.x
index 613a715..7e0c539 100644
--- a/libraries/eina/src/lib/eina_binbuf_template_c.x
+++ b/libraries/eina/src/lib/eina_binbuf_template_c.x
@@ -65,6 +65,15 @@ _FUNC_EXPAND(new)(void)
65 return buf; 65 return buf;
66} 66}
67 67
68EAPI _STRBUF_STRUCT_NAME *
69_FUNC_EXPAND(manage_new_length)(_STRBUF_DATA_TYPE *str, size_t length)
70{
71 _STRBUF_STRUCT_NAME *buf =
72 eina_strbuf_common_manage_new(_STRBUF_CSIZE, (void *) str, length);
73 EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
74 return buf;
75}
76
68EAPI void 77EAPI void
69_FUNC_EXPAND(free)(_STRBUF_STRUCT_NAME *buf) 78_FUNC_EXPAND(free)(_STRBUF_STRUCT_NAME *buf)
70{ 79{
diff --git a/libraries/eina/src/lib/eina_cpu.c b/libraries/eina/src/lib/eina_cpu.c
index 8af550d..5b190e4 100644
--- a/libraries/eina/src/lib/eina_cpu.c
+++ b/libraries/eina/src/lib/eina_cpu.c
@@ -24,7 +24,7 @@
24# ifdef _WIN32 24# ifdef _WIN32
25# define WIN32_LEAN_AND_MEAN 25# define WIN32_LEAN_AND_MEAN
26# include <windows.h> 26# include <windows.h>
27# elif defined (__SUNPRO_C) || defined(__GNU__) 27# elif defined (__sun) || defined(__GNU__)
28# include <unistd.h> 28# include <unistd.h>
29# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \ 29# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
30 defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \ 30 defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
@@ -140,7 +140,7 @@ EAPI int eina_cpu_count(void)
140 GetSystemInfo(&sysinfo); 140 GetSystemInfo(&sysinfo);
141 return sysinfo.dwNumberOfProcessors; 141 return sysinfo.dwNumberOfProcessors;
142 142
143# elif defined (__SUNPRO_C) || defined(__GNU__) 143# elif defined (__sun) || defined(__GNU__)
144 /* 144 /*
145 * _SC_NPROCESSORS_ONLN: number of processors that are online, that 145 * _SC_NPROCESSORS_ONLN: number of processors that are online, that
146 is available when sysconf is called. The number 146 is available when sysconf is called. The number
diff --git a/libraries/eina/src/lib/eina_file.c b/libraries/eina/src/lib/eina_file.c
index 84b9e78..0b836b3 100644
--- a/libraries/eina/src/lib/eina_file.c
+++ b/libraries/eina/src/lib/eina_file.c
@@ -38,13 +38,18 @@ extern "C"
38void *alloca (size_t); 38void *alloca (size_t);
39#endif 39#endif
40 40
41#include <stdlib.h>
41#include <string.h> 42#include <string.h>
42#include <stddef.h> 43#include <stddef.h>
43#include <dirent.h> 44#ifdef HAVE_DIRENT_H
45# include <dirent.h>
46#endif
44#include <sys/types.h> 47#include <sys/types.h>
45#include <sys/stat.h> 48#include <sys/stat.h>
46#include <unistd.h> 49#include <unistd.h>
47#include <sys/mman.h> 50#ifdef HAVE_SYS_MMAN_H
51# include <sys/mman.h>
52#endif
48#include <fcntl.h> 53#include <fcntl.h>
49 54
50#define PATH_DELIM '/' 55#define PATH_DELIM '/'
@@ -60,6 +65,8 @@ void *alloca (size_t);
60#include "eina_list.h" 65#include "eina_list.h"
61#include "eina_lock.h" 66#include "eina_lock.h"
62#include "eina_mmap.h" 67#include "eina_mmap.h"
68#include "eina_log.h"
69#include "eina_xattr.h"
63 70
64#ifdef HAVE_ESCAPE_H 71#ifdef HAVE_ESCAPE_H
65# include <Escape.h> 72# include <Escape.h>
@@ -95,9 +102,8 @@ void *alloca (size_t);
95#define EINA_SMALL_PAGE 4096 102#define EINA_SMALL_PAGE 4096
96# define EINA_HUGE_PAGE 16 * 1024 * 1024 103# define EINA_HUGE_PAGE 16 * 1024 * 1024
97 104
105#ifdef HAVE_DIRENT_H
98typedef struct _Eina_File_Iterator Eina_File_Iterator; 106typedef struct _Eina_File_Iterator Eina_File_Iterator;
99typedef struct _Eina_File_Map Eina_File_Map;
100
101struct _Eina_File_Iterator 107struct _Eina_File_Iterator
102{ 108{
103 Eina_Iterator iterator; 109 Eina_Iterator iterator;
@@ -107,6 +113,7 @@ struct _Eina_File_Iterator
107 113
108 char dir[1]; 114 char dir[1];
109}; 115};
116#endif
110 117
111struct _Eina_File 118struct _Eina_File
112{ 119{
@@ -132,8 +139,10 @@ struct _Eina_File
132 139
133 Eina_Bool shared : 1; 140 Eina_Bool shared : 1;
134 Eina_Bool delete_me : 1; 141 Eina_Bool delete_me : 1;
142 Eina_Bool global_faulty : 1;
135}; 143};
136 144
145typedef struct _Eina_File_Map Eina_File_Map;
137struct _Eina_File_Map 146struct _Eina_File_Map
138{ 147{
139 void *map; 148 void *map;
@@ -144,6 +153,7 @@ struct _Eina_File_Map
144 int refcount; 153 int refcount;
145 154
146 Eina_Bool hugetlb : 1; 155 Eina_Bool hugetlb : 1;
156 Eina_Bool faulty : 1;
147}; 157};
148 158
149static Eina_Hash *_eina_file_cache = NULL; 159static Eina_Hash *_eina_file_cache = NULL;
@@ -156,6 +166,7 @@ static int _eina_file_log_dom = -1;
156 * The code and description of the issue can be found at : 166 * The code and description of the issue can be found at :
157 * http://womble.decadent.org.uk/readdir_r-advisory.html 167 * http://womble.decadent.org.uk/readdir_r-advisory.html
158 */ 168 */
169#ifdef HAVE_DIRENT_H
159static long 170static long
160_eina_name_max(DIR *dirp) 171_eina_name_max(DIR *dirp)
161{ 172{
@@ -390,6 +401,7 @@ _eina_file_stat_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
390 401
391 return EINA_TRUE; 402 return EINA_TRUE;
392} 403}
404#endif
393 405
394static void 406static void
395_eina_file_real_close(Eina_File *file) 407_eina_file_real_close(Eina_File *file)
@@ -511,8 +523,8 @@ slprintf(char *str, size_t size, const char *format, ...)
511 va_end(ap); 523 va_end(ap);
512} 524}
513 525
514static char* 526static char *
515_eina_file_escape(const char* path, int* length) 527_eina_file_escape(const char *path, int *length)
516{ 528{
517 char *result = strdup(path ? path : ""); 529 char *result = strdup(path ? path : "");
518 char *p = result; 530 char *p = result;
@@ -738,6 +750,7 @@ eina_file_split(char *path)
738EAPI Eina_Iterator * 750EAPI Eina_Iterator *
739eina_file_ls(const char *dir) 751eina_file_ls(const char *dir)
740{ 752{
753#ifdef HAVE_DIRENT_H
741 Eina_File_Iterator *it; 754 Eina_File_Iterator *it;
742 size_t length; 755 size_t length;
743 756
@@ -773,11 +786,16 @@ eina_file_ls(const char *dir)
773 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free); 786 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free);
774 787
775 return &it->iterator; 788 return &it->iterator;
789#else
790 (void) dir;
791 return NULL;
792#endif
776} 793}
777 794
778EAPI Eina_Iterator * 795EAPI Eina_Iterator *
779eina_file_direct_ls(const char *dir) 796eina_file_direct_ls(const char *dir)
780{ 797{
798#ifdef HAVE_DIRENT_H
781 Eina_File_Direct_Iterator *it; 799 Eina_File_Direct_Iterator *it;
782 size_t length; 800 size_t length;
783 801
@@ -825,11 +843,16 @@ eina_file_direct_ls(const char *dir)
825 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free); 843 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
826 844
827 return &it->iterator; 845 return &it->iterator;
846#else
847 (void) dir;
848 return NULL;
849#endif
828} 850}
829 851
830EAPI Eina_Iterator * 852EAPI Eina_Iterator *
831eina_file_stat_ls(const char *dir) 853eina_file_stat_ls(const char *dir)
832{ 854{
855#ifdef HAVE_DIRENT_H
833 Eina_File_Direct_Iterator *it; 856 Eina_File_Direct_Iterator *it;
834 size_t length; 857 size_t length;
835 858
@@ -877,6 +900,10 @@ eina_file_stat_ls(const char *dir)
877 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free); 900 it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
878 901
879 return &it->iterator; 902 return &it->iterator;
903#else
904 (void) dir;
905 return NULL;
906#endif
880} 907}
881 908
882EAPI Eina_File * 909EAPI Eina_File *
@@ -887,7 +914,9 @@ eina_file_open(const char *path, Eina_Bool shared)
887 char *filename; 914 char *filename;
888 struct stat file_stat; 915 struct stat file_stat;
889 int fd = -1; 916 int fd = -1;
917#ifdef HAVE_EXECVP
890 int flags; 918 int flags;
919#endif
891 920
892 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL); 921 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
893 922
@@ -1184,4 +1213,91 @@ eina_file_map_free(Eina_File *file, void *map)
1184 eina_lock_release(&file->lock); 1213 eina_lock_release(&file->lock);
1185} 1214}
1186 1215
1216EAPI Eina_Bool
1217eina_file_map_faulted(Eina_File *file, void *map)
1218{
1219 Eina_File_Map *em;
1220
1221 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
1222
1223 eina_lock_take(&file->lock);
1224
1225 if (file->global_map == map) return file->global_faulty;
1226
1227 em = eina_hash_find(file->rmap, &map);
1228 if (!em) return EINA_FALSE;
1229
1230 return em->faulty;
1231}
1232
1233EAPI Eina_Iterator *
1234eina_file_xattr_get(Eina_File *file)
1235{
1236 EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
1237
1238 return eina_xattr_fd_ls(file->fd);
1239}
1240
1241EAPI Eina_Iterator *
1242eina_file_xattr_value_get(Eina_File *file)
1243{
1244 EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
1245
1246 return eina_xattr_value_fd_ls(file->fd);
1247}
1248
1249void
1250eina_file_mmap_faulty(void *addr, long page_size)
1251{
1252 Eina_File_Map *m;
1253 Eina_File *f;
1254 Eina_Iterator *itf;
1255 Eina_Iterator *itm;
1256
1257 /* NOTE: I actually don't know if other thread are running, I will try to take the lock.
1258 It may be possible that if other thread are not running and they were in the middle of
1259 accessing an Eina_File this lock are still taken and we will result as a deadlock. */
1260 eina_lock_take(&_eina_file_lock_cache);
1261
1262 itf = eina_hash_iterator_data_new(_eina_file_cache);
1263 EINA_ITERATOR_FOREACH(itf, f)
1264 {
1265 Eina_Bool faulty = EINA_FALSE;
1266
1267 eina_lock_take(&f->lock);
1268
1269 if (f->global_map)
1270 {
1271 if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) &&
1272 (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map)
1273 {
1274 f->global_faulty = EINA_TRUE;
1275 faulty = EINA_TRUE;
1276 }
1277 }
1278
1279 if (!faulty)
1280 {
1281 itm = eina_hash_iterator_data_new(f->map);
1282 EINA_ITERATOR_FOREACH(itm, m)
1283 {
1284 if ((unsigned char *) addr < (((unsigned char *)m->map) + m->length) &&
1285 (((unsigned char *) addr) + page_size) >= (unsigned char *) m->map)
1286 {
1287 m->faulty = EINA_TRUE;
1288 faulty = EINA_TRUE;
1289 break;
1290 }
1291 }
1292 eina_iterator_free(itm);
1293 }
1294
1295 eina_lock_release(&f->lock);
1296
1297 if (faulty) break;
1298 }
1299 eina_iterator_free(itf);
1300
1301 eina_lock_release(&_eina_file_lock_cache);
1302}
1187 1303
diff --git a/libraries/eina/src/lib/eina_hash.c b/libraries/eina/src/lib/eina_hash.c
index 5df20aa..5196894 100644
--- a/libraries/eina/src/lib/eina_hash.c
+++ b/libraries/eina/src/lib/eina_hash.c
@@ -854,8 +854,9 @@ eina_hash_free(Eina_Hash *hash)
854{ 854{
855 int i; 855 int i;
856 856
857 if (!hash) return ;
858
857 EINA_MAGIC_CHECK_HASH(hash); 859 EINA_MAGIC_CHECK_HASH(hash);
858 EINA_SAFETY_ON_NULL_RETURN(hash);
859 860
860 if (hash->buckets) 861 if (hash->buckets)
861 { 862 {
@@ -871,8 +872,9 @@ eina_hash_free_buckets(Eina_Hash *hash)
871{ 872{
872 int i; 873 int i;
873 874
875 if (!hash) return ;
876
874 EINA_MAGIC_CHECK_HASH(hash); 877 EINA_MAGIC_CHECK_HASH(hash);
875 EINA_SAFETY_ON_NULL_RETURN(hash);
876 878
877 if (hash->buckets) 879 if (hash->buckets)
878 { 880 {
diff --git a/libraries/eina/src/lib/eina_inarray.c b/libraries/eina/src/lib/eina_inarray.c
new file mode 100644
index 0000000..dc95bc6
--- /dev/null
+++ b/libraries/eina/src/lib/eina_inarray.c
@@ -0,0 +1,777 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 - ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdlib.h>
24#include <string.h>
25
26#include "eina_config.h"
27#include "eina_private.h"
28#include "eina_error.h"
29#include "eina_log.h"
30
31/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
32#include "eina_safety_checks.h"
33#include "eina_inarray.h"
34
35/*============================================================================*
36* Local *
37*============================================================================*/
38
39/**
40 * @cond LOCAL
41 */
42
43static const char EINA_MAGIC_INARRAY_STR[] = "Eina Inline Array";
44static const char EINA_MAGIC_INARRAY_ITERATOR_STR[] = "Eina Inline Array Iterator";
45static const char EINA_MAGIC_INARRAY_ACCESSOR_STR[] = "Eina Inline Array Accessor";
46
47typedef struct _Eina_Iterator_Inarray Eina_Iterator_Inarray;
48typedef struct _Eina_Accessor_Inarray Eina_Accessor_Inarray;
49
50struct _Eina_Iterator_Inarray
51{
52 Eina_Iterator iterator;
53 const Eina_Inarray *array;
54 unsigned int pos;
55 EINA_MAGIC
56};
57
58struct _Eina_Accessor_Inarray
59{
60 Eina_Accessor accessor;
61 const Eina_Inarray *array;
62 EINA_MAGIC
63};
64
65static int _eina_inarray_log_dom = -1;
66
67#ifdef ERR
68#undef ERR
69#endif
70#define ERR(...) EINA_LOG_DOM_ERR(_eina_inarray_log_dom, __VA_ARGS__)
71
72#ifdef DBG
73#undef DBG
74#endif
75#define DBG(...) EINA_LOG_DOM_DBG(_eina_inarray_log_dom, __VA_ARGS__)
76
77#define EINA_MAGIC_CHECK_INARRAY(d, ...) \
78 do \
79 { \
80 if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_INARRAY)) \
81 { \
82 EINA_MAGIC_FAIL(d, EINA_MAGIC_INARRAY); \
83 return __VA_ARGS__; \
84 } \
85 eina_error_set(0); \
86 } \
87 while(0)
88
89#define EINA_MAGIC_CHECK_INARRAY_ITERATOR(d, ...) \
90 do \
91 { \
92 if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_INARRAY_ITERATOR)) \
93 { \
94 EINA_MAGIC_FAIL(d, EINA_MAGIC_INARRAY_ITERATOR); \
95 return __VA_ARGS__; \
96 } \
97 eina_error_set(0); \
98 } \
99 while(0)
100
101#define EINA_MAGIC_CHECK_INARRAY_ACCESSOR(d, ...) \
102 do \
103 { \
104 if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_INARRAY_ACCESSOR)) \
105 { \
106 EINA_MAGIC_FAIL(d, EINA_MAGIC_INARRAY_ACCESSOR); \
107 return __VA_ARGS__; \
108 } \
109 eina_error_set(0); \
110 } \
111 while(0)
112
113static void
114_eina_inarray_setup(Eina_Inarray *array, unsigned int member_size, unsigned int step)
115{
116 EINA_MAGIC_SET(array, EINA_MAGIC_INARRAY);
117 array->member_size = member_size;
118 array->len = 0;
119 array->max = 0;
120 array->step = (step > 0) ? step : 32;
121 array->members = NULL;
122}
123
124static Eina_Bool
125_eina_inarray_resize(Eina_Inarray *array, unsigned int new_size)
126{
127 unsigned int new_max;
128 void *tmp;
129
130 if (new_size < array->max)
131 return EINA_TRUE;
132
133 if (new_size % array->step == 0)
134 new_max = new_size;
135 else
136 new_max = ((new_size / array->step) + 1) * array->step;
137
138 tmp = realloc(array->members, new_max * array->member_size);
139 if ((!tmp) && (new_max > 0))
140 {
141 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
142 return EINA_FALSE;
143 }
144
145 array->members = tmp;
146 array->max = new_max;
147 return EINA_TRUE;
148}
149
150static inline void *
151_eina_inarray_get(const Eina_Inarray *array, unsigned int position)
152{
153 unsigned int offset = position * array->member_size;
154 return (unsigned char *)array->members + offset;
155}
156
157static int
158_eina_inarray_search(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
159{
160 const unsigned char *start, *found;
161 start = array->members;
162 found = bsearch(data, start, array->len, array->member_size, compare);
163 if (!found)
164 return -1;
165 return (found - start) / array->member_size;
166}
167
168static unsigned int
169_eina_inarray_search_sorted_near(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare, int *cmp)
170{
171 unsigned int start, last, middle;
172
173 if (array->len == 0)
174 {
175 *cmp = -1;
176 return 0;
177 }
178 else if (array->len == 1)
179 {
180 *cmp = compare(data, array->members);
181 return 0;
182 }
183
184 start = 0;
185 last = array->len - 1; /* inclusive */
186 do
187 {
188 void *p;
189 middle = start + (last - start) / 2; /* avoid overflow */
190 p = _eina_inarray_get(array, middle);
191 *cmp = compare(data, p);
192 if (*cmp == 0)
193 return middle;
194 else if (*cmp > 0)
195 start = middle + 1;
196 else if (middle > 0)
197 last = middle - 1;
198 else
199 break;
200 }
201 while (start <= last);
202 return middle;
203}
204
205
206static Eina_Bool
207_eina_inarray_iterator_next(Eina_Iterator_Inarray *it, void **data)
208{
209 EINA_MAGIC_CHECK_INARRAY_ITERATOR(it, EINA_FALSE);
210
211 if (it->pos >= it->array->len)
212 return EINA_FALSE;
213
214 *data = _eina_inarray_get(it->array, it->pos);
215 it->pos++;
216
217 return EINA_TRUE;
218}
219
220static Eina_Bool
221_eina_inarray_iterator_prev(Eina_Iterator_Inarray *it, void **data)
222{
223 EINA_MAGIC_CHECK_INARRAY_ITERATOR(it, EINA_FALSE);
224
225 if (it->pos == 0)
226 return EINA_FALSE;
227
228 it->pos--;
229 *data = _eina_inarray_get(it->array, it->pos);
230
231 return EINA_TRUE;
232}
233
234static Eina_Inarray *
235_eina_inarray_iterator_get_container(Eina_Iterator_Inarray *it)
236{
237 EINA_MAGIC_CHECK_INARRAY_ITERATOR(it, NULL);
238 return (Eina_Inarray *)it->array;
239}
240
241static void
242_eina_inarray_iterator_free(Eina_Iterator_Inarray *it)
243{
244 EINA_MAGIC_CHECK_INARRAY_ITERATOR(it);
245 MAGIC_FREE(it);
246}
247
248static Eina_Bool
249_eina_inarray_accessor_get_at(Eina_Accessor_Inarray *it, unsigned int pos, void **data)
250{
251 EINA_MAGIC_CHECK_INARRAY_ACCESSOR(it, EINA_FALSE);
252
253 if (pos >= it->array->len)
254 return EINA_FALSE;
255
256 *data = _eina_inarray_get(it->array, pos);
257 return EINA_TRUE;
258}
259
260static Eina_Inarray *
261_eina_inarray_accessor_get_container(Eina_Accessor_Inarray *it)
262{
263 EINA_MAGIC_CHECK_INARRAY_ACCESSOR(it, NULL);
264 return (Eina_Inarray *)it->array;
265}
266
267static void
268_eina_inarray_accessor_free(Eina_Accessor_Inarray *it)
269{
270 EINA_MAGIC_CHECK_INARRAY_ACCESSOR(it);
271 MAGIC_FREE(it);
272}
273
274/**
275 * @endcond
276 */
277
278
279/*============================================================================*
280* Global *
281*============================================================================*/
282
283/**
284 * @internal
285 * @brief Initialize the inline array module.
286 *
287 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
288 *
289 * This function sets up the inline array module of Eina. It is called
290 * by eina_init().
291 *
292 * @see eina_init()
293 */
294Eina_Bool
295eina_inarray_init(void)
296{
297 _eina_inarray_log_dom = eina_log_domain_register("eina_inarray",
298 EINA_LOG_COLOR_DEFAULT);
299 if (_eina_inarray_log_dom < 0)
300 {
301 EINA_LOG_ERR("Could not register log domain: eina_inarray");
302 return EINA_FALSE;
303 }
304
305#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
306 EMS(EINA_MAGIC_INARRAY);
307 EMS(EINA_MAGIC_INARRAY_ITERATOR);
308 EMS(EINA_MAGIC_INARRAY_ACCESSOR);
309#undef EMS
310
311 return EINA_TRUE;
312}
313
314/**
315 * @internal
316 * @brief Shut down the inline array module.
317 *
318 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
319 *
320 * This function shuts down the inline array module set up by
321 * eina_inarray_init(). It is called by eina_shutdown().
322 *
323 * @see eina_shutdown()
324 */
325Eina_Bool
326eina_inarray_shutdown(void)
327{
328 eina_log_domain_unregister(_eina_inarray_log_dom);
329 _eina_inarray_log_dom = -1;
330 return EINA_TRUE;
331}
332
333/*============================================================================*
334* API *
335*============================================================================*/
336EAPI Eina_Inarray *
337eina_inarray_new(unsigned int member_size, unsigned int step)
338{
339 Eina_Inarray *ret;
340
341 EINA_SAFETY_ON_TRUE_RETURN_VAL(member_size == 0, NULL);
342
343 ret = malloc(sizeof(*ret));
344 if (!ret)
345 {
346 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
347 return NULL;
348 }
349 eina_error_set(0);
350 _eina_inarray_setup(ret, member_size, step);
351 return ret;
352}
353
354EAPI void
355eina_inarray_free(Eina_Inarray *array)
356{
357 EINA_MAGIC_CHECK_INARRAY(array);
358 free(array->members);
359 free(array);
360}
361
362EAPI void
363eina_inarray_setup(Eina_Inarray *array, unsigned int member_size, unsigned int step)
364{
365 EINA_SAFETY_ON_NULL_RETURN(array);
366 EINA_SAFETY_ON_TRUE_RETURN(member_size == 0);
367 _eina_inarray_setup(array, member_size, step);
368}
369
370EAPI void
371eina_inarray_flush(Eina_Inarray *array)
372{
373 EINA_MAGIC_CHECK_INARRAY(array);
374 free(array->members);
375 array->len = 0;
376 array->max = 0;
377 array->members = NULL;
378}
379
380EAPI int
381eina_inarray_append(Eina_Inarray *array, const void *data)
382{
383 void *p;
384
385 EINA_MAGIC_CHECK_INARRAY(array, -1);
386 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
387
388 if (!_eina_inarray_resize(array, array->len + 1))
389 return -1;
390
391 p = _eina_inarray_get(array, array->len);
392 memcpy(p, data, array->member_size);
393
394 array->len++;
395 return array->len - 1;
396}
397
398EAPI int
399eina_inarray_insert(Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
400{
401 const unsigned char *itr, *itr_end;
402 unsigned int sz;
403
404 EINA_MAGIC_CHECK_INARRAY(array, -1);
405 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
406 EINA_SAFETY_ON_NULL_RETURN_VAL(compare, -1);
407
408 sz = array->member_size;
409 itr = array->members;
410 itr_end = itr + array->len * sz;
411 for (; itr < itr_end; itr += sz)
412 {
413 unsigned int offset, position;
414 int cmp = compare(itr, data);
415 if (cmp <= 0)
416 continue;
417
418 offset = itr - (unsigned char *)array->members;
419 position = offset / sz;
420 if (!eina_inarray_insert_at(array, position, data))
421 return -1;
422 return position;
423 }
424 return eina_inarray_append(array, data);
425}
426
427EAPI int
428eina_inarray_insert_sorted(Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
429{
430 unsigned int pos;
431 int cmp;
432
433 EINA_MAGIC_CHECK_INARRAY(array, -1);
434 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
435 EINA_SAFETY_ON_NULL_RETURN_VAL(compare, -1);
436
437 pos = _eina_inarray_search_sorted_near(array, data, compare, &cmp);
438 if (cmp > 0)
439 pos++;
440
441 if (!eina_inarray_insert_at(array, pos, data))
442 return -1;
443 return pos;
444}
445
446EAPI int
447eina_inarray_remove(Eina_Inarray *array, const void *data)
448{
449 const unsigned char *itr, *itr_end;
450 unsigned int position, sz;
451
452 EINA_MAGIC_CHECK_INARRAY(array, -1);
453 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
454
455 sz = array->member_size;
456 if ((data >= array->members) &&
457 (data < _eina_inarray_get(array, array->len)))
458 {
459 unsigned int offset = ((unsigned char *)data -
460 (unsigned char *)array->members);
461 position = offset / sz;
462 goto found;
463 }
464
465 itr = array->members;
466 itr_end = itr + array->len * sz;
467 for (; itr < itr_end; itr += sz)
468 {
469 if (memcmp(data, itr, sz) == 0)
470 {
471 unsigned int offset = itr - (unsigned char *)array->members;
472 position = offset / sz;
473 goto found;
474 }
475 }
476 return -1;
477
478found:
479 if (!eina_inarray_remove_at(array, position))
480 return -1;
481 return position;
482}
483
484EAPI int
485eina_inarray_pop(Eina_Inarray *array)
486{
487 EINA_MAGIC_CHECK_INARRAY(array, -1);
488 EINA_SAFETY_ON_TRUE_RETURN_VAL(array->len == 0, -1);
489 if (!_eina_inarray_resize(array, array->len - 1))
490 return -1;
491 array->len--;
492 return array->len + 1;
493}
494
495EAPI void *
496eina_inarray_nth(const Eina_Inarray *array, unsigned int position)
497{
498 EINA_MAGIC_CHECK_INARRAY(array, NULL);
499 EINA_SAFETY_ON_TRUE_RETURN_VAL(position >= array->len, NULL);
500 return _eina_inarray_get(array, position);
501}
502
503EAPI Eina_Bool
504eina_inarray_insert_at(Eina_Inarray *array, unsigned int position, const void *data)
505{
506 unsigned int sz;
507 unsigned char *p;
508
509 EINA_MAGIC_CHECK_INARRAY(array, EINA_FALSE);
510 EINA_SAFETY_ON_TRUE_RETURN_VAL(position > array->len, EINA_FALSE);
511
512 if (!_eina_inarray_resize(array, array->len + 1))
513 return EINA_FALSE;
514
515 p = _eina_inarray_get(array, position);
516 sz = array->member_size;
517 if (array->len > position)
518 memmove(p + sz, p, (array->len - position) * sz);
519 memcpy(p, data, sz);
520
521 array->len++;
522 return EINA_TRUE;
523}
524
525EAPI void *
526eina_inarray_alloc_at(Eina_Inarray *array, unsigned int position, unsigned int member_count)
527{
528 unsigned int sz;
529 unsigned char *p;
530
531 EINA_MAGIC_CHECK_INARRAY(array, NULL);
532 EINA_SAFETY_ON_TRUE_RETURN_VAL(position > array->len, NULL);
533 EINA_SAFETY_ON_TRUE_RETURN_VAL(member_count == 0, NULL);
534
535 if (!_eina_inarray_resize(array, array->len + member_count))
536 return NULL;
537
538 p = _eina_inarray_get(array, position);
539 sz = array->member_size;
540 if (array->len > position)
541 memmove(p + member_count * sz, p, (array->len - position) * sz);
542
543 array->len += member_count;
544 return p;
545}
546
547EAPI Eina_Bool
548eina_inarray_replace_at(Eina_Inarray *array, unsigned int position, const void *data)
549{
550 unsigned char *p;
551
552 EINA_MAGIC_CHECK_INARRAY(array, EINA_FALSE);
553 EINA_SAFETY_ON_TRUE_RETURN_VAL(position >= array->len, EINA_FALSE);
554
555 p = _eina_inarray_get(array, position);
556 memcpy(p, data, array->member_size);
557
558 return EINA_TRUE;
559}
560
561EAPI Eina_Bool
562eina_inarray_remove_at(Eina_Inarray *array, unsigned int position)
563{
564 EINA_MAGIC_CHECK_INARRAY(array, EINA_FALSE);
565 EINA_SAFETY_ON_TRUE_RETURN_VAL(position >= array->len, EINA_FALSE);
566
567 if (position + 1 < array->len)
568 {
569 unsigned int sz = array->member_size;
570 unsigned char *p = _eina_inarray_get(array, position);
571 memmove(p, p + sz, (array->len - position - 1) * sz);
572 }
573
574 _eina_inarray_resize(array, array->len - 1);
575 array->len--;
576 return EINA_TRUE;
577}
578
579EAPI void
580eina_inarray_reverse(Eina_Inarray *array)
581{
582 size_t sz;
583 unsigned char *fwd, *rev, *fwd_end;
584 void *tmp;
585
586 EINA_MAGIC_CHECK_INARRAY(array);
587
588 if (array->len < 2)
589 return;
590
591 sz = array->member_size;
592
593 tmp = alloca(sz);
594 EINA_SAFETY_ON_NULL_RETURN(tmp);
595
596 fwd = array->members;
597 fwd_end = fwd + (array->len / 2) * sz;
598
599 rev = fwd + (array->len - 1) * sz;
600
601 for (; fwd < fwd_end; fwd += sz, rev -= sz)
602 {
603 memcpy(tmp, fwd, sz);
604 memcpy(fwd, rev, sz);
605 memcpy(rev, tmp, sz);
606 }
607}
608
609EAPI void
610eina_inarray_sort(Eina_Inarray *array, Eina_Compare_Cb compare)
611{
612 EINA_MAGIC_CHECK_INARRAY(array);
613 EINA_SAFETY_ON_NULL_RETURN(compare);
614 qsort(array->members, array->len, array->member_size, compare);
615}
616
617EAPI int
618eina_inarray_search(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
619{
620 EINA_MAGIC_CHECK_INARRAY(array, -1);
621 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
622 EINA_SAFETY_ON_NULL_RETURN_VAL(compare, -1);
623 return _eina_inarray_search(array, data, compare);
624}
625
626EAPI int
627eina_inarray_search_sorted(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
628{
629 unsigned int pos;
630 int cmp;
631
632 EINA_MAGIC_CHECK_INARRAY(array, -1);
633 EINA_SAFETY_ON_NULL_RETURN_VAL(data, -1);
634 EINA_SAFETY_ON_NULL_RETURN_VAL(compare, -1);
635
636 pos = _eina_inarray_search_sorted_near(array, data, compare, &cmp);
637 if (cmp == 0)
638 return pos;
639 return -1;
640}
641
642EAPI Eina_Bool
643eina_inarray_foreach(const Eina_Inarray *array, Eina_Each_Cb function, const void *user_data)
644{
645 unsigned char *itr, *itr_end;
646 unsigned int sz;
647 Eina_Bool ret = EINA_TRUE;
648
649 EINA_MAGIC_CHECK_INARRAY(array, EINA_FALSE);
650 EINA_SAFETY_ON_NULL_RETURN_VAL(function, EINA_FALSE);
651
652 sz = array->member_size;
653 itr = array->members;
654 itr_end = itr + array->len * sz;
655 for (; (itr < itr_end) && (ret); itr += sz)
656 ret = function(array, itr, (void *)user_data);
657 return ret;
658}
659
660EAPI int
661eina_inarray_foreach_remove(Eina_Inarray *array, Eina_Each_Cb match, const void *user_data)
662{
663 unsigned int i = 0, count = 0;
664
665 EINA_MAGIC_CHECK_INARRAY(array, -1);
666 EINA_SAFETY_ON_NULL_RETURN_VAL(match, -1);
667
668 while (i < array->len)
669 {
670 void *p = _eina_inarray_get(array, i);
671 if (match(array, p, (void *)user_data) == EINA_FALSE)
672 {
673 i++;
674 continue;
675 }
676
677 eina_inarray_remove_at(array, i);
678 count++;
679 }
680
681 return count;
682}
683
684EAPI unsigned int
685eina_inarray_count(const Eina_Inarray *array)
686{
687 EINA_MAGIC_CHECK_INARRAY(array, 0);
688 return array->len;
689}
690
691EAPI Eina_Iterator *
692eina_inarray_iterator_new(const Eina_Inarray *array)
693{
694 Eina_Iterator_Inarray *it;
695
696 EINA_MAGIC_CHECK_INARRAY(array, NULL);
697
698 eina_error_set(0);
699 it = calloc(1, sizeof(Eina_Iterator_Inarray));
700 if (!it)
701 {
702 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
703 return NULL;
704 }
705
706 EINA_MAGIC_SET(it, EINA_MAGIC_INARRAY_ITERATOR);
707 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
708
709 it->array = array;
710
711 it->iterator.version = EINA_ITERATOR_VERSION;
712 it->iterator.next = FUNC_ITERATOR_NEXT(_eina_inarray_iterator_next);
713 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER
714 (_eina_inarray_iterator_get_container);
715 it->iterator.free = FUNC_ITERATOR_FREE(_eina_inarray_iterator_free);
716
717 return &it->iterator;
718}
719
720EAPI Eina_Iterator *
721eina_inarray_iterator_reversed_new(const Eina_Inarray *array)
722{
723 Eina_Iterator_Inarray *it;
724
725 EINA_MAGIC_CHECK_INARRAY(array, NULL);
726
727 eina_error_set(0);
728 it = calloc(1, sizeof(Eina_Iterator_Inarray));
729 if (!it)
730 {
731 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
732 return NULL;
733 }
734
735 EINA_MAGIC_SET(it, EINA_MAGIC_INARRAY_ITERATOR);
736 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
737
738 it->array = array;
739 it->pos = array->len;
740
741 it->iterator.version = EINA_ITERATOR_VERSION;
742 it->iterator.next = FUNC_ITERATOR_NEXT(_eina_inarray_iterator_prev);
743 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER
744 (_eina_inarray_iterator_get_container);
745 it->iterator.free = FUNC_ITERATOR_FREE(_eina_inarray_iterator_free);
746
747 return &it->iterator;
748}
749
750EAPI Eina_Accessor *
751eina_inarray_accessor_new(const Eina_Inarray *array)
752{
753 Eina_Accessor_Inarray *ac;
754
755 EINA_MAGIC_CHECK_INARRAY(array, NULL);
756
757 eina_error_set(0);
758 ac = calloc(1, sizeof(Eina_Accessor_Inarray));
759 if (!ac)
760 {
761 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
762 return NULL;
763 }
764
765 EINA_MAGIC_SET(ac, EINA_MAGIC_INARRAY_ACCESSOR);
766 EINA_MAGIC_SET(&ac->accessor, EINA_MAGIC_ACCESSOR);
767
768 ac->array = array;
769
770 ac->accessor.version = EINA_ACCESSOR_VERSION;
771 ac->accessor.get_at = FUNC_ACCESSOR_GET_AT(_eina_inarray_accessor_get_at);
772 ac->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER
773 (_eina_inarray_accessor_get_container);
774 ac->accessor.free = FUNC_ACCESSOR_FREE(_eina_inarray_accessor_free);
775
776 return &ac->accessor;
777}
diff --git a/libraries/eina/src/lib/eina_log.c b/libraries/eina/src/lib/eina_log.c
index dd772d2..4e2bb6d 100644
--- a/libraries/eina/src/lib/eina_log.c
+++ b/libraries/eina/src/lib/eina_log.c
@@ -71,6 +71,7 @@
71#define EINA_LOG_ENV_FILE_DISABLE "EINA_LOG_FILE_DISABLE" 71#define EINA_LOG_ENV_FILE_DISABLE "EINA_LOG_FILE_DISABLE"
72#define EINA_LOG_ENV_FUNCTION_DISABLE "EINA_LOG_FUNCTION_DISABLE" 72#define EINA_LOG_ENV_FUNCTION_DISABLE "EINA_LOG_FUNCTION_DISABLE"
73 73
74#ifdef EINA_ENABLE_LOG
74 75
75// Structure for storing domain level settings passed from the command line 76// Structure for storing domain level settings passed from the command line
76// that will be matched with application-defined domains. 77// that will be matched with application-defined domains.
@@ -1294,6 +1295,8 @@ eina_log_print_unlocked(int domain,
1294 abort(); 1295 abort();
1295} 1296}
1296 1297
1298#endif
1299
1297/** 1300/**
1298 * @endcond 1301 * @endcond
1299 */ 1302 */
@@ -1321,6 +1324,7 @@ eina_log_print_unlocked(int domain,
1321Eina_Bool 1324Eina_Bool
1322eina_log_init(void) 1325eina_log_init(void)
1323{ 1326{
1327#ifdef EINA_ENABLE_LOG
1324 const char *level, *tmp; 1328 const char *level, *tmp;
1325 int color_disable; 1329 int color_disable;
1326 1330
@@ -1392,6 +1396,7 @@ eina_log_init(void)
1392 // Parse pending domains passed through EINA_LOG_LEVELS 1396 // Parse pending domains passed through EINA_LOG_LEVELS
1393 eina_log_domain_parse_pendings(); 1397 eina_log_domain_parse_pendings();
1394 1398
1399#endif
1395 return EINA_TRUE; 1400 return EINA_TRUE;
1396} 1401}
1397 1402
@@ -1413,6 +1418,7 @@ eina_log_init(void)
1413Eina_Bool 1418Eina_Bool
1414eina_log_shutdown(void) 1419eina_log_shutdown(void)
1415{ 1420{
1421#ifdef EINA_ENABLE_LOG
1416 Eina_Inlist *tmp; 1422 Eina_Inlist *tmp;
1417 1423
1418 while (_log_domains_count--) 1424 while (_log_domains_count--)
@@ -1443,6 +1449,7 @@ eina_log_shutdown(void)
1443 free(tmp); 1449 free(tmp);
1444 } 1450 }
1445 1451
1452#endif
1446 return EINA_TRUE; 1453 return EINA_TRUE;
1447} 1454}
1448 1455
@@ -1460,10 +1467,12 @@ eina_log_shutdown(void)
1460void 1467void
1461eina_log_threads_init(void) 1468eina_log_threads_init(void)
1462{ 1469{
1470#ifdef EINA_ENABLE_LOG
1463 if (_threads_inited) return; 1471 if (_threads_inited) return;
1464 _main_thread = SELF(); 1472 _main_thread = SELF();
1465 if (!INIT()) return; 1473 if (!INIT()) return;
1466 _threads_inited = EINA_TRUE; 1474 _threads_inited = EINA_TRUE;
1475#endif
1467} 1476}
1468 1477
1469/** 1478/**
@@ -1478,11 +1487,13 @@ eina_log_threads_init(void)
1478void 1487void
1479eina_log_threads_shutdown(void) 1488eina_log_threads_shutdown(void)
1480{ 1489{
1490#ifdef EINA_ENABLE_LOG
1481 if (!_threads_inited) return; 1491 if (!_threads_inited) return;
1482 CHECK_MAIN(); 1492 CHECK_MAIN();
1483 SHUTDOWN(); 1493 SHUTDOWN();
1484 _threads_enabled = EINA_FALSE; 1494 _threads_enabled = EINA_FALSE;
1485 _threads_inited = EINA_FALSE; 1495 _threads_inited = EINA_FALSE;
1496#endif
1486} 1497}
1487 1498
1488#endif 1499#endif
@@ -1504,7 +1515,7 @@ EAPI int EINA_LOG_DOMAIN_GLOBAL = 0;
1504EAPI void 1515EAPI void
1505eina_log_threads_enable(void) 1516eina_log_threads_enable(void)
1506{ 1517{
1507#ifdef EFL_HAVE_THREADS 1518#if defined (EFL_HAVE_THREADS) && defined (EINA_ENABLE_LOG)
1508 if (_threads_enabled) return; 1519 if (_threads_enabled) return;
1509 if (!_threads_inited) eina_log_threads_init(); 1520 if (!_threads_inited) eina_log_threads_init();
1510 _threads_enabled = EINA_TRUE; 1521 _threads_enabled = EINA_TRUE;
@@ -1515,32 +1526,45 @@ eina_log_threads_enable(void)
1515EAPI void 1526EAPI void
1516eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) 1527eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
1517{ 1528{
1529#ifdef EINA_ENABLE_LOG
1518 LOG_LOCK(); 1530 LOG_LOCK();
1519 _print_cb = cb; 1531 _print_cb = cb;
1520 _print_cb_data = data; 1532 _print_cb_data = data;
1521 eina_log_print_prefix_update(); 1533 eina_log_print_prefix_update();
1522 LOG_UNLOCK(); 1534 LOG_UNLOCK();
1535#else
1536 (void) cb;
1537 (void) data;
1538#endif
1523} 1539}
1524 1540
1525EAPI void 1541EAPI void
1526eina_log_level_set(int level) 1542eina_log_level_set(int level)
1527{ 1543{
1544#ifdef EINA_ENABLE_LOG
1528 _log_level = level; 1545 _log_level = level;
1529 if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) && 1546 if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
1530 ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count))) 1547 ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
1531 _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level; 1548 _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
1549#else
1550 (void) level;
1551#endif
1532} 1552}
1533 1553
1534EAPI int 1554EAPI int
1535eina_log_level_get(void) 1555eina_log_level_get(void)
1536{ 1556{
1557#ifdef EINA_ENABLE_LOG
1537 return _log_level; 1558 return _log_level;
1559#else
1560 return 0;
1561#endif
1538} 1562}
1539 1563
1540EAPI Eina_Bool 1564EAPI Eina_Bool
1541eina_log_main_thread_check(void) 1565eina_log_main_thread_check(void)
1542{ 1566{
1543#ifdef EFL_HAVE_THREADS 1567#if defined (EFL_HAVE_THREADS) && defined (EINA_ENABLE_LOG)
1544 return ((!_threads_enabled) || IS_MAIN(SELF())); 1568 return ((!_threads_enabled) || IS_MAIN(SELF()));
1545#else 1569#else
1546 return EINA_TRUE; 1570 return EINA_TRUE;
@@ -1550,66 +1574,107 @@ eina_log_main_thread_check(void)
1550EAPI void 1574EAPI void
1551eina_log_color_disable_set(Eina_Bool disabled) 1575eina_log_color_disable_set(Eina_Bool disabled)
1552{ 1576{
1577#ifdef EINA_ENABLE_LOG
1553 _disable_color = disabled; 1578 _disable_color = disabled;
1579#else
1580 (void) disabled;
1581#endif
1554} 1582}
1555 1583
1556EAPI Eina_Bool 1584EAPI Eina_Bool
1557eina_log_color_disable_get(void) 1585eina_log_color_disable_get(void)
1558{ 1586{
1587#ifdef EINA_ENABLE_LOG
1559 return _disable_color; 1588 return _disable_color;
1589#else
1590 return EINA_TRUE;
1591#endif
1560} 1592}
1561 1593
1562EAPI void 1594EAPI void
1563eina_log_file_disable_set(Eina_Bool disabled) 1595eina_log_file_disable_set(Eina_Bool disabled)
1564{ 1596{
1597#ifdef EINA_ENABLE_LOG
1565 _disable_file = disabled; 1598 _disable_file = disabled;
1599#else
1600 (void) disabled;
1601#endif
1566} 1602}
1567 1603
1568EAPI Eina_Bool 1604EAPI Eina_Bool
1569eina_log_file_disable_get(void) 1605eina_log_file_disable_get(void)
1570{ 1606{
1607#ifdef EINA_ENABLE_LOG
1571 return _disable_file; 1608 return _disable_file;
1609#else
1610 return EINA_TRUE;
1611#endif
1572} 1612}
1573 1613
1574EAPI void 1614EAPI void
1575eina_log_function_disable_set(Eina_Bool disabled) 1615eina_log_function_disable_set(Eina_Bool disabled)
1576{ 1616{
1617#ifdef EINA_ENABLE_LOG
1577 _disable_function = disabled; 1618 _disable_function = disabled;
1619#else
1620 (void) disabled;
1621#endif
1578} 1622}
1579 1623
1580EAPI Eina_Bool 1624EAPI Eina_Bool
1581eina_log_function_disable_get(void) 1625eina_log_function_disable_get(void)
1582{ 1626{
1627#ifdef EINA_ENABLE_LOG
1583 return _disable_function; 1628 return _disable_function;
1629#else
1630 return EINA_TRUE;
1631#endif
1584} 1632}
1585 1633
1586EAPI void 1634EAPI void
1587eina_log_abort_on_critical_set(Eina_Bool abort_on_critical) 1635eina_log_abort_on_critical_set(Eina_Bool abort_on_critical)
1588{ 1636{
1637#ifdef EINA_ENABLE_LOG
1589 _abort_on_critical = abort_on_critical; 1638 _abort_on_critical = abort_on_critical;
1639#else
1640 (void) abort_on_critical;
1641#endif
1590} 1642}
1591 1643
1592EAPI Eina_Bool 1644EAPI Eina_Bool
1593eina_log_abort_on_critical_get(void) 1645eina_log_abort_on_critical_get(void)
1594{ 1646{
1647#ifdef EINA_ENABLE_LOG
1595 return _abort_on_critical; 1648 return _abort_on_critical;
1649#else
1650 return EINA_FALSE;
1651#endif
1596} 1652}
1597 1653
1598EAPI void 1654EAPI void
1599eina_log_abort_on_critical_level_set(int critical_level) 1655eina_log_abort_on_critical_level_set(int critical_level)
1600{ 1656{
1657#ifdef EINA_ENABLE_LOG
1601 _abort_level_on_critical = critical_level; 1658 _abort_level_on_critical = critical_level;
1659#else
1660 (void) critical_level;
1661#endif
1602} 1662}
1603 1663
1604EAPI int 1664EAPI int
1605eina_log_abort_on_critical_level_get(void) 1665eina_log_abort_on_critical_level_get(void)
1606{ 1666{
1667#ifdef EINA_ENABLE_LOG
1607 return _abort_level_on_critical; 1668 return _abort_level_on_critical;
1669#else
1670 return 0;
1671#endif
1608} 1672}
1609 1673
1610EAPI int 1674EAPI int
1611eina_log_domain_register(const char *name, const char *color) 1675eina_log_domain_register(const char *name, const char *color)
1612{ 1676{
1677#ifdef EINA_ENABLE_LOG
1613 int r; 1678 int r;
1614 1679
1615 EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1); 1680 EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
@@ -1618,20 +1683,30 @@ eina_log_domain_register(const char *name, const char *color)
1618 r = eina_log_domain_register_unlocked(name, color); 1683 r = eina_log_domain_register_unlocked(name, color);
1619 LOG_UNLOCK(); 1684 LOG_UNLOCK();
1620 return r; 1685 return r;
1686#else
1687 (void) name;
1688 (void) color;
1689 return 0;
1690#endif
1621} 1691}
1622 1692
1623EAPI void 1693EAPI void
1624eina_log_domain_unregister(int domain) 1694eina_log_domain_unregister(int domain)
1625{ 1695{
1696#ifdef EINA_ENABLE_LOG
1626 EINA_SAFETY_ON_FALSE_RETURN(domain >= 0); 1697 EINA_SAFETY_ON_FALSE_RETURN(domain >= 0);
1627 LOG_LOCK(); 1698 LOG_LOCK();
1628 eina_log_domain_unregister_unlocked(domain); 1699 eina_log_domain_unregister_unlocked(domain);
1629 LOG_UNLOCK(); 1700 LOG_UNLOCK();
1701#else
1702 (void) domain;
1703#endif
1630} 1704}
1631 1705
1632EAPI void 1706EAPI void
1633eina_log_domain_level_set(const char *domain_name, int level) 1707eina_log_domain_level_set(const char *domain_name, int level)
1634{ 1708{
1709#ifdef EINA_ENABLE_LOG
1635 Eina_Log_Domain_Level_Pending *pending; 1710 Eina_Log_Domain_Level_Pending *pending;
1636 size_t namelen; 1711 size_t namelen;
1637 unsigned int i; 1712 unsigned int i;
@@ -1672,11 +1747,16 @@ eina_log_domain_level_set(const char *domain_name, int level)
1672 memcpy(pending->name, domain_name, namelen + 1); 1747 memcpy(pending->name, domain_name, namelen + 1);
1673 1748
1674 _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(pending)); 1749 _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(pending));
1750#else
1751 (void) domain_name;
1752 (void) level;
1753#endif
1675} 1754}
1676 1755
1677EAPI int 1756EAPI int
1678eina_log_domain_level_get(const char *domain_name) 1757eina_log_domain_level_get(const char *domain_name)
1679{ 1758{
1759#ifdef EINA_ENABLE_LOG
1680 Eina_Log_Domain_Level_Pending *pending; 1760 Eina_Log_Domain_Level_Pending *pending;
1681 size_t namelen; 1761 size_t namelen;
1682 unsigned int i; 1762 unsigned int i;
@@ -1711,17 +1791,26 @@ eina_log_domain_level_get(const char *domain_name)
1711 } 1791 }
1712 1792
1713 return _log_level; 1793 return _log_level;
1794#else
1795 (void) domain_name;
1796 return 0;
1797#endif
1714} 1798}
1715 1799
1716EAPI int 1800EAPI int
1717eina_log_domain_registered_level_get(int domain) 1801eina_log_domain_registered_level_get(int domain)
1718{ 1802{
1803#ifdef EINA_ENABLE_LOG
1719 EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN); 1804 EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN);
1720 EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count, 1805 EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count,
1721 EINA_LOG_LEVEL_UNKNOWN); 1806 EINA_LOG_LEVEL_UNKNOWN);
1722 EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted, 1807 EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
1723 EINA_LOG_LEVEL_UNKNOWN); 1808 EINA_LOG_LEVEL_UNKNOWN);
1724 return _log_domains[domain].level; 1809 return _log_domains[domain].level;
1810#else
1811 (void) domain;
1812 return 0;
1813#endif
1725} 1814}
1726 1815
1727EAPI void 1816EAPI void
@@ -1734,9 +1823,20 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d,
1734 __UNUSED__ void *data, 1823 __UNUSED__ void *data,
1735 va_list args) 1824 va_list args)
1736{ 1825{
1826#ifdef EINA_ENABLE_LOG
1737 _eina_log_print_prefix(stderr, d, level, file, fnc, line); 1827 _eina_log_print_prefix(stderr, d, level, file, fnc, line);
1738 vfprintf(stderr, fmt, args); 1828 vfprintf(stderr, fmt, args);
1739 putc('\n', stderr); 1829 putc('\n', stderr);
1830#else
1831 (void) d;
1832 (void) level;
1833 (void) file;
1834 (void) fnc;
1835 (void) line;
1836 (void) fmt;
1837 (void) data;
1838 (void) args;
1839#endif
1740} 1840}
1741 1841
1742EAPI void 1842EAPI void
@@ -1749,9 +1849,20 @@ eina_log_print_cb_stdout(const Eina_Log_Domain *d,
1749 __UNUSED__ void *data, 1849 __UNUSED__ void *data,
1750 va_list args) 1850 va_list args)
1751{ 1851{
1852#ifdef EINA_ENABLE_LOG
1752 _eina_log_print_prefix(stdout, d, level, file, fnc, line); 1853 _eina_log_print_prefix(stdout, d, level, file, fnc, line);
1753 vprintf(fmt, args); 1854 vprintf(fmt, args);
1754 putchar('\n'); 1855 putchar('\n');
1856#else
1857 (void) d;
1858 (void) level;
1859 (void) file;
1860 (void) fnc;
1861 (void) line;
1862 (void) fmt;
1863 (void) data;
1864 (void) args;
1865#endif
1755} 1866}
1756 1867
1757EAPI void 1868EAPI void
@@ -1764,6 +1875,7 @@ eina_log_print_cb_file(const Eina_Log_Domain *d,
1764 void *data, 1875 void *data,
1765 va_list args) 1876 va_list args)
1766{ 1877{
1878#ifdef EINA_ENABLE_LOG
1767 FILE *f = data; 1879 FILE *f = data;
1768#ifdef EFL_HAVE_THREADS 1880#ifdef EFL_HAVE_THREADS
1769 if (_threads_enabled) 1881 if (_threads_enabled)
@@ -1787,12 +1899,22 @@ end:
1787#endif 1899#endif
1788 vfprintf(f, fmt, args); 1900 vfprintf(f, fmt, args);
1789 putc('\n', f); 1901 putc('\n', f);
1902#else
1903 (void) d;
1904 (void) file;
1905 (void) fnc;
1906 (void) line;
1907 (void) fmt;
1908 (void) data;
1909 (void) args;
1910#endif
1790} 1911}
1791 1912
1792EAPI void 1913EAPI void
1793eina_log_print(int domain, Eina_Log_Level level, const char *file, 1914eina_log_print(int domain, Eina_Log_Level level, const char *file,
1794 const char *fnc, int line, const char *fmt, ...) 1915 const char *fnc, int line, const char *fmt, ...)
1795{ 1916{
1917#ifdef EINA_ENABLE_LOG
1796 va_list args; 1918 va_list args;
1797 1919
1798#ifdef EINA_SAFETY_CHECKS 1920#ifdef EINA_SAFETY_CHECKS
@@ -1820,12 +1942,22 @@ eina_log_print(int domain, Eina_Log_Level level, const char *file,
1820 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args); 1942 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
1821 LOG_UNLOCK(); 1943 LOG_UNLOCK();
1822 va_end(args); 1944 va_end(args);
1945#else
1946 (void) domain;
1947 (void) level;
1948 (void) file;
1949 (void) fnc;
1950 (void) line;
1951 (void) fmt;
1952#endif
1823} 1953}
1824 1954
1825EAPI void 1955EAPI void
1826eina_log_vprint(int domain, Eina_Log_Level level, const char *file, 1956eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
1827 const char *fnc, int line, const char *fmt, va_list args) 1957 const char *fnc, int line, const char *fmt, va_list args)
1828{ 1958{
1959#ifdef EINA_ENABLE_LOG
1960
1829#ifdef EINA_SAFETY_CHECKS 1961#ifdef EINA_SAFETY_CHECKS
1830 if (EINA_UNLIKELY(!file)) 1962 if (EINA_UNLIKELY(!file))
1831 { 1963 {
@@ -1849,4 +1981,13 @@ eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
1849 LOG_LOCK(); 1981 LOG_LOCK();
1850 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args); 1982 eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
1851 LOG_UNLOCK(); 1983 LOG_UNLOCK();
1984#else
1985 (void) domain;
1986 (void) level;
1987 (void) file;
1988 (void) fnc;
1989 (void) line;
1990 (void) fmt;
1991 (void) args;
1992#endif
1852} 1993}
diff --git a/libraries/eina/src/lib/eina_magic.c b/libraries/eina/src/lib/eina_magic.c
index 1adde92..d1f71cc 100644
--- a/libraries/eina/src/lib/eina_magic.c
+++ b/libraries/eina/src/lib/eina_magic.c
@@ -79,7 +79,7 @@ _eina_magic_strings_sort_cmp(const void *p1, const void *p2)
79static int 79static int
80_eina_magic_strings_find_cmp(const void *p1, const void *p2) 80_eina_magic_strings_find_cmp(const void *p1, const void *p2)
81{ 81{
82 Eina_Magic a = (Eina_Magic)p1; 82 Eina_Magic a = (Eina_Magic)(size_t)p1;
83 const Eina_Magic_String *b = p2; 83 const Eina_Magic_String *b = p2;
84 return a - b->magic; 84 return a - b->magic;
85} 85}
@@ -129,6 +129,10 @@ _eina_magic_strings_alloc(void)
129* Global * 129* Global *
130*============================================================================*/ 130*============================================================================*/
131 131
132EAPI Eina_Error EINA_ERROR_MAGIC_FAILED = 0;
133
134static const char EINA_ERROR_MAGIC_FAILED_STR[] = "Magic check failed.";
135
132/** 136/**
133 * @internal 137 * @internal
134 * @brief Initialize the magic string module. 138 * @brief Initialize the magic string module.
@@ -150,6 +154,8 @@ eina_magic_string_init(void)
150 EINA_LOG_ERR("Could not register log domain: eina_magic_string"); 154 EINA_LOG_ERR("Could not register log domain: eina_magic_string");
151 return EINA_FALSE; 155 return EINA_FALSE;
152 } 156 }
157 EINA_ERROR_MAGIC_FAILED = eina_error_msg_static_register(
158 EINA_ERROR_MAGIC_FAILED_STR);
153 159
154 return EINA_TRUE; 160 return EINA_TRUE;
155} 161}
@@ -206,7 +212,7 @@ eina_magic_string_get(Eina_Magic magic)
206 _eina_magic_strings_dirty = 0; 212 _eina_magic_strings_dirty = 0;
207 } 213 }
208 214
209 ems = bsearch((void *)magic, _eina_magic_strings, 215 ems = bsearch((void *)(size_t)magic, _eina_magic_strings,
210 _eina_magic_strings_count, sizeof(Eina_Magic_String), 216 _eina_magic_strings_count, sizeof(Eina_Magic_String),
211 _eina_magic_strings_find_cmp); 217 _eina_magic_strings_find_cmp);
212 if (ems) 218 if (ems)
@@ -271,6 +277,7 @@ eina_magic_fail(void *d,
271 const char *fnc, 277 const char *fnc,
272 int line) 278 int line)
273{ 279{
280 eina_error_set(EINA_ERROR_MAGIC_FAILED);
274 if (!d) 281 if (!d)
275 eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL, 282 eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
276 file, fnc, line, 283 file, fnc, line,
diff --git a/libraries/eina/src/lib/eina_main.c b/libraries/eina/src/lib/eina_main.c
index 8727f83..79f8a36 100644
--- a/libraries/eina/src/lib/eina_main.c
+++ b/libraries/eina/src/lib/eina_main.c
@@ -67,6 +67,8 @@
67#include "eina_rectangle.h" 67#include "eina_rectangle.h"
68#include "eina_safety_checks.h" 68#include "eina_safety_checks.h"
69#include "eina_inlist.h" 69#include "eina_inlist.h"
70#include "eina_inarray.h"
71#include "eina_value.h"
70 72
71/*============================================================================* 73/*============================================================================*
72* Local * 74* Local *
@@ -131,6 +133,7 @@ EAPI Eina_Inlist *_eina_tracking = NULL;
131 S(magic_string); 133 S(magic_string);
132 S(iterator); 134 S(iterator);
133 S(accessor); 135 S(accessor);
136 S(inarray);
134 S(array); 137 S(array);
135 S(module); 138 S(module);
136 S(mempool); 139 S(mempool);
@@ -149,6 +152,7 @@ EAPI Eina_Inlist *_eina_tracking = NULL;
149 S(simple_xml); 152 S(simple_xml);
150 S(file); 153 S(file);
151 S(prefix); 154 S(prefix);
155 S(value);
152#undef S 156#undef S
153 157
154struct eina_desc_setup 158struct eina_desc_setup
@@ -161,17 +165,18 @@ struct eina_desc_setup
161static const struct eina_desc_setup _eina_desc_setup[] = { 165static const struct eina_desc_setup _eina_desc_setup[] = {
162#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown} 166#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown}
163 /* log is a special case as it needs printf */ 167 /* log is a special case as it needs printf */
168 S(stringshare),
164 S(error), 169 S(error),
165 S(safety_checks), 170 S(safety_checks),
166 S(magic_string), 171 S(magic_string),
167 S(iterator), 172 S(iterator),
168 S(accessor), 173 S(accessor),
174 S(inarray),
169 S(array), 175 S(array),
170 S(module), 176 S(module),
171 S(mempool), 177 S(mempool),
172 S(list), 178 S(list),
173 S(binshare), 179 S(binshare),
174 S(stringshare),
175 S(ustringshare), 180 S(ustringshare),
176 S(matrixsparse), 181 S(matrixsparse),
177 S(convert), 182 S(convert),
@@ -183,7 +188,8 @@ static const struct eina_desc_setup _eina_desc_setup[] = {
183 S(quadtree), 188 S(quadtree),
184 S(simple_xml), 189 S(simple_xml),
185 S(file), 190 S(file),
186 S(prefix) 191 S(prefix),
192 S(value)
187#undef S 193#undef S
188}; 194};
189static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) / 195static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) /
@@ -236,8 +242,8 @@ eina_init(void)
236 _mt_enabled = 1; 242 _mt_enabled = 1;
237 mtrace(); 243 mtrace();
238 } 244 }
239#endif 245#endif
240 246
241 if (!eina_log_init()) 247 if (!eina_log_init())
242 { 248 {
243 fprintf(stderr, "Could not initialize eina logging system.\n"); 249 fprintf(stderr, "Could not initialize eina logging system.\n");
@@ -304,7 +310,7 @@ eina_shutdown(void)
304 muntrace(); 310 muntrace();
305 _mt_enabled = 0; 311 _mt_enabled = 0;
306 } 312 }
307#endif 313#endif
308 } 314 }
309 315
310 return _eina_main_count; 316 return _eina_main_count;
diff --git a/libraries/eina/src/lib/eina_mmap.c b/libraries/eina/src/lib/eina_mmap.c
index fb27bd7..7929f0e 100644
--- a/libraries/eina/src/lib/eina_mmap.c
+++ b/libraries/eina/src/lib/eina_mmap.c
@@ -110,6 +110,8 @@ _eina_mmap_safe_sigbus(int sig __UNUSED__,
110 errno = perrno; 110 errno = perrno;
111 abort(); 111 abort();
112 } 112 }
113 /* Look into mmaped Eina_File if it was one of them, just to remember for later request */
114 eina_file_mmap_faulty(addr, _eina_mmap_pagesize);
113 /* restore previous errno */ 115 /* restore previous errno */
114 errno = perrno; 116 errno = perrno;
115} 117}
@@ -162,6 +164,9 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
162 sa.sa_sigaction = _eina_mmap_safe_sigbus; 164 sa.sa_sigaction = _eina_mmap_safe_sigbus;
163 sa.sa_flags = SA_RESTART | SA_SIGINFO; 165 sa.sa_flags = SA_RESTART | SA_SIGINFO;
164 sigemptyset(&sa.sa_mask); 166 sigemptyset(&sa.sa_mask);
167 /* FIXME: This is rubbish. We return EINA_FALSE whether sigaction
168 * fails or not. And we never set mmap_safe, so we always hit this
169 * code path. */
165 if (sigaction(SIGBUS, &sa, NULL) == 0) return EINA_FALSE; 170 if (sigaction(SIGBUS, &sa, NULL) == 0) return EINA_FALSE;
166 /* setup of SIGBUS handler failed, lets close zero page dev and fail */ 171 /* setup of SIGBUS handler failed, lets close zero page dev and fail */
167 close(_eina_mmap_zero_fd); 172 close(_eina_mmap_zero_fd);
diff --git a/libraries/eina/src/lib/eina_module.c b/libraries/eina/src/lib/eina_module.c
index 0dd19a6..26df980 100644
--- a/libraries/eina/src/lib/eina_module.c
+++ b/libraries/eina/src/lib/eina_module.c
@@ -37,6 +37,7 @@ extern "C"
37void *alloca (size_t); 37void *alloca (size_t);
38#endif 38#endif
39 39
40#include <stdlib.h>
40#include <stdio.h> 41#include <stdio.h>
41#include <sys/types.h> 42#include <sys/types.h>
42#include <string.h> 43#include <string.h>
diff --git a/libraries/eina/src/lib/eina_prefix.c b/libraries/eina/src/lib/eina_prefix.c
index 9445222..5b4b0c0 100644
--- a/libraries/eina/src/lib/eina_prefix.c
+++ b/libraries/eina/src/lib/eina_prefix.c
@@ -150,25 +150,24 @@ _fallback(Eina_Prefix *pfx, const char *pkg_bin, const char *pkg_lib,
150 STRDUP_REP(pfx->prefix_path_lib, pkg_lib); 150 STRDUP_REP(pfx->prefix_path_lib, pkg_lib);
151 STRDUP_REP(pfx->prefix_path_data, pkg_data); 151 STRDUP_REP(pfx->prefix_path_data, pkg_data);
152 STRDUP_REP(pfx->prefix_path_locale, pkg_locale); 152 STRDUP_REP(pfx->prefix_path_locale, pkg_locale);
153 fprintf(stderr, 153 WRN("Could not determine its installed prefix for '%s'\n"
154 "WARNING: Could not determine its installed prefix for '%s'\n" 154 " so am falling back on the compiled in default:\n"
155 " so am falling back on the compiled in default:\n" 155 " %s\n"
156 " %s\n" 156 " implied by the following:\n"
157 " implied by the following:\n" 157 " bindir = %s\n"
158 " bindir = %s\n" 158 " libdir = %s\n"
159 " libdir = %s\n" 159 " datadir = %s\n"
160 " datadir = %s\n" 160 " localedir = %s\n"
161 " localedir = %s\n" 161 " Try setting the following environment variables:\n"
162 " Try setting the following environment variables:\n" 162 " %s_PREFIX - points to the base prefix of install\n"
163 " %s_PREFIX - points to the base prefix of install\n" 163 " or the next 4 variables\n"
164 " or the next 4 variables\n" 164 " %s_BIN_DIR - provide a specific binary directory\n"
165 " %s_BIN_DIR - provide a specific binary directory\n" 165 " %s_LIB_DIR - provide a specific library directory\n"
166 " %s_LIB_DIR - provide a specific library directory\n" 166 " %s_DATA_DIR - provide a specific data directory\n"
167 " %s_DATA_DIR - provide a specific data directory\n" 167 " %s_LOCALE_DIR - provide a specific locale directory",
168 " %s_LOCALE_DIR - provide a specific locale directory\n" 168 envprefix,
169 , envprefix, 169 pfx->prefix_path, pkg_bin, pkg_lib, pkg_data, pkg_locale,
170 pfx->prefix_path, pkg_bin, pkg_lib, pkg_data, pkg_locale, 170 envprefix, envprefix, envprefix, envprefix, envprefix);
171 envprefix, envprefix, envprefix, envprefix, envprefix);
172 pfx->fallback = 1; 171 pfx->fallback = 1;
173 return 1; 172 return 1;
174} 173}
diff --git a/libraries/eina/src/lib/eina_private.h b/libraries/eina/src/lib/eina_private.h
index d390397..e31ab47 100644
--- a/libraries/eina/src/lib/eina_private.h
+++ b/libraries/eina/src/lib/eina_private.h
@@ -91,6 +91,10 @@
91#define EINA_MAGIC_SIMPLE_XML_DATA 0x98761261 91#define EINA_MAGIC_SIMPLE_XML_DATA 0x98761261
92#define EINA_MAGIC_SIMPLE_XML_ATTRIBUTE 0x98761262 92#define EINA_MAGIC_SIMPLE_XML_ATTRIBUTE 0x98761262
93 93
94#define EINA_MAGIC_INARRAY 0x98761270
95#define EINA_MAGIC_INARRAY_ITERATOR 0x98761271
96#define EINA_MAGIC_INARRAY_ACCESSOR 0x98761272
97
94#define EINA_MAGIC_CLASS 0x9877CB30 98#define EINA_MAGIC_CLASS 0x9877CB30
95 99
96/* undef the following, we want out version */ 100/* undef the following, we want out version */
@@ -136,5 +140,7 @@ void eina_log_threads_init(void);
136void eina_log_threads_shutdown(void); 140void eina_log_threads_shutdown(void);
137#endif 141#endif
138 142
143void eina_file_mmap_faulty(void *addr, long page_size);
144
139#endif /* EINA_PRIVATE_H_ */ 145#endif /* EINA_PRIVATE_H_ */
140 146
diff --git a/libraries/eina/src/lib/eina_rbtree.c b/libraries/eina/src/lib/eina_rbtree.c
index c0c9f9e..5f1232c 100644
--- a/libraries/eina/src/lib/eina_rbtree.c
+++ b/libraries/eina/src/lib/eina_rbtree.c
@@ -83,7 +83,7 @@ _eina_rbtree_iterator_list_new(const Eina_Rbtree *tree)
83static Eina_Rbtree * 83static Eina_Rbtree *
84_eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree *it) 84_eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree *it)
85{ 85{
86 if (eina_array_count_get(it->stack) <= 0) 86 if (eina_array_count(it->stack) <= 0)
87 return NULL; 87 return NULL;
88 88
89 return eina_array_data_get(it->stack, 0); 89 return eina_array_data_get(it->stack, 0);
@@ -110,10 +110,10 @@ _eina_rbtree_iterator_next(Eina_Iterator_Rbtree *it, void **data)
110 Eina_Iterator_Rbtree_List *new; 110 Eina_Iterator_Rbtree_List *new;
111 Eina_Rbtree *tree; 111 Eina_Rbtree *tree;
112 112
113 if (eina_array_count_get(it->stack) <= 0) 113 if (eina_array_count(it->stack) <= 0)
114 return EINA_FALSE; 114 return EINA_FALSE;
115 115
116 last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1); 116 last = eina_array_data_get(it->stack, eina_array_count(it->stack) - 1);
117 tree = last->tree; 117 tree = last->tree;
118 118
119 if (!last->tree || last->up == EINA_TRUE) 119 if (!last->tree || last->up == EINA_TRUE)
@@ -128,10 +128,10 @@ _eina_rbtree_iterator_next(Eina_Iterator_Rbtree *it, void **data)
128 { 128 {
129 free(last); 129 free(last);
130 130
131 if (eina_array_count_get(it->stack) > 0) 131 if (eina_array_count(it->stack) > 0)
132 { 132 {
133 last = eina_array_data_get(it->stack, 133 last = eina_array_data_get(it->stack,
134 eina_array_count_get( 134 eina_array_count(
135 it-> 135 it->
136 stack) 136 stack)
137 - 1); 137 - 1);
diff --git a/libraries/eina/src/lib/eina_simple_xml_parser.c b/libraries/eina/src/lib/eina_simple_xml_parser.c
index 08a8259..4e357ba 100644
--- a/libraries/eina/src/lib/eina_simple_xml_parser.c
+++ b/libraries/eina/src/lib/eina_simple_xml_parser.c
@@ -38,7 +38,10 @@ extern "C"
38void *alloca (size_t); 38void *alloca (size_t);
39#endif 39#endif
40 40
41#include <strings.h> 41#ifdef HAVE_STRINGS_H
42# include <strings.h>
43#endif
44#include <stdlib.h>
42#include <string.h> 45#include <string.h>
43#include <ctype.h> 46#include <ctype.h>
44 47
@@ -121,7 +124,7 @@ static inline const char *
121_eina_simple_xml_whitespace_find(const char *itr, const char *itr_end) 124_eina_simple_xml_whitespace_find(const char *itr, const char *itr_end)
122{ 125{
123 for (; itr < itr_end; itr++) 126 for (; itr < itr_end; itr++)
124 if (isspace(*itr)) break; 127 if (isspace((unsigned char)*itr)) break;
125 return itr; 128 return itr;
126} 129}
127 130
@@ -129,7 +132,7 @@ static inline const char *
129_eina_simple_xml_whitespace_skip(const char *itr, const char *itr_end) 132_eina_simple_xml_whitespace_skip(const char *itr, const char *itr_end)
130{ 133{
131 for (; itr < itr_end; itr++) 134 for (; itr < itr_end; itr++)
132 if (!isspace(*itr)) break; 135 if (!isspace((unsigned char)*itr)) break;
133 return itr; 136 return itr;
134} 137}
135 138
@@ -137,7 +140,7 @@ static inline const char *
137_eina_simple_xml_whitespace_unskip(const char *itr, const char *itr_start) 140_eina_simple_xml_whitespace_unskip(const char *itr, const char *itr_start)
138{ 141{
139 for (itr--; itr > itr_start; itr--) 142 for (itr--; itr > itr_start; itr--)
140 if (!isspace(*itr)) break; 143 if (!isspace((unsigned char)*itr)) break;
141 return itr + 1; 144 return itr + 1;
142} 145}
143 146
@@ -309,7 +312,7 @@ eina_simple_xml_parse(const char *buf, unsigned buflen, Eina_Bool strip, Eina_Si
309 (!memcmp(itr + 2, "DOCTYPE", 312 (!memcmp(itr + 2, "DOCTYPE",
310 sizeof("DOCTYPE") - 1)) && 313 sizeof("DOCTYPE") - 1)) &&
311 ((itr[2 + sizeof("DOCTYPE") - 1] == '>') || 314 ((itr[2 + sizeof("DOCTYPE") - 1] == '>') ||
312 (isspace(itr[2 + sizeof("DOCTYPE") - 1])))) 315 (isspace((unsigned char)itr[2 + sizeof("DOCTYPE") - 1]))))
313 { 316 {
314 type = EINA_SIMPLE_XML_DOCTYPE; 317 type = EINA_SIMPLE_XML_DOCTYPE;
315 toff = sizeof("!DOCTYPE") - 1; 318 toff = sizeof("!DOCTYPE") - 1;
@@ -455,7 +458,7 @@ eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen)
455 458
456 for (; itr < itr_end; itr++) 459 for (; itr < itr_end; itr++)
457 { 460 {
458 if (!isspace(*itr)) 461 if (!isspace((unsigned char)*itr))
459 { 462 {
460 /* user skip tagname and already gave it the attributes */ 463 /* user skip tagname and already gave it the attributes */
461 if (*itr == '=') 464 if (*itr == '=')
@@ -492,7 +495,7 @@ eina_simple_xml_attributes_parse(const char *buf, unsigned buflen, Eina_Simple_X
492 495
493 key = p; 496 key = p;
494 for (key_end = key; key_end < itr_end; key_end++) 497 for (key_end = key; key_end < itr_end; key_end++)
495 if ((*key_end == '=') || (isspace(*key_end))) break; 498 if ((*key_end == '=') || (isspace((unsigned char)*key_end))) break;
496 if (key_end == itr_end) return EINA_FALSE; 499 if (key_end == itr_end) return EINA_FALSE;
497 if (key_end == key) continue; 500 if (key_end == key) continue;
498 501
@@ -504,7 +507,7 @@ eina_simple_xml_attributes_parse(const char *buf, unsigned buflen, Eina_Simple_X
504 value++; 507 value++;
505 } 508 }
506 for (; value < itr_end; value++) 509 for (; value < itr_end; value++)
507 if (!isspace(*value)) break; 510 if (!isspace((unsigned char)*value)) break;
508 if (value == itr_end) return EINA_FALSE; 511 if (value == itr_end) return EINA_FALSE;
509 512
510 if ((*value == '"') || (*value == '\'')) 513 if ((*value == '"') || (*value == '\''))
diff --git a/libraries/eina/src/lib/eina_strbuf.c b/libraries/eina/src/lib/eina_strbuf.c
index 74b1eb9..828d842 100644
--- a/libraries/eina/src/lib/eina_strbuf.c
+++ b/libraries/eina/src/lib/eina_strbuf.c
@@ -162,9 +162,9 @@ eina_strbuf_insert_vprintf(Eina_Strbuf *buf,
162EAPI void 162EAPI void
163eina_strbuf_trim(Eina_Strbuf *buf) 163eina_strbuf_trim(Eina_Strbuf *buf)
164{ 164{
165 char *c = buf->buf; 165 unsigned char *c = buf->buf;
166 166
167 while (buf->len > 0 && isspace(((unsigned char*)(buf->buf))[buf->len - 1])) 167 while (buf->len > 0 && isspace(c[buf->len - 1]))
168 buf->len--; 168 buf->len--;
169 while (buf->len > 0 && isspace(*c)) 169 while (buf->len > 0 && isspace(*c))
170 { 170 {
@@ -178,7 +178,7 @@ eina_strbuf_trim(Eina_Strbuf *buf)
178EAPI void 178EAPI void
179eina_strbuf_ltrim(Eina_Strbuf *buf) 179eina_strbuf_ltrim(Eina_Strbuf *buf)
180{ 180{
181 char *c = buf->buf; 181 unsigned char *c = buf->buf;
182 182
183 while (buf->len > 0 && isspace(*c)) 183 while (buf->len > 0 && isspace(*c))
184 { 184 {
diff --git a/libraries/eina/src/lib/eina_value.c b/libraries/eina/src/lib/eina_value.c
index 554f907..ba8af52 100644
--- a/libraries/eina/src/lib/eina_value.c
+++ b/libraries/eina/src/lib/eina_value.c
@@ -28,8 +28,4762 @@
28# include "config.h" 28# include "config.h"
29#endif 29#endif
30 30
31#ifdef HAVE_ALLOCA_H
32# include <alloca.h>
33#elif defined __GNUC__
34# define alloca __builtin_alloca
35#elif defined _AIX
36# define alloca __alloca
37#elif defined _MSC_VER
38# include <malloc.h>
39# define alloca _alloca
40#else
41# include <stddef.h>
42# ifdef __cplusplus
43extern "C"
44# endif
45void *alloca (size_t);
46#endif
47
48#include <stdio.h> /* asprintf() */
49#include <inttypes.h> /* PRId64 and PRIu64 */
50#include <sys/time.h> /* struct timeval */
51
31#include "eina_config.h" 52#include "eina_config.h"
32#include "eina_private.h" 53#include "eina_private.h"
54#include "eina_error.h"
55#include "eina_log.h"
56#include "eina_strbuf.h"
57#include "eina_mempool.h"
58#include "eina_lock.h"
59
60/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
61#include "eina_safety_checks.h"
62#include "eina_value.h"
63
64/*============================================================================*
65* Local *
66*============================================================================*/
67
68/**
69 * @cond LOCAL
70 */
71
72static Eina_Mempool *_eina_value_mp = NULL;
73static Eina_Hash *_eina_value_inner_mps = NULL;
74static Eina_Lock _eina_value_inner_mps_lock;
75static char *_eina_value_mp_choice = NULL;
76static int _eina_value_log_dom = -1;
77
78#ifdef ERR
79#undef ERR
80#endif
81#define ERR(...) EINA_LOG_DOM_ERR(_eina_value_log_dom, __VA_ARGS__)
82
83#ifdef DBG
84#undef DBG
85#endif
86#define DBG(...) EINA_LOG_DOM_DBG(_eina_value_log_dom, __VA_ARGS__)
87
88static const unsigned char eina_value_uchar_max = 255U;
89static const char eina_value_char_max = 127;
90static const char eina_value_char_min = -127 - 1;
91
92static const unsigned short eina_value_ushort_max = 65535U;
93static const short eina_value_short_max = 32767;
94static const short eina_value_short_min = -32767 - 1;
95
96static const unsigned int eina_value_uint_max = 4294967295U;
97static const int eina_value_int_max = 2147483647;
98static const int eina_value_int_min = -2147483647 - 1;
99
100static const uint64_t eina_value_uint64_max = 18446744073709551615ULL;
101static const int64_t eina_value_int64_max = 9223372036854775807LL;
102static const int64_t eina_value_int64_min = -9223372036854775807LL - 1LL;
103
104#if __WORDSIZE == 64
105static const unsigned long eina_value_ulong_max = 18446744073709551615ULL;
106static const long eina_value_long_max = 9223372036854775807LL;
107static const long eina_value_long_min = -9223372036854775807LL - 1LL;
108#else
109static const unsigned long eina_value_ulong_max = 4294967295U;
110static const long eina_value_long_max = 2147483647;
111static const long eina_value_long_min = -2147483647 - 1;
112#endif
113
114
115static Eina_Bool
116_eina_value_type_uchar_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
117{
118 unsigned char *tmem = mem;
119 *tmem = 0;
120 return EINA_TRUE;
121}
122
123static Eina_Bool
124_eina_value_type_uchar_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
125{
126 return EINA_TRUE;
127}
128
129static Eina_Bool
130_eina_value_type_uchar_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
131{
132 const unsigned char *s = src;
133 unsigned char *d = dst;
134 *d = *s;
135 return EINA_TRUE;
136}
137
138static int
139_eina_value_type_uchar_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
140{
141 const unsigned char *ta = a, *tb = b;
142 if (*ta < *tb)
143 return -1;
144 else if (*ta > *tb)
145 return 1;
146 return 0;
147}
148
149static Eina_Bool
150_eina_value_type_uchar_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
151{
152 const unsigned char v = *(const unsigned char *)type_mem;
153
154 eina_error_set(0);
155
156 if (convert == EINA_VALUE_TYPE_UCHAR)
157 {
158 unsigned char other_mem = v;
159 return eina_value_type_pset(convert, convert_mem, &other_mem);
160 }
161 else if (convert == EINA_VALUE_TYPE_USHORT)
162 {
163 unsigned short other_mem = v;
164 return eina_value_type_pset(convert, convert_mem, &other_mem);
165 }
166 else if (convert == EINA_VALUE_TYPE_UINT)
167 {
168 unsigned int other_mem = v;
169 return eina_value_type_pset(convert, convert_mem, &other_mem);
170 }
171 else if (convert == EINA_VALUE_TYPE_ULONG)
172 {
173 unsigned long other_mem = v;
174 return eina_value_type_pset(convert, convert_mem, &other_mem);
175 }
176 else if (convert == EINA_VALUE_TYPE_UINT64)
177 {
178 uint64_t other_mem = v;
179 return eina_value_type_pset(convert, convert_mem, &other_mem);
180 }
181 else if (convert == EINA_VALUE_TYPE_CHAR)
182 {
183 char other_mem = v;
184 if (EINA_UNLIKELY(v > (unsigned char)eina_value_char_max))
185 return EINA_FALSE;
186 return eina_value_type_pset(convert, convert_mem, &other_mem);
187 }
188 else if (convert == EINA_VALUE_TYPE_SHORT)
189 {
190 short other_mem = v;
191 return eina_value_type_pset(convert, convert_mem, &other_mem);
192 }
193 else if (convert == EINA_VALUE_TYPE_INT)
194 {
195 int other_mem = v;
196 return eina_value_type_pset(convert, convert_mem, &other_mem);
197 }
198 else if (convert == EINA_VALUE_TYPE_LONG)
199 {
200 long other_mem = v;
201 return eina_value_type_pset(convert, convert_mem, &other_mem);
202 }
203 else if (convert == EINA_VALUE_TYPE_INT64)
204 {
205 int64_t other_mem = v;
206 return eina_value_type_pset(convert, convert_mem, &other_mem);
207 }
208 else if (convert == EINA_VALUE_TYPE_FLOAT)
209 {
210 float other_mem = v;
211 return eina_value_type_pset(convert, convert_mem, &other_mem);
212 }
213 else if (convert == EINA_VALUE_TYPE_DOUBLE)
214 {
215 double other_mem = v;
216 return eina_value_type_pset(convert, convert_mem, &other_mem);
217 }
218 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
219 convert == EINA_VALUE_TYPE_STRING)
220 {
221 const char *other_mem;
222 char buf[64];
223 snprintf(buf, sizeof(buf), "%hhu", v);
224 other_mem = buf; /* required due &buf == buf */
225 return eina_value_type_pset(convert, convert_mem, &other_mem);
226 }
227 else
228 {
229 eina_error_set(EINA_ERROR_VALUE_FAILED);
230 return EINA_FALSE;
231 }
232
233 return EINA_TRUE;
234}
235
236static Eina_Bool
237_eina_value_type_uchar_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
238{
239 unsigned char *tmem = mem;
240 *tmem = va_arg(args, unsigned int); /* char is promoted to int for va_arg */
241 return EINA_TRUE;
242}
243
244static Eina_Bool
245_eina_value_type_uchar_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
246{
247 unsigned char *tmem = mem;
248 const unsigned char *p = ptr;
249 *tmem = *p;
250 return EINA_TRUE;
251}
252
253static Eina_Bool
254_eina_value_type_uchar_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
255{
256 const unsigned char *tmem = mem;
257 unsigned char *p = ptr;
258 *p = *tmem;
259 return EINA_TRUE;
260}
261
262static Eina_Bool
263_eina_value_type_ushort_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
264{
265 unsigned short *tmem = mem;
266 *tmem = 0;
267 return EINA_TRUE;
268}
269
270static Eina_Bool
271_eina_value_type_ushort_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
272{
273 return EINA_TRUE;
274}
275
276static Eina_Bool
277_eina_value_type_ushort_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
278{
279 const unsigned short *s = src;
280 unsigned short *d = dst;
281 *d = *s;
282 return EINA_TRUE;
283}
284
285static int
286_eina_value_type_ushort_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
287{
288 const unsigned short *ta = a, *tb = b;
289 if (*ta < *tb)
290 return -1;
291 else if (*ta > *tb)
292 return 1;
293 return 0;
294}
295
296static Eina_Bool
297_eina_value_type_ushort_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
298{
299 const unsigned short v = *(const unsigned short *)type_mem;
300
301 eina_error_set(0);
302
303 if (convert == EINA_VALUE_TYPE_UCHAR)
304 {
305 unsigned char other_mem = v;
306 if (EINA_UNLIKELY(v > eina_value_uchar_max))
307 return EINA_FALSE;
308 return eina_value_type_pset(convert, convert_mem, &other_mem);
309 }
310 else if (convert == EINA_VALUE_TYPE_USHORT)
311 {
312 unsigned short other_mem = v;
313 return eina_value_type_pset(convert, convert_mem, &other_mem);
314 }
315 else if (convert == EINA_VALUE_TYPE_UINT)
316 {
317 unsigned int other_mem = v;
318 return eina_value_type_pset(convert, convert_mem, &other_mem);
319 }
320 else if (convert == EINA_VALUE_TYPE_ULONG)
321 {
322 unsigned long other_mem = v;
323 return eina_value_type_pset(convert, convert_mem, &other_mem);
324 }
325 else if (convert == EINA_VALUE_TYPE_UINT64)
326 {
327 uint64_t other_mem = v;
328 return eina_value_type_pset(convert, convert_mem, &other_mem);
329 }
330 else if (convert == EINA_VALUE_TYPE_CHAR)
331 {
332 char other_mem = v;
333 if (EINA_UNLIKELY(v > (unsigned char)eina_value_char_max))
334 return EINA_FALSE;
335 return eina_value_type_pset(convert, convert_mem, &other_mem);
336 }
337 else if (convert == EINA_VALUE_TYPE_SHORT)
338 {
339 short other_mem = v;
340 if (EINA_UNLIKELY(v > (unsigned short)eina_value_short_max))
341 return EINA_FALSE;
342 return eina_value_type_pset(convert, convert_mem, &other_mem);
343 }
344 else if (convert == EINA_VALUE_TYPE_INT)
345 {
346 int other_mem = v;
347 return eina_value_type_pset(convert, convert_mem, &other_mem);
348 }
349 else if (convert == EINA_VALUE_TYPE_LONG)
350 {
351 long other_mem = v;
352 return eina_value_type_pset(convert, convert_mem, &other_mem);
353 }
354 else if (convert == EINA_VALUE_TYPE_INT64)
355 {
356 int64_t other_mem = v;
357 return eina_value_type_pset(convert, convert_mem, &other_mem);
358 }
359 else if (convert == EINA_VALUE_TYPE_FLOAT)
360 {
361 float other_mem = v;
362 return eina_value_type_pset(convert, convert_mem, &other_mem);
363 }
364 else if (convert == EINA_VALUE_TYPE_DOUBLE)
365 {
366 double other_mem = v;
367 return eina_value_type_pset(convert, convert_mem, &other_mem);
368 }
369 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
370 convert == EINA_VALUE_TYPE_STRING)
371 {
372 const char *other_mem;
373 char buf[64];
374 snprintf(buf, sizeof(buf), "%hu", v);
375 other_mem = buf; /* required due &buf == buf */
376 return eina_value_type_pset(convert, convert_mem, &other_mem);
377 }
378 else
379 {
380 eina_error_set(EINA_ERROR_VALUE_FAILED);
381 return EINA_FALSE;
382 }
383
384 return EINA_TRUE;
385}
386
387static Eina_Bool
388_eina_value_type_ushort_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
389{
390 unsigned short *tmem = mem;
391 *tmem = va_arg(args, unsigned int); /* short is promoted to int for va_arg */
392 return EINA_TRUE;
393}
394
395static Eina_Bool
396_eina_value_type_ushort_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
397{
398 unsigned short *tmem = mem;
399 const unsigned short *p = ptr;
400 *tmem = *p;
401 return EINA_TRUE;
402}
403
404static Eina_Bool
405_eina_value_type_ushort_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
406{
407 const unsigned short *tmem = mem;
408 unsigned short *p = ptr;
409 *p = *tmem;
410 return EINA_TRUE;
411}
412
413static Eina_Bool
414_eina_value_type_uint_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
415{
416 unsigned int *tmem = mem;
417 *tmem = 0;
418 return EINA_TRUE;
419}
420
421static Eina_Bool
422_eina_value_type_uint_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
423{
424 return EINA_TRUE;
425}
426
427static Eina_Bool
428_eina_value_type_uint_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
429{
430 const unsigned int *s = src;
431 unsigned int *d = dst;
432 *d = *s;
433 return EINA_TRUE;
434}
435
436static int
437_eina_value_type_uint_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
438{
439 const unsigned int *ta = a, *tb = b;
440 if (*ta < *tb)
441 return -1;
442 else if (*ta > *tb)
443 return 1;
444 return 0;
445}
446
447static Eina_Bool
448_eina_value_type_uint_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
449{
450 const unsigned int v = *(const unsigned int *)type_mem;
451
452 eina_error_set(0);
453
454 if (convert == EINA_VALUE_TYPE_UCHAR)
455 {
456 unsigned char other_mem = v;
457 if (EINA_UNLIKELY(v > eina_value_uchar_max))
458 return EINA_FALSE;
459 return eina_value_type_pset(convert, convert_mem, &other_mem);
460 }
461 else if (convert == EINA_VALUE_TYPE_USHORT)
462 {
463 unsigned short other_mem = v;
464 if (EINA_UNLIKELY(v > eina_value_ushort_max))
465 return EINA_FALSE;
466 return eina_value_type_pset(convert, convert_mem, &other_mem);
467 }
468 else if (convert == EINA_VALUE_TYPE_UINT)
469 {
470 unsigned int other_mem = v;
471 return eina_value_type_pset(convert, convert_mem, &other_mem);
472 }
473 else if (convert == EINA_VALUE_TYPE_ULONG)
474 {
475 unsigned long other_mem = v;
476 return eina_value_type_pset(convert, convert_mem, &other_mem);
477 }
478 else if (convert == EINA_VALUE_TYPE_UINT64)
479 {
480 uint64_t other_mem = v;
481 return eina_value_type_pset(convert, convert_mem, &other_mem);
482 }
483 else if (convert == EINA_VALUE_TYPE_CHAR)
484 {
485 char other_mem = v;
486 if (EINA_UNLIKELY(v > (unsigned char)eina_value_char_max))
487 return EINA_FALSE;
488 return eina_value_type_pset(convert, convert_mem, &other_mem);
489 }
490 else if (convert == EINA_VALUE_TYPE_SHORT)
491 {
492 short other_mem = v;
493 if (EINA_UNLIKELY(v > (unsigned short)eina_value_short_max))
494 return EINA_FALSE;
495 return eina_value_type_pset(convert, convert_mem, &other_mem);
496 }
497 else if (convert == EINA_VALUE_TYPE_INT)
498 {
499 int other_mem = v;
500 if (EINA_UNLIKELY(v > (unsigned int)eina_value_int_max))
501 return EINA_FALSE;
502 return eina_value_type_pset(convert, convert_mem, &other_mem);
503 }
504 else if (convert == EINA_VALUE_TYPE_LONG)
505 {
506 long other_mem = v;
507 return eina_value_type_pset(convert, convert_mem, &other_mem);
508 }
509 else if (convert == EINA_VALUE_TYPE_INT64)
510 {
511 int64_t other_mem = v;
512 return eina_value_type_pset(convert, convert_mem, &other_mem);
513 }
514 else if (convert == EINA_VALUE_TYPE_FLOAT)
515 {
516 float other_mem = v;
517 return eina_value_type_pset(convert, convert_mem, &other_mem);
518 }
519 else if (convert == EINA_VALUE_TYPE_DOUBLE)
520 {
521 double other_mem = v;
522 return eina_value_type_pset(convert, convert_mem, &other_mem);
523 }
524 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
525 convert == EINA_VALUE_TYPE_STRING)
526 {
527 const char *other_mem;
528 char buf[64];
529 snprintf(buf, sizeof(buf), "%u", v);
530 other_mem = buf; /* required due &buf == buf */
531 return eina_value_type_pset(convert, convert_mem, &other_mem);
532 }
533 else
534 {
535 eina_error_set(EINA_ERROR_VALUE_FAILED);
536 return EINA_FALSE;
537 }
538
539 return EINA_TRUE;
540}
541
542static Eina_Bool
543_eina_value_type_uint_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
544{
545 unsigned int *tmem = mem;
546 *tmem = va_arg(args, unsigned int);
547 return EINA_TRUE;
548}
549
550static Eina_Bool
551_eina_value_type_uint_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
552{
553 unsigned int *tmem = mem;
554 const unsigned int *p = ptr;
555 *tmem = *p;
556 return EINA_TRUE;
557}
558
559static Eina_Bool
560_eina_value_type_uint_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
561{
562 const unsigned int *tmem = mem;
563 unsigned int *p = ptr;
564 *p = *tmem;
565 return EINA_TRUE;
566}
567
568static Eina_Bool
569_eina_value_type_ulong_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
570{
571 unsigned long *tmem = mem;
572 *tmem = 0;
573 return EINA_TRUE;
574}
575
576static Eina_Bool
577_eina_value_type_ulong_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
578{
579 return EINA_TRUE;
580}
581
582static Eina_Bool
583_eina_value_type_ulong_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
584{
585 const unsigned long *s = src;
586 unsigned long *d = dst;
587 *d = *s;
588 return EINA_TRUE;
589}
590
591static int
592_eina_value_type_ulong_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
593{
594 const unsigned long *ta = a, *tb = b;
595 if (*ta < *tb)
596 return -1;
597 else if (*ta > *tb)
598 return 1;
599 return 0;
600}
601
602static Eina_Bool
603_eina_value_type_ulong_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
604{
605 const unsigned long v = *(const unsigned long *)type_mem;
606
607 eina_error_set(0);
608
609 if (convert == EINA_VALUE_TYPE_UCHAR)
610 {
611 unsigned char other_mem = v;
612 if (EINA_UNLIKELY(v > eina_value_uchar_max))
613 return EINA_FALSE;
614 return eina_value_type_pset(convert, convert_mem, &other_mem);
615 }
616 else if (convert == EINA_VALUE_TYPE_USHORT)
617 {
618 unsigned short other_mem = v;
619 if (EINA_UNLIKELY(v > eina_value_ushort_max))
620 return EINA_FALSE;
621 return eina_value_type_pset(convert, convert_mem, &other_mem);
622 }
623 else if (convert == EINA_VALUE_TYPE_UINT)
624 {
625 unsigned int other_mem = v;
626 if (EINA_UNLIKELY(v > eina_value_uint_max))
627 return EINA_FALSE;
628 return eina_value_type_pset(convert, convert_mem, &other_mem);
629 }
630 else if (convert == EINA_VALUE_TYPE_ULONG)
631 {
632 unsigned long other_mem = v;
633 return eina_value_type_pset(convert, convert_mem, &other_mem);
634 }
635 else if (convert == EINA_VALUE_TYPE_UINT64)
636 {
637 uint64_t other_mem = v;
638 return eina_value_type_pset(convert, convert_mem, &other_mem);
639 }
640 else if (convert == EINA_VALUE_TYPE_CHAR)
641 {
642 char other_mem = v;
643 if (EINA_UNLIKELY(v > (unsigned char)eina_value_char_max))
644 return EINA_FALSE;
645 return eina_value_type_pset(convert, convert_mem, &other_mem);
646 }
647 else if (convert == EINA_VALUE_TYPE_SHORT)
648 {
649 short other_mem = v;
650 if (EINA_UNLIKELY(v > (unsigned short)eina_value_short_max))
651 return EINA_FALSE;
652 return eina_value_type_pset(convert, convert_mem, &other_mem);
653 }
654 else if (convert == EINA_VALUE_TYPE_INT)
655 {
656 int other_mem = v;
657 if (EINA_UNLIKELY(v > (unsigned int)eina_value_int_max))
658 return EINA_FALSE;
659 return eina_value_type_pset(convert, convert_mem, &other_mem);
660 }
661 else if (convert == EINA_VALUE_TYPE_LONG)
662 {
663 long other_mem = v;
664 if (EINA_UNLIKELY(v > (unsigned long)eina_value_long_max))
665 return EINA_FALSE;
666 return eina_value_type_pset(convert, convert_mem, &other_mem);
667 }
668 else if (convert == EINA_VALUE_TYPE_INT64)
669 {
670 int64_t other_mem = v;
671 return eina_value_type_pset(convert, convert_mem, &other_mem);
672 }
673 else if (convert == EINA_VALUE_TYPE_FLOAT)
674 {
675 float other_mem = v;
676 return eina_value_type_pset(convert, convert_mem, &other_mem);
677 }
678 else if (convert == EINA_VALUE_TYPE_DOUBLE)
679 {
680 double other_mem = v;
681 return eina_value_type_pset(convert, convert_mem, &other_mem);
682 }
683 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
684 convert == EINA_VALUE_TYPE_STRING)
685 {
686 const char *other_mem;
687 char buf[64];
688 snprintf(buf, sizeof(buf), "%lu", v);
689 other_mem = buf; /* required due &buf == buf */
690 return eina_value_type_pset(convert, convert_mem, &other_mem);
691 }
692 else
693 {
694 eina_error_set(EINA_ERROR_VALUE_FAILED);
695 return EINA_FALSE;
696 }
697
698 return EINA_TRUE;
699}
700
701static Eina_Bool
702_eina_value_type_ulong_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
703{
704 unsigned long *tmem = mem;
705 *tmem = va_arg(args, unsigned long);
706 return EINA_TRUE;
707}
708
709static Eina_Bool
710_eina_value_type_ulong_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
711{
712 unsigned long *tmem = mem;
713 const unsigned long *p = ptr;
714 *tmem = *p;
715 return EINA_TRUE;
716}
717
718static Eina_Bool
719_eina_value_type_ulong_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
720{
721 const unsigned long *tmem = mem;
722 unsigned long *p = ptr;
723 *p = *tmem;
724 return EINA_TRUE;
725}
726
727static Eina_Bool
728_eina_value_type_uint64_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
729{
730 uint64_t *tmem = mem;
731 *tmem = 0;
732 return EINA_TRUE;
733}
734
735static Eina_Bool
736_eina_value_type_uint64_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
737{
738 return EINA_TRUE;
739}
740
741static Eina_Bool
742_eina_value_type_uint64_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
743{
744 const uint64_t *s = src;
745 uint64_t *d = dst;
746 *d = *s;
747 return EINA_TRUE;
748}
749
750static int
751_eina_value_type_uint64_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
752{
753 const uint64_t *ta = a, *tb = b;
754 if (*ta < *tb)
755 return -1;
756 else if (*ta > *tb)
757 return 1;
758 return 0;
759}
760
761static Eina_Bool
762_eina_value_type_uint64_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
763{
764 const uint64_t v = *(const uint64_t *)type_mem;
765
766 eina_error_set(0);
767
768 if (convert == EINA_VALUE_TYPE_UCHAR)
769 {
770 unsigned char other_mem = v;
771 if (EINA_UNLIKELY(v > eina_value_uchar_max))
772 return EINA_FALSE;
773 return eina_value_type_pset(convert, convert_mem, &other_mem);
774 }
775 else if (convert == EINA_VALUE_TYPE_USHORT)
776 {
777 unsigned short other_mem = v;
778 if (EINA_UNLIKELY(v > eina_value_ushort_max))
779 return EINA_FALSE;
780 return eina_value_type_pset(convert, convert_mem, &other_mem);
781 }
782 else if (convert == EINA_VALUE_TYPE_UINT)
783 {
784 unsigned int other_mem = v;
785 if (EINA_UNLIKELY(v > eina_value_uint_max))
786 return EINA_FALSE;
787 return eina_value_type_pset(convert, convert_mem, &other_mem);
788 }
789 else if (convert == EINA_VALUE_TYPE_ULONG)
790 {
791 unsigned long other_mem = v;
792 if (EINA_UNLIKELY((sizeof(other_mem) != sizeof(v)) &&
793 (v > eina_value_ulong_max)))
794 return EINA_FALSE;
795 return eina_value_type_pset(convert, convert_mem, &other_mem);
796 }
797 else if (convert == EINA_VALUE_TYPE_UINT64)
798 {
799 uint64_t other_mem = v;
800 return eina_value_type_pset(convert, convert_mem, &other_mem);
801 }
802 else if (convert == EINA_VALUE_TYPE_CHAR)
803 {
804 char other_mem = v;
805 if (EINA_UNLIKELY(v > (unsigned char)eina_value_char_max))
806 return EINA_FALSE;
807 return eina_value_type_pset(convert, convert_mem, &other_mem);
808 }
809 else if (convert == EINA_VALUE_TYPE_SHORT)
810 {
811 short other_mem = v;
812 if (EINA_UNLIKELY(v > (unsigned short)eina_value_short_max))
813 return EINA_FALSE;
814 return eina_value_type_pset(convert, convert_mem, &other_mem);
815 }
816 else if (convert == EINA_VALUE_TYPE_INT)
817 {
818 int other_mem = v;
819 if (EINA_UNLIKELY(v > (unsigned int)eina_value_int_max))
820 return EINA_FALSE;
821 return eina_value_type_pset(convert, convert_mem, &other_mem);
822 }
823 else if (convert == EINA_VALUE_TYPE_LONG)
824 {
825 long other_mem = v;
826 if (EINA_UNLIKELY(v > (unsigned long)eina_value_long_max))
827 return EINA_FALSE;
828 return eina_value_type_pset(convert, convert_mem, &other_mem);
829 }
830 else if (convert == EINA_VALUE_TYPE_INT64)
831 {
832 int64_t other_mem = v;
833 if (EINA_UNLIKELY(v > (uint64_t)eina_value_int64_max))
834 return EINA_FALSE;
835 return eina_value_type_pset(convert, convert_mem, &other_mem);
836 }
837 else if (convert == EINA_VALUE_TYPE_FLOAT)
838 {
839 float other_mem = v;
840 return eina_value_type_pset(convert, convert_mem, &other_mem);
841 }
842 else if (convert == EINA_VALUE_TYPE_DOUBLE)
843 {
844 double other_mem = v;
845 return eina_value_type_pset(convert, convert_mem, &other_mem);
846 }
847 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
848 convert == EINA_VALUE_TYPE_STRING)
849 {
850 const char *other_mem;
851 char buf[64];
852 snprintf(buf, sizeof(buf), "%"PRIu64, v);
853 other_mem = buf; /* required due &buf == buf */
854 return eina_value_type_pset(convert, convert_mem, &other_mem);
855 }
856 else
857 {
858 eina_error_set(EINA_ERROR_VALUE_FAILED);
859 return EINA_FALSE;
860 }
861
862 return EINA_TRUE;
863}
864
865static Eina_Bool
866_eina_value_type_uint64_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
867{
868 uint64_t *tmem = mem;
869 *tmem = va_arg(args, uint64_t);
870 return EINA_TRUE;
871}
872
873static Eina_Bool
874_eina_value_type_uint64_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
875{
876 uint64_t *tmem = mem;
877 const uint64_t *p = ptr;
878 *tmem = *p;
879 return EINA_TRUE;
880}
881
882static Eina_Bool
883_eina_value_type_uint64_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
884{
885 const uint64_t *tmem = mem;
886 uint64_t *p = ptr;
887 *p = *tmem;
888 return EINA_TRUE;
889}
890
891static Eina_Bool
892_eina_value_type_char_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
893{
894 char *tmem = mem;
895 *tmem = 0;
896 return EINA_TRUE;
897}
898
899static Eina_Bool
900_eina_value_type_char_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
901{
902 return EINA_TRUE;
903}
904
905static Eina_Bool
906_eina_value_type_char_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
907{
908 const char *s = src;
909 char *d = dst;
910 *d = *s;
911 return EINA_TRUE;
912}
913
914static int
915_eina_value_type_char_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
916{
917 const char *ta = a, *tb = b;
918 if (*ta < *tb)
919 return -1;
920 else if (*ta > *tb)
921 return 1;
922 return 0;
923}
924
925static Eina_Bool
926_eina_value_type_char_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
927{
928 const signed char v = *(const signed char *)type_mem;
929
930 eina_error_set(0);
931
932 if (convert == EINA_VALUE_TYPE_UCHAR)
933 {
934 unsigned char other_mem = v;
935 if (EINA_UNLIKELY(v < 0))
936 return EINA_FALSE;
937 return eina_value_type_pset(convert, convert_mem, &other_mem);
938 }
939 else if (convert == EINA_VALUE_TYPE_USHORT)
940 {
941 unsigned short other_mem = v;
942 if (EINA_UNLIKELY(v < 0))
943 return EINA_FALSE;
944 return eina_value_type_pset(convert, convert_mem, &other_mem);
945 }
946 else if (convert == EINA_VALUE_TYPE_UINT)
947 {
948 unsigned int other_mem = v;
949 if (EINA_UNLIKELY(v < 0))
950 return EINA_FALSE;
951 return eina_value_type_pset(convert, convert_mem, &other_mem);
952 }
953 else if (convert == EINA_VALUE_TYPE_ULONG)
954 {
955 unsigned long other_mem = v;
956 if (EINA_UNLIKELY(v < 0))
957 return EINA_FALSE;
958 return eina_value_type_pset(convert, convert_mem, &other_mem);
959 }
960 else if (convert == EINA_VALUE_TYPE_UINT64)
961 {
962 uint64_t other_mem = v;
963 if (EINA_UNLIKELY(v < 0))
964 return EINA_FALSE;
965 return eina_value_type_pset(convert, convert_mem, &other_mem);
966 }
967 else if (convert == EINA_VALUE_TYPE_CHAR)
968 {
969 char other_mem = v;
970 return eina_value_type_pset(convert, convert_mem, &other_mem);
971 }
972 else if (convert == EINA_VALUE_TYPE_SHORT)
973 {
974 short other_mem = v;
975 return eina_value_type_pset(convert, convert_mem, &other_mem);
976 }
977 else if (convert == EINA_VALUE_TYPE_INT)
978 {
979 int other_mem = v;
980 return eina_value_type_pset(convert, convert_mem, &other_mem);
981 }
982 else if (convert == EINA_VALUE_TYPE_LONG)
983 {
984 long other_mem = v;
985 return eina_value_type_pset(convert, convert_mem, &other_mem);
986 }
987 else if (convert == EINA_VALUE_TYPE_INT64)
988 {
989 int64_t other_mem = v;
990 return eina_value_type_pset(convert, convert_mem, &other_mem);
991 }
992 else if (convert == EINA_VALUE_TYPE_FLOAT)
993 {
994 float other_mem = v;
995 return eina_value_type_pset(convert, convert_mem, &other_mem);
996 }
997 else if (convert == EINA_VALUE_TYPE_DOUBLE)
998 {
999 double other_mem = v;
1000 return eina_value_type_pset(convert, convert_mem, &other_mem);
1001 }
1002 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1003 convert == EINA_VALUE_TYPE_STRING)
1004 {
1005 const char *other_mem;
1006 char buf[64];
1007 snprintf(buf, sizeof(buf), "%hhd", v);
1008 other_mem = buf; /* required due &buf == buf */
1009 return eina_value_type_pset(convert, convert_mem, &other_mem);
1010 }
1011 else
1012 {
1013 eina_error_set(EINA_ERROR_VALUE_FAILED);
1014 return EINA_FALSE;
1015 }
1016
1017 return EINA_TRUE;
1018}
1019
1020static Eina_Bool
1021_eina_value_type_char_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1022{
1023 char *tmem = mem;
1024 *tmem = va_arg(args, int); /* char is promoted to int for va_arg */
1025 return EINA_TRUE;
1026}
1027
1028static Eina_Bool
1029_eina_value_type_char_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1030{
1031 char *tmem = mem;
1032 const char *p = ptr;
1033 *tmem = *p;
1034 return EINA_TRUE;
1035}
1036
1037static Eina_Bool
1038_eina_value_type_char_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1039{
1040 const char *tmem = mem;
1041 char *p = ptr;
1042 *p = *tmem;
1043 return EINA_TRUE;
1044}
1045
1046static Eina_Bool
1047_eina_value_type_short_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1048{
1049 short *tmem = mem;
1050 *tmem = 0;
1051 return EINA_TRUE;
1052}
1053
1054static Eina_Bool
1055_eina_value_type_short_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1056{
1057 return EINA_TRUE;
1058}
1059
1060static Eina_Bool
1061_eina_value_type_short_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1062{
1063 const short *s = src;
1064 short *d = dst;
1065 *d = *s;
1066 return EINA_TRUE;
1067}
1068
1069static int
1070_eina_value_type_short_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1071{
1072 const short *ta = a, *tb = b;
1073 if (*ta < *tb)
1074 return -1;
1075 else if (*ta > *tb)
1076 return 1;
1077 return 0;
1078}
1079
1080static Eina_Bool
1081_eina_value_type_short_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1082{
1083 const short v = *(const short *)type_mem;
1084
1085 eina_error_set(0);
1086
1087 if (convert == EINA_VALUE_TYPE_UCHAR)
1088 {
1089 unsigned char other_mem = v;
1090 if (EINA_UNLIKELY(v < 0))
1091 return EINA_FALSE;
1092 if (EINA_UNLIKELY(v > eina_value_uchar_max))
1093 return EINA_FALSE;
1094 return eina_value_type_pset(convert, convert_mem, &other_mem);
1095 }
1096 else if (convert == EINA_VALUE_TYPE_USHORT)
1097 {
1098 unsigned short other_mem = v;
1099 if (EINA_UNLIKELY(v < 0))
1100 return EINA_FALSE;
1101 return eina_value_type_pset(convert, convert_mem, &other_mem);
1102 }
1103 else if (convert == EINA_VALUE_TYPE_UINT)
1104 {
1105 unsigned int other_mem = v;
1106 if (EINA_UNLIKELY(v < 0))
1107 return EINA_FALSE;
1108 return eina_value_type_pset(convert, convert_mem, &other_mem);
1109 }
1110 else if (convert == EINA_VALUE_TYPE_ULONG)
1111 {
1112 unsigned long other_mem = v;
1113 if (EINA_UNLIKELY(v < 0))
1114 return EINA_FALSE;
1115 return eina_value_type_pset(convert, convert_mem, &other_mem);
1116 }
1117 else if (convert == EINA_VALUE_TYPE_UINT64)
1118 {
1119 uint64_t other_mem = v;
1120 if (EINA_UNLIKELY(v < 0))
1121 return EINA_FALSE;
1122 return eina_value_type_pset(convert, convert_mem, &other_mem);
1123 }
1124 else if (convert == EINA_VALUE_TYPE_CHAR)
1125 {
1126 char other_mem = v;
1127 if (EINA_UNLIKELY(v < eina_value_char_min))
1128 return EINA_FALSE;
1129 if (EINA_UNLIKELY(v > eina_value_char_max))
1130 return EINA_FALSE;
1131 return eina_value_type_pset(convert, convert_mem, &other_mem);
1132 }
1133 else if (convert == EINA_VALUE_TYPE_SHORT)
1134 {
1135 short other_mem = v;
1136 return eina_value_type_pset(convert, convert_mem, &other_mem);
1137 }
1138 else if (convert == EINA_VALUE_TYPE_INT)
1139 {
1140 int other_mem = v;
1141 return eina_value_type_pset(convert, convert_mem, &other_mem);
1142 }
1143 else if (convert == EINA_VALUE_TYPE_LONG)
1144 {
1145 long other_mem = v;
1146 return eina_value_type_pset(convert, convert_mem, &other_mem);
1147 }
1148 else if (convert == EINA_VALUE_TYPE_INT64)
1149 {
1150 int64_t other_mem = v;
1151 return eina_value_type_pset(convert, convert_mem, &other_mem);
1152 }
1153 else if (convert == EINA_VALUE_TYPE_FLOAT)
1154 {
1155 float other_mem = v;
1156 return eina_value_type_pset(convert, convert_mem, &other_mem);
1157 }
1158 else if (convert == EINA_VALUE_TYPE_DOUBLE)
1159 {
1160 double other_mem = v;
1161 return eina_value_type_pset(convert, convert_mem, &other_mem);
1162 }
1163 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1164 convert == EINA_VALUE_TYPE_STRING)
1165 {
1166 const char *other_mem;
1167 char buf[64];
1168 snprintf(buf, sizeof(buf), "%hd", v);
1169 other_mem = buf; /* required due &buf == buf */
1170 return eina_value_type_pset(convert, convert_mem, &other_mem);
1171 }
1172 else
1173 {
1174 eina_error_set(EINA_ERROR_VALUE_FAILED);
1175 return EINA_FALSE;
1176 }
1177
1178 return EINA_TRUE;
1179}
1180
1181static Eina_Bool
1182_eina_value_type_short_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1183{
1184 short *tmem = mem;
1185 *tmem = va_arg(args, int); /* short int is promoted to int for va_arg */
1186 return EINA_TRUE;
1187}
1188
1189static Eina_Bool
1190_eina_value_type_short_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1191{
1192 short *tmem = mem;
1193 const short *p = ptr;
1194 *tmem = *p;
1195 return EINA_TRUE;
1196}
1197
1198static Eina_Bool
1199_eina_value_type_short_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1200{
1201 const short *tmem = mem;
1202 short *p = ptr;
1203 *p = *tmem;
1204 return EINA_TRUE;
1205}
1206
1207static Eina_Bool
1208_eina_value_type_int_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1209{
1210 int *tmem = mem;
1211 *tmem = 0;
1212 return EINA_TRUE;
1213}
1214
1215static Eina_Bool
1216_eina_value_type_int_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1217{
1218 return EINA_TRUE;
1219}
1220
1221static Eina_Bool
1222_eina_value_type_int_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1223{
1224 const int *s = src;
1225 int *d = dst;
1226 *d = *s;
1227 return EINA_TRUE;
1228}
1229
1230static int
1231_eina_value_type_int_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1232{
1233 const int *ta = a, *tb = b;
1234 if (*ta < *tb)
1235 return -1;
1236 else if (*ta > *tb)
1237 return 1;
1238 return 0;
1239}
1240
1241static Eina_Bool
1242_eina_value_type_int_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1243{
1244 const int v = *(const int *)type_mem;
1245
1246 eina_error_set(0);
1247
1248 if (convert == EINA_VALUE_TYPE_UCHAR)
1249 {
1250 unsigned char other_mem = v;
1251 if (EINA_UNLIKELY(v < 0))
1252 return EINA_FALSE;
1253 if (EINA_UNLIKELY(v > eina_value_uchar_max))
1254 return EINA_FALSE;
1255 return eina_value_type_pset(convert, convert_mem, &other_mem);
1256 }
1257 else if (convert == EINA_VALUE_TYPE_USHORT)
1258 {
1259 unsigned short other_mem = v;
1260 if (EINA_UNLIKELY(v < 0))
1261 return EINA_FALSE;
1262 if (EINA_UNLIKELY(v > eina_value_ushort_max))
1263 return EINA_FALSE;
1264 return eina_value_type_pset(convert, convert_mem, &other_mem);
1265 }
1266 else if (convert == EINA_VALUE_TYPE_UINT)
1267 {
1268 unsigned int other_mem = v;
1269 if (EINA_UNLIKELY(v < 0))
1270 return EINA_FALSE;
1271 return eina_value_type_pset(convert, convert_mem, &other_mem);
1272 }
1273 else if (convert == EINA_VALUE_TYPE_ULONG)
1274 {
1275 unsigned long other_mem = v;
1276 if (EINA_UNLIKELY(v < 0))
1277 return EINA_FALSE;
1278 return eina_value_type_pset(convert, convert_mem, &other_mem);
1279 }
1280 else if (convert == EINA_VALUE_TYPE_UINT64)
1281 {
1282 uint64_t other_mem = v;
1283 if (EINA_UNLIKELY(v < 0))
1284 return EINA_FALSE;
1285 return eina_value_type_pset(convert, convert_mem, &other_mem);
1286 }
1287 else if (convert == EINA_VALUE_TYPE_CHAR)
1288 {
1289 char other_mem = v;
1290 if (EINA_UNLIKELY(v < eina_value_char_min))
1291 return EINA_FALSE;
1292 if (EINA_UNLIKELY(v > eina_value_char_max))
1293 return EINA_FALSE;
1294 return eina_value_type_pset(convert, convert_mem, &other_mem);
1295 }
1296 else if (convert == EINA_VALUE_TYPE_SHORT)
1297 {
1298 short other_mem = v;
1299 if (EINA_UNLIKELY(v < eina_value_short_min))
1300 return EINA_FALSE;
1301 if (EINA_UNLIKELY(v > eina_value_short_max))
1302 return EINA_FALSE;
1303 return eina_value_type_pset(convert, convert_mem, &other_mem);
1304 }
1305 else if (convert == EINA_VALUE_TYPE_INT)
1306 {
1307 int other_mem = v;
1308 return eina_value_type_pset(convert, convert_mem, &other_mem);
1309 }
1310 else if (convert == EINA_VALUE_TYPE_LONG)
1311 {
1312 long other_mem = v;
1313 return eina_value_type_pset(convert, convert_mem, &other_mem);
1314 }
1315 else if (convert == EINA_VALUE_TYPE_INT64)
1316 {
1317 int64_t other_mem = v;
1318 return eina_value_type_pset(convert, convert_mem, &other_mem);
1319 }
1320 else if (convert == EINA_VALUE_TYPE_FLOAT)
1321 {
1322 float other_mem = v;
1323 return eina_value_type_pset(convert, convert_mem, &other_mem);
1324 }
1325 else if (convert == EINA_VALUE_TYPE_DOUBLE)
1326 {
1327 double other_mem = v;
1328 return eina_value_type_pset(convert, convert_mem, &other_mem);
1329 }
1330 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1331 convert == EINA_VALUE_TYPE_STRING)
1332 {
1333 const char *other_mem;
1334 char buf[64];
1335 snprintf(buf, sizeof(buf), "%d", v);
1336 other_mem = buf; /* required due &buf == buf */
1337 return eina_value_type_pset(convert, convert_mem, &other_mem);
1338 }
1339 else
1340 {
1341 eina_error_set(EINA_ERROR_VALUE_FAILED);
1342 return EINA_FALSE;
1343 }
1344
1345 return EINA_TRUE;
1346}
1347
1348static Eina_Bool
1349_eina_value_type_int_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1350{
1351 int *tmem = mem;
1352 *tmem = va_arg(args, int);
1353 return EINA_TRUE;
1354}
1355
1356static Eina_Bool
1357_eina_value_type_int_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1358{
1359 int *tmem = mem;
1360 const int *p = ptr;
1361 *tmem = *p;
1362 return EINA_TRUE;
1363}
1364
1365static Eina_Bool
1366_eina_value_type_int_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1367{
1368 const int *tmem = mem;
1369 int *p = ptr;
1370 *p = *tmem;
1371 return EINA_TRUE;
1372}
1373
1374static Eina_Bool
1375_eina_value_type_long_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1376{
1377 long *tmem = mem;
1378 *tmem = 0;
1379 return EINA_TRUE;
1380}
1381
1382static Eina_Bool
1383_eina_value_type_long_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1384{
1385 return EINA_TRUE;
1386}
1387
1388static Eina_Bool
1389_eina_value_type_long_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1390{
1391 const long *s = src;
1392 long *d = dst;
1393 *d = *s;
1394 return EINA_TRUE;
1395}
1396
1397static int
1398_eina_value_type_long_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1399{
1400 const long *ta = a, *tb = b;
1401 if (*ta < *tb)
1402 return -1;
1403 else if (*ta > *tb)
1404 return 1;
1405 return 0;
1406}
1407
1408static Eina_Bool
1409_eina_value_type_long_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1410{
1411 const long v = *(const long *)type_mem;
1412
1413 eina_error_set(0);
1414
1415 if (convert == EINA_VALUE_TYPE_UCHAR)
1416 {
1417 unsigned char other_mem = v;
1418 if (EINA_UNLIKELY(v < 0))
1419 return EINA_FALSE;
1420 if (EINA_UNLIKELY((unsigned long) v > eina_value_uchar_max))
1421 return EINA_FALSE;
1422 return eina_value_type_pset(convert, convert_mem, &other_mem);
1423 }
1424 else if (convert == EINA_VALUE_TYPE_USHORT)
1425 {
1426 unsigned short other_mem = v;
1427 if (EINA_UNLIKELY(v < 0))
1428 return EINA_FALSE;
1429 if (EINA_UNLIKELY((unsigned long) v > eina_value_ushort_max))
1430 return EINA_FALSE;
1431 return eina_value_type_pset(convert, convert_mem, &other_mem);
1432 }
1433 else if (convert == EINA_VALUE_TYPE_UINT)
1434 {
1435 unsigned int other_mem = v;
1436 if (EINA_UNLIKELY(v < 0))
1437 return EINA_FALSE;
1438 if (EINA_UNLIKELY((unsigned long) v > eina_value_uint_max))
1439 return EINA_FALSE;
1440 return eina_value_type_pset(convert, convert_mem, &other_mem);
1441 }
1442 else if (convert == EINA_VALUE_TYPE_ULONG)
1443 {
1444 unsigned long other_mem = v;
1445 if (EINA_UNLIKELY(v < 0))
1446 return EINA_FALSE;
1447 return eina_value_type_pset(convert, convert_mem, &other_mem);
1448 }
1449 else if (convert == EINA_VALUE_TYPE_UINT64)
1450 {
1451 uint64_t other_mem = v;
1452 if (EINA_UNLIKELY(v < 0))
1453 return EINA_FALSE;
1454 return eina_value_type_pset(convert, convert_mem, &other_mem);
1455 }
1456 else if (convert == EINA_VALUE_TYPE_CHAR)
1457 {
1458 char other_mem = v;
1459 if (EINA_UNLIKELY(v < eina_value_char_min))
1460 return EINA_FALSE;
1461 if (EINA_UNLIKELY(v > eina_value_char_max))
1462 return EINA_FALSE;
1463 return eina_value_type_pset(convert, convert_mem, &other_mem);
1464 }
1465 else if (convert == EINA_VALUE_TYPE_SHORT)
1466 {
1467 short other_mem = v;
1468 if (EINA_UNLIKELY(v < eina_value_short_min))
1469 return EINA_FALSE;
1470 if (EINA_UNLIKELY(v > eina_value_short_max))
1471 return EINA_FALSE;
1472 return eina_value_type_pset(convert, convert_mem, &other_mem);
1473 }
1474 else if (convert == EINA_VALUE_TYPE_INT)
1475 {
1476 int other_mem = v;
1477 if (EINA_UNLIKELY(v < eina_value_int_min))
1478 return EINA_FALSE;
1479 if (EINA_UNLIKELY(v > eina_value_int_max))
1480 return EINA_FALSE;
1481 return eina_value_type_pset(convert, convert_mem, &other_mem);
1482 }
1483 else if (convert == EINA_VALUE_TYPE_LONG)
1484 {
1485 long other_mem = v;
1486 return eina_value_type_pset(convert, convert_mem, &other_mem);
1487 }
1488 else if (convert == EINA_VALUE_TYPE_INT64)
1489 {
1490 int64_t other_mem = v;
1491 return eina_value_type_pset(convert, convert_mem, &other_mem);
1492 }
1493 else if (convert == EINA_VALUE_TYPE_FLOAT)
1494 {
1495 float other_mem = v;
1496 return eina_value_type_pset(convert, convert_mem, &other_mem);
1497 }
1498 else if (convert == EINA_VALUE_TYPE_DOUBLE)
1499 {
1500 double other_mem = v;
1501 return eina_value_type_pset(convert, convert_mem, &other_mem);
1502 }
1503 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1504 convert == EINA_VALUE_TYPE_STRING)
1505 {
1506 const char *other_mem;
1507 char buf[64];
1508 snprintf(buf, sizeof(buf), "%ld", v);
1509 other_mem = buf; /* required due &buf == buf */
1510 return eina_value_type_pset(convert, convert_mem, &other_mem);
1511 }
1512 else
1513 {
1514 eina_error_set(EINA_ERROR_VALUE_FAILED);
1515 return EINA_FALSE;
1516 }
1517
1518 return EINA_TRUE;
1519}
1520
1521static Eina_Bool
1522_eina_value_type_long_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1523{
1524 long *tmem = mem;
1525 *tmem = va_arg(args, long);
1526 return EINA_TRUE;
1527}
1528
1529static Eina_Bool
1530_eina_value_type_long_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1531{
1532 long *tmem = mem;
1533 const long *p = ptr;
1534 *tmem = *p;
1535 return EINA_TRUE;
1536}
1537
1538static Eina_Bool
1539_eina_value_type_long_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1540{
1541 const long *tmem = mem;
1542 long *p = ptr;
1543 *p = *tmem;
1544 return EINA_TRUE;
1545}
1546
1547static Eina_Bool
1548_eina_value_type_int64_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1549{
1550 int64_t *tmem = mem;
1551 *tmem = 0;
1552 return EINA_TRUE;
1553}
1554
1555static Eina_Bool
1556_eina_value_type_int64_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1557{
1558 return EINA_TRUE;
1559}
1560
1561static Eina_Bool
1562_eina_value_type_int64_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1563{
1564 const int64_t *s = src;
1565 int64_t *d = dst;
1566 *d = *s;
1567 return EINA_TRUE;
1568}
1569
1570static int
1571_eina_value_type_int64_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1572{
1573 const int64_t *ta = a, *tb = b;
1574 if (*ta < *tb)
1575 return -1;
1576 else if (*ta > *tb)
1577 return 1;
1578 return 0;
1579}
1580
1581static Eina_Bool
1582_eina_value_type_int64_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1583{
1584 const int64_t v = *(const int64_t *)type_mem;
1585
1586 eina_error_set(0);
1587
1588 if (convert == EINA_VALUE_TYPE_UCHAR)
1589 {
1590 unsigned char other_mem = v;
1591 if (EINA_UNLIKELY(v < 0))
1592 return EINA_FALSE;
1593 if (EINA_UNLIKELY(v > eina_value_uchar_max))
1594 return EINA_FALSE;
1595 return eina_value_type_pset(convert, convert_mem, &other_mem);
1596 }
1597 else if (convert == EINA_VALUE_TYPE_USHORT)
1598 {
1599 unsigned short other_mem = v;
1600 if (EINA_UNLIKELY(v < 0))
1601 return EINA_FALSE;
1602 if (EINA_UNLIKELY(v > eina_value_ushort_max))
1603 return EINA_FALSE;
1604 return eina_value_type_pset(convert, convert_mem, &other_mem);
1605 }
1606 else if (convert == EINA_VALUE_TYPE_UINT)
1607 {
1608 unsigned int other_mem = v;
1609 if (EINA_UNLIKELY(v < 0))
1610 return EINA_FALSE;
1611 if (EINA_UNLIKELY(v > eina_value_uint_max))
1612 return EINA_FALSE;
1613 return eina_value_type_pset(convert, convert_mem, &other_mem);
1614 }
1615 else if (convert == EINA_VALUE_TYPE_ULONG)
1616 {
1617 unsigned long other_mem = v;
1618 if (EINA_UNLIKELY(v < 0))
1619 return EINA_FALSE;
1620 if (EINA_UNLIKELY((sizeof(other_mem) != sizeof(v)) &&
1621 (v > eina_value_ulong_max)))
1622 return EINA_FALSE;
1623 return eina_value_type_pset(convert, convert_mem, &other_mem);
1624 }
1625 else if (convert == EINA_VALUE_TYPE_UINT64)
1626 {
1627 uint64_t other_mem = v;
1628 if (EINA_UNLIKELY(v < 0))
1629 return EINA_FALSE;
1630 return eina_value_type_pset(convert, convert_mem, &other_mem);
1631 }
1632 else if (convert == EINA_VALUE_TYPE_CHAR)
1633 {
1634 char other_mem = v;
1635 if (EINA_UNLIKELY(v < eina_value_char_min))
1636 return EINA_FALSE;
1637 if (EINA_UNLIKELY(v > eina_value_char_max))
1638 return EINA_FALSE;
1639 return eina_value_type_pset(convert, convert_mem, &other_mem);
1640 }
1641 else if (convert == EINA_VALUE_TYPE_SHORT)
1642 {
1643 short other_mem = v;
1644 if (EINA_UNLIKELY(v < eina_value_short_min))
1645 return EINA_FALSE;
1646 if (EINA_UNLIKELY(v > eina_value_short_max))
1647 return EINA_FALSE;
1648 return eina_value_type_pset(convert, convert_mem, &other_mem);
1649 }
1650 else if (convert == EINA_VALUE_TYPE_INT)
1651 {
1652 int other_mem = v;
1653 if (EINA_UNLIKELY(v < eina_value_int_min))
1654 return EINA_FALSE;
1655 if (EINA_UNLIKELY(v > eina_value_int_max))
1656 return EINA_FALSE;
1657 return eina_value_type_pset(convert, convert_mem, &other_mem);
1658 }
1659 else if (convert == EINA_VALUE_TYPE_LONG)
1660 {
1661 long other_mem = v;
1662 if (EINA_UNLIKELY(v < eina_value_long_min))
1663 return EINA_FALSE;
1664 if (EINA_UNLIKELY(v > eina_value_long_max))
1665 return EINA_FALSE;
1666 return eina_value_type_pset(convert, convert_mem, &other_mem);
1667 }
1668 else if (convert == EINA_VALUE_TYPE_INT64)
1669 {
1670 int64_t other_mem = v;
1671 return eina_value_type_pset(convert, convert_mem, &other_mem);
1672 }
1673 else if (convert == EINA_VALUE_TYPE_FLOAT)
1674 {
1675 float other_mem = v;
1676 return eina_value_type_pset(convert, convert_mem, &other_mem);
1677 }
1678 else if (convert == EINA_VALUE_TYPE_DOUBLE)
1679 {
1680 double other_mem = v;
1681 return eina_value_type_pset(convert, convert_mem, &other_mem);
1682 }
1683 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1684 convert == EINA_VALUE_TYPE_STRING)
1685 {
1686 const char *other_mem;
1687 char buf[64];
1688 snprintf(buf, sizeof(buf), "%"PRId64, v);
1689 other_mem = buf; /* required due &buf == buf */
1690 return eina_value_type_pset(convert, convert_mem, &other_mem);
1691 }
1692 else
1693 {
1694 eina_error_set(EINA_ERROR_VALUE_FAILED);
1695 return EINA_FALSE;
1696 }
1697
1698 return EINA_TRUE;
1699}
1700
1701static Eina_Bool
1702_eina_value_type_int64_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1703{
1704 int64_t *tmem = mem;
1705 *tmem = va_arg(args, int64_t);
1706 return EINA_TRUE;
1707}
1708
1709static Eina_Bool
1710_eina_value_type_int64_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1711{
1712 int64_t *tmem = mem;
1713 const int64_t *p = ptr;
1714 *tmem = *p;
1715 return EINA_TRUE;
1716}
1717
1718static Eina_Bool
1719_eina_value_type_int64_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1720{
1721 const int64_t *tmem = mem;
1722 int64_t *p = ptr;
1723 *p = *tmem;
1724 return EINA_TRUE;
1725}
1726
1727static Eina_Bool
1728_eina_value_type_float_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1729{
1730 float *tmem = mem;
1731 *tmem = 0;
1732 return EINA_TRUE;
1733}
1734
1735static Eina_Bool
1736_eina_value_type_float_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1737{
1738 return EINA_TRUE;
1739}
1740
1741static Eina_Bool
1742_eina_value_type_float_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1743{
1744 const float *s = src;
1745 float *d = dst;
1746 *d = *s;
1747 return EINA_TRUE;
1748}
1749
1750static int
1751_eina_value_type_float_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1752{
1753 const float *ta = a, *tb = b;
1754 if (*ta < *tb)
1755 return -1;
1756 else if (*ta > *tb)
1757 return 1;
1758 return 0;
1759}
1760
1761static Eina_Bool
1762_eina_value_type_float_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1763{
1764 const float v = *(const float *)type_mem;
1765
1766 eina_error_set(0);
1767
1768 if (convert == EINA_VALUE_TYPE_UCHAR)
1769 {
1770 unsigned char other_mem = v;
1771 if (EINA_UNLIKELY(v < 0))
1772 return EINA_FALSE;
1773 if (EINA_UNLIKELY(v > eina_value_uchar_max))
1774 return EINA_FALSE;
1775 return eina_value_type_pset(convert, convert_mem, &other_mem);
1776 }
1777 else if (convert == EINA_VALUE_TYPE_USHORT)
1778 {
1779 unsigned short other_mem = v;
1780 if (EINA_UNLIKELY(v < 0))
1781 return EINA_FALSE;
1782 if (EINA_UNLIKELY(v > eina_value_ushort_max))
1783 return EINA_FALSE;
1784 return eina_value_type_pset(convert, convert_mem, &other_mem);
1785 }
1786 else if (convert == EINA_VALUE_TYPE_UINT)
1787 {
1788 unsigned int other_mem = v;
1789 if (EINA_UNLIKELY(v < 0))
1790 return EINA_FALSE;
1791 if (EINA_UNLIKELY(v > eina_value_uint_max))
1792 return EINA_FALSE;
1793 return eina_value_type_pset(convert, convert_mem, &other_mem);
1794 }
1795 else if (convert == EINA_VALUE_TYPE_ULONG)
1796 {
1797 unsigned long other_mem = v;
1798 if (EINA_UNLIKELY(v < 0))
1799 return EINA_FALSE;
1800 if (EINA_UNLIKELY((sizeof(other_mem) != sizeof(v)) &&
1801 (v > eina_value_ulong_max)))
1802 return EINA_FALSE;
1803 return eina_value_type_pset(convert, convert_mem, &other_mem);
1804 }
1805 else if (convert == EINA_VALUE_TYPE_UINT64)
1806 {
1807 uint64_t other_mem = v;
1808 if (EINA_UNLIKELY(v < 0))
1809 return EINA_FALSE;
1810 if (EINA_UNLIKELY(v > eina_value_uint64_max))
1811 return EINA_FALSE;
1812 return eina_value_type_pset(convert, convert_mem, &other_mem);
1813 }
1814 else if (convert == EINA_VALUE_TYPE_CHAR)
1815 {
1816 char other_mem = v;
1817 if (EINA_UNLIKELY(v < eina_value_char_min))
1818 return EINA_FALSE;
1819 if (EINA_UNLIKELY(v > eina_value_char_max))
1820 return EINA_FALSE;
1821 return eina_value_type_pset(convert, convert_mem, &other_mem);
1822 }
1823 else if (convert == EINA_VALUE_TYPE_SHORT)
1824 {
1825 short other_mem = v;
1826 if (EINA_UNLIKELY(v < eina_value_short_min))
1827 return EINA_FALSE;
1828 if (EINA_UNLIKELY(v > eina_value_short_max))
1829 return EINA_FALSE;
1830 return eina_value_type_pset(convert, convert_mem, &other_mem);
1831 }
1832 else if (convert == EINA_VALUE_TYPE_INT)
1833 {
1834 int other_mem = v;
1835 if (EINA_UNLIKELY(v < eina_value_int_min))
1836 return EINA_FALSE;
1837 if (EINA_UNLIKELY(v > eina_value_int_max))
1838 return EINA_FALSE;
1839 return eina_value_type_pset(convert, convert_mem, &other_mem);
1840 }
1841 else if (convert == EINA_VALUE_TYPE_LONG)
1842 {
1843 long other_mem = v;
1844 if (EINA_UNLIKELY(v < eina_value_long_min))
1845 return EINA_FALSE;
1846 if (EINA_UNLIKELY(v > eina_value_long_max))
1847 return EINA_FALSE;
1848 return eina_value_type_pset(convert, convert_mem, &other_mem);
1849 }
1850 else if (convert == EINA_VALUE_TYPE_INT64)
1851 {
1852 int64_t other_mem = v;
1853 if (EINA_UNLIKELY(v < eina_value_int64_min))
1854 return EINA_FALSE;
1855 if (EINA_UNLIKELY(v > eina_value_int64_max))
1856 return EINA_FALSE;
1857 return eina_value_type_pset(convert, convert_mem, &other_mem);
1858 }
1859 else if (convert == EINA_VALUE_TYPE_FLOAT)
1860 {
1861 float other_mem = v;
1862 return eina_value_type_pset(convert, convert_mem, &other_mem);
1863 }
1864 else if (convert == EINA_VALUE_TYPE_DOUBLE)
1865 {
1866 double other_mem = v;
1867 return eina_value_type_pset(convert, convert_mem, &other_mem);
1868 }
1869 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
1870 convert == EINA_VALUE_TYPE_STRING)
1871 {
1872 const char *other_mem;
1873 char buf[64];
1874 snprintf(buf, sizeof(buf), "%f", v);
1875 other_mem = buf; /* required due &buf == buf */
1876 return eina_value_type_pset(convert, convert_mem, &other_mem);
1877 }
1878 else
1879 {
1880 eina_error_set(EINA_ERROR_VALUE_FAILED);
1881 return EINA_FALSE;
1882 }
1883
1884 return EINA_TRUE;
1885}
1886
1887static Eina_Bool
1888_eina_value_type_float_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
1889{
1890 float *tmem = mem;
1891 *tmem = va_arg(args, double); /* float is promoted to double for va_args */
1892 return EINA_TRUE;
1893}
1894
1895static Eina_Bool
1896_eina_value_type_float_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
1897{
1898 float *tmem = mem;
1899 const float *p = ptr;
1900 *tmem = *p;
1901 return EINA_TRUE;
1902}
1903
1904static Eina_Bool
1905_eina_value_type_float_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
1906{
1907 const float *tmem = mem;
1908 float *p = ptr;
1909 *p = *tmem;
1910 return EINA_TRUE;
1911}
1912
1913static Eina_Bool
1914_eina_value_type_double_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
1915{
1916 double *tmem = mem;
1917 *tmem = 0;
1918 return EINA_TRUE;
1919}
1920
1921static Eina_Bool
1922_eina_value_type_double_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
1923{
1924 return EINA_TRUE;
1925}
1926
1927static Eina_Bool
1928_eina_value_type_double_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
1929{
1930 const double *s = src;
1931 double *d = dst;
1932 *d = *s;
1933 return EINA_TRUE;
1934}
1935
1936static int
1937_eina_value_type_double_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
1938{
1939 const double *ta = a, *tb = b;
1940 if (*ta < *tb)
1941 return -1;
1942 else if (*ta > *tb)
1943 return 1;
1944 return 0;
1945}
1946
1947static Eina_Bool
1948_eina_value_type_double_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
1949{
1950 const double v = *(const double *)type_mem;
1951
1952 eina_error_set(0);
1953
1954 if (convert == EINA_VALUE_TYPE_UCHAR)
1955 {
1956 unsigned char other_mem = v;
1957 if (EINA_UNLIKELY(v < 0))
1958 return EINA_FALSE;
1959 if (EINA_UNLIKELY(v > eina_value_uchar_max))
1960 return EINA_FALSE;
1961 return eina_value_type_pset(convert, convert_mem, &other_mem);
1962 }
1963 else if (convert == EINA_VALUE_TYPE_USHORT)
1964 {
1965 unsigned short other_mem = v;
1966 if (EINA_UNLIKELY(v < 0))
1967 return EINA_FALSE;
1968 if (EINA_UNLIKELY(v > eina_value_ushort_max))
1969 return EINA_FALSE;
1970 return eina_value_type_pset(convert, convert_mem, &other_mem);
1971 }
1972 else if (convert == EINA_VALUE_TYPE_UINT)
1973 {
1974 unsigned int other_mem = v;
1975 if (EINA_UNLIKELY(v < 0))
1976 return EINA_FALSE;
1977 if (EINA_UNLIKELY(v > eina_value_uint_max))
1978 return EINA_FALSE;
1979 return eina_value_type_pset(convert, convert_mem, &other_mem);
1980 }
1981 else if (convert == EINA_VALUE_TYPE_ULONG)
1982 {
1983 unsigned long other_mem = v;
1984 if (EINA_UNLIKELY(v < 0))
1985 return EINA_FALSE;
1986 if (EINA_UNLIKELY((sizeof(other_mem) != sizeof(v)) &&
1987 (v > eina_value_ulong_max)))
1988 return EINA_FALSE;
1989 return eina_value_type_pset(convert, convert_mem, &other_mem);
1990 }
1991 else if (convert == EINA_VALUE_TYPE_UINT64)
1992 {
1993 uint64_t other_mem = v;
1994 if (EINA_UNLIKELY(v < 0))
1995 return EINA_FALSE;
1996 return eina_value_type_pset(convert, convert_mem, &other_mem);
1997 }
1998 else if (convert == EINA_VALUE_TYPE_CHAR)
1999 {
2000 char other_mem = v;
2001 if (EINA_UNLIKELY(v < eina_value_char_min))
2002 return EINA_FALSE;
2003 if (EINA_UNLIKELY(v > eina_value_char_max))
2004 return EINA_FALSE;
2005 return eina_value_type_pset(convert, convert_mem, &other_mem);
2006 }
2007 else if (convert == EINA_VALUE_TYPE_SHORT)
2008 {
2009 short other_mem = v;
2010 if (EINA_UNLIKELY(v < eina_value_short_min))
2011 return EINA_FALSE;
2012 if (EINA_UNLIKELY(v > eina_value_short_max))
2013 return EINA_FALSE;
2014 return eina_value_type_pset(convert, convert_mem, &other_mem);
2015 }
2016 else if (convert == EINA_VALUE_TYPE_INT)
2017 {
2018 int other_mem = v;
2019 if (EINA_UNLIKELY(v < eina_value_int_min))
2020 return EINA_FALSE;
2021 if (EINA_UNLIKELY(v > eina_value_int_max))
2022 return EINA_FALSE;
2023 return eina_value_type_pset(convert, convert_mem, &other_mem);
2024 }
2025 else if (convert == EINA_VALUE_TYPE_LONG)
2026 {
2027 long other_mem = v;
2028 if (EINA_UNLIKELY(v < eina_value_long_min))
2029 return EINA_FALSE;
2030 if (EINA_UNLIKELY(v > eina_value_long_max))
2031 return EINA_FALSE;
2032 return eina_value_type_pset(convert, convert_mem, &other_mem);
2033 }
2034 else if (convert == EINA_VALUE_TYPE_INT64)
2035 {
2036 int64_t other_mem = v;
2037 return eina_value_type_pset(convert, convert_mem, &other_mem);
2038 }
2039 else if (convert == EINA_VALUE_TYPE_FLOAT)
2040 {
2041 float other_mem = v;
2042 return eina_value_type_pset(convert, convert_mem, &other_mem);
2043 }
2044 else if (convert == EINA_VALUE_TYPE_DOUBLE)
2045 {
2046 double other_mem = v;
2047 return eina_value_type_pset(convert, convert_mem, &other_mem);
2048 }
2049 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
2050 convert == EINA_VALUE_TYPE_STRING)
2051 {
2052 const char *other_mem;
2053 char buf[64];
2054 snprintf(buf, sizeof(buf), "%g", (double)v);
2055 other_mem = buf; /* required due &buf == buf */
2056 return eina_value_type_pset(convert, convert_mem, &other_mem);
2057 }
2058 else
2059 {
2060 eina_error_set(EINA_ERROR_VALUE_FAILED);
2061 return EINA_FALSE;
2062 }
2063
2064 return EINA_TRUE;
2065}
2066
2067static Eina_Bool
2068_eina_value_type_double_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
2069{
2070 double *tmem = mem;
2071 *tmem = va_arg(args, double);
2072 return EINA_TRUE;
2073}
2074
2075static Eina_Bool
2076_eina_value_type_double_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
2077{
2078 double *tmem = mem;
2079 const double *p = ptr;
2080 *tmem = *p;
2081 return EINA_TRUE;
2082}
2083
2084static Eina_Bool
2085_eina_value_type_double_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
2086{
2087 const double *tmem = mem;
2088 double *p = ptr;
2089 *p = *tmem;
2090 return EINA_TRUE;
2091}
2092
2093static Eina_Bool
2094_eina_value_type_string_common_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
2095{
2096 const char **tmem = mem;
2097 *tmem = NULL;
2098 return EINA_TRUE;
2099}
2100
2101static int
2102_eina_value_type_string_common_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
2103{
2104 const char *sa = *(const char **)a;
2105 const char *sb = *(const char **)b;
2106 if (sa == sb)
2107 return 0;
2108 if (sa == NULL)
2109 return -1;
2110 if (sb == NULL)
2111 return 1;
2112 return strcmp(sa, sb);
2113}
2114
2115static Eina_Bool
2116_eina_value_type_string_common_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
2117{
2118 const char *v = *(const char **)type_mem;
2119
2120 eina_error_set(0);
2121
2122 if (convert == EINA_VALUE_TYPE_UCHAR)
2123 {
2124 unsigned char other_mem;
2125 if ((sscanf(v, "%hhu", &other_mem) != 1) &&
2126 (sscanf(v, "%hhx", &other_mem) != 1) &&
2127 (sscanf(v, "%hho", &other_mem) != 1))
2128 return EINA_FALSE;
2129 return eina_value_type_pset(convert, convert_mem, &other_mem);
2130 }
2131 else if (convert == EINA_VALUE_TYPE_USHORT)
2132 {
2133 unsigned short other_mem;
2134 if ((sscanf(v, "%hu", &other_mem) != 1) &&
2135 (sscanf(v, "%hx", &other_mem) != 1) &&
2136 (sscanf(v, "%ho", &other_mem) != 1))
2137 return EINA_FALSE;
2138 return eina_value_type_pset(convert, convert_mem, &other_mem);
2139 }
2140 else if (convert == EINA_VALUE_TYPE_UINT)
2141 {
2142 unsigned int other_mem;
2143 if ((sscanf(v, "%u", &other_mem) != 1) &&
2144 (sscanf(v, "%x", &other_mem) != 1) &&
2145 (sscanf(v, "%o", &other_mem) != 1))
2146 return EINA_FALSE;
2147 return eina_value_type_pset(convert, convert_mem, &other_mem);
2148 }
2149 else if (convert == EINA_VALUE_TYPE_ULONG)
2150 {
2151 unsigned long other_mem;
2152 if ((sscanf(v, "%lu", &other_mem) != 1) &&
2153 (sscanf(v, "%lx", &other_mem) != 1) &&
2154 (sscanf(v, "%lo", &other_mem) != 1))
2155 return EINA_FALSE;
2156 return eina_value_type_pset(convert, convert_mem, &other_mem);
2157 }
2158 else if (convert == EINA_VALUE_TYPE_UINT64)
2159 {
2160 uint64_t other_mem;
2161 if ((sscanf(v, "%"SCNu64, &other_mem) != 1) &&
2162 (sscanf(v, "%"SCNx64, &other_mem) != 1) &&
2163 (sscanf(v, "%"SCNo64, &other_mem) != 1))
2164 return EINA_FALSE;
2165 return eina_value_type_pset(convert, convert_mem, &other_mem);
2166 }
2167 else if (convert == EINA_VALUE_TYPE_CHAR)
2168 {
2169 char other_mem;
2170 if ((sscanf(v, "%hhd", &other_mem) != 1) &&
2171 (sscanf(v, "%hhx", &other_mem) != 1) &&
2172 (sscanf(v, "%hho", &other_mem) != 1))
2173 return EINA_FALSE;
2174 return eina_value_type_pset(convert, convert_mem, &other_mem);
2175 }
2176 else if (convert == EINA_VALUE_TYPE_SHORT)
2177 {
2178 short other_mem;
2179 if ((sscanf(v, "%hd", &other_mem) != 1) &&
2180 (sscanf(v, "%hx", &other_mem) != 1) &&
2181 (sscanf(v, "%ho", &other_mem) != 1))
2182 return EINA_FALSE;
2183 return eina_value_type_pset(convert, convert_mem, &other_mem);
2184 }
2185 else if (convert == EINA_VALUE_TYPE_INT)
2186 {
2187 int other_mem;
2188 if ((sscanf(v, "%d", &other_mem) != 1) &&
2189 (sscanf(v, "%x", &other_mem) != 1) &&
2190 (sscanf(v, "%o", &other_mem) != 1))
2191 return EINA_FALSE;
2192 return eina_value_type_pset(convert, convert_mem, &other_mem);
2193 }
2194 else if (convert == EINA_VALUE_TYPE_LONG)
2195 {
2196 long other_mem;
2197 if ((sscanf(v, "%ld", &other_mem) != 1) &&
2198 (sscanf(v, "%lx", &other_mem) != 1) &&
2199 (sscanf(v, "%lo", &other_mem) != 1))
2200 return EINA_FALSE;
2201 return eina_value_type_pset(convert, convert_mem, &other_mem);
2202 }
2203 else if (convert == EINA_VALUE_TYPE_INT64)
2204 {
2205 int64_t other_mem;
2206 if ((sscanf(v, "%"SCNd64, &other_mem) != 1) &&
2207 (sscanf(v, "%"SCNx64, &other_mem) != 1) &&
2208 (sscanf(v, "%"SCNo64, &other_mem) != 1))
2209 return EINA_FALSE;
2210 return eina_value_type_pset(convert, convert_mem, &other_mem);
2211 }
2212 else if (convert == EINA_VALUE_TYPE_FLOAT)
2213 {
2214 float other_mem;
2215 if (sscanf(v, "%f", &other_mem) != 1)
2216 return EINA_FALSE;
2217 return eina_value_type_pset(convert, convert_mem, &other_mem);
2218 }
2219 else if (convert == EINA_VALUE_TYPE_DOUBLE)
2220 {
2221 double other_mem;
2222 if (sscanf(v, "%lf", &other_mem) != 1)
2223 return EINA_FALSE;
2224 return eina_value_type_pset(convert, convert_mem, &other_mem);
2225 }
2226 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
2227 convert == EINA_VALUE_TYPE_STRING)
2228 {
2229 return eina_value_type_pset(convert, convert_mem, &v);
2230 }
2231 else
2232 {
2233 eina_error_set(EINA_ERROR_VALUE_FAILED);
2234 return EINA_FALSE;
2235 }
2236
2237 return EINA_TRUE;
2238}
2239
2240static Eina_Bool
2241_eina_value_type_string_common_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
2242{
2243 memcpy(ptr, mem, sizeof(const char *));
2244 return EINA_TRUE;
2245}
2246
2247static Eina_Bool
2248_eina_value_type_stringshare_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
2249{
2250 const char **tmem = mem;
2251 if (*tmem) eina_stringshare_del(*tmem);
2252 return EINA_TRUE;
2253}
2254
2255static Eina_Bool
2256_eina_value_type_stringshare_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
2257{
2258 const char * const*s = src;
2259 const char **d = dst;
2260 *d = *s;
2261 eina_stringshare_ref(*d);
2262 return EINA_TRUE;
2263}
2264
2265static Eina_Bool
2266_eina_value_type_stringshare_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
2267{
2268 const char *str = va_arg(args, const char *);
2269 return eina_stringshare_replace((const char **)mem, str);
2270}
2271
2272static Eina_Bool
2273_eina_value_type_stringshare_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
2274{
2275 const char * const *str = ptr;
2276 return eina_stringshare_replace((const char **)mem, *str);
2277}
2278
2279static Eina_Bool
2280_eina_value_type_string_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
2281{
2282 char **tmem = mem;
2283 if (*tmem) free(*tmem);
2284 return EINA_TRUE;
2285}
2286
2287static Eina_Bool
2288_eina_value_type_string_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
2289{
2290 const char * const *s = src;
2291 char **d = dst;
2292 if (*s == NULL)
2293 *d = NULL;
2294 else
2295 {
2296 *d = strdup(*s);
2297 if (*d == NULL)
2298 {
2299 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
2300 return EINA_FALSE;
2301 }
2302 }
2303 return EINA_TRUE;
2304}
2305
2306static Eina_Bool
2307_eina_value_type_string_vset(const Eina_Value_Type *type __UNUSED__, void *mem, va_list args)
2308{
2309 char **tmem = mem;
2310 const char *str = va_arg(args, const char *);
2311 free(*tmem);
2312 if (str == NULL)
2313 *tmem = NULL;
2314 else
2315 {
2316 *tmem = strdup(str);
2317 if (*tmem == NULL)
2318 {
2319 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
2320 return EINA_FALSE;
2321 }
2322 }
2323 eina_error_set(0);
2324 return EINA_TRUE;
2325}
2326
2327static Eina_Bool
2328_eina_value_type_string_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
2329{
2330 char **tmem = mem;
2331 const char * const *str = ptr;
2332 free(*tmem);
2333 if (*str == NULL)
2334 *tmem = NULL;
2335 else
2336 {
2337 *tmem = strdup(*str);
2338 if (*tmem == NULL)
2339 {
2340 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
2341 return EINA_FALSE;
2342 }
2343 }
2344 eina_error_set(0);
2345 return EINA_TRUE;
2346}
2347
2348static Eina_Bool
2349_eina_value_type_array_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
2350{
2351 memset(mem, 0, sizeof(Eina_Value_Array));
2352 return EINA_TRUE;
2353}
2354
2355static Eina_Bool
2356_eina_value_type_array_flush_elements(Eina_Value_Array *tmem)
2357{
2358 const Eina_Value_Type *subtype = tmem->subtype;
2359 Eina_Bool ret = EINA_TRUE;
2360 unsigned char sz;
2361 char *ptr, *ptr_end;
2362
2363 if (!tmem->array) return EINA_TRUE;
2364
2365 sz = tmem->array->member_size;
2366 ptr = tmem->array->members;
2367 ptr_end = ptr + tmem->array->len * sz;
2368
2369 for (; ptr < ptr_end; ptr += sz)
2370 ret &= eina_value_type_flush(subtype, ptr);
2371
2372 eina_inarray_flush(tmem->array);
2373 return ret;
2374}
2375
2376static Eina_Bool
2377_eina_value_type_array_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
2378{
2379 Eina_Value_Array *tmem = mem;
2380 Eina_Bool ret =_eina_value_type_array_flush_elements(tmem);
2381
2382 if (tmem->array) eina_inarray_free(tmem->array);
2383 tmem->array = NULL;
2384 tmem->subtype = NULL;
2385 return ret;
2386}
2387
2388static Eina_Bool
2389_eina_value_type_array_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
2390{
2391 const Eina_Value_Type *subtype;
2392 const Eina_Value_Array *s = src;
2393 Eina_Value_Array *d = dst;
2394 unsigned int i, count, sz;
2395 char *ptr, *ptr_end;
2396
2397 d->subtype = subtype = s->subtype;
2398 d->step = s->step;
2399
2400 if ((!s->array) || (!s->subtype))
2401 {
2402 d->array = NULL;
2403 return EINA_TRUE;
2404 }
2405
2406 if (!subtype->copy)
2407 {
2408 eina_error_set(EINA_ERROR_VALUE_FAILED);
2409 return EINA_FALSE;
2410 }
2411
2412 d->array = eina_inarray_new(subtype->value_size, s->step);
2413 if (!d->array)
2414 return EINA_FALSE;
2415
2416 sz = s->array->member_size;
2417
2418 count = eina_inarray_count(s->array);
2419 ptr = s->array->members;
2420 ptr_end = ptr + (count * sz);
2421
2422 for (i = 0; ptr < ptr_end; ptr += sz, i++)
2423 {
2424 void *imem = eina_inarray_alloc_at(d->array, i, 1);
2425 if (!imem) goto error;
2426 if (!subtype->copy(subtype, ptr, imem))
2427 {
2428 eina_inarray_pop(d->array);
2429 goto error;
2430 }
2431 }
2432
2433 return EINA_TRUE;
2434
2435 error:
2436 _eina_value_type_array_flush_elements(d);
2437 return EINA_FALSE;
2438}
2439
2440static int
2441_eina_value_type_array_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
2442{
2443 const Eina_Value_Type *subtype;
2444 const Eina_Value_Array *eva_a = a, *eva_b = b;
2445 const char *a_ptr, *a_ptr_end, *b_ptr;
2446 unsigned int count_a, count_b, count, sz;
2447 int cmp = 0;
2448
2449 if (eva_a->subtype != eva_b->subtype)
2450 {
2451 eina_error_set(EINA_ERROR_VALUE_FAILED);
2452 return -1;
2453 }
2454
2455 subtype = eva_a->subtype;
2456 if (!subtype->compare)
2457 {
2458 eina_error_set(EINA_ERROR_VALUE_FAILED);
2459 return 0;
2460 }
2461
2462 if ((!eva_a->array) && (!eva_b->array))
2463 return 0;
2464 else if (!eva_a->array)
2465 return -1;
2466 else if (!eva_b->array)
2467 return 1;
2468
2469 count_a = eina_inarray_count(eva_a->array);
2470 count_b = eina_inarray_count(eva_b->array);
2471
2472 if (count_a <= count_b)
2473 count = count_a;
2474 else
2475 count = count_b;
2476
2477 sz = eva_a->array->member_size;
2478
2479 a_ptr = eva_a->array->members;
2480 a_ptr_end = a_ptr + (count * sz);
2481 b_ptr = eva_b->array->members;
2482
2483 for (; (cmp == 0) && (a_ptr < a_ptr_end); a_ptr += sz, b_ptr += sz)
2484 cmp = subtype->compare(subtype, a_ptr, b_ptr);
2485
2486 if (cmp == 0)
2487 {
2488 if (count_a < count_b)
2489 return -1;
2490 else if (count_a > count_b)
2491 return 1;
2492 return 0;
2493 }
2494
2495 return cmp;
2496}
2497
2498static Eina_Bool
2499_eina_value_type_array_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
2500{
2501 const Eina_Value_Array *tmem = type_mem;
2502 Eina_Bool ret = EINA_FALSE;
2503
2504 if ((convert == EINA_VALUE_TYPE_STRING) ||
2505 (convert == EINA_VALUE_TYPE_STRINGSHARE))
2506 {
2507 Eina_Strbuf *str = eina_strbuf_new();
2508 if (!tmem->array) eina_strbuf_append(str, "[]");
2509 else
2510 {
2511 const Eina_Value_Type *subtype = tmem->subtype;
2512 unsigned char sz;
2513 const char *ptr, *ptr_end;
2514 Eina_Value tmp;
2515 Eina_Bool first = EINA_TRUE;
2516
2517 eina_value_setup(&tmp, EINA_VALUE_TYPE_STRING);
2518
2519 eina_strbuf_append_char(str, '[');
2520
2521 sz = tmem->array->member_size;
2522 ptr = tmem->array->members;
2523 ptr_end = ptr + tmem->array->len * sz;
2524 for (; ptr < ptr_end; ptr += sz)
2525 {
2526 Eina_Bool r = EINA_FALSE;
2527 if (subtype->convert_to)
2528 {
2529 r = subtype->convert_to(subtype, EINA_VALUE_TYPE_STRING,
2530 ptr, tmp.value.buf);
2531 if (r)
2532 {
2533 if (first) first = EINA_FALSE;
2534 else eina_strbuf_append_length(str, ", ", 2);
2535 eina_strbuf_append(str, tmp.value.ptr);
2536 free(tmp.value.ptr);
2537 tmp.value.ptr = NULL;
2538 }
2539 }
2540
2541 if (!r)
2542 {
2543 if (first)
2544 {
2545 first = EINA_FALSE;
2546 eina_strbuf_append_char(str, '?');
2547 }
2548 else
2549 eina_strbuf_append_length(str, ", ?", 3);
2550 }
2551 }
2552
2553 eina_strbuf_append_char(str, ']');
2554 ptr = eina_strbuf_string_get(str);
2555 ret = eina_value_type_pset(convert, convert_mem, &ptr);
2556 eina_strbuf_free(str);
2557 }
2558 }
2559 else if ((tmem->array) && (tmem->array->len == 1))
2560 {
2561 const Eina_Value_Type *subtype = tmem->subtype;
2562 void *imem = tmem->array->members;
2563
2564 if (subtype->convert_to)
2565 ret = subtype->convert_to(subtype, convert, imem, convert_mem);
2566 if ((!ret) && (convert->convert_from))
2567 ret = convert->convert_from(convert, subtype, convert_mem, imem);
2568 }
2569
2570 if (!ret)
2571 {
2572 eina_error_set(EINA_ERROR_VALUE_FAILED);
2573 return EINA_FALSE;
2574 }
2575 return EINA_TRUE;
2576}
2577
2578static Eina_Bool
2579_eina_value_type_array_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
2580{
2581 Eina_Value_Array *tmem = type_mem;
2582 Eina_Value_Array desc = {convert, tmem->step, NULL};
2583 char *buf;
2584 void *imem;
2585
2586 if (!eina_value_type_pset(type, tmem, &desc))
2587 return EINA_FALSE;
2588
2589 buf = alloca(convert->value_size);
2590 if (!eina_value_type_pget(convert, convert_mem, &buf))
2591 return EINA_FALSE;
2592
2593 imem = eina_inarray_alloc_at(tmem->array, 0, 1);
2594 if (!imem)
2595 return EINA_FALSE;
2596
2597 if (!eina_value_type_setup(convert, imem)) goto error_setup;
2598 if (!eina_value_type_pset(convert, imem, &buf)) goto error_set;
2599 return EINA_TRUE;
2600
2601 error_set:
2602 eina_value_type_flush(convert, imem);
2603 error_setup:
2604 eina_inarray_remove_at(tmem->array, 0);
2605 return EINA_FALSE;
2606}
2607
2608static Eina_Bool
2609_eina_value_type_array_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
2610{
2611 Eina_Value_Array *tmem = mem;
2612 const Eina_Value_Array *desc = ptr;
2613 Eina_Inarray *desc_array;
2614
2615 if ((!tmem->subtype) && (!desc->subtype))
2616 return EINA_TRUE;
2617
2618 desc_array = desc->array;
2619 if (desc_array)
2620 {
2621 EINA_SAFETY_ON_FALSE_RETURN_VAL
2622 (desc_array->member_size == desc->subtype->value_size, EINA_FALSE);
2623 }
2624
2625 if (tmem->array)
2626 {
2627 _eina_value_type_array_flush_elements(tmem);
2628 if (desc_array)
2629 eina_inarray_free(tmem->array);
2630 else
2631 eina_inarray_setup(tmem->array, desc->subtype->value_size,
2632 desc->step);
2633 }
2634 else if (!desc_array)
2635 {
2636 tmem->array = eina_inarray_new(desc->subtype->value_size, desc->step);
2637 if (!tmem->array)
2638 return EINA_FALSE;
2639 }
2640
2641 if (desc_array)
2642 tmem->array = desc_array;
2643
2644 tmem->subtype = desc->subtype;
2645
2646 return EINA_TRUE;
2647}
2648
2649static Eina_Bool
2650_eina_value_type_array_vset(const Eina_Value_Type *type, void *mem, va_list args)
2651{
2652 const Eina_Value_Array desc = va_arg(args, Eina_Value_Array);
2653 _eina_value_type_array_pset(type, mem, &desc);
2654 return EINA_TRUE;
2655}
2656
2657static Eina_Bool
2658_eina_value_type_array_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
2659{
2660 memcpy(ptr, mem, sizeof(Eina_Value_Array));
2661 return EINA_TRUE;
2662}
2663
2664static const Eina_Value_Type _EINA_VALUE_TYPE_ARRAY = {
2665 EINA_VALUE_TYPE_VERSION,
2666 sizeof(Eina_Value_Array),
2667 "Eina_Value_Array",
2668 _eina_value_type_array_setup,
2669 _eina_value_type_array_flush,
2670 _eina_value_type_array_copy,
2671 _eina_value_type_array_compare,
2672 _eina_value_type_array_convert_to,
2673 _eina_value_type_array_convert_from,
2674 _eina_value_type_array_vset,
2675 _eina_value_type_array_pset,
2676 _eina_value_type_array_pget
2677};
2678
2679static Eina_Bool
2680_eina_value_type_list_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
2681{
2682 memset(mem, 0, sizeof(Eina_Value_List));
2683 return EINA_TRUE;
2684}
2685
2686static Eina_Bool
2687_eina_value_type_list_flush_elements(Eina_Value_List *tmem)
2688{
2689 const Eina_Value_Type *subtype = tmem->subtype;
2690 Eina_Bool ret = EINA_TRUE;
2691
2692 if (!tmem->list) return EINA_TRUE;
2693
2694 while (tmem->list)
2695 {
2696 void *mem = eina_value_list_node_memory_get(tmem->subtype, tmem->list);
2697 ret &= eina_value_type_flush(subtype, mem);
2698 eina_value_list_node_memory_flush(tmem->subtype, tmem->list);
2699 tmem->list = eina_list_remove_list(tmem->list, tmem->list);
2700 }
2701
2702 return ret;
2703}
2704
2705static Eina_Bool
2706_eina_value_type_list_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
2707{
2708 Eina_Value_List *tmem = mem;
2709 Eina_Bool ret =_eina_value_type_list_flush_elements(tmem);
2710
2711 if (tmem->list) eina_list_free(tmem->list);
2712 tmem->list = NULL;
2713 tmem->subtype = NULL;
2714 return ret;
2715}
2716
2717static Eina_Bool
2718_eina_value_type_list_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
2719{
2720 const Eina_Value_Type *subtype;
2721 const Eina_Value_List *s = src;
2722 Eina_Value_List *d = dst;
2723 const Eina_List *snode;
2724
2725 d->subtype = subtype = s->subtype;
2726 if ((!s->list) || (!s->subtype))
2727 {
2728 d->list = NULL;
2729 return EINA_TRUE;
2730 }
2731
2732 if (!subtype->copy)
2733 {
2734 eina_error_set(EINA_ERROR_VALUE_FAILED);
2735 return EINA_FALSE;
2736 }
2737
2738 d->list = NULL;
2739 for (snode = s->list; snode != NULL; snode = snode->next)
2740 {
2741 const void *ptr = eina_value_list_node_memory_get(subtype, snode);
2742 Eina_List *dnode;
2743 void *imem;
2744
2745 d->list = eina_list_append(d->list, (void*)1L);
2746 dnode = eina_list_last(d->list);
2747 EINA_SAFETY_ON_NULL_GOTO(dnode, error);
2748 EINA_SAFETY_ON_FALSE_GOTO(dnode->data == (void*)1L, error);
2749
2750 imem = eina_value_list_node_memory_setup(subtype, dnode);
2751 if (!subtype->copy(subtype, ptr, imem))
2752 {
2753 eina_value_list_node_memory_flush(subtype, dnode);
2754 d->list = eina_list_remove_list(d->list, dnode);
2755 goto error;
2756 }
2757 }
2758 return EINA_TRUE;
2759
2760 error:
2761 _eina_value_type_list_flush_elements(d);
2762 return EINA_FALSE;
2763}
2764
2765static int
2766_eina_value_type_list_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
2767{
2768 const Eina_Value_Type *subtype;
2769 const Eina_Value_List *eva_a = a, *eva_b = b;
2770 const Eina_List *anode, *bnode;
2771 int cmp = 0;
2772
2773 if (eva_a->subtype != eva_b->subtype)
2774 {
2775 eina_error_set(EINA_ERROR_VALUE_FAILED);
2776 return -1;
2777 }
2778
2779 subtype = eva_a->subtype;
2780 if (!subtype->compare)
2781 {
2782 eina_error_set(EINA_ERROR_VALUE_FAILED);
2783 return 0;
2784 }
2785
2786 if ((!eva_a->list) && (!eva_b->list))
2787 return 0;
2788 else if (!eva_a->list)
2789 return -1;
2790 else if (!eva_b->list)
2791 return 1;
2792
2793 for (anode = eva_a->list, bnode = eva_b->list;
2794 (cmp == 0) && (anode) && (bnode);
2795 anode = anode->next, bnode = bnode->next)
2796 {
2797 const void *amem = eina_value_list_node_memory_get(subtype, anode);
2798 const void *bmem = eina_value_list_node_memory_get(subtype, bnode);
2799 cmp = subtype->compare(subtype, amem, bmem);
2800 }
2801
2802 if (cmp == 0)
2803 {
2804 if ((!anode) && (bnode))
2805 return -1;
2806 else if ((anode) && (!bnode))
2807 return 1;
2808 return 0;
2809 }
2810
2811 return cmp;
2812}
2813
2814static Eina_Bool
2815_eina_value_type_list_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
2816{
2817 const Eina_Value_List *tmem = type_mem;
2818 Eina_Bool ret = EINA_FALSE;
2819
2820 if ((convert == EINA_VALUE_TYPE_STRING) ||
2821 (convert == EINA_VALUE_TYPE_STRINGSHARE))
2822 {
2823 Eina_Strbuf *str = eina_strbuf_new();
2824 if (!tmem->list) eina_strbuf_append(str, "[]");
2825 else
2826 {
2827 const Eina_Value_Type *subtype = tmem->subtype;
2828 const Eina_List *node;
2829 Eina_Value tmp;
2830 const char *s;
2831 Eina_Bool first = EINA_TRUE;
2832
2833 eina_value_setup(&tmp, EINA_VALUE_TYPE_STRING);
2834
2835 eina_strbuf_append_char(str, '[');
2836
2837 for (node = tmem->list; node != NULL; node = node->next)
2838 {
2839 Eina_Bool r = EINA_FALSE;
2840
2841 if (subtype->convert_to)
2842 {
2843 const void *ptr;
2844 ptr = eina_value_list_node_memory_get(subtype, node);
2845 r = subtype->convert_to(subtype, EINA_VALUE_TYPE_STRING,
2846 ptr, tmp.value.buf);
2847 if (r)
2848 {
2849 if (first) first = EINA_FALSE;
2850 else eina_strbuf_append_length(str, ", ", 2);
2851 eina_strbuf_append(str, tmp.value.ptr);
2852 free(tmp.value.ptr);
2853 tmp.value.ptr = NULL;
2854 }
2855 }
2856
2857 if (!r)
2858 {
2859 if (first)
2860 {
2861 first = EINA_FALSE;
2862 eina_strbuf_append_char(str, '?');
2863 }
2864 else
2865 eina_strbuf_append_length(str, ", ?", 3);
2866 }
2867 }
2868
2869 eina_strbuf_append_char(str, ']');
2870 s = eina_strbuf_string_get(str);
2871 ret = eina_value_type_pset(convert, convert_mem, &s);
2872 eina_strbuf_free(str);
2873 }
2874 }
2875 else if ((tmem->list) && (tmem->list->next == NULL))
2876 {
2877 const Eina_Value_Type *subtype = tmem->subtype;
2878 void *imem = eina_value_list_node_memory_get(subtype, tmem->list);
2879
2880 if (subtype->convert_to)
2881 ret = subtype->convert_to(subtype, convert, imem, convert_mem);
2882 if ((!ret) && (convert->convert_from))
2883 ret = convert->convert_from(convert, subtype, convert_mem, imem);
2884 }
2885
2886 if (!ret)
2887 {
2888 eina_error_set(EINA_ERROR_VALUE_FAILED);
2889 return EINA_FALSE;
2890 }
2891 return EINA_TRUE;
2892}
2893
2894static Eina_Bool
2895_eina_value_type_list_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
2896{
2897 Eina_Value_List *tmem = type_mem;
2898 Eina_Value_List desc = {convert, NULL};
2899 Eina_List *node;
2900 char *buf;
2901 void *imem;
2902
2903 if (!eina_value_type_pset(type, tmem, &desc))
2904 return EINA_FALSE;
2905
2906 buf = alloca(convert->value_size);
2907 if (!eina_value_type_pget(convert, convert_mem, &buf))
2908 return EINA_FALSE;
2909
2910 tmem->list = eina_list_append(tmem->list, (void*)1L);
2911 node = eina_list_last(tmem->list);
2912 EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
2913 EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
2914
2915 imem = eina_value_list_node_memory_setup(tmem->subtype, node);
2916 if (!imem)
2917 {
2918 tmem->list = eina_list_remove_list(tmem->list, node);
2919 return EINA_FALSE;
2920 }
2921
2922 if (!eina_value_type_setup(tmem->subtype, imem)) goto error_setup;
2923 if (!eina_value_type_pset(tmem->subtype, imem, &buf)) goto error_set;
2924 return EINA_TRUE;
2925
2926 error_set:
2927 eina_value_type_flush(tmem->subtype, imem);
2928 error_setup:
2929 eina_value_list_node_memory_flush(tmem->subtype, node);
2930 tmem->list = eina_list_remove_list(tmem->list, node);
2931 return EINA_FALSE;
2932}
2933
2934static Eina_Bool
2935_eina_value_type_list_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
2936{
2937 Eina_Value_List *tmem = mem;
2938 const Eina_Value_List *desc = ptr;
2939
2940 if ((!tmem->subtype) && (!desc->subtype))
2941 return EINA_TRUE;
2942
2943 _eina_value_type_list_flush_elements(tmem);
2944 tmem->subtype = desc->subtype;
2945 tmem->list = desc->list;
2946
2947 return EINA_TRUE;
2948}
2949
2950static Eina_Bool
2951_eina_value_type_list_vset(const Eina_Value_Type *type, void *mem, va_list args)
2952{
2953 const Eina_Value_List desc = va_arg(args, Eina_Value_List);
2954 _eina_value_type_list_pset(type, mem, &desc);
2955 return EINA_TRUE;
2956}
2957
2958static Eina_Bool
2959_eina_value_type_list_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
2960{
2961 memcpy(ptr, mem, sizeof(Eina_Value_List));
2962 return EINA_TRUE;
2963}
2964
2965static const Eina_Value_Type _EINA_VALUE_TYPE_LIST = {
2966 EINA_VALUE_TYPE_VERSION,
2967 sizeof(Eina_Value_List),
2968 "Eina_Value_List",
2969 _eina_value_type_list_setup,
2970 _eina_value_type_list_flush,
2971 _eina_value_type_list_copy,
2972 _eina_value_type_list_compare,
2973 _eina_value_type_list_convert_to,
2974 _eina_value_type_list_convert_from,
2975 _eina_value_type_list_vset,
2976 _eina_value_type_list_pset,
2977 _eina_value_type_list_pget
2978};
2979
2980static Eina_Bool
2981_eina_value_type_hash_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
2982{
2983 memset(mem, 0, sizeof(Eina_Value_Hash));
2984 return EINA_TRUE;
2985}
2986
2987struct _eina_value_type_hash_flush_each_ctx
2988{
2989 const Eina_Value_Type *subtype;
2990 Eina_Bool ret;
2991};
2992
2993static Eina_Bool
2994_eina_value_type_hash_flush_each(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *mem, void *user_data)
2995{
2996 struct _eina_value_type_hash_flush_each_ctx *ctx = user_data;
2997 ctx->ret &= eina_value_type_flush(ctx->subtype, mem);
2998 return EINA_TRUE;
2999}
3000
3001static Eina_Bool
3002_eina_value_type_hash_flush_elements(Eina_Value_Hash *tmem)
3003{
3004 struct _eina_value_type_hash_flush_each_ctx ctx = {
3005 tmem->subtype,
3006 EINA_TRUE
3007 };
3008
3009 if (!tmem->hash) return EINA_TRUE;
3010
3011 eina_hash_foreach(tmem->hash, _eina_value_type_hash_flush_each, &ctx);
3012 eina_hash_free(tmem->hash);
3013 tmem->hash = NULL;
3014 return ctx.ret;
3015}
3016
3017static Eina_Bool
3018_eina_value_type_hash_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
3019{
3020 Eina_Value_Hash *tmem = mem;
3021 Eina_Bool ret =_eina_value_type_hash_flush_elements(tmem);
3022 tmem->subtype = NULL;
3023 return ret;
3024}
3025
3026static unsigned int
3027_eina_value_hash_key_length(const void *key)
3028{
3029 if (!key)
3030 return 0;
3031 return (int)strlen(key) + 1;
3032}
3033
3034static int
3035_eina_value_hash_key_cmp(const void *key1, int key1_len, const void *key2, int key2_len)
3036{
3037 int r = key1_len - key2_len;
3038 if (r != 0)
3039 return r;
3040 return strcmp(key1, key2);
3041}
3042
3043static Eina_Bool
3044_eina_value_type_hash_create(Eina_Value_Hash *desc)
3045{
3046 if (!desc->buckets_power_size)
3047 desc->buckets_power_size = 5;
3048
3049 desc->hash = eina_hash_new(_eina_value_hash_key_length,
3050 _eina_value_hash_key_cmp,
3051 EINA_KEY_HASH(eina_hash_superfast),
3052 NULL, desc->buckets_power_size);
3053 return !!desc->hash;
3054}
3055
3056struct _eina_value_type_hash_copy_each_ctx
3057{
3058 const Eina_Value_Type *subtype;
3059 Eina_Value_Hash *dest;
3060 Eina_Bool ret;
3061};
3062
3063static Eina_Bool
3064_eina_value_type_hash_copy_each(const Eina_Hash *hash __UNUSED__, const void *key, void *_ptr, void *user_data)
3065{
3066 struct _eina_value_type_hash_copy_each_ctx *ctx = user_data;
3067 const void *ptr = _ptr;
3068 void *imem = malloc(ctx->subtype->value_size);
3069 if (!imem)
3070 {
3071 ctx->ret = EINA_FALSE;
3072 return EINA_FALSE;
3073 }
3074 if (!ctx->subtype->copy(ctx->subtype, ptr, imem))
3075 {
3076 free(imem);
3077 ctx->ret = EINA_FALSE;
3078 return EINA_FALSE;
3079 }
3080 if (!eina_hash_add(ctx->dest->hash, key, imem))
3081 {
3082 eina_value_type_flush(ctx->subtype, imem);
3083 free(imem);
3084 ctx->ret = EINA_FALSE;
3085 return EINA_FALSE;
3086 }
3087 return EINA_TRUE;
3088}
3089
3090static Eina_Bool
3091_eina_value_type_hash_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
3092{
3093 const Eina_Value_Hash *s = src;
3094 Eina_Value_Hash *d = dst;
3095 struct _eina_value_type_hash_copy_each_ctx ctx = {s->subtype, d, EINA_TRUE};
3096
3097 d->subtype = s->subtype;
3098 d->buckets_power_size = s->buckets_power_size;
3099
3100 if ((!s->hash) || (!s->subtype))
3101 {
3102 d->hash = NULL;
3103 return EINA_TRUE;
3104 }
3105
3106 if (!s->subtype->copy)
3107 {
3108 eina_error_set(EINA_ERROR_VALUE_FAILED);
3109 return EINA_FALSE;
3110 }
3111
3112 if (!_eina_value_type_hash_create(d))
3113 return EINA_FALSE;
3114
3115 eina_hash_foreach(s->hash, _eina_value_type_hash_copy_each, &ctx);
3116 if (!ctx.ret)
3117 {
3118 _eina_value_type_hash_flush_elements(d);
3119 return EINA_FALSE;
3120 }
3121 return EINA_TRUE;
3122}
3123
3124struct _eina_value_type_hash_compare_each_ctx
3125{
3126 const Eina_Value_Type *subtype;
3127 const Eina_Hash *other;
3128 int cmp;
3129};
3130
3131static Eina_Bool
3132_eina_value_type_hash_compare_each(const Eina_Hash *hash __UNUSED__, const void *key, void *_ptr, void *user_data)
3133{
3134 struct _eina_value_type_hash_compare_each_ctx *ctx = user_data;
3135 const void *self_ptr = _ptr;
3136 const void *other_ptr = eina_hash_find(ctx->other, key);
3137 if (!other_ptr) return EINA_TRUE;
3138 ctx->cmp = ctx->subtype->compare(ctx->subtype, self_ptr, other_ptr);
3139 return ctx->cmp == 0;
3140}
3141
3142static int
3143_eina_value_type_hash_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
3144{
3145 const Eina_Value_Hash *eva_a = a, *eva_b = b;
3146 struct _eina_value_type_hash_compare_each_ctx ctx = {
3147 eva_a->subtype, eva_b->hash, 0
3148 };
3149
3150 if (eva_a->subtype != eva_b->subtype)
3151 {
3152 eina_error_set(EINA_ERROR_VALUE_FAILED);
3153 return -1;
3154 }
3155
3156 if (!eva_a->subtype->compare)
3157 {
3158 eina_error_set(EINA_ERROR_VALUE_FAILED);
3159 return 0;
3160 }
3161
3162 if ((!eva_a->hash) && (!eva_b->hash))
3163 return 0;
3164 else if (!eva_a->hash)
3165 return -1;
3166 else if (!eva_b->hash)
3167 return 1;
3168
3169 eina_hash_foreach(eva_a->hash, _eina_value_type_hash_compare_each, &ctx);
3170 if (ctx.cmp == 0)
3171 {
3172 unsigned int count_a = eina_hash_population(eva_a->hash);
3173 unsigned int count_b = eina_hash_population(eva_b->hash);
3174 if (count_a < count_b)
3175 return -1;
3176 else if (count_a > count_b)
3177 return 1;
3178 return 0;
3179 }
3180
3181 return ctx.cmp;
3182}
3183
3184static Eina_Bool
3185_eina_value_type_hash_find_first(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *ptr, void *user_data)
3186{
3187 void **ret = user_data;
3188 *ret = ptr;
3189 return EINA_FALSE;
3190}
3191
3192struct _eina_value_type_hash_convert_to_string_each_ctx
3193{
3194 const Eina_Value_Type *subtype;
3195 Eina_Strbuf *str;
3196 Eina_Value tmp;
3197 Eina_Bool first;
3198};
3199
3200static Eina_Bool
3201_eina_value_type_hash_convert_to_string_each(const Eina_Hash *hash __UNUSED__, const void *_key, void *_ptr, void *user_data)
3202{
3203 struct _eina_value_type_hash_convert_to_string_each_ctx *ctx = user_data;
3204 const char *key = _key;
3205 const void *ptr = _ptr;
3206 Eina_Bool r = EINA_FALSE;
3207
3208 if (ctx->first) ctx->first = EINA_FALSE;
3209 else eina_strbuf_append_length(ctx->str, ", ", 2);
3210
3211 eina_strbuf_append(ctx->str, key);
3212 eina_strbuf_append_length(ctx->str, ": ", 2);
3213
3214 if (ctx->subtype->convert_to)
3215 {
3216 r = ctx->subtype->convert_to(ctx->subtype, EINA_VALUE_TYPE_STRING,
3217 ptr, ctx->tmp.value.buf);
3218 if (r)
3219 {
3220 eina_strbuf_append(ctx->str, ctx->tmp.value.ptr);
3221 free(ctx->tmp.value.ptr);
3222 ctx->tmp.value.ptr = NULL;
3223 }
3224 }
3225
3226 if (!r)
3227 eina_strbuf_append_char(ctx->str, '?');
3228
3229 return EINA_TRUE;
3230}
3231
3232static Eina_Bool
3233_eina_value_type_hash_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
3234{
3235 const Eina_Value_Hash *tmem = type_mem;
3236 Eina_Bool ret = EINA_FALSE;
3237
3238 if ((convert == EINA_VALUE_TYPE_STRING) ||
3239 (convert == EINA_VALUE_TYPE_STRINGSHARE))
3240 {
3241 Eina_Strbuf *str = eina_strbuf_new();
3242 if (!tmem->hash) eina_strbuf_append(str, "{}");
3243 else
3244 {
3245 struct _eina_value_type_hash_convert_to_string_each_ctx ctx;
3246 const char *s;
3247
3248 ctx.subtype = tmem->subtype;
3249 ctx.str = str;
3250 ctx.first = EINA_TRUE;
3251 eina_value_setup(&ctx.tmp, EINA_VALUE_TYPE_STRING);
3252
3253 eina_strbuf_append_char(str, '{');
3254
3255 eina_hash_foreach(tmem->hash,
3256 _eina_value_type_hash_convert_to_string_each,
3257 &ctx);
3258
3259 eina_strbuf_append_char(str, '}');
3260 s = eina_strbuf_string_get(str);
3261 ret = eina_value_type_pset(convert, convert_mem, &s);
3262 eina_strbuf_free(str);
3263 }
3264 }
3265 else if ((tmem->hash) && (eina_hash_population(tmem->hash) == 1))
3266 {
3267 const Eina_Value_Type *subtype = tmem->subtype;
3268 void *imem = NULL;
3269
3270 eina_hash_foreach(tmem->hash, _eina_value_type_hash_find_first, &imem);
3271 if (!imem) /* shouldn't happen... */
3272 ret = EINA_FALSE;
3273 else
3274 {
3275 if (subtype->convert_to)
3276 ret = subtype->convert_to(subtype, convert, imem, convert_mem);
3277 if ((!ret) && (convert->convert_from))
3278 ret = convert->convert_from(convert, subtype, convert_mem, imem);
3279 }
3280 }
3281
3282 if (!ret)
3283 {
3284 eina_error_set(EINA_ERROR_VALUE_FAILED);
3285 return EINA_FALSE;
3286 }
3287 return EINA_TRUE;
3288}
3289
3290static Eina_Bool
3291_eina_value_type_hash_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
3292{
3293 Eina_Value_Hash *tmem = mem;
3294 const Eina_Value_Hash *desc = ptr;
3295
3296 if ((!tmem->subtype) && (!desc->subtype))
3297 return EINA_TRUE;
3298
3299 if (tmem->hash) _eina_value_type_hash_flush_elements(tmem);
3300
3301 if (desc->hash)
3302 tmem->hash = desc->hash;
3303 else if (!_eina_value_type_hash_create(tmem))
3304 return EINA_FALSE;
3305
3306 tmem->subtype = desc->subtype;
3307
3308 return EINA_TRUE;
3309}
3310
3311static Eina_Bool
3312_eina_value_type_hash_vset(const Eina_Value_Type *type, void *mem, va_list args)
3313{
3314 const Eina_Value_Hash desc = va_arg(args, Eina_Value_Hash);
3315 _eina_value_type_hash_pset(type, mem, &desc);
3316 return EINA_TRUE;
3317}
3318
3319static Eina_Bool
3320_eina_value_type_hash_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
3321{
3322 memcpy(ptr, mem, sizeof(Eina_Value_Hash));
3323 return EINA_TRUE;
3324}
3325
3326static const Eina_Value_Type _EINA_VALUE_TYPE_HASH = {
3327 EINA_VALUE_TYPE_VERSION,
3328 sizeof(Eina_Value_Hash),
3329 "Eina_Value_Hash",
3330 _eina_value_type_hash_setup,
3331 _eina_value_type_hash_flush,
3332 _eina_value_type_hash_copy,
3333 _eina_value_type_hash_compare,
3334 _eina_value_type_hash_convert_to,
3335 NULL, /* no convert from */
3336 _eina_value_type_hash_vset,
3337 _eina_value_type_hash_pset,
3338 _eina_value_type_hash_pget
3339};
3340
3341static Eina_Bool
3342_eina_value_type_timeval_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
3343{
3344 memset(mem, 0, sizeof(struct timeval));
3345 return EINA_TRUE;
3346}
3347
3348static Eina_Bool
3349_eina_value_type_timeval_flush(const Eina_Value_Type *type __UNUSED__, void *mem __UNUSED__)
3350{
3351 return EINA_TRUE;
3352}
3353
3354static Eina_Bool
3355_eina_value_type_timeval_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
3356{
3357 const struct timeval *s = src;
3358 struct timeval *d = dst;
3359 *d = *s;
3360 return EINA_TRUE;
3361}
3362
3363static inline struct timeval _eina_value_type_timeval_fix(const struct timeval *input)
3364{
3365 struct timeval ret = *input;
3366 if (EINA_UNLIKELY(ret.tv_usec < 0))
3367 {
3368 ret.tv_sec -= 1;
3369 ret.tv_usec += 1e6;
3370 }
3371 return ret;
3372}
3373
3374static int
3375_eina_value_type_timeval_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
3376{
3377 struct timeval va = _eina_value_type_timeval_fix(a);
3378 struct timeval vb = _eina_value_type_timeval_fix(b);
3379
3380 if (va.tv_sec < vb.tv_sec)
3381 return -1;
3382 else if (va.tv_sec > vb.tv_sec)
3383 return 1;
3384
3385 if (va.tv_usec < vb.tv_usec)
3386 return -1;
3387 else if (va.tv_usec > vb.tv_usec)
3388 return 1;
3389
3390 return 0;
3391}
3392
3393static Eina_Bool
3394_eina_value_type_timeval_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
3395{
3396 struct timeval v = _eina_value_type_timeval_fix(type_mem);
3397
3398 eina_error_set(0);
3399
3400 if (convert == EINA_VALUE_TYPE_UCHAR)
3401 {
3402 unsigned char other_mem = v.tv_sec;
3403 if (EINA_UNLIKELY(v.tv_sec < 0))
3404 return EINA_FALSE;
3405 if (EINA_UNLIKELY(v.tv_sec > eina_value_uchar_max))
3406 return EINA_FALSE;
3407 return eina_value_type_pset(convert, convert_mem, &other_mem);
3408 }
3409 else if (convert == EINA_VALUE_TYPE_USHORT)
3410 {
3411 unsigned short other_mem = v.tv_sec;
3412 if (EINA_UNLIKELY(v.tv_sec < 0))
3413 return EINA_FALSE;
3414 if (EINA_UNLIKELY(v.tv_sec > eina_value_ushort_max))
3415 return EINA_FALSE;
3416 return eina_value_type_pset(convert, convert_mem, &other_mem);
3417 }
3418 else if (convert == EINA_VALUE_TYPE_UINT)
3419 {
3420 unsigned int other_mem = v.tv_sec;
3421 if (EINA_UNLIKELY(v.tv_sec < 0))
3422 return EINA_FALSE;
3423 if (EINA_UNLIKELY((unsigned long) v.tv_sec > eina_value_uint_max))
3424 return EINA_FALSE;
3425 return eina_value_type_pset(convert, convert_mem, &other_mem);
3426 }
3427 else if (convert == EINA_VALUE_TYPE_ULONG)
3428 {
3429 unsigned long other_mem = v.tv_sec;
3430 if (EINA_UNLIKELY(v.tv_sec < 0))
3431 return EINA_FALSE;
3432 if (EINA_UNLIKELY((sizeof(other_mem) != sizeof(v)) &&
3433 ((unsigned long)v.tv_sec > eina_value_ulong_max)))
3434 return EINA_FALSE;
3435 return eina_value_type_pset(convert, convert_mem, &other_mem);
3436 }
3437 else if (convert == EINA_VALUE_TYPE_UINT64)
3438 {
3439 uint64_t other_mem = v.tv_sec;
3440 if (EINA_UNLIKELY(v.tv_sec < 0))
3441 return EINA_FALSE;
3442 return eina_value_type_pset(convert, convert_mem, &other_mem);
3443 }
3444 else if (convert == EINA_VALUE_TYPE_CHAR)
3445 {
3446 char other_mem = v.tv_sec;
3447 if (EINA_UNLIKELY(v.tv_sec < eina_value_char_min))
3448 return EINA_FALSE;
3449 if (EINA_UNLIKELY(v.tv_sec > eina_value_char_max))
3450 return EINA_FALSE;
3451 return eina_value_type_pset(convert, convert_mem, &other_mem);
3452 }
3453 else if (convert == EINA_VALUE_TYPE_SHORT)
3454 {
3455 short other_mem = v.tv_sec;
3456 if (EINA_UNLIKELY(v.tv_sec < eina_value_short_min))
3457 return EINA_FALSE;
3458 if (EINA_UNLIKELY(v.tv_sec > eina_value_short_max))
3459 return EINA_FALSE;
3460 return eina_value_type_pset(convert, convert_mem, &other_mem);
3461 }
3462 else if (convert == EINA_VALUE_TYPE_INT)
3463 {
3464 int other_mem = v.tv_sec;
3465 if (EINA_UNLIKELY(v.tv_sec < eina_value_int_min))
3466 return EINA_FALSE;
3467 if (EINA_UNLIKELY(v.tv_sec > eina_value_int_max))
3468 return EINA_FALSE;
3469 return eina_value_type_pset(convert, convert_mem, &other_mem);
3470 }
3471 else if (convert == EINA_VALUE_TYPE_LONG)
3472 {
3473 long other_mem = v.tv_sec;
3474 if (EINA_UNLIKELY(v.tv_sec < eina_value_long_min))
3475 return EINA_FALSE;
3476 if (EINA_UNLIKELY(v.tv_sec > eina_value_long_max))
3477 return EINA_FALSE;
3478 return eina_value_type_pset(convert, convert_mem, &other_mem);
3479 }
3480 else if (convert == EINA_VALUE_TYPE_INT64)
3481 {
3482 int64_t other_mem = v.tv_sec;
3483 return eina_value_type_pset(convert, convert_mem, &other_mem);
3484 }
3485 else if (convert == EINA_VALUE_TYPE_FLOAT)
3486 {
3487 float other_mem = (float)v.tv_sec + (float)v.tv_usec / 1.0e6;
3488 return eina_value_type_pset(convert, convert_mem, &other_mem);
3489 }
3490 else if (convert == EINA_VALUE_TYPE_DOUBLE)
3491 {
3492 double other_mem = (double)v.tv_sec + (double)v.tv_usec / 1.0e6;
3493 return eina_value_type_pset(convert, convert_mem, &other_mem);
3494 }
3495 else if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
3496 convert == EINA_VALUE_TYPE_STRING)
3497 {
3498 const char *other_mem;
3499 char buf[64];
3500 snprintf(buf, sizeof(buf), "%ld.%06ld", v.tv_sec, v.tv_usec);
3501 other_mem = buf; /* required due &buf == buf */
3502 return eina_value_type_pset(convert, convert_mem, &other_mem);
3503 }
3504 else
3505 {
3506 eina_error_set(EINA_ERROR_VALUE_FAILED);
3507 return EINA_FALSE;
3508 }
3509}
3510
3511static Eina_Bool
3512_eina_value_type_timeval_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
3513{
3514 struct timeval *tmem = mem;
3515 *tmem = _eina_value_type_timeval_fix(ptr);
3516 return EINA_TRUE;
3517}
3518
3519static Eina_Bool
3520_eina_value_type_timeval_vset(const Eina_Value_Type *type, void *mem, va_list args)
3521{
3522 const struct timeval desc = va_arg(args, struct timeval);
3523 _eina_value_type_timeval_pset(type, mem, &desc);
3524 return EINA_TRUE;
3525}
3526
3527static Eina_Bool
3528_eina_value_type_timeval_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
3529{
3530 memcpy(ptr, mem, sizeof(struct timeval));
3531 return EINA_TRUE;
3532}
3533
3534static const Eina_Value_Type _EINA_VALUE_TYPE_TIMEVAL = {
3535 EINA_VALUE_TYPE_VERSION,
3536 sizeof(struct timeval),
3537 "struct timeval",
3538 _eina_value_type_timeval_setup,
3539 _eina_value_type_timeval_flush,
3540 _eina_value_type_timeval_copy,
3541 _eina_value_type_timeval_compare,
3542 _eina_value_type_timeval_convert_to,
3543 NULL, /* no convert from */
3544 _eina_value_type_timeval_vset,
3545 _eina_value_type_timeval_pset,
3546 _eina_value_type_timeval_pget
3547};
3548
3549static Eina_Bool
3550_eina_value_type_blob_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
3551{
3552 memset(mem, 0, sizeof(Eina_Value_Blob));
3553 return EINA_TRUE;
3554}
3555
3556static inline const Eina_Value_Blob_Operations *
3557_eina_value_type_blob_ops_get(const Eina_Value_Blob *blob)
3558{
3559 if (!blob) return NULL;
3560 if (!blob->ops) return NULL;
3561 EINA_SAFETY_ON_FALSE_RETURN_VAL
3562 (blob->ops->version == EINA_VALUE_BLOB_OPERATIONS_VERSION, NULL);
3563 return blob->ops;
3564}
3565
3566static Eina_Bool
3567_eina_value_type_blob_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
3568{
3569 const Eina_Value_Blob_Operations *ops = _eina_value_type_blob_ops_get(mem);
3570 Eina_Value_Blob *tmem = mem;
3571 if ((ops) && (ops->free))
3572 ops->free(ops, (void *)tmem->memory, tmem->size);
3573 return EINA_TRUE;
3574}
3575
3576static Eina_Bool
3577_eina_value_type_blob_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
3578{
3579 const Eina_Value_Blob_Operations *ops = _eina_value_type_blob_ops_get(src);
3580 const Eina_Value_Blob *s = src;
3581 Eina_Value_Blob *d = dst;
3582
3583 *d = *s;
3584
3585 if ((ops) && (ops->copy))
3586 {
3587 d->memory = ops->copy(ops, s->memory, s->size);
3588 if ((d->memory == NULL) && (s->size > 0))
3589 return EINA_FALSE;
3590 }
3591
3592 return EINA_TRUE;
3593}
3594
3595static int
3596_eina_value_type_blob_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
3597{
3598 const Eina_Value_Blob_Operations *ops = _eina_value_type_blob_ops_get(a);
3599 const Eina_Value_Blob *ta = a, *tb = b;
3600 size_t minsize;
3601 if (ta->ops != tb->ops)
3602 {
3603 eina_error_set(EINA_ERROR_VALUE_FAILED);
3604 return -1;
3605 }
3606 if ((ops) && (ops->compare))
3607 return ops->compare(ops, ta->memory, ta->size, tb->memory, tb->size);
3608
3609 if (ta->size < tb->size)
3610 minsize = ta->size;
3611 else
3612 minsize = tb->size;
3613
3614 return memcmp(ta->memory, tb->memory, minsize);
3615}
3616
3617static Eina_Bool
3618_eina_value_type_blob_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
3619{
3620 const Eina_Value_Blob *tmem = type_mem;
3621
3622 eina_error_set(0);
3623 if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
3624 convert == EINA_VALUE_TYPE_STRING)
3625 {
3626 const Eina_Value_Blob_Operations *ops;
3627 Eina_Strbuf *str;
3628 const char *other_mem;
3629 Eina_Bool ret = EINA_FALSE, first = EINA_TRUE;
3630 const unsigned char *ptr, *ptr_end;
3631
3632 ops = _eina_value_type_blob_ops_get(tmem);
3633 if ((ops) && (ops->to_string))
3634 {
3635 char *x = ops->to_string(ops, tmem->memory, tmem->size);
3636 if (x)
3637 {
3638 ret = eina_value_type_pset(convert, convert_mem, &x);
3639 free(x);
3640 }
3641 return ret;
3642 }
3643
3644 str = eina_strbuf_new();
3645 if (!str)
3646 return EINA_FALSE;
3647
3648 if (!eina_strbuf_append_printf(str, "BLOB(%u, [", tmem->size))
3649 goto error;
3650
3651 ptr = tmem->memory;
3652 ptr_end = ptr + tmem->size;
3653 for (; ptr < ptr_end; ptr++)
3654 {
3655 if (first)
3656 {
3657 first = EINA_FALSE;
3658 if (!eina_strbuf_append_printf(str, "%02hhx", *ptr))
3659 goto error;
3660 }
3661 else
3662 {
3663 if (!eina_strbuf_append_printf(str, " %02hhx", *ptr))
3664 goto error;
3665 }
3666 }
3667
3668 if (!eina_strbuf_append(str, "])"))
3669 goto error;
3670
3671 other_mem = eina_strbuf_string_get(str);
3672 ret = eina_value_type_pset(convert, convert_mem, &other_mem);
3673
3674 error:
3675 eina_strbuf_free(str);
3676 return ret;
3677 }
3678 else
3679 {
3680 eina_error_set(EINA_ERROR_VALUE_FAILED);
3681 return EINA_FALSE;
3682 }
3683}
3684
3685static Eina_Bool
3686_eina_value_type_blob_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
3687{
3688 Eina_Value_Blob desc;
3689 char *buf;
3690
3691 desc.ops = EINA_VALUE_BLOB_OPERATIONS_MALLOC;
3692
3693 if ((convert == EINA_VALUE_TYPE_STRING) ||
3694 (convert == EINA_VALUE_TYPE_STRINGSHARE))
3695 {
3696 const char *str = *(const char **)convert_mem;
3697 if (!str)
3698 {
3699 desc.size = 0;
3700 desc.memory = NULL;
3701 }
3702 else
3703 {
3704 desc.size = strlen(str) + 1;
3705 desc.memory = buf = malloc(desc.size);
3706 if (!desc.memory)
3707 {
3708 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
3709 return EINA_FALSE;
3710 }
3711 memcpy(buf, str, desc.size);
3712 }
3713 }
3714 else if (convert == EINA_VALUE_TYPE_ARRAY)
3715 {
3716 const Eina_Value_Array *a = convert_mem;
3717 if ((!a->array) || (a->array->len == 0))
3718 {
3719 desc.size = 0;
3720 desc.memory = NULL;
3721 }
3722 else
3723 {
3724 desc.size = a->array->len * a->array->member_size;
3725 desc.memory = buf = malloc(desc.size);
3726 if (!desc.memory)
3727 {
3728 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
3729 return EINA_FALSE;
3730 }
3731 memcpy(buf, a->array->members, desc.size);
3732 }
3733 }
3734 else if (convert == EINA_VALUE_TYPE_BLOB)
3735 {
3736 const Eina_Value_Blob *b = convert_mem;
3737 if (b->size == 0)
3738 {
3739 desc.size = 0;
3740 desc.memory = NULL;
3741 }
3742 else
3743 {
3744 desc.size = b->size;
3745 desc.memory = buf = malloc(desc.size);
3746 if (!desc.memory)
3747 {
3748 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
3749 return EINA_FALSE;
3750 }
3751 memcpy(buf, b->memory, desc.size);
3752 }
3753 }
3754 else
3755 {
3756 desc.size = convert->value_size;
3757 desc.memory = buf = malloc(convert->value_size);
3758 if (!desc.memory)
3759 {
3760 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
3761 return EINA_FALSE;
3762 }
3763 if (!eina_value_type_pget(convert, convert_mem, buf))
3764 {
3765 free(buf);
3766 return EINA_FALSE;
3767 }
3768 }
3769 return eina_value_type_pset(type, type_mem, &desc);
3770}
3771
3772static Eina_Bool
3773_eina_value_type_blob_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
3774{
3775 const Eina_Value_Blob_Operations *ops = _eina_value_type_blob_ops_get(mem);
3776 Eina_Value_Blob *tmem = mem;
3777 const Eina_Value_Blob *desc = ptr;
3778
3779 if ((ops) && (ops->free))
3780 ops->free(ops, (void *)tmem->memory, tmem->size);
3781
3782 *tmem = *desc;
3783 return EINA_TRUE;
3784}
3785
3786static Eina_Bool
3787_eina_value_type_blob_vset(const Eina_Value_Type *type, void *mem, va_list args)
3788{
3789 const Eina_Value_Blob desc = va_arg(args, Eina_Value_Blob);
3790 _eina_value_type_blob_pset(type, mem, &desc);
3791 return EINA_TRUE;
3792}
3793
3794static Eina_Bool
3795_eina_value_type_blob_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
3796{
3797 memcpy(ptr, mem, sizeof(Eina_Value_Blob));
3798 return EINA_TRUE;
3799}
3800
3801static const Eina_Value_Type _EINA_VALUE_TYPE_BLOB = {
3802 EINA_VALUE_TYPE_VERSION,
3803 sizeof(Eina_Value_Blob),
3804 "Eina_Value_Blob",
3805 _eina_value_type_blob_setup,
3806 _eina_value_type_blob_flush,
3807 _eina_value_type_blob_copy,
3808 _eina_value_type_blob_compare,
3809 _eina_value_type_blob_convert_to,
3810 _eina_value_type_blob_convert_from,
3811 _eina_value_type_blob_vset,
3812 _eina_value_type_blob_pset,
3813 _eina_value_type_blob_pget
3814};
3815
3816static int
3817_eina_value_struct_operations_binsearch_cmp(const void *pa, const void *pb)
3818{
3819 const Eina_Value_Struct_Member *a = pa, *b = pb;
3820 return strcmp(a->name, b->name);
3821}
3822
3823static const Eina_Value_Struct_Member *
3824_eina_value_struct_operations_binsearch_find_member(const Eina_Value_Struct_Operations *ops __UNUSED__, const Eina_Value_Struct_Desc *desc, const char *name)
3825{
3826 unsigned int count = desc->member_count;
3827 Eina_Value_Struct_Member search;
3828 if (count == 0)
3829 {
3830 const Eina_Value_Struct_Member *itr = desc->members;
3831 for (; itr->name != NULL; itr++)
3832 count++;
3833 }
3834
3835 search.name = name;
3836 return bsearch(&search, desc->members, count,
3837 sizeof(Eina_Value_Struct_Member),
3838 _eina_value_struct_operations_binsearch_cmp);
3839}
3840
3841static Eina_Value_Struct_Operations _EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = {
3842 EINA_VALUE_STRUCT_OPERATIONS_VERSION,
3843 NULL, /* default alloc */
3844 NULL, /* default free */
3845 NULL, /* default copy */
3846 NULL, /* default compare */
3847 _eina_value_struct_operations_binsearch_find_member
3848};
3849
3850static const Eina_Value_Struct_Member *
3851_eina_value_struct_operations_stringshare_find_member(const Eina_Value_Struct_Operations *ops __UNUSED__, const Eina_Value_Struct_Desc *desc, const char *name)
3852{
3853 const Eina_Value_Struct_Member *itr = desc->members;
3854
3855 /* assumes name is stringshared.
3856 *
3857 * we do this because it's the recommended usage pattern, moreover
3858 * we expect to find the member, as users shouldn't look for
3859 * non-existent members!
3860 */
3861 if (desc->member_count > 0)
3862 {
3863 const Eina_Value_Struct_Member *itr_end = itr + desc->member_count;
3864 for (; itr < itr_end; itr++)
3865 if (itr->name == name)
3866 return itr;
3867 }
3868 else
3869 {
3870 for (; itr->name != NULL; itr++)
3871 if (itr->name == name)
3872 return itr;
3873 }
3874
3875 name = eina_stringshare_add(name);
3876 eina_stringshare_del(name); /* we'll not use the contents, this is fine */
3877 /* stringshare and look again */
3878 if (desc->member_count > 0)
3879 {
3880 const Eina_Value_Struct_Member *itr_end = itr + desc->member_count;
3881 for (; itr < itr_end; itr++)
3882 if (itr->name == name)
3883 return itr;
3884 }
3885 else
3886 {
3887 for (; itr->name != NULL; itr++)
3888 if (itr->name == name)
3889 return itr;
3890 }
3891
3892 return NULL;
3893}
3894
3895static Eina_Value_Struct_Operations _EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE = {
3896 EINA_VALUE_STRUCT_OPERATIONS_VERSION,
3897 NULL, /* default alloc */
3898 NULL, /* default free */
3899 NULL, /* default copy */
3900 NULL, /* default compare */
3901 _eina_value_struct_operations_stringshare_find_member
3902};
3903
3904static inline const Eina_Value_Struct_Operations *
3905_eina_value_type_struct_ops_get(const Eina_Value_Struct *st)
3906{
3907 if (!st) return NULL;
3908 if (!st->desc) return NULL;
3909 if (!st->desc->ops) return NULL;
3910 EINA_SAFETY_ON_FALSE_RETURN_VAL
3911 (st->desc->ops->version == EINA_VALUE_STRUCT_OPERATIONS_VERSION, NULL);
3912 return st->desc->ops;
3913}
3914
3915EAPI const Eina_Value_Struct_Member *
3916eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name)
3917{
3918 const Eina_Value_Struct_Operations *ops;
3919 const Eina_Value_Struct_Member *itr;
3920
3921 EINA_SAFETY_ON_NULL_RETURN_VAL(st, NULL);
3922 EINA_SAFETY_ON_NULL_RETURN_VAL(st->desc, NULL);
3923
3924 ops = _eina_value_type_struct_ops_get(st);
3925 if ((ops) && (ops->find_member))
3926 return ops->find_member(ops, st->desc, name);
3927
3928 itr = st->desc->members;
3929 if (st->desc->member_count)
3930 {
3931 const Eina_Value_Struct_Member *itr_end = itr + st->desc->member_count;
3932 for (; itr < itr_end; itr++)
3933 {
3934 if (strcmp(name, itr->name) == 0)
3935 return itr;
3936 }
3937 return NULL;
3938 }
3939 else
3940 {
3941 for (; itr->name != NULL; itr++)
3942 {
3943 if (strcmp(name, itr->name) == 0)
3944 return itr;
3945 }
3946 return NULL;
3947 }
3948}
3949
3950static Eina_Bool
3951_eina_value_type_struct_setup(const Eina_Value_Type *type __UNUSED__, void *mem)
3952{
3953 memset(mem, 0, sizeof(Eina_Value_Struct));
3954 return EINA_TRUE;
3955}
3956
3957static Eina_Bool
3958_eina_value_type_struct_flush_member(const Eina_Value_Struct_Member *member, Eina_Value_Struct *st)
3959{
3960 unsigned char *base = st->memory;
3961 return eina_value_type_flush(member->type, base + member->offset);
3962}
3963
3964static Eina_Bool
3965_eina_value_type_struct_flush(const Eina_Value_Type *type __UNUSED__, void *mem)
3966{
3967 const Eina_Value_Struct_Operations *ops;
3968 const Eina_Value_Struct_Member *itr;
3969 Eina_Value_Struct *tmem = mem;
3970 Eina_Bool ret = EINA_TRUE;
3971
3972 itr = tmem->desc->members;
3973 if (tmem->desc->member_count > 0)
3974 {
3975 const Eina_Value_Struct_Member *itr_end;
3976 itr_end = itr + tmem->desc->member_count;
3977 for (; itr < itr_end; itr++)
3978 ret &= _eina_value_type_struct_flush_member(itr, tmem);
3979 }
3980 else
3981 {
3982 for (; itr->name != NULL; itr++)
3983 ret &= _eina_value_type_struct_flush_member(itr, tmem);
3984 }
3985
3986 ops = _eina_value_type_struct_ops_get(mem);
3987 if ((ops) && (ops->free))
3988 ops->free(ops, tmem->desc, tmem->memory);
3989 else
3990 free(tmem->memory);
3991
3992 return ret;
3993}
3994
3995static Eina_Bool
3996_eina_value_type_struct_copy_member(const Eina_Value_Struct_Member *member, const Eina_Value_Struct *s, Eina_Value_Struct *d)
3997{
3998 const unsigned char *base_s = s->memory;
3999 unsigned char *base_d = d->memory;
4000 return eina_value_type_copy(member->type,
4001 base_s + member->offset,
4002 base_d + member->offset);
4003}
4004
4005static Eina_Bool
4006_eina_value_type_struct_copy(const Eina_Value_Type *type __UNUSED__, const void *src, void *dst)
4007{
4008 const Eina_Value_Struct_Operations *ops;
4009 const Eina_Value_Struct_Member *itr;
4010 const Eina_Value_Struct *s = src;
4011 Eina_Value_Struct *d = dst;
4012
4013 *d = *s;
4014
4015 ops = _eina_value_type_struct_ops_get(src);
4016 if ((ops) && (ops->copy))
4017 {
4018 d->memory = ops->copy(ops, s->desc, s->memory);
4019 if (d->memory == NULL)
4020 return EINA_FALSE;
4021 return EINA_TRUE;
4022 }
4023
4024 d->memory = malloc(s->desc->size);
4025 if (!d->memory)
4026 {
4027 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
4028 return EINA_FALSE;
4029 }
4030
4031 itr = s->desc->members;
4032 if (s->desc->member_count > 0)
4033 {
4034 const Eina_Value_Struct_Member *itr_end = itr + s->desc->member_count;
4035 for (; itr < itr_end; itr++)
4036 if (!_eina_value_type_struct_copy_member(itr, s, d))
4037 goto error;
4038 }
4039 else
4040 {
4041 for (; itr->name != NULL; itr++)
4042 if (!_eina_value_type_struct_copy_member(itr, s, d))
4043 goto error;
4044 }
4045
4046
4047 return EINA_TRUE;
4048
4049 error:
4050 itr--;
4051 for (; itr >= s->desc->members; itr--)
4052 _eina_value_type_struct_flush_member(itr, d);
4053 free(d->memory);
4054 return EINA_FALSE;
4055}
4056
4057static inline int
4058_eina_value_type_struct_compare_member(const Eina_Value_Struct_Member *member, const Eina_Value_Struct *ta, const Eina_Value_Struct *tb)
4059{
4060 const unsigned char *base_a = ta->memory;
4061 const unsigned char *base_b = tb->memory;
4062 return eina_value_type_compare(member->type,
4063 base_a + member->offset,
4064 base_b + member->offset);
4065}
4066
4067static int
4068_eina_value_type_struct_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
4069{
4070 const Eina_Value_Struct_Operations *ops = _eina_value_type_struct_ops_get(a);
4071 const Eina_Value_Struct *ta = a, *tb = b;
4072 const Eina_Value_Struct_Member *itr;
4073 int cmp = 0;
4074
4075 if (ta->desc != tb->desc)
4076 {
4077 eina_error_set(EINA_ERROR_VALUE_FAILED);
4078 return -1;
4079 }
4080 if (ta->desc->ops != tb->desc->ops)
4081 {
4082 eina_error_set(EINA_ERROR_VALUE_FAILED);
4083 return -1;
4084 }
4085 if ((!ta->memory) && (!tb->memory))
4086 return 0;
4087 else if (!ta->memory)
4088 return -1;
4089 else if (!tb->memory)
4090 return 1;
4091
4092 if ((ops) && (ops->compare))
4093 return ops->compare(ops, ta->desc, ta->memory, tb->memory);
4094
4095 itr = ta->desc->members;
4096 if (ta->desc->member_count > 0)
4097 {
4098 const Eina_Value_Struct_Member *itr_end = itr + ta->desc->member_count;
4099 for (; (cmp == 0) && (itr < itr_end); itr++)
4100 cmp = _eina_value_type_struct_compare_member(itr, ta, tb);
4101 }
4102 else
4103 {
4104 for (; (cmp == 0) && (itr->name != NULL); itr++)
4105 cmp = _eina_value_type_struct_compare_member(itr, ta, tb);
4106 }
4107 return cmp;
4108}
4109
4110static void
4111_eina_value_type_struct_convert_to_string_member(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member, Eina_Strbuf *str)
4112{
4113 const unsigned char *p = st->memory;
4114 Eina_Bool first = st->desc->members == member;
4115 Eina_Bool r = EINA_FALSE;
4116
4117 if (first) eina_strbuf_append_printf(str, "%s: ", member->name);
4118 else eina_strbuf_append_printf(str, ", %s: ", member->name);
4119
4120 if ((member->type) && (member->type->convert_to))
4121 {
4122 const Eina_Value_Type *type = member->type;
4123 char *conv = NULL;
4124
4125 r = eina_value_type_convert_to(type, EINA_VALUE_TYPE_STRING,
4126 p + member->offset, &conv);
4127 if (r)
4128 {
4129 eina_strbuf_append(str, conv);
4130 free(conv);
4131 }
4132 }
4133
4134 if (!r)
4135 eina_strbuf_append_char(str, '?');
4136}
4137
4138static Eina_Bool
4139_eina_value_type_struct_convert_to(const Eina_Value_Type *type __UNUSED__, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
4140{
4141 const Eina_Value_Struct *tmem = type_mem;
4142
4143 eina_error_set(0);
4144 if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
4145 convert == EINA_VALUE_TYPE_STRING)
4146 {
4147 Eina_Strbuf *str = eina_strbuf_new();
4148 const char *s;
4149 Eina_Bool ret;
4150
4151 if (!tmem->memory) eina_strbuf_append(str, "{}");
4152 else
4153 {
4154 const Eina_Value_Struct_Member *itr = tmem->desc->members;
4155
4156 eina_strbuf_append_char(str, '{');
4157
4158 if (tmem->desc->member_count > 0)
4159 {
4160 const Eina_Value_Struct_Member *itr_end;
4161
4162 itr_end = itr + tmem->desc->member_count;
4163 for (; itr < itr_end; itr++)
4164 _eina_value_type_struct_convert_to_string_member
4165 (tmem, itr, str);
4166 }
4167 else
4168 {
4169 for (; itr->name != NULL; itr++)
4170 _eina_value_type_struct_convert_to_string_member
4171 (tmem, itr, str);
4172 }
4173
4174 eina_strbuf_append_char(str, '}');
4175 }
4176 s = eina_strbuf_string_get(str);
4177 ret = eina_value_type_pset(convert, convert_mem, &s);
4178 eina_strbuf_free(str);
4179 return ret;
4180 }
4181 else
4182 {
4183 eina_error_set(EINA_ERROR_VALUE_FAILED);
4184 return EINA_FALSE;
4185 }
4186}
4187
4188static Eina_Bool
4189_eina_value_type_struct_desc_check(const Eina_Value_Struct_Desc *desc)
4190{
4191 unsigned int minsize = 0;
4192 const Eina_Value_Struct_Member *itr;
4193
4194 EINA_SAFETY_ON_NULL_RETURN_VAL(desc, EINA_FALSE);
4195 EINA_SAFETY_ON_FALSE_RETURN_VAL
4196 (desc->version == EINA_VALUE_STRUCT_DESC_VERSION, EINA_FALSE);
4197
4198 itr = desc->members;
4199 if (desc->member_count > 0)
4200 {
4201 const Eina_Value_Struct_Member *itr_end = itr + desc->member_count;
4202 for (; itr < itr_end; itr++)
4203 {
4204 unsigned int member_end;
4205
4206 EINA_SAFETY_ON_FALSE_RETURN_VAL
4207 (eina_value_type_check(itr->type), EINA_FALSE);
4208 EINA_SAFETY_ON_FALSE_RETURN_VAL
4209 (itr->type->value_size > 0, EINA_FALSE);
4210
4211 member_end = itr->offset + itr->type->value_size;
4212 if (minsize < member_end)
4213 minsize = member_end;
4214 }
4215 }
4216 else
4217 {
4218 for (; itr->name != NULL; itr++)
4219 {
4220 unsigned int member_end;
4221
4222 EINA_SAFETY_ON_FALSE_RETURN_VAL
4223 (eina_value_type_check(itr->type), EINA_FALSE);
4224 EINA_SAFETY_ON_FALSE_RETURN_VAL
4225 (itr->type->value_size > 0, EINA_FALSE);
4226
4227 member_end = itr->offset + itr->type->value_size;
4228 if (minsize < member_end)
4229 minsize = member_end;
4230 }
4231 }
4232
4233 EINA_SAFETY_ON_FALSE_RETURN_VAL(minsize > 0, EINA_FALSE);
4234 EINA_SAFETY_ON_FALSE_RETURN_VAL(desc->size >= minsize, EINA_FALSE);
4235 return EINA_TRUE;
4236}
4237
4238static Eina_Bool
4239_eina_value_type_struct_pset(const Eina_Value_Type *type __UNUSED__, void *mem, const void *ptr)
4240{
4241 const Eina_Value_Struct_Operations *ops = _eina_value_type_struct_ops_get(mem);
4242 Eina_Value_Struct *tmem = mem;
4243 const Eina_Value_Struct *desc = ptr;
4244
4245 if (!_eina_value_type_struct_desc_check(desc->desc))
4246 {
4247 eina_error_set(EINA_ERROR_VALUE_FAILED);
4248 return EINA_FALSE;
4249 }
4250
4251 if ((ops) && (ops->free))
4252 ops->free(ops, tmem->desc, tmem->memory);
4253 else
4254 free(tmem->memory);
4255
4256 *tmem = *desc;
4257
4258 ops = _eina_value_type_struct_ops_get(desc);
4259 if (!tmem->memory)
4260 {
4261 if ((ops) && (ops->alloc))
4262 tmem->memory = ops->alloc(ops, tmem->desc);
4263 else
4264 tmem->memory = malloc(tmem->desc->size);
4265
4266 if (!tmem->memory)
4267 {
4268 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
4269 return EINA_FALSE;
4270 }
4271 }
4272
4273 eina_error_set(0);
4274 return EINA_TRUE;
4275}
4276
4277static Eina_Bool
4278_eina_value_type_struct_vset(const Eina_Value_Type *type, void *mem, va_list args)
4279{
4280 const Eina_Value_Struct desc = va_arg(args, Eina_Value_Struct);
4281 _eina_value_type_struct_pset(type, mem, &desc);
4282 return EINA_TRUE;
4283}
4284
4285static Eina_Bool
4286_eina_value_type_struct_pget(const Eina_Value_Type *type __UNUSED__, const void *mem, void *ptr)
4287{
4288 memcpy(ptr, mem, sizeof(Eina_Value_Struct));
4289 return EINA_TRUE;
4290}
4291
4292static const Eina_Value_Type _EINA_VALUE_TYPE_STRUCT = {
4293 EINA_VALUE_TYPE_VERSION,
4294 sizeof(Eina_Value_Struct),
4295 "Eina_Value_Struct",
4296 _eina_value_type_struct_setup,
4297 _eina_value_type_struct_flush,
4298 _eina_value_type_struct_copy,
4299 _eina_value_type_struct_compare,
4300 _eina_value_type_struct_convert_to,
4301 NULL, /* no convert from */
4302 _eina_value_type_struct_vset,
4303 _eina_value_type_struct_pset,
4304 _eina_value_type_struct_pget
4305};
4306
4307/* keep all basic types inlined in an array so we can compare if it's
4308 * a basic type using pointer arithmetic.
4309 *
4310 * NOTE-1: JUST BASIC TYPES, DO NOT ADD MORE TYPES HERE!!!
4311 * NOTE-2: KEEP ORDER, see eina_value_init()
4312 */
4313static const Eina_Value_Type _EINA_VALUE_TYPE_BASICS[] = {
4314 {
4315 EINA_VALUE_TYPE_VERSION,
4316 sizeof(unsigned char),
4317 "unsigned char",
4318 _eina_value_type_uchar_setup,
4319 _eina_value_type_uchar_flush,
4320 _eina_value_type_uchar_copy,
4321 _eina_value_type_uchar_compare,
4322 _eina_value_type_uchar_convert_to,
4323 NULL, /* no convert from */
4324 _eina_value_type_uchar_vset,
4325 _eina_value_type_uchar_pset,
4326 _eina_value_type_uchar_pget
4327 },
4328 {
4329 EINA_VALUE_TYPE_VERSION,
4330 sizeof(unsigned short),
4331 "unsigned short",
4332 _eina_value_type_ushort_setup,
4333 _eina_value_type_ushort_flush,
4334 _eina_value_type_ushort_copy,
4335 _eina_value_type_ushort_compare,
4336 _eina_value_type_ushort_convert_to,
4337 NULL, /* no convert from */
4338 _eina_value_type_ushort_vset,
4339 _eina_value_type_ushort_pset,
4340 _eina_value_type_ushort_pget
4341 },
4342 {
4343 EINA_VALUE_TYPE_VERSION,
4344 sizeof(unsigned int),
4345 "unsigned int",
4346 _eina_value_type_uint_setup,
4347 _eina_value_type_uint_flush,
4348 _eina_value_type_uint_copy,
4349 _eina_value_type_uint_compare,
4350 _eina_value_type_uint_convert_to,
4351 NULL, /* no convert from */
4352 _eina_value_type_uint_vset,
4353 _eina_value_type_uint_pset,
4354 _eina_value_type_uint_pget
4355 },
4356 {
4357 EINA_VALUE_TYPE_VERSION,
4358 sizeof(unsigned long),
4359 "unsigned long",
4360 _eina_value_type_ulong_setup,
4361 _eina_value_type_ulong_flush,
4362 _eina_value_type_ulong_copy,
4363 _eina_value_type_ulong_compare,
4364 _eina_value_type_ulong_convert_to,
4365 NULL, /* no convert from */
4366 _eina_value_type_ulong_vset,
4367 _eina_value_type_ulong_pset,
4368 _eina_value_type_ulong_pget
4369 },
4370 {
4371 EINA_VALUE_TYPE_VERSION,
4372 sizeof(uint64_t),
4373 "uint64_t",
4374 _eina_value_type_uint64_setup,
4375 _eina_value_type_uint64_flush,
4376 _eina_value_type_uint64_copy,
4377 _eina_value_type_uint64_compare,
4378 _eina_value_type_uint64_convert_to,
4379 NULL, /* no convert from */
4380 _eina_value_type_uint64_vset,
4381 _eina_value_type_uint64_pset,
4382 _eina_value_type_uint64_pget
4383 },
4384 {
4385 EINA_VALUE_TYPE_VERSION,
4386 sizeof(char),
4387 "char",
4388 _eina_value_type_char_setup,
4389 _eina_value_type_char_flush,
4390 _eina_value_type_char_copy,
4391 _eina_value_type_char_compare,
4392 _eina_value_type_char_convert_to,
4393 NULL, /* no convert from */
4394 _eina_value_type_char_vset,
4395 _eina_value_type_char_pset,
4396 _eina_value_type_char_pget
4397 },
4398 {
4399 EINA_VALUE_TYPE_VERSION,
4400 sizeof(short),
4401 "short",
4402 _eina_value_type_short_setup,
4403 _eina_value_type_short_flush,
4404 _eina_value_type_short_copy,
4405 _eina_value_type_short_compare,
4406 _eina_value_type_short_convert_to,
4407 NULL, /* no convert from */
4408 _eina_value_type_short_vset,
4409 _eina_value_type_short_pset,
4410 _eina_value_type_short_pget
4411 },
4412 {
4413 EINA_VALUE_TYPE_VERSION,
4414 sizeof(int),
4415 "int",
4416 _eina_value_type_int_setup,
4417 _eina_value_type_int_flush,
4418 _eina_value_type_int_copy,
4419 _eina_value_type_int_compare,
4420 _eina_value_type_int_convert_to,
4421 NULL, /* no convert from */
4422 _eina_value_type_int_vset,
4423 _eina_value_type_int_pset,
4424 _eina_value_type_int_pget
4425 },
4426 {
4427 EINA_VALUE_TYPE_VERSION,
4428 sizeof(long),
4429 "long",
4430 _eina_value_type_long_setup,
4431 _eina_value_type_long_flush,
4432 _eina_value_type_long_copy,
4433 _eina_value_type_long_compare,
4434 _eina_value_type_long_convert_to,
4435 NULL, /* no convert from */
4436 _eina_value_type_long_vset,
4437 _eina_value_type_long_pset,
4438 _eina_value_type_long_pget
4439 },
4440 {
4441 EINA_VALUE_TYPE_VERSION,
4442 sizeof(int64_t),
4443 "int64_t",
4444 _eina_value_type_int64_setup,
4445 _eina_value_type_int64_flush,
4446 _eina_value_type_int64_copy,
4447 _eina_value_type_int64_compare,
4448 _eina_value_type_int64_convert_to,
4449 NULL, /* no convert from */
4450 _eina_value_type_int64_vset,
4451 _eina_value_type_int64_pset,
4452 _eina_value_type_int64_pget
4453 },
4454 {
4455 EINA_VALUE_TYPE_VERSION,
4456 sizeof(float),
4457 "float",
4458 _eina_value_type_float_setup,
4459 _eina_value_type_float_flush,
4460 _eina_value_type_float_copy,
4461 _eina_value_type_float_compare,
4462 _eina_value_type_float_convert_to,
4463 NULL, /* no convert from */
4464 _eina_value_type_float_vset,
4465 _eina_value_type_float_pset,
4466 _eina_value_type_float_pget
4467 },
4468 {
4469 EINA_VALUE_TYPE_VERSION,
4470 sizeof(double),
4471 "double",
4472 _eina_value_type_double_setup,
4473 _eina_value_type_double_flush,
4474 _eina_value_type_double_copy,
4475 _eina_value_type_double_compare,
4476 _eina_value_type_double_convert_to,
4477 NULL, /* no convert from */
4478 _eina_value_type_double_vset,
4479 _eina_value_type_double_pset,
4480 _eina_value_type_double_pget
4481 },
4482 {
4483 EINA_VALUE_TYPE_VERSION,
4484 sizeof(const char *),
4485 "stringshare",
4486 _eina_value_type_string_common_setup,
4487 _eina_value_type_stringshare_flush,
4488 _eina_value_type_stringshare_copy,
4489 _eina_value_type_string_common_compare,
4490 _eina_value_type_string_common_convert_to,
4491 NULL, /* no convert from */
4492 _eina_value_type_stringshare_vset,
4493 _eina_value_type_stringshare_pset,
4494 _eina_value_type_string_common_pget
4495 },
4496 {
4497 EINA_VALUE_TYPE_VERSION,
4498 sizeof(char *),
4499 "string",
4500 _eina_value_type_string_common_setup,
4501 _eina_value_type_string_flush,
4502 _eina_value_type_string_copy,
4503 _eina_value_type_string_common_compare,
4504 _eina_value_type_string_common_convert_to,
4505 NULL, /* no convert from */
4506 _eina_value_type_string_vset,
4507 _eina_value_type_string_pset,
4508 _eina_value_type_string_common_pget
4509 }
4510};
4511
4512static void
4513_eina_value_blob_operations_malloc_free(const Eina_Value_Blob_Operations *ops __UNUSED__, void *memory, size_t size __UNUSED__)
4514{
4515 free(memory);
4516}
4517
4518static void *
4519_eina_value_blob_operations_malloc_copy(const Eina_Value_Blob_Operations *ops __UNUSED__, const void *memory, size_t size)
4520{
4521 void *ret = malloc(size);
4522 if (!ret)
4523 {
4524 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
4525 return NULL;
4526 }
4527 memcpy(ret, memory, size);
4528 return ret;
4529}
4530
4531static const Eina_Value_Blob_Operations _EINA_VALUE_BLOB_OPERATIONS_MALLOC = {
4532 EINA_VALUE_BLOB_OPERATIONS_VERSION,
4533 _eina_value_blob_operations_malloc_free,
4534 _eina_value_blob_operations_malloc_copy,
4535 NULL,
4536 NULL
4537};
4538
4539typedef struct _Eina_Value_Inner_Mp Eina_Value_Inner_Mp;
4540struct _Eina_Value_Inner_Mp
4541{
4542 Eina_Mempool *mempool;
4543 int references;
4544};
4545
4546/**
4547 * @endcond
4548 */
4549
4550static const char EINA_ERROR_VALUE_FAILED_STR[] = "Value check failed.";
4551
4552/**
4553 */
4554
4555static inline void
4556_eina_value_inner_mp_dispose(int size, Eina_Value_Inner_Mp *imp)
4557{
4558 EINA_SAFETY_ON_FALSE_RETURN(imp->references == 0);
4559
4560 eina_hash_del_by_key(_eina_value_inner_mps, &size);
4561 eina_mempool_del(imp->mempool);
4562 free(imp);
4563}
4564
4565static inline Eina_Value_Inner_Mp *
4566_eina_value_inner_mp_get(int size)
4567{
4568 Eina_Value_Inner_Mp *imp = eina_hash_find(_eina_value_inner_mps, &size);
4569 if (imp) return imp;
4570
4571 imp = malloc(sizeof(Eina_Value_Inner_Mp));
4572 if (!imp)
4573 return NULL;
4574
4575 imp->references = 0;
4576
4577 imp->mempool = eina_mempool_add(_eina_value_mp_choice,
4578 "Eina_Value_Inner_Mp", NULL, size, 128);
4579 if (!imp->mempool)
4580 {
4581 free(imp);
4582 return NULL;
4583 }
4584
4585 if (!eina_hash_add(_eina_value_inner_mps, &size, imp))
4586 {
4587 eina_mempool_del(imp->mempool);
4588 free(imp);
4589 return NULL;
4590 }
4591
4592 return imp;
4593}
4594
4595static inline void *
4596_eina_value_inner_alloc_internal(int size)
4597{
4598 Eina_Value_Inner_Mp *imp;
4599 void *mem;
4600
4601 imp = _eina_value_inner_mp_get(size);
4602 if (!imp) return NULL;
4603
4604 mem = eina_mempool_malloc(imp->mempool, size);
4605 if (mem) imp->references++;
4606 else if (imp->references == 0) _eina_value_inner_mp_dispose(size, imp);
4607
4608 return mem;
4609}
4610
4611static inline void
4612_eina_value_inner_free_internal(int size, void *mem)
4613{
4614 Eina_Value_Inner_Mp *imp = eina_hash_find(_eina_value_inner_mps, &size);
4615 EINA_SAFETY_ON_NULL_RETURN(imp);
4616
4617 eina_mempool_free(imp->mempool, mem);
4618
4619 imp->references--;
4620 if (imp->references > 0) return;
4621 _eina_value_inner_mp_dispose(size, imp);
4622}
4623
4624EAPI void *
4625eina_value_inner_alloc(size_t size)
4626{
4627 void *mem;
4628
4629 if (size > 256) return malloc(size);
4630
4631 eina_lock_take(&_eina_value_inner_mps_lock);
4632 mem = _eina_value_inner_alloc_internal(size);
4633 eina_lock_release(&_eina_value_inner_mps_lock);
4634
4635 return mem;
4636}
4637
4638EAPI void
4639eina_value_inner_free(size_t size, void *mem)
4640{
4641 if (size > 256)
4642 {
4643 free(mem);
4644 return;
4645 }
4646
4647 eina_lock_take(&_eina_value_inner_mps_lock);
4648 _eina_value_inner_free_internal(size, mem);
4649 eina_lock_release(&_eina_value_inner_mps_lock);
4650}
4651
4652/**
4653 * @internal
4654 * @brief Initialize the value module.
4655 *
4656 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
4657 *
4658 * This function sets up the value module of Eina. It is called
4659 * by eina_init().
4660 *
4661 * @see eina_init()
4662 */
4663Eina_Bool
4664eina_value_init(void)
4665{
4666 const char *choice, *tmp;
4667
4668 _eina_value_log_dom = eina_log_domain_register("eina_value",
4669 EINA_LOG_COLOR_DEFAULT);
4670 if (_eina_value_log_dom < 0)
4671 {
4672 EINA_LOG_ERR("Could not register log domain: eina_value");
4673 return EINA_FALSE;
4674 }
4675
4676#ifdef EINA_DEFAULT_MEMPOOL
4677 choice = "pass_through";
4678#else
4679 choice = "chained_mempool";
4680#endif
4681 tmp = getenv("EINA_MEMPOOL");
4682 if (tmp && tmp[0])
4683 choice = tmp;
4684
4685 if (choice)
4686 _eina_value_mp_choice = strdup(choice);
4687
4688 _eina_value_mp = eina_mempool_add
4689 (_eina_value_mp_choice, "value", NULL, sizeof(Eina_Value), 320);
4690 if (!_eina_value_mp)
4691 {
4692 ERR("Mempool for value cannot be allocated in value init.");
4693 goto on_init_fail_mp;
4694 }
4695
4696 if (!eina_lock_new(&_eina_value_inner_mps_lock))
4697 {
4698 ERR("Cannot create lock in value init.");
4699 goto on_init_fail_lock;
4700 }
4701 _eina_value_inner_mps = eina_hash_int32_new(NULL);
4702 if (!_eina_value_inner_mps)
4703 {
4704 ERR("Cannot create hash for inner mempools in value init.");
4705 goto on_init_fail_hash;
4706 }
4707
4708 EINA_ERROR_VALUE_FAILED = eina_error_msg_static_register(
4709 EINA_ERROR_VALUE_FAILED_STR);
4710
4711 EINA_VALUE_TYPE_UCHAR = _EINA_VALUE_TYPE_BASICS + 0;
4712 EINA_VALUE_TYPE_USHORT = _EINA_VALUE_TYPE_BASICS + 1;
4713 EINA_VALUE_TYPE_UINT = _EINA_VALUE_TYPE_BASICS + 2;
4714 EINA_VALUE_TYPE_ULONG = _EINA_VALUE_TYPE_BASICS + 3;
4715 EINA_VALUE_TYPE_UINT64 = _EINA_VALUE_TYPE_BASICS + 4;
4716 EINA_VALUE_TYPE_CHAR = _EINA_VALUE_TYPE_BASICS + 5;
4717 EINA_VALUE_TYPE_SHORT = _EINA_VALUE_TYPE_BASICS + 6;
4718 EINA_VALUE_TYPE_INT = _EINA_VALUE_TYPE_BASICS + 7;
4719 EINA_VALUE_TYPE_LONG = _EINA_VALUE_TYPE_BASICS + 8;
4720 EINA_VALUE_TYPE_INT64 = _EINA_VALUE_TYPE_BASICS + 9;
4721 EINA_VALUE_TYPE_FLOAT = _EINA_VALUE_TYPE_BASICS + 10;
4722 EINA_VALUE_TYPE_DOUBLE = _EINA_VALUE_TYPE_BASICS + 11;
4723 EINA_VALUE_TYPE_STRINGSHARE = _EINA_VALUE_TYPE_BASICS + 12;
4724 EINA_VALUE_TYPE_STRING = _EINA_VALUE_TYPE_BASICS + 13;
4725
4726 _EINA_VALUE_TYPE_BASICS_START = _EINA_VALUE_TYPE_BASICS + 0;
4727 _EINA_VALUE_TYPE_BASICS_END = _EINA_VALUE_TYPE_BASICS + 13;
4728
4729 EINA_SAFETY_ON_FALSE_RETURN_VAL((sizeof(_EINA_VALUE_TYPE_BASICS)/sizeof(_EINA_VALUE_TYPE_BASICS[0])) == 14, EINA_FALSE);
4730
4731
4732 EINA_VALUE_TYPE_ARRAY = &_EINA_VALUE_TYPE_ARRAY;
4733 EINA_VALUE_TYPE_LIST = &_EINA_VALUE_TYPE_LIST;
4734 EINA_VALUE_TYPE_HASH = &_EINA_VALUE_TYPE_HASH;
4735 EINA_VALUE_TYPE_TIMEVAL = &_EINA_VALUE_TYPE_TIMEVAL;
4736 EINA_VALUE_TYPE_BLOB = &_EINA_VALUE_TYPE_BLOB;
4737 EINA_VALUE_TYPE_STRUCT = &_EINA_VALUE_TYPE_STRUCT;
4738
4739 EINA_VALUE_BLOB_OPERATIONS_MALLOC = &_EINA_VALUE_BLOB_OPERATIONS_MALLOC;
4740
4741 EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = &_EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH;
4742 EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE = &_EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE;
4743
4744 return EINA_TRUE;
4745
4746 on_init_fail_hash:
4747 eina_lock_free(&_eina_value_inner_mps_lock);
4748 on_init_fail_lock:
4749 eina_mempool_del(_eina_value_mp);
4750 on_init_fail_mp:
4751 free(_eina_value_mp_choice);
4752 _eina_value_mp_choice = NULL;
4753 eina_log_domain_unregister(_eina_value_log_dom);
4754 _eina_value_log_dom = -1;
4755 return EINA_FALSE;
4756}
4757
4758/**
4759 * @internal
4760 * @brief Shut down the value module.
4761 *
4762 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
4763 *
4764 * This function shuts down the value module set up by
4765 * eina_value_init(). It is called by eina_shutdown().
4766 *
4767 * @see eina_shutdown()
4768 */
4769Eina_Bool
4770eina_value_shutdown(void)
4771{
4772 eina_lock_take(&_eina_value_inner_mps_lock);
4773 if (eina_hash_population(_eina_value_inner_mps) != 0)
4774 ERR("Cannot free eina_value internal memory pools -- still in use!");
4775 else
4776 eina_hash_free(_eina_value_inner_mps);
4777 eina_lock_release(&_eina_value_inner_mps_lock);
4778 eina_lock_free(&_eina_value_inner_mps_lock);
4779
4780 free(_eina_value_mp_choice);
4781 _eina_value_mp_choice = NULL;
4782 eina_mempool_del(_eina_value_mp);
4783 eina_log_domain_unregister(_eina_value_log_dom);
4784 _eina_value_log_dom = -1;
4785 return EINA_TRUE;
4786}
33 4787
34/*============================================================================* 4788/*============================================================================*
35* Global * 4789* Global *
@@ -39,9 +4793,232 @@
39* API * 4793* API *
40*============================================================================*/ 4794*============================================================================*/
41 4795
4796EAPI const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START = NULL;
4797EAPI const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END = NULL;
4798
4799EAPI const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR = NULL;
4800EAPI const Eina_Value_Type *EINA_VALUE_TYPE_USHORT = NULL;
4801EAPI const Eina_Value_Type *EINA_VALUE_TYPE_UINT = NULL;
4802EAPI const Eina_Value_Type *EINA_VALUE_TYPE_ULONG = NULL;
4803EAPI const Eina_Value_Type *EINA_VALUE_TYPE_UINT64 = NULL;
4804EAPI const Eina_Value_Type *EINA_VALUE_TYPE_CHAR = NULL;
4805EAPI const Eina_Value_Type *EINA_VALUE_TYPE_SHORT = NULL;
4806EAPI const Eina_Value_Type *EINA_VALUE_TYPE_INT = NULL;
4807EAPI const Eina_Value_Type *EINA_VALUE_TYPE_LONG = NULL;
4808EAPI const Eina_Value_Type *EINA_VALUE_TYPE_INT64 = NULL;
4809EAPI const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT = NULL;
4810EAPI const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE = NULL;
4811EAPI const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE = NULL;
4812EAPI const Eina_Value_Type *EINA_VALUE_TYPE_STRING = NULL;
4813EAPI const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY = NULL;
4814EAPI const Eina_Value_Type *EINA_VALUE_TYPE_LIST = NULL;
4815EAPI const Eina_Value_Type *EINA_VALUE_TYPE_HASH = NULL;
4816EAPI const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL = NULL;
4817EAPI const Eina_Value_Type *EINA_VALUE_TYPE_BLOB = NULL;
4818EAPI const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT = NULL;
4819
4820EAPI const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC = NULL;
4821
4822EAPI const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH = NULL;
4823EAPI const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE = NULL;
4824
4825EAPI Eina_Error EINA_ERROR_VALUE_FAILED = 0;
4826
42EAPI const unsigned int eina_prime_table[] = 4827EAPI const unsigned int eina_prime_table[] =
43{ 4828{
44 17, 31, 61, 127, 257, 509, 1021, 4829 17, 31, 61, 127, 257, 509, 1021,
45 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573, 4830 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
46 2097143, 4194301, 8388617, 16777213 4831 2097143, 4194301, 8388617, 16777213
47}; 4832};
4833
4834EAPI Eina_Value *
4835eina_value_new(const Eina_Value_Type *type)
4836{
4837 Eina_Value *value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));;
4838 if (!value)
4839 {
4840 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
4841 return NULL;
4842 }
4843 if (!eina_value_setup(value, type))
4844 {
4845 free(value);
4846 return NULL;
4847 }
4848 return value;
4849}
4850
4851EAPI void
4852eina_value_free(Eina_Value *value)
4853{
4854 EINA_SAFETY_ON_NULL_RETURN(value);
4855 eina_value_flush(value);
4856 eina_mempool_free(_eina_value_mp, value);
4857}
4858
4859
4860EAPI Eina_Bool
4861eina_value_copy(const Eina_Value *value, Eina_Value *copy)
4862{
4863 const Eina_Value_Type *type;
4864 const void *src;
4865 void *dst;
4866 Eina_Bool ret;
4867
4868 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
4869 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type),
4870 EINA_FALSE);
4871 EINA_SAFETY_ON_NULL_RETURN_VAL(copy, EINA_FALSE);
4872 EINA_SAFETY_ON_NULL_RETURN_VAL(value->type->copy, EINA_FALSE);
4873
4874 type = value->type;
4875 if (!eina_value_setup(copy, type))
4876 return EINA_FALSE;
4877
4878 src = eina_value_memory_get(value);
4879 dst = eina_value_memory_get(copy);
4880 ret = type->copy(type, src, dst);
4881 if (!ret)
4882 eina_value_flush(copy);
4883
4884 return ret;
4885}
4886
4887EAPI Eina_Bool
4888eina_value_convert(const Eina_Value *value, Eina_Value *convert)
4889{
4890 Eina_Bool ret = EINA_FALSE;
4891 const Eina_Value_Type *type, *convert_type;
4892 const void *type_mem;
4893 void *convert_mem;
4894
4895 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
4896 EINA_SAFETY_ON_NULL_RETURN_VAL(convert, EINA_FALSE);
4897 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type),
4898 EINA_FALSE);
4899 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(convert->type),
4900 EINA_FALSE);
4901
4902 type = value->type;
4903 convert_type = convert->type;
4904
4905 type_mem = eina_value_memory_get(value);
4906 convert_mem = eina_value_memory_get(convert);
4907
4908 if (type->convert_to)
4909 ret = type->convert_to(type, convert_type, type_mem, convert_mem);
4910
4911 if ((!ret) && (convert_type->convert_from))
4912 ret = convert_type->convert_from(convert_type, type, convert_mem,
4913 type_mem);
4914
4915 return ret;
4916}
4917
4918EAPI char *
4919eina_value_to_string(const Eina_Value *value)
4920{
4921 Eina_Value tmp;
4922
4923 EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
4924 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), NULL);
4925
4926 if (!eina_value_setup(&tmp, EINA_VALUE_TYPE_STRING))
4927 return NULL;
4928 if (!eina_value_convert(value, &tmp))
4929 return NULL;
4930
4931 return tmp.value.ptr; /* steal value */
4932}
4933
4934EAPI Eina_Value *
4935eina_value_array_new(const Eina_Value_Type *subtype, unsigned int step)
4936{
4937 Eina_Value *value;
4938
4939 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(subtype), EINA_FALSE);
4940
4941 value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));;
4942 if (!value)
4943 return NULL;
4944
4945 if (!eina_value_array_setup(value, subtype, step))
4946 {
4947 eina_mempool_free(_eina_value_mp, value);
4948 return NULL;
4949 }
4950
4951 return value;
4952}
4953
4954EAPI Eina_Value *
4955eina_value_list_new(const Eina_Value_Type *subtype)
4956{
4957 Eina_Value *value;
4958
4959 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(subtype), EINA_FALSE);
4960
4961 value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));;
4962 if (!value)
4963 return NULL;
4964
4965 if (!eina_value_list_setup(value, subtype))
4966 {
4967 eina_mempool_free(_eina_value_mp, value);
4968 return NULL;
4969 }
4970
4971 return value;
4972}
4973
4974EAPI Eina_Value *
4975eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size)
4976{
4977 Eina_Value *value;
4978
4979 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(subtype), EINA_FALSE);
4980
4981 value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));;
4982 if (!value)
4983 return NULL;
4984
4985 if (!eina_value_hash_setup(value, subtype, buckets_power_size))
4986 {
4987 eina_mempool_free(_eina_value_mp, value);
4988 return NULL;
4989 }
4990
4991 return value;
4992}
4993
4994EAPI Eina_Value *
4995eina_value_struct_new(const Eina_Value_Struct_Desc *desc)
4996{
4997 Eina_Value *value;
4998
4999 value = eina_mempool_malloc(_eina_value_mp, sizeof(Eina_Value));;
5000 if (!value)
5001 return NULL;
5002
5003 if (!eina_value_struct_setup(value, desc))
5004 {
5005 eina_mempool_free(_eina_value_mp, value);
5006 return NULL;
5007 }
5008
5009 return value;
5010}
5011
5012EAPI Eina_Bool
5013eina_value_type_check(const Eina_Value_Type *type)
5014{
5015 EINA_SAFETY_ON_NULL_RETURN_VAL(type, EINA_FALSE);
5016 return type->version == EINA_VALUE_TYPE_VERSION;
5017}
5018
5019EAPI const char *
5020eina_value_type_name_get(const Eina_Value_Type *type)
5021{
5022 EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), NULL);
5023 return type->name;
5024}
diff --git a/libraries/eina/src/lib/eina_xattr.c b/libraries/eina/src/lib/eina_xattr.c
index bd5b98e..d4ed139 100644
--- a/libraries/eina/src/lib/eina_xattr.c
+++ b/libraries/eina/src/lib/eina_xattr.c
@@ -20,6 +20,7 @@
20# include "config.h" 20# include "config.h"
21#endif 21#endif
22 22
23#include <stdlib.h>
23#include <sys/types.h> 24#include <sys/types.h>
24#include <string.h> 25#include <string.h>
25#include <math.h> 26#include <math.h>
@@ -34,6 +35,7 @@
34#include "eina_safety_checks.h" 35#include "eina_safety_checks.h"
35#include "eina_xattr.h" 36#include "eina_xattr.h"
36#include "eina_convert.h" 37#include "eina_convert.h"
38#include "eina_stringshare.h"
37 39
38/*============================================================================* 40/*============================================================================*
39 * Local * 41 * Local *
@@ -49,14 +51,83 @@ struct _Eina_Xattr_Iterator
49{ 51{
50 Eina_Iterator iterator; 52 Eina_Iterator iterator;
51 53
54 const char *file;
55 Eina_Xattr *attr;
56
52 ssize_t length; 57 ssize_t length;
53 ssize_t offset; 58 ssize_t offset;
54 59
60 int fd;
61
55 char xattr[1]; 62 char xattr[1];
56}; 63};
57 64
58#ifdef HAVE_XATTR 65#ifdef HAVE_XATTR
59static Eina_Bool 66static Eina_Bool
67_eina_xattr_value_ls_fd_iterator_next(Eina_Xattr_Iterator *it, void **data)
68{
69 char *tmp;
70
71 if (it->offset >= it->length)
72 return EINA_FALSE;
73
74 *data = it->attr;
75 it->attr->name = it->xattr + it->offset;
76
77 it->attr->length = fgetxattr(it->fd, it->attr->name, NULL, 0);
78 if (it->attr->length)
79 {
80 tmp = realloc((void*) it->attr->value, it->attr->length);
81 if (!tmp)
82 {
83 free((void*) it->attr->value);
84 it->attr->value = NULL;
85 it->attr->length = 0;
86 }
87 else
88 {
89 it->attr->length = fgetxattr(it->fd, it->attr->name,
90 (void *) it->attr->value,
91 it->attr->length);
92 }
93 }
94
95 return EINA_TRUE;
96}
97
98static Eina_Bool
99_eina_xattr_value_ls_iterator_next(Eina_Xattr_Iterator *it, void **data)
100{
101 char *tmp;
102
103 if (it->offset >= it->length)
104 return EINA_FALSE;
105
106 *data = it->attr;
107 it->attr->name = it->xattr + it->offset;
108
109 it->attr->length = getxattr(it->file, it->attr->name, NULL, 0);
110 if (it->attr->length)
111 {
112 tmp = realloc((void*) it->attr->value, it->attr->length);
113 if (!tmp)
114 {
115 free((void*) it->attr->value);
116 it->attr->value = NULL;
117 it->attr->length = 0;
118 }
119 else
120 {
121 it->attr->length = getxattr(it->file, it->attr->name,
122 (void*) it->attr->value,
123 it->attr->length);
124 }
125 }
126
127 return EINA_TRUE;
128}
129
130static Eina_Bool
60_eina_xattr_ls_iterator_next(Eina_Xattr_Iterator *it, void **data) 131_eina_xattr_ls_iterator_next(Eina_Xattr_Iterator *it, void **data)
61{ 132{
62 if (it->offset >= it->length) 133 if (it->offset >= it->length)
@@ -78,6 +149,9 @@ static void
78_eina_xattr_ls_iterator_free(Eina_Xattr_Iterator *it) 149_eina_xattr_ls_iterator_free(Eina_Xattr_Iterator *it)
79{ 150{
80 EINA_MAGIC_SET(&it->iterator, 0); 151 EINA_MAGIC_SET(&it->iterator, 0);
152 if (it->attr) free((void *) it->attr->value);
153 eina_stringshare_del(it->file);
154 free(it->attr);
81 free(it); 155 free(it);
82} 156}
83#endif 157#endif
@@ -96,6 +170,85 @@ _eina_xattr_ls_iterator_free(Eina_Xattr_Iterator *it)
96 * API * 170 * API *
97 *============================================================================*/ 171 *============================================================================*/
98 172
173EAPI Eina_Iterator *
174eina_xattr_value_fd_ls(int fd)
175{
176#ifdef HAVE_XATTR
177 Eina_Xattr_Iterator *it;
178 ssize_t length;
179
180 if (fd < 0) return NULL;
181
182 length = flistxattr(fd, NULL, 0);
183 if (length <= 0) return NULL;
184
185 it = calloc(1, sizeof (Eina_Xattr_Iterator) + length - 1);
186 if (!it) return NULL;
187
188 it->attr = calloc(1, sizeof (Eina_Xattr));
189 if (!it->attr)
190 {
191 free(it);
192 return NULL;
193 }
194
195 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
196
197 it->fd = fd;
198 it->length = flistxattr(fd, it->xattr, length);
199 if (it->length != length)
200 {
201 free(it);
202 return NULL;
203 }
204
205 it->iterator.version = EINA_ITERATOR_VERSION;
206 it->iterator.next = FUNC_ITERATOR_NEXT(_eina_xattr_value_ls_fd_iterator_next);
207 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_xattr_ls_iterator_container);
208 it->iterator.free = FUNC_ITERATOR_FREE(_eina_xattr_ls_iterator_free);
209
210 return &it->iterator;
211#else
212 return NULL;
213 (void)fd;
214#endif
215}
216
217EAPI Eina_Iterator *
218eina_xattr_fd_ls(int fd)
219{
220#ifdef HAVE_XATTR
221 Eina_Xattr_Iterator *it;
222 ssize_t length;
223
224 if (fd < 0) return NULL;
225
226 length = flistxattr(fd, NULL, 0);
227 if (length <= 0) return NULL;
228
229 it = calloc(1, sizeof (Eina_Xattr_Iterator) + length - 1);
230 if (!it) return NULL;
231
232 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
233
234 it->length = flistxattr(fd, it->xattr, length);
235 if (it->length != length)
236 {
237 free(it);
238 return NULL;
239 }
240
241 it->iterator.version = EINA_ITERATOR_VERSION;
242 it->iterator.next = FUNC_ITERATOR_NEXT(_eina_xattr_ls_iterator_next);
243 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_xattr_ls_iterator_container);
244 it->iterator.free = FUNC_ITERATOR_FREE(_eina_xattr_ls_iterator_free);
245
246 return &it->iterator;
247#else
248 return NULL;
249 (void)fd;
250#endif
251}
99 252
100EAPI Eina_Iterator * 253EAPI Eina_Iterator *
101eina_xattr_ls(const char *file) 254eina_xattr_ls(const char *file)
@@ -133,6 +286,44 @@ eina_xattr_ls(const char *file)
133#endif 286#endif
134} 287}
135 288
289EAPI Eina_Iterator *
290eina_xattr_value_ls(const char *file)
291{
292#ifdef HAVE_XATTR
293 Eina_Xattr_Iterator *it;
294 ssize_t length;
295
296 EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
297
298 length = listxattr(file, NULL, 0);
299 if (length <= 0) return NULL;
300
301 it = calloc(1, sizeof (Eina_Xattr_Iterator) + length - 1);
302 if (!it) return NULL;
303
304 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
305
306 it->length = listxattr(file, it->xattr, length);
307 if (it->length != length)
308 {
309 free(it);
310 return NULL;
311 }
312
313 it->file = eina_stringshare_add(file);
314
315 it->iterator.version = EINA_ITERATOR_VERSION;
316 it->iterator.next = FUNC_ITERATOR_NEXT(_eina_xattr_value_ls_iterator_next);
317 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_xattr_ls_iterator_container);
318 it->iterator.free = FUNC_ITERATOR_FREE(_eina_xattr_ls_iterator_free);
319
320 return &it->iterator;
321#else
322 return NULL;
323 (void)file;
324#endif
325}
326
136EAPI void * 327EAPI void *
137eina_xattr_get(const char *file, const char *attribute, ssize_t *size) 328eina_xattr_get(const char *file, const char *attribute, ssize_t *size)
138{ 329{
diff --git a/libraries/eina/src/modules/Makefile.in b/libraries/eina/src/modules/Makefile.in
index f3385f1..1ee8386 100644
--- a/libraries/eina/src/modules/Makefile.in
+++ b/libraries/eina/src/modules/Makefile.in
@@ -147,7 +147,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
147EGREP = @EGREP@ 147EGREP = @EGREP@
148EINA_CFLAGS = @EINA_CFLAGS@ 148EINA_CFLAGS = @EINA_CFLAGS@
149EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 149EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
150EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
150EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 151EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
152EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
151EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 153EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
152EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 154EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
153EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 155EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -199,8 +201,6 @@ PACKAGE_URL = @PACKAGE_URL@
199PACKAGE_VERSION = @PACKAGE_VERSION@ 201PACKAGE_VERSION = @PACKAGE_VERSION@
200PATH_SEPARATOR = @PATH_SEPARATOR@ 202PATH_SEPARATOR = @PATH_SEPARATOR@
201PKG_CONFIG = @PKG_CONFIG@ 203PKG_CONFIG = @PKG_CONFIG@
202PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
203PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
204RANLIB = @RANLIB@ 204RANLIB = @RANLIB@
205SED = @SED@ 205SED = @SED@
206SET_MAKE = @SET_MAKE@ 206SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/Makefile.in b/libraries/eina/src/modules/mp/Makefile.in
index d7e67ad..d3a6dd9 100644
--- a/libraries/eina/src/modules/mp/Makefile.in
+++ b/libraries/eina/src/modules/mp/Makefile.in
@@ -155,7 +155,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
155EGREP = @EGREP@ 155EGREP = @EGREP@
156EINA_CFLAGS = @EINA_CFLAGS@ 156EINA_CFLAGS = @EINA_CFLAGS@
157EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 157EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
158EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
158EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 159EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
160EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
159EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 161EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
160EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 162EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
161EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 163EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -207,8 +209,6 @@ PACKAGE_URL = @PACKAGE_URL@
207PACKAGE_VERSION = @PACKAGE_VERSION@ 209PACKAGE_VERSION = @PACKAGE_VERSION@
208PATH_SEPARATOR = @PATH_SEPARATOR@ 210PATH_SEPARATOR = @PATH_SEPARATOR@
209PKG_CONFIG = @PKG_CONFIG@ 211PKG_CONFIG = @PKG_CONFIG@
210PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
211PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
212RANLIB = @RANLIB@ 212RANLIB = @RANLIB@
213SED = @SED@ 213SED = @SED@
214SET_MAKE = @SET_MAKE@ 214SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/buddy/Makefile.in b/libraries/eina/src/modules/mp/buddy/Makefile.in
index 64d7fc7..5619b2c 100644
--- a/libraries/eina/src/modules/mp/buddy/Makefile.in
+++ b/libraries/eina/src/modules/mp/buddy/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/buddy/eina_buddy.c b/libraries/eina/src/modules/mp/buddy/eina_buddy.c
index f402c6f..7d830db 100644
--- a/libraries/eina/src/modules/mp/buddy/eina_buddy.c
+++ b/libraries/eina/src/modules/mp/buddy/eina_buddy.c
@@ -133,23 +133,23 @@ static void _free(void *data, void *element)
133 Buddy *b = data; 133 Buddy *b = data;
134 Block *block, *buddy; 134 Block *block, *buddy;
135 size_t offset; 135 size_t offset;
136 size_t index; 136 size_t idx;
137 137
138 offset = (unsigned char *)element - (unsigned char *)b->heap; 138 offset = (unsigned char *)element - (unsigned char *)b->heap;
139 if (offset > b->size) 139 if (offset > b->size)
140 return; 140 return;
141 141
142 index = offset >> b->min_order; 142 idx = offset >> b->min_order;
143 block = &b->blocks[index]; 143 block = &b->blocks[idx];
144 144
145 //printf("free %x index = %d order = %d buddy = %d\n", offset, index, block->order, index ^ (1 << block->order)); 145 //printf("free %x idx = %d order = %d buddy = %d\n", offset, idx, block->order, idx ^ (1 << block->order));
146 /* we should always work with the buddy at right */ 146 /* we should always work with the buddy at right */
147 if (index & (1 << block->order)) 147 if (idx & (1 << block->order))
148 { 148 {
149 Block *left; 149 Block *left;
150 150
151 index = index ^ (1 << block->order); 151 idx = idx ^ (1 << block->order);
152 left = &b->blocks[index]; 152 left = &b->blocks[idx];
153 if (!left->available) 153 if (!left->available)
154 goto end; 154 goto end;
155 else 155 else
@@ -170,7 +170,7 @@ check:
170 170
171 } 171 }
172 172
173 buddy = &b->blocks[index ^ (1 << block->order)]; 173 buddy = &b->blocks[idx ^ (1 << block->order)];
174 if (!buddy->available) 174 if (!buddy->available)
175 { 175 {
176 goto end; /* merge two blocks */ 176 goto end; /* merge two blocks */
@@ -239,7 +239,7 @@ static void _statistics(void *data)
239 239
240 printf("Information:\n"); 240 printf("Information:\n");
241 printf( 241 printf(
242 "size = %li, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%luKB)\n", 242 "size = %zu, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%uKB)\n",
243 b->size, 243 b->size,
244 b->min_order, 244 b->min_order,
245 b->max_order, 245 b->max_order,
@@ -255,7 +255,7 @@ static void _statistics(void *data)
255 printf("\n2^%d:", b->min_order + i); 255 printf("\n2^%d:", b->min_order + i);
256 EINA_INLIST_FOREACH(b->areas[i], block) 256 EINA_INLIST_FOREACH(b->areas[i], block)
257 { 257 {
258 printf(" %li", (block - &b->blocks[0])); 258 printf(" %d", (block - &b->blocks[0]));
259 } 259 }
260 } 260 }
261 printf("\nBlocks dumping:\n"); 261 printf("\nBlocks dumping:\n");
diff --git a/libraries/eina/src/modules/mp/chained_pool/Makefile.in b/libraries/eina/src/modules/mp/chained_pool/Makefile.in
index b728672..03b639f 100644
--- a/libraries/eina/src/modules/mp/chained_pool/Makefile.in
+++ b/libraries/eina/src/modules/mp/chained_pool/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c b/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c
index 009b62b..020d0ad 100644
--- a/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c
+++ b/libraries/eina/src/modules/mp/chained_pool/eina_chained_mempool.c
@@ -31,6 +31,10 @@
31# endif 31# endif
32#endif 32#endif
33 33
34#ifdef EINA_DEBUG_MALLOC
35# include <malloc.h>
36#endif
37
34#ifdef EFL_HAVE_WIN32_THREADS 38#ifdef EFL_HAVE_WIN32_THREADS
35# define WIN32_LEAN_AND_MEAN 39# define WIN32_LEAN_AND_MEAN
36# include <windows.h> 40# include <windows.h>
@@ -51,7 +55,7 @@
51# include <valgrind/memcheck.h> 55# include <valgrind/memcheck.h>
52#endif 56#endif
53 57
54#ifdef DEBUG 58#if defined DEBUG || defined EINA_DEBUG_MALLOC
55#include <assert.h> 59#include <assert.h>
56#include "eina_log.h" 60#include "eina_log.h"
57 61
@@ -74,6 +78,9 @@ struct _Chained_Mempool
74 int alloc_size; 78 int alloc_size;
75 int group_size; 79 int group_size;
76 int usage; 80 int usage;
81#ifdef EINA_DEBUG_MALLOC
82 int minimal_size;
83#endif
77#ifdef EFL_DEBUG_THREADS 84#ifdef EFL_DEBUG_THREADS
78 pthread_t self; 85 pthread_t self;
79#endif 86#endif
@@ -125,6 +132,20 @@ _eina_chained_mp_pool_new(Chained_Mempool *pool)
125 return NULL; 132 return NULL;
126 } 133 }
127 134
135#ifdef EINA_DEBUG_MALLOC
136 {
137 size_t sz;
138
139 sz = malloc_usable_size(p);
140 if (sz - pool->minimal_size > 0)
141 INF("Just allocated %0.2f%% to much memory in '%s' for one block of size %i that means %i bytes to much.",
142 ((float)(sz - pool->minimal_size) * 100) / (float) (pool->alloc_size),
143 pool->name,
144 pool->alloc_size,
145 sz - pool->minimal_size);
146 }
147#endif
148
128 alignof = eina_mempool_alignof(sizeof(Chained_Pool)); 149 alignof = eina_mempool_alignof(sizeof(Chained_Pool));
129 ptr = (unsigned char *)p + alignof; 150 ptr = (unsigned char *)p + alignof;
130 p->usage = 0; 151 p->usage = 0;
@@ -444,6 +465,10 @@ eina_chained_mempool_init(const char *context,
444 memcpy((char *)mp->name, context, length); 465 memcpy((char *)mp->name, context, length);
445 } 466 }
446 467
468#ifdef EINA_DEBUG_MALLOC
469 mp->minimal_size = item_size * mp->pool_size + sizeof(Chained_Pool);
470#endif
471
447 mp->item_alloc = eina_mempool_alignof(item_size); 472 mp->item_alloc = eina_mempool_alignof(item_size);
448 mp->group_size = mp->item_alloc * mp->pool_size; 473 mp->group_size = mp->item_alloc * mp->pool_size;
449 mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool)); 474 mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
@@ -517,7 +542,7 @@ static Eina_Mempool_Backend _eina_chained_mp_backend = {
517 542
518Eina_Bool chained_init(void) 543Eina_Bool chained_init(void)
519{ 544{
520#ifdef DEBUG 545#if defined DEBUG || defined EINA_DEBUG_MALLOC
521 _eina_chained_mp_log_dom = eina_log_domain_register("eina_mempool", 546 _eina_chained_mp_log_dom = eina_log_domain_register("eina_mempool",
522 EINA_LOG_COLOR_DEFAULT); 547 EINA_LOG_COLOR_DEFAULT);
523 if (_eina_chained_mp_log_dom < 0) 548 if (_eina_chained_mp_log_dom < 0)
@@ -533,7 +558,7 @@ Eina_Bool chained_init(void)
533void chained_shutdown(void) 558void chained_shutdown(void)
534{ 559{
535 eina_mempool_unregister(&_eina_chained_mp_backend); 560 eina_mempool_unregister(&_eina_chained_mp_backend);
536#ifdef DEBUG 561#if defined DEBUG || defined EINA_DEBUG_MALLOC
537 eina_log_domain_unregister(_eina_chained_mp_log_dom); 562 eina_log_domain_unregister(_eina_chained_mp_log_dom);
538 _eina_chained_mp_log_dom = -1; 563 _eina_chained_mp_log_dom = -1;
539#endif 564#endif
diff --git a/libraries/eina/src/modules/mp/ememoa_fixed/Makefile.in b/libraries/eina/src/modules/mp/ememoa_fixed/Makefile.in
index ec97bb1..ccc4f1a 100644
--- a/libraries/eina/src/modules/mp/ememoa_fixed/Makefile.in
+++ b/libraries/eina/src/modules/mp/ememoa_fixed/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/ememoa_unknown/Makefile.in b/libraries/eina/src/modules/mp/ememoa_unknown/Makefile.in
index b295c64..8b0ec6e 100644
--- a/libraries/eina/src/modules/mp/ememoa_unknown/Makefile.in
+++ b/libraries/eina/src/modules/mp/ememoa_unknown/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/fixed_bitmap/Makefile.in b/libraries/eina/src/modules/mp/fixed_bitmap/Makefile.in
index c1541fc..337f820 100644
--- a/libraries/eina/src/modules/mp/fixed_bitmap/Makefile.in
+++ b/libraries/eina/src/modules/mp/fixed_bitmap/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/one_big/Makefile.in b/libraries/eina/src/modules/mp/one_big/Makefile.in
index e999b78..c8560c9 100644
--- a/libraries/eina/src/modules/mp/one_big/Makefile.in
+++ b/libraries/eina/src/modules/mp/one_big/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/modules/mp/pass_through/Makefile.in b/libraries/eina/src/modules/mp/pass_through/Makefile.in
index 01e7b51..f5664be 100644
--- a/libraries/eina/src/modules/mp/pass_through/Makefile.in
+++ b/libraries/eina/src/modules/mp/pass_through/Makefile.in
@@ -163,7 +163,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@ 163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@ 164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 167EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
168EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 169EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 170EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 171EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -215,8 +217,6 @@ PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@ 217PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@ 218PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@ 219PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@ 220RANLIB = @RANLIB@
221SED = @SED@ 221SED = @SED@
222SET_MAKE = @SET_MAKE@ 222SET_MAKE = @SET_MAKE@
diff --git a/libraries/eina/src/tests/Makefile.am b/libraries/eina/src/tests/Makefile.am
index a413e6e..7e05ba9 100644
--- a/libraries/eina/src/tests/Makefile.am
+++ b/libraries/eina/src/tests/Makefile.am
@@ -28,7 +28,7 @@ endif
28 28
29if EFL_ENABLE_TESTS 29if EFL_ENABLE_TESTS
30 30
31check_PROGRAMS = eina_suite 31check_PROGRAMS = eina_suite cxx_compile_test
32 32
33eina_suite_SOURCES = \ 33eina_suite_SOURCES = \
34eina_suite.c \ 34eina_suite.c \
@@ -38,6 +38,7 @@ eina_test_ustringshare.c\
38eina_test_ustr.c \ 38eina_test_ustr.c \
39eina_test_binshare.c \ 39eina_test_binshare.c \
40eina_test_binbuf.c \ 40eina_test_binbuf.c \
41eina_test_inarray.c \
41eina_test_array.c \ 42eina_test_array.c \
42eina_test_clist.c \ 43eina_test_clist.c \
43eina_test_error.c \ 44eina_test_error.c \
@@ -64,10 +65,14 @@ eina_test_tiler.c \
64eina_test_strbuf.c \ 65eina_test_strbuf.c \
65eina_test_str.c \ 66eina_test_str.c \
66eina_test_quadtree.c \ 67eina_test_quadtree.c \
67eina_test_simple_xml_parser.c 68eina_test_simple_xml_parser.c \
69eina_test_value.c
68 70
69eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la -lm 71eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la -lm
70 72
73cxx_compile_test_SOURCES = cxx_compile_test.cxx
74cxx_compile_test_LDADD = $(top_builddir)/src/lib/libeina.la
75
71module_dummydir = $(libdir)/eina/test 76module_dummydir = $(libdir)/eina/test
72module_dummy_LTLIBRARIES = module_dummy.la 77module_dummy_LTLIBRARIES = module_dummy.la
73 78
diff --git a/libraries/eina/src/tests/Makefile.in b/libraries/eina/src/tests/Makefile.in
index b5983b3..c56211a 100644
--- a/libraries/eina/src/tests/Makefile.in
+++ b/libraries/eina/src/tests/Makefile.in
@@ -37,7 +37,8 @@ build_triplet = @build@
37host_triplet = @host@ 37host_triplet = @host@
38@EINA_HAVE_GLIB_TRUE@am__append_1 = -DEINA_BENCH_HAVE_GLIB 38@EINA_HAVE_GLIB_TRUE@am__append_1 = -DEINA_BENCH_HAVE_GLIB
39@EINA_ENABLE_BENCHMARK_E17_TRUE@am__append_2 = -DEINA_ENABLE_BENCH_E17 39@EINA_ENABLE_BENCHMARK_E17_TRUE@am__append_2 = -DEINA_ENABLE_BENCH_E17
40@EFL_ENABLE_TESTS_TRUE@check_PROGRAMS = eina_suite$(EXEEXT) 40@EFL_ENABLE_TESTS_TRUE@check_PROGRAMS = eina_suite$(EXEEXT) \
41@EFL_ENABLE_TESTS_TRUE@ cxx_compile_test$(EXEEXT)
41@EFL_ENABLE_BENCHMARK_TRUE@bench_PROGRAMS = eina_bench$(EXEEXT) 42@EFL_ENABLE_BENCHMARK_TRUE@bench_PROGRAMS = eina_bench$(EXEEXT)
42subdir = src/tests 43subdir = src/tests
43DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 44DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -107,6 +108,12 @@ module_dummy_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
107@EFL_ENABLE_TESTS_TRUE@am_module_dummy_la_rpath = -rpath \ 108@EFL_ENABLE_TESTS_TRUE@am_module_dummy_la_rpath = -rpath \
108@EFL_ENABLE_TESTS_TRUE@ $(module_dummydir) 109@EFL_ENABLE_TESTS_TRUE@ $(module_dummydir)
109PROGRAMS = $(bench_PROGRAMS) 110PROGRAMS = $(bench_PROGRAMS)
111am__cxx_compile_test_SOURCES_DIST = cxx_compile_test.cxx
112@EFL_ENABLE_TESTS_TRUE@am_cxx_compile_test_OBJECTS = \
113@EFL_ENABLE_TESTS_TRUE@ cxx_compile_test.$(OBJEXT)
114cxx_compile_test_OBJECTS = $(am_cxx_compile_test_OBJECTS)
115@EFL_ENABLE_TESTS_TRUE@cxx_compile_test_DEPENDENCIES = \
116@EFL_ENABLE_TESTS_TRUE@ $(top_builddir)/src/lib/libeina.la
110am__eina_bench_SOURCES_DIST = eina_bench.c eina_bench_sort.c \ 117am__eina_bench_SOURCES_DIST = eina_bench.c eina_bench_sort.c \
111 eina_bench_hash.c eina_bench_stringshare.c \ 118 eina_bench_hash.c eina_bench_stringshare.c \
112 eina_bench_convert.c eina_bench_mempool.c \ 119 eina_bench_convert.c eina_bench_mempool.c \
@@ -142,16 +149,17 @@ eina_bench_OBJECTS = $(am_eina_bench_OBJECTS)
142am__eina_suite_SOURCES_DIST = eina_suite.c eina_test_fp.c \ 149am__eina_suite_SOURCES_DIST = eina_suite.c eina_test_fp.c \
143 eina_test_stringshare.c eina_test_ustringshare.c \ 150 eina_test_stringshare.c eina_test_ustringshare.c \
144 eina_test_ustr.c eina_test_binshare.c eina_test_binbuf.c \ 151 eina_test_ustr.c eina_test_binshare.c eina_test_binbuf.c \
145 eina_test_array.c eina_test_clist.c eina_test_error.c \ 152 eina_test_inarray.c eina_test_array.c eina_test_clist.c \
146 eina_test_sched.c eina_test_log.c eina_test_magic.c \ 153 eina_test_error.c eina_test_sched.c eina_test_log.c \
147 eina_test_inlist.c eina_test_main.c eina_test_counter.c \ 154 eina_test_magic.c eina_test_inlist.c eina_test_main.c \
148 eina_test_lalloc.c eina_test_hash.c eina_test_iterator.c \ 155 eina_test_counter.c eina_test_lalloc.c eina_test_hash.c \
149 eina_test_accessor.c eina_test_module.c eina_test_convert.c \ 156 eina_test_iterator.c eina_test_accessor.c eina_test_module.c \
150 eina_test_rbtree.c eina_test_file.c eina_test_benchmark.c \ 157 eina_test_convert.c eina_test_rbtree.c eina_test_file.c \
151 eina_test_mempool.c eina_test_rectangle.c eina_test_list.c \ 158 eina_test_benchmark.c eina_test_mempool.c \
159 eina_test_rectangle.c eina_test_list.c \
152 eina_test_matrixsparse.c eina_test_tiler.c eina_test_strbuf.c \ 160 eina_test_matrixsparse.c eina_test_tiler.c eina_test_strbuf.c \
153 eina_test_str.c eina_test_quadtree.c \ 161 eina_test_str.c eina_test_quadtree.c \
154 eina_test_simple_xml_parser.c 162 eina_test_simple_xml_parser.c eina_test_value.c
155@EFL_ENABLE_TESTS_TRUE@am_eina_suite_OBJECTS = eina_suite.$(OBJEXT) \ 163@EFL_ENABLE_TESTS_TRUE@am_eina_suite_OBJECTS = eina_suite.$(OBJEXT) \
156@EFL_ENABLE_TESTS_TRUE@ eina_test_fp.$(OBJEXT) \ 164@EFL_ENABLE_TESTS_TRUE@ eina_test_fp.$(OBJEXT) \
157@EFL_ENABLE_TESTS_TRUE@ eina_test_stringshare.$(OBJEXT) \ 165@EFL_ENABLE_TESTS_TRUE@ eina_test_stringshare.$(OBJEXT) \
@@ -159,6 +167,7 @@ am__eina_suite_SOURCES_DIST = eina_suite.c eina_test_fp.c \
159@EFL_ENABLE_TESTS_TRUE@ eina_test_ustr.$(OBJEXT) \ 167@EFL_ENABLE_TESTS_TRUE@ eina_test_ustr.$(OBJEXT) \
160@EFL_ENABLE_TESTS_TRUE@ eina_test_binshare.$(OBJEXT) \ 168@EFL_ENABLE_TESTS_TRUE@ eina_test_binshare.$(OBJEXT) \
161@EFL_ENABLE_TESTS_TRUE@ eina_test_binbuf.$(OBJEXT) \ 169@EFL_ENABLE_TESTS_TRUE@ eina_test_binbuf.$(OBJEXT) \
170@EFL_ENABLE_TESTS_TRUE@ eina_test_inarray.$(OBJEXT) \
162@EFL_ENABLE_TESTS_TRUE@ eina_test_array.$(OBJEXT) \ 171@EFL_ENABLE_TESTS_TRUE@ eina_test_array.$(OBJEXT) \
163@EFL_ENABLE_TESTS_TRUE@ eina_test_clist.$(OBJEXT) \ 172@EFL_ENABLE_TESTS_TRUE@ eina_test_clist.$(OBJEXT) \
164@EFL_ENABLE_TESTS_TRUE@ eina_test_error.$(OBJEXT) \ 173@EFL_ENABLE_TESTS_TRUE@ eina_test_error.$(OBJEXT) \
@@ -185,7 +194,8 @@ am__eina_suite_SOURCES_DIST = eina_suite.c eina_test_fp.c \
185@EFL_ENABLE_TESTS_TRUE@ eina_test_strbuf.$(OBJEXT) \ 194@EFL_ENABLE_TESTS_TRUE@ eina_test_strbuf.$(OBJEXT) \
186@EFL_ENABLE_TESTS_TRUE@ eina_test_str.$(OBJEXT) \ 195@EFL_ENABLE_TESTS_TRUE@ eina_test_str.$(OBJEXT) \
187@EFL_ENABLE_TESTS_TRUE@ eina_test_quadtree.$(OBJEXT) \ 196@EFL_ENABLE_TESTS_TRUE@ eina_test_quadtree.$(OBJEXT) \
188@EFL_ENABLE_TESTS_TRUE@ eina_test_simple_xml_parser.$(OBJEXT) 197@EFL_ENABLE_TESTS_TRUE@ eina_test_simple_xml_parser.$(OBJEXT) \
198@EFL_ENABLE_TESTS_TRUE@ eina_test_value.$(OBJEXT)
189eina_suite_OBJECTS = $(am_eina_suite_OBJECTS) 199eina_suite_OBJECTS = $(am_eina_suite_OBJECTS)
190@EFL_ENABLE_TESTS_TRUE@eina_suite_DEPENDENCIES = \ 200@EFL_ENABLE_TESTS_TRUE@eina_suite_DEPENDENCIES = \
191@EFL_ENABLE_TESTS_TRUE@ $(top_builddir)/src/lib/libeina.la 201@EFL_ENABLE_TESTS_TRUE@ $(top_builddir)/src/lib/libeina.la
@@ -232,10 +242,11 @@ AM_V_GEN = $(am__v_GEN_$(V))
232am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) 242am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
233am__v_GEN_0 = @echo " GEN " $@; 243am__v_GEN_0 = @echo " GEN " $@;
234SOURCES = $(libcity_la_SOURCES) $(module_dummy_la_SOURCES) \ 244SOURCES = $(libcity_la_SOURCES) $(module_dummy_la_SOURCES) \
235 $(eina_bench_SOURCES) $(nodist_EXTRA_eina_bench_SOURCES) \ 245 $(cxx_compile_test_SOURCES) $(eina_bench_SOURCES) \
236 $(eina_suite_SOURCES) 246 $(nodist_EXTRA_eina_bench_SOURCES) $(eina_suite_SOURCES)
237DIST_SOURCES = $(am__libcity_la_SOURCES_DIST) \ 247DIST_SOURCES = $(am__libcity_la_SOURCES_DIST) \
238 $(am__module_dummy_la_SOURCES_DIST) \ 248 $(am__module_dummy_la_SOURCES_DIST) \
249 $(am__cxx_compile_test_SOURCES_DIST) \
239 $(am__eina_bench_SOURCES_DIST) $(am__eina_suite_SOURCES_DIST) 250 $(am__eina_bench_SOURCES_DIST) $(am__eina_suite_SOURCES_DIST)
240ETAGS = etags 251ETAGS = etags
241CTAGS = ctags 252CTAGS = ctags
@@ -282,7 +293,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
282EGREP = @EGREP@ 293EGREP = @EGREP@
283EINA_CFLAGS = @EINA_CFLAGS@ 294EINA_CFLAGS = @EINA_CFLAGS@
284EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ 295EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
296EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
285EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 297EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
298EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
286EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 299EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
287EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 300EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
288EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 301EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
@@ -334,8 +347,6 @@ PACKAGE_URL = @PACKAGE_URL@
334PACKAGE_VERSION = @PACKAGE_VERSION@ 347PACKAGE_VERSION = @PACKAGE_VERSION@
335PATH_SEPARATOR = @PATH_SEPARATOR@ 348PATH_SEPARATOR = @PATH_SEPARATOR@
336PKG_CONFIG = @PKG_CONFIG@ 349PKG_CONFIG = @PKG_CONFIG@
337PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
338PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
339RANLIB = @RANLIB@ 350RANLIB = @RANLIB@
340SED = @SED@ 351SED = @SED@
341SET_MAKE = @SET_MAKE@ 352SET_MAKE = @SET_MAKE@
@@ -426,6 +437,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/include \
426@EFL_ENABLE_TESTS_TRUE@eina_test_ustr.c \ 437@EFL_ENABLE_TESTS_TRUE@eina_test_ustr.c \
427@EFL_ENABLE_TESTS_TRUE@eina_test_binshare.c \ 438@EFL_ENABLE_TESTS_TRUE@eina_test_binshare.c \
428@EFL_ENABLE_TESTS_TRUE@eina_test_binbuf.c \ 439@EFL_ENABLE_TESTS_TRUE@eina_test_binbuf.c \
440@EFL_ENABLE_TESTS_TRUE@eina_test_inarray.c \
429@EFL_ENABLE_TESTS_TRUE@eina_test_array.c \ 441@EFL_ENABLE_TESTS_TRUE@eina_test_array.c \
430@EFL_ENABLE_TESTS_TRUE@eina_test_clist.c \ 442@EFL_ENABLE_TESTS_TRUE@eina_test_clist.c \
431@EFL_ENABLE_TESTS_TRUE@eina_test_error.c \ 443@EFL_ENABLE_TESTS_TRUE@eina_test_error.c \
@@ -452,9 +464,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/include \
452@EFL_ENABLE_TESTS_TRUE@eina_test_strbuf.c \ 464@EFL_ENABLE_TESTS_TRUE@eina_test_strbuf.c \
453@EFL_ENABLE_TESTS_TRUE@eina_test_str.c \ 465@EFL_ENABLE_TESTS_TRUE@eina_test_str.c \
454@EFL_ENABLE_TESTS_TRUE@eina_test_quadtree.c \ 466@EFL_ENABLE_TESTS_TRUE@eina_test_quadtree.c \
455@EFL_ENABLE_TESTS_TRUE@eina_test_simple_xml_parser.c 467@EFL_ENABLE_TESTS_TRUE@eina_test_simple_xml_parser.c \
468@EFL_ENABLE_TESTS_TRUE@eina_test_value.c
456 469
457@EFL_ENABLE_TESTS_TRUE@eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la -lm 470@EFL_ENABLE_TESTS_TRUE@eina_suite_LDADD = @CHECK_LIBS@ $(top_builddir)/src/lib/libeina.la -lm
471@EFL_ENABLE_TESTS_TRUE@cxx_compile_test_SOURCES = cxx_compile_test.cxx
472@EFL_ENABLE_TESTS_TRUE@cxx_compile_test_LDADD = $(top_builddir)/src/lib/libeina.la
458@EFL_ENABLE_TESTS_TRUE@module_dummydir = $(libdir)/eina/test 473@EFL_ENABLE_TESTS_TRUE@module_dummydir = $(libdir)/eina/test
459@EFL_ENABLE_TESTS_TRUE@module_dummy_LTLIBRARIES = module_dummy.la 474@EFL_ENABLE_TESTS_TRUE@module_dummy_LTLIBRARIES = module_dummy.la
460@EFL_ENABLE_TESTS_TRUE@module_dummy_la_SOURCES = \ 475@EFL_ENABLE_TESTS_TRUE@module_dummy_la_SOURCES = \
@@ -506,7 +521,7 @@ EXTRA_DIST = eina_bench.h \
506all: all-am 521all: all-am
507 522
508.SUFFIXES: 523.SUFFIXES:
509.SUFFIXES: .c .cc .lo .o .obj 524.SUFFIXES: .c .cc .cxx .lo .o .obj
510$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 525$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
511 @for dep in $?; do \ 526 @for dep in $?; do \
512 case '$(am__configure_deps)' in \ 527 case '$(am__configure_deps)' in \
@@ -633,6 +648,9 @@ clean-checkPROGRAMS:
633 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ 648 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
634 echo " rm -f" $$list; \ 649 echo " rm -f" $$list; \
635 rm -f $$list 650 rm -f $$list
651cxx_compile_test$(EXEEXT): $(cxx_compile_test_OBJECTS) $(cxx_compile_test_DEPENDENCIES)
652 @rm -f cxx_compile_test$(EXEEXT)
653 $(AM_V_CXXLD)$(CXXLINK) $(cxx_compile_test_OBJECTS) $(cxx_compile_test_LDADD) $(LIBS)
636eina_bench$(EXEEXT): $(eina_bench_OBJECTS) $(eina_bench_DEPENDENCIES) 654eina_bench$(EXEEXT): $(eina_bench_OBJECTS) $(eina_bench_DEPENDENCIES)
637 @rm -f eina_bench$(EXEEXT) 655 @rm -f eina_bench$(EXEEXT)
638 $(AM_V_CXXLD)$(CXXLINK) $(eina_bench_OBJECTS) $(eina_bench_LDADD) $(LIBS) 656 $(AM_V_CXXLD)$(CXXLINK) $(eina_bench_OBJECTS) $(eina_bench_LDADD) $(LIBS)
@@ -647,6 +665,7 @@ distclean-compile:
647 -rm -f *.tab.c 665 -rm -f *.tab.c
648 666
649@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/city.Plo@am__quote@ 667@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/city.Plo@am__quote@
668@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cxx_compile_test.Po@am__quote@
650@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@ 669@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@
651@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_hash.Po@am__quote@ 670@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_hash.Po@am__quote@
652@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_list.Po@am__quote@ 671@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_list.Po@am__quote@
@@ -675,6 +694,7 @@ distclean-compile:
675@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_file.Po@am__quote@ 694@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_file.Po@am__quote@
676@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_fp.Po@am__quote@ 695@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_fp.Po@am__quote@
677@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_hash.Po@am__quote@ 696@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_hash.Po@am__quote@
697@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_inarray.Po@am__quote@
678@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_inlist.Po@am__quote@ 698@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_inlist.Po@am__quote@
679@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_iterator.Po@am__quote@ 699@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_iterator.Po@am__quote@
680@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_lalloc.Po@am__quote@ 700@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_lalloc.Po@am__quote@
@@ -696,6 +716,7 @@ distclean-compile:
696@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_tiler.Po@am__quote@ 716@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_tiler.Po@am__quote@
697@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_ustr.Po@am__quote@ 717@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_ustr.Po@am__quote@
698@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_ustringshare.Po@am__quote@ 718@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_ustringshare.Po@am__quote@
719@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eina_test_value.Po@am__quote@
699@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_hash.Po@am__quote@ 720@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_hash.Po@am__quote@
700@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_list.Po@am__quote@ 721@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_list.Po@am__quote@
701@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_mempool.Po@am__quote@ 722@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_mempool.Po@am__quote@
@@ -759,6 +780,30 @@ module_dummy_la-eina_test_module_dummy.lo: eina_test_module_dummy.c
759@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 780@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
760@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< 781@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
761 782
783.cxx.o:
784@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
785@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
786@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
787@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
788@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
789@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
790
791.cxx.obj:
792@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
793@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
794@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
795@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
796@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
797@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
798
799.cxx.lo:
800@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
801@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
802@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
803@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
804@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
805@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
806
762mostlyclean-libtool: 807mostlyclean-libtool:
763 -rm -f *.lo 808 -rm -f *.lo
764 809
diff --git a/libraries/eina/src/tests/cxx_compile_test.cxx b/libraries/eina/src/tests/cxx_compile_test.cxx
new file mode 100644
index 0000000..7d8af76
--- /dev/null
+++ b/libraries/eina/src/tests/cxx_compile_test.cxx
@@ -0,0 +1,34 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include "Eina.h"
24
25#include <iostream>
26using namespace std;
27
28int main()
29{
30 eina_init();
31 cout << "Eina compiles with C++!";
32 eina_shutdown();
33 return 0;
34}
diff --git a/libraries/eina/src/tests/eina_bench.c b/libraries/eina/src/tests/eina_bench.c
index a4eadbe..03aaaf9 100644
--- a/libraries/eina/src/tests/eina_bench.c
+++ b/libraries/eina/src/tests/eina_bench.c
@@ -73,7 +73,6 @@ int
73main(int argc, char **argv) 73main(int argc, char **argv)
74{ 74{
75 Eina_Benchmark *test; 75 Eina_Benchmark *test;
76 Eina_Array *ea;
77 unsigned int i; 76 unsigned int i;
78 77
79 if (argc != 2) 78 if (argc != 2)
@@ -91,7 +90,7 @@ main(int argc, char **argv)
91 90
92 etc[i].build(test); 91 etc[i].build(test);
93 92
94 ea = eina_benchmark_run(test); 93 eina_benchmark_run(test);
95 94
96 eina_benchmark_free(test); 95 eina_benchmark_free(test);
97 } 96 }
diff --git a/libraries/eina/src/tests/eina_bench_hash.c b/libraries/eina/src/tests/eina_bench_hash.c
index 5b42318..0429097 100644
--- a/libraries/eina/src/tests/eina_bench_hash.c
+++ b/libraries/eina/src/tests/eina_bench_hash.c
@@ -139,6 +139,8 @@ eina_bench_lookup_rbtree(int request)
139 EINA_RBTREE_CMP_KEY_CB( 139 EINA_RBTREE_CMP_KEY_CB(
140 _eina_bench_rbtree_key), 140 _eina_bench_rbtree_key),
141 NULL); 141 NULL);
142 /* Suppress warnings as we really don't want to do anything. */
143 (void) tmp;
142 } 144 }
143 145
144 eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL); 146 eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL);
diff --git a/libraries/eina/src/tests/eina_bench_quad.c b/libraries/eina/src/tests/eina_bench_quad.c
index 76d6667..8401fd4 100644
--- a/libraries/eina/src/tests/eina_bench_quad.c
+++ b/libraries/eina/src/tests/eina_bench_quad.c
@@ -19,6 +19,8 @@
19#define WIDTH 720 19#define WIDTH 720
20#define HEIGHT 576 20#define HEIGHT 576
21 21
22#include <stdlib.h>
23
22#include "eina_main.h" 24#include "eina_main.h"
23#include "eina_mempool.h" 25#include "eina_mempool.h"
24#include "eina_rectangle.h" 26#include "eina_rectangle.h"
diff --git a/libraries/eina/src/tests/eina_bench_stringshare.c b/libraries/eina/src/tests/eina_bench_stringshare.c
index a2c7b38..22d18fa 100644
--- a/libraries/eina/src/tests/eina_bench_stringshare.c
+++ b/libraries/eina/src/tests/eina_bench_stringshare.c
@@ -64,6 +64,8 @@ eina_bench_stringshare_job(int request)
64 tmp = eina_stringshare_add(build); 64 tmp = eina_stringshare_add(build);
65 } 65 }
66 66
67 /* Suppress warnings as we really don't want to do anything. */
68 (void) tmp;
67 eina_shutdown(); 69 eina_shutdown();
68} 70}
69 71
@@ -125,6 +127,9 @@ eina_bench_evas_job(int request)
125 eina_convert_xtoa(rand() % request, build + 7); 127 eina_convert_xtoa(rand() % request, build + 7);
126 tmp = evas_stringshare_add(build); 128 tmp = evas_stringshare_add(build);
127 } 129 }
130
131 /* Suppress warnings as we really don't want to do anything. */
132 (void) tmp;
128} 133}
129 134
130static void 135static void
@@ -155,6 +160,9 @@ eina_bench_ecore_job(int request)
155 tmp = ecore_string_instance(build); 160 tmp = ecore_string_instance(build);
156 } 161 }
157 162
163 /* Suppress warnings as we really don't want to do anything. */
164 (void) tmp;
165
158 ecore_string_shutdown(); 166 ecore_string_shutdown();
159} 167}
160 168
diff --git a/libraries/eina/src/tests/eina_suite.c b/libraries/eina/src/tests/eina_suite.c
index 9b748fc..648a717 100644
--- a/libraries/eina/src/tests/eina_suite.c
+++ b/libraries/eina/src/tests/eina_suite.c
@@ -34,6 +34,7 @@ struct _Eina_Test_Case
34 34
35static const Eina_Test_Case etc[] = { 35static const Eina_Test_Case etc[] = {
36 { "FixedPoint", eina_test_fp }, 36 { "FixedPoint", eina_test_fp },
37 { "Inarray", eina_test_inarray },
37 { "Array", eina_test_array }, 38 { "Array", eina_test_array },
38 { "Binary Share", eina_test_binshare }, 39 { "Binary Share", eina_test_binshare },
39 { "String Share", eina_test_stringshare }, 40 { "String Share", eina_test_stringshare },
@@ -66,6 +67,7 @@ static const Eina_Test_Case etc[] = {
66 { "QuadTree", eina_test_quadtree }, 67 { "QuadTree", eina_test_quadtree },
67 { "Sched", eina_test_sched }, 68 { "Sched", eina_test_sched },
68 { "Simple Xml Parser", eina_test_simple_xml_parser}, 69 { "Simple Xml Parser", eina_test_simple_xml_parser},
70 { "Value", eina_test_value },
69 { NULL, NULL } 71 { NULL, NULL }
70}; 72};
71 73
diff --git a/libraries/eina/src/tests/eina_suite.h b/libraries/eina/src/tests/eina_suite.h
index 643d6cc..6eaaec7 100644
--- a/libraries/eina/src/tests/eina_suite.h
+++ b/libraries/eina/src/tests/eina_suite.h
@@ -24,6 +24,7 @@
24void eina_test_stringshare(TCase *tc); 24void eina_test_stringshare(TCase *tc);
25void eina_test_ustringshare(TCase *tc); 25void eina_test_ustringshare(TCase *tc);
26void eina_test_binshare(TCase *tc); 26void eina_test_binshare(TCase *tc);
27void eina_test_inarray(TCase *tc);
27void eina_test_array(TCase *tc); 28void eina_test_array(TCase *tc);
28void eina_test_log(TCase *tc); 29void eina_test_log(TCase *tc);
29void eina_test_error(TCase *tc); 30void eina_test_error(TCase *tc);
@@ -54,5 +55,6 @@ void eina_test_quadtree(TCase *tc);
54void eina_test_fp(TCase *tc); 55void eina_test_fp(TCase *tc);
55void eina_test_sched(TCase *tc); 56void eina_test_sched(TCase *tc);
56void eina_test_simple_xml_parser(TCase *tc); 57void eina_test_simple_xml_parser(TCase *tc);
58void eina_test_value(TCase *tc);
57 59
58#endif /* EINA_SUITE_H_ */ 60#endif /* EINA_SUITE_H_ */
diff --git a/libraries/eina/src/tests/eina_test_array.c b/libraries/eina/src/tests/eina_test_array.c
index 0b054ea..1929601 100644
--- a/libraries/eina/src/tests/eina_test_array.c
+++ b/libraries/eina/src/tests/eina_test_array.c
@@ -151,7 +151,7 @@ START_TEST(eina_array_remove_stuff)
151 } 151 }
152 fail_if(eina_array_remove(ea, keep_int, NULL) != EINA_TRUE); 152 fail_if(eina_array_remove(ea, keep_int, NULL) != EINA_TRUE);
153 153
154 fail_if(eina_array_count_get(ea) != 990); 154 fail_if(eina_array_count(ea) != 990);
155 EINA_ARRAY_ITER_NEXT(ea, i, tmp, it) 155 EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
156 fail_if(*tmp == 0); 156 fail_if(*tmp == 0);
157 157
@@ -165,7 +165,7 @@ START_TEST(eina_array_remove_stuff)
165 eina_array_remove(ea, keep_int, NULL); 165 eina_array_remove(ea, keep_int, NULL);
166 166
167 // Remove all items 167 // Remove all items
168 fail_if(eina_array_count_get(ea) != 980); 168 fail_if(eina_array_count(ea) != 980);
169 EINA_ARRAY_ITER_NEXT(ea, i, tmp, it) 169 EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
170 { 170 {
171 fail_if(*tmp == 0); 171 fail_if(*tmp == 0);
@@ -174,7 +174,7 @@ START_TEST(eina_array_remove_stuff)
174 174
175 eina_array_remove(ea, keep_int, NULL); 175 eina_array_remove(ea, keep_int, NULL);
176 176
177 fail_if(eina_array_count_get(ea) != 0); 177 fail_if(eina_array_count(ea) != 0);
178 178
179 eina_array_free(ea); 179 eina_array_free(ea);
180 180
diff --git a/libraries/eina/src/tests/eina_test_binbuf.c b/libraries/eina/src/tests/eina_test_binbuf.c
index 713e078..d62072e 100644
--- a/libraries/eina/src/tests/eina_test_binbuf.c
+++ b/libraries/eina/src/tests/eina_test_binbuf.c
@@ -27,8 +27,8 @@
27START_TEST(binbuf_simple) 27START_TEST(binbuf_simple)
28{ 28{
29 Eina_Binbuf *buf; 29 Eina_Binbuf *buf;
30 char *txt; 30 unsigned char *txt;
31 const char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here."; 31 const unsigned char cbuf[] = "Null in the middle \0 and more text afterwards and \0 anotehr null just there and another one \0 here.";
32 size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ 32 size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */
33 33
34 34
@@ -69,7 +69,7 @@ END_TEST
69START_TEST(binbuf_remove) 69START_TEST(binbuf_remove)
70{ 70{
71 Eina_Binbuf *buf; 71 Eina_Binbuf *buf;
72 const char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!"; 72 const unsigned char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!";
73 size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */ 73 size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */
74 74
75 eina_init(); 75 eina_init();
@@ -98,6 +98,33 @@ START_TEST(binbuf_remove)
98} 98}
99END_TEST 99END_TEST
100 100
101START_TEST(binbuf_manage_simple)
102{
103 Eina_Binbuf *buf;
104 const char *_cbuf = "12\0 456 78\0 abcthis is some more random junk here!";
105 const unsigned char *cbuf = (const unsigned char *) _cbuf;
106 size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */
107 unsigned char *alloc_buf = malloc(size);
108 memcpy(alloc_buf, cbuf, size);
109
110 eina_init();
111
112 buf = eina_binbuf_manage_new_length(alloc_buf, size);
113 fail_if(!buf);
114
115 fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size));
116 fail_if(size != eina_binbuf_length_get(buf));
117 eina_binbuf_append_length(buf, cbuf, size);
118 fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size));
119 fail_if(memcmp(eina_binbuf_string_get(buf) + size, cbuf, size));
120 fail_if(2 * size != eina_binbuf_length_get(buf));
121
122 eina_binbuf_free(buf);
123
124 eina_shutdown();
125}
126END_TEST
127
101START_TEST(binbuf_insert) 128START_TEST(binbuf_insert)
102{ 129{
103#if 0 130#if 0
@@ -154,7 +181,7 @@ END_TEST
154START_TEST(binbuf_realloc) 181START_TEST(binbuf_realloc)
155{ 182{
156 Eina_Binbuf *buf; 183 Eina_Binbuf *buf;
157 char pattern[1024 * 16]; 184 unsigned char pattern[1024 * 16];
158 unsigned int i; 185 unsigned int i;
159 size_t sz; 186 size_t sz;
160 187
@@ -232,4 +259,5 @@ eina_test_binbuf(TCase *tc)
232 tcase_add_test(tc, binbuf_remove); 259 tcase_add_test(tc, binbuf_remove);
233 tcase_add_test(tc, binbuf_insert); 260 tcase_add_test(tc, binbuf_insert);
234 tcase_add_test(tc, binbuf_realloc); 261 tcase_add_test(tc, binbuf_realloc);
262 tcase_add_test(tc, binbuf_manage_simple);
235} 263}
diff --git a/libraries/eina/src/tests/eina_test_file.c b/libraries/eina/src/tests/eina_test_file.c
index aeb5461..55e9976 100644
--- a/libraries/eina/src/tests/eina_test_file.c
+++ b/libraries/eina/src/tests/eina_test_file.c
@@ -48,7 +48,7 @@ START_TEST(eina_file_split_simple)
48#endif 48#endif
49 49
50 fail_if(!ea); 50 fail_if(!ea);
51 fail_if(eina_array_count_get(ea) != 5); 51 fail_if(eina_array_count(ea) != 5);
52 fail_if(strcmp(eina_array_data_get(ea, 0), "this")); 52 fail_if(strcmp(eina_array_data_get(ea, 0), "this"));
53 fail_if(strcmp(eina_array_data_get(ea, 1), "is")); 53 fail_if(strcmp(eina_array_data_get(ea, 1), "is"));
54 fail_if(strcmp(eina_array_data_get(ea, 2), "a")); 54 fail_if(strcmp(eina_array_data_get(ea, 2), "a"));
@@ -66,7 +66,7 @@ START_TEST(eina_file_split_simple)
66#endif 66#endif
67 67
68 fail_if(!ea); 68 fail_if(!ea);
69 fail_if(eina_array_count_get(ea) != 6); 69 fail_if(eina_array_count(ea) != 6);
70 fail_if(strcmp(eina_array_data_get(ea, 0), "this")); 70 fail_if(strcmp(eina_array_data_get(ea, 0), "this"));
71 fail_if(strcmp(eina_array_data_get(ea, 1), "is")); 71 fail_if(strcmp(eina_array_data_get(ea, 1), "is"));
72 fail_if(strcmp(eina_array_data_get(ea, 2), "a ")); 72 fail_if(strcmp(eina_array_data_get(ea, 2), "a "));
diff --git a/libraries/eina/src/tests/eina_test_inarray.c b/libraries/eina/src/tests/eina_test_inarray.c
new file mode 100644
index 0000000..22ba763
--- /dev/null
+++ b/libraries/eina/src/tests/eina_test_inarray.c
@@ -0,0 +1,401 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdio.h>
24
25#include "eina_suite.h"
26#include "Eina.h"
27
28START_TEST(eina_inarray_test_simple)
29{
30 const int test_members = 5;
31 Eina_Inarray *array;
32 int i, pos, *member;
33 const struct spec {
34 int pos, value;
35 } *s, specs[] = {
36 {test_members, 1234},
37 {5, 0x1337},
38 {0, 0xbeef},
39 {-1, -1}
40 };
41
42 eina_init();
43
44 array = eina_inarray_new(sizeof(int), 2);
45 fail_unless(array != NULL);
46
47 for (i = 0; i < test_members; i++)
48 {
49 pos = eina_inarray_append(array, &i);
50 fail_unless(pos == i);
51 }
52 fail_unless(eina_inarray_count(array) == (unsigned)test_members);
53
54 for (i = 0; i < test_members; i++)
55 {
56 member = eina_inarray_nth(array, i);
57 fail_unless(*member == i);
58 }
59
60 for (s = specs; s->pos >= 0; s++)
61 {
62 fail_unless(eina_inarray_insert_at(array, s->pos, &s->value));
63
64 for (i = 0; i < s->pos; i++)
65 {
66 member = eina_inarray_nth(array, i);
67 fail_unless(*member == i);
68 }
69 member = eina_inarray_nth(array, s->pos);
70 fail_unless(*member == s->value);
71 for (i = s->pos + 1; i < test_members + 1; i++)
72 {
73 member = eina_inarray_nth(array, i);
74 fail_unless(*member == i - 1);
75 }
76
77 fail_unless(eina_inarray_remove_at(array, s->pos));
78 for (i = 0; i < test_members; i++)
79 {
80 member = eina_inarray_nth(array, i);
81 fail_unless(*member == i);
82 }
83 }
84
85 eina_inarray_free(array);
86 eina_shutdown();
87}
88END_TEST
89
90
91START_TEST(eina_inarray_test_alloc_at)
92{
93 Eina_Inarray *array;
94 int *member;
95 int i;
96
97 eina_init();
98
99 array = eina_inarray_new(sizeof(int), 2);
100 fail_unless(array != NULL);
101
102 member = eina_inarray_alloc_at(array, 0, 4);
103 fail_unless(member != NULL);
104 fail_unless(eina_inarray_count(array) == 4);
105
106 for (i = 0; i < 4; i++)
107 member[i] = i + 2;
108
109 member = eina_inarray_alloc_at(array, 0, 2);
110 fail_unless(member != NULL);
111 fail_unless(eina_inarray_count(array) == 6);
112 for (i = 0; i < 2; i++)
113 member[i] = i;
114
115 member = eina_inarray_alloc_at(array, 6, 2);
116 fail_unless(member != NULL);
117 fail_unless(eina_inarray_count(array) == 8);
118 for (i = 0; i < 2; i++)
119 member[i] = i + 6;
120
121 member = array->members;
122 for (i = 0; i < 8; i++)
123 fail_unless(member[i] == i);
124
125 eina_inarray_free(array);
126 eina_shutdown();
127}
128END_TEST
129
130static const short rand_numbers[] = {
131 9, 0, 2, 3, 6, 5, 4, 7, 8, 1, 10
132};
133static const int numbers_count = sizeof(rand_numbers)/sizeof(rand_numbers[0]);
134
135static void
136show_sort_array(const Eina_Inarray *array)
137{
138 int i, len = eina_inarray_count(array);
139 printf("array with %d members:\n", len);
140 for (i = 0; i < len; i++)
141 {
142 short *member = eina_inarray_nth(array, i);
143 printf("\tarray[%2d]=%5hd\n", i, *member);
144 }
145}
146
147static Eina_Bool
148check_short_sorted(const Eina_Inarray *array)
149{
150 int i;
151 for (i = 0; i < numbers_count; i++)
152 {
153 short *member = eina_inarray_nth(array, i);
154 if (*member != (short)i)
155 {
156 show_sort_array(array);
157 fprintf(stderr, "not sorted at %d: %hd\n", i, *member);
158 return EINA_FALSE;
159 }
160 }
161 return EINA_TRUE;
162}
163
164static int
165short_cmp(const void *pa, const void *pb)
166{
167 const short *a = pa, *b = pb;
168 return *a - *b;
169}
170
171START_TEST(eina_inarray_test_insert_sort)
172{
173 Eina_Inarray *array;
174 int i, pos;
175
176 eina_init();
177
178 array = eina_inarray_new(sizeof(short), 1);
179 fail_unless(array != NULL);
180
181 /* insert sorted and already sorted sequence */
182 for (i = 0; i < numbers_count; i++)
183 {
184 short val = i;
185 pos = eina_inarray_insert(array, &val, short_cmp);
186 fail_unless(pos == (int)val);
187 }
188 fail_unless(check_short_sorted(array));
189 eina_inarray_flush(array);
190
191 for (i = 0; i < numbers_count; i++)
192 {
193 short val = i;
194 pos = eina_inarray_insert_sorted(array, &val, short_cmp);
195 fail_unless(pos == (int)val);
196 }
197 fail_unless(check_short_sorted(array));
198 eina_inarray_flush(array);
199
200 /* insert sorted the reverse sequence */
201 for (i = 0; i < numbers_count; i++)
202 {
203 short val = numbers_count - i - 1;
204 pos = eina_inarray_insert(array, &val, short_cmp);
205 fail_unless(pos == 0);
206 }
207 fail_unless(check_short_sorted(array));
208 eina_inarray_flush(array);
209
210 for (i = 0; i < numbers_count; i++)
211 {
212 short val = numbers_count - i - 1;
213 pos = eina_inarray_insert_sorted(array, &val, short_cmp);
214 fail_unless(pos == 0);
215 }
216 fail_unless(check_short_sorted(array));
217 eina_inarray_flush(array);
218
219 /* insert sorted random numbers */
220 for (i = 0; i < numbers_count; i++)
221 {
222 short val = rand_numbers[i];
223 eina_inarray_insert(array, &val, short_cmp);
224 }
225 fail_unless(check_short_sorted(array));
226 eina_inarray_flush(array);
227
228 for (i = 0; i < numbers_count; i++)
229 {
230 short val = rand_numbers[i];
231 eina_inarray_insert_sorted(array, &val, short_cmp);
232 }
233 fail_unless(check_short_sorted(array));
234 eina_inarray_flush(array);
235
236 eina_inarray_free(array);
237 eina_shutdown();
238}
239END_TEST
240
241START_TEST(eina_inarray_test_sort)
242{
243 Eina_Inarray *array;
244 int i;
245
246 eina_init();
247
248 array = eina_inarray_new(sizeof(short), 1);
249 fail_unless(array != NULL);
250
251 for (i = 0; i < numbers_count; i++)
252 {
253 short val = rand_numbers[i];
254 eina_inarray_append(array, &val);
255 }
256 eina_inarray_sort(array, short_cmp);
257 fail_unless(check_short_sorted(array));
258 eina_inarray_free(array);
259 eina_shutdown();
260}
261END_TEST
262
263START_TEST(eina_inarray_test_reverse)
264{
265 Eina_Inarray *array;
266 int i;
267
268 eina_init();
269
270 array = eina_inarray_new(sizeof(short), 1);
271 fail_unless(array != NULL);
272
273 for (i = 0; i < numbers_count; i++)
274 {
275 short val = i;
276 eina_inarray_append(array, &val);
277 }
278 eina_inarray_reverse(array);
279
280 for (i = 0; i < numbers_count; i++)
281 {
282 short *member = eina_inarray_nth(array, i);
283 fail_unless(*member == (numbers_count - i - 1));
284 }
285
286 eina_inarray_free(array);
287 eina_shutdown();
288}
289END_TEST
290
291static Eina_Bool
292array_foreach(const void *array __UNUSED__, void *p, void *user_data __UNUSED__)
293{
294 short *member = p;
295 int *i = user_data;
296 fail_unless(*i == *member);
297 (*i)++;
298 return EINA_TRUE;
299}
300
301static Eina_Bool
302array_foreach_stop_2nd(const void *array __UNUSED__, void *p, void *user_data __UNUSED__)
303{
304 short *member = p;
305 int *i = user_data;
306 fail_unless(*i == *member);
307 if (*i == 1)
308 return EINA_FALSE;
309 (*i)++;
310 return EINA_TRUE;
311}
312
313START_TEST(eina_inarray_test_itr)
314{
315 Eina_Inarray *array;
316 Eina_Iterator *it;
317 Eina_Accessor *ac;
318 short *member;
319 int i;
320
321 eina_init();
322
323 array = eina_inarray_new(sizeof(short), 1);
324 fail_unless(array != NULL);
325
326 for (i = 0; i < numbers_count; i++)
327 {
328 short val = i;
329 eina_inarray_append(array, &val);
330 }
331 i = 0;
332 EINA_INARRAY_FOREACH(array, member)
333 {
334 fail_unless(*member == i);
335 i++;
336 }
337 fail_unless(i == numbers_count);
338
339 i--;
340 EINA_INARRAY_REVERSE_FOREACH(array, member)
341 {
342 fail_unless(*member == i);
343 i--;
344 }
345 fail_unless(i == -1);
346
347 i = 0;
348 fail_unless(eina_inarray_foreach(array, array_foreach, &i));
349 fail_unless(i == numbers_count);
350
351 i = 0;
352 fail_if(eina_inarray_foreach(array, array_foreach_stop_2nd, &i));
353 fail_unless(i == 1);
354
355 it = eina_inarray_iterator_new(array);
356 fail_unless(it != NULL);
357 i = 0;
358 EINA_ITERATOR_FOREACH(it, member)
359 {
360 fail_unless(*member == i);
361 i++;
362 }
363 fail_unless(i == numbers_count);
364 eina_iterator_free(it);
365
366 it = eina_inarray_iterator_reversed_new(array);
367 fail_unless(it != NULL);
368 i--;
369 EINA_ITERATOR_FOREACH(it, member)
370 {
371 fail_unless(*member == i);
372 i--;
373 }
374 fail_unless(i == -1);
375 eina_iterator_free(it);
376
377 ac = eina_inarray_accessor_new(array);
378 fail_unless(ac != NULL);
379 for (i = 0; i < numbers_count; i++)
380 {
381 fail_unless(eina_accessor_data_get(ac, i, (void **)&member));
382 fail_unless(*member == i);
383 }
384 fail_unless(i == numbers_count);
385 eina_accessor_free(ac);
386
387 eina_inarray_free(array);
388 eina_shutdown();
389}
390END_TEST
391
392void
393eina_test_inarray(TCase *tc)
394{
395 tcase_add_test(tc, eina_inarray_test_simple);
396 tcase_add_test(tc, eina_inarray_test_alloc_at);
397 tcase_add_test(tc, eina_inarray_test_insert_sort);
398 tcase_add_test(tc, eina_inarray_test_sort);
399 tcase_add_test(tc, eina_inarray_test_reverse);
400 tcase_add_test(tc, eina_inarray_test_itr);
401}
diff --git a/libraries/eina/src/tests/eina_test_value.c b/libraries/eina/src/tests/eina_test_value.c
new file mode 100644
index 0000000..2d04c2f
--- /dev/null
+++ b/libraries/eina/src/tests/eina_test_value.c
@@ -0,0 +1,1799 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <stdio.h>
24#include <inttypes.h>
25
26#include "eina_suite.h"
27#include "Eina.h"
28
29#define FP_ERR (0.0000001)
30#define CHECK_FP(a, b) ((a - b) < FP_ERR)
31
32START_TEST(eina_value_test_simple)
33{
34 Eina_Value *value;
35 char c;
36 short s;
37 int i;
38 long l;
39 int64_t i64;
40 unsigned char uc;
41 unsigned short us;
42 unsigned int ui;
43 unsigned long ul;
44 uint64_t u64;
45 float f;
46 double d;
47
48 eina_init();
49
50 value = eina_value_new(EINA_VALUE_TYPE_CHAR);
51 fail_unless(value != NULL);
52 fail_unless(eina_value_set(value, 'x'));
53 fail_unless(eina_value_get(value, &c));
54 fail_unless(c == 'x');
55 eina_value_flush(value);
56
57 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT));
58 fail_unless(eina_value_set(value, 300));
59 fail_unless(eina_value_get(value, &s));
60 fail_unless(s == 300);
61 eina_value_flush(value);
62
63 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT));
64 fail_unless(eina_value_set(value, -12345));
65 fail_unless(eina_value_get(value, &i));
66 fail_unless(i == -12345);
67 eina_value_flush(value);
68
69 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG));
70 fail_unless(eina_value_set(value, 0xb33f));
71 fail_unless(eina_value_get(value, &l));
72 fail_unless(l == 0xb33f);
73 eina_value_flush(value);
74
75 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64));
76 fail_unless(eina_value_set(value, 0x0011223344556677));
77 fail_unless(eina_value_get(value, &i64));
78 fail_unless(i64 == 0x0011223344556677);
79 eina_value_flush(value);
80
81 /* unsigned: */
82
83 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR));
84 fail_unless(eina_value_set(value, 200));
85 fail_unless(eina_value_get(value, &uc));
86 fail_unless(uc == 200);
87 eina_value_flush(value);
88
89 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT));
90 fail_unless(eina_value_set(value, 65535));
91 fail_unless(eina_value_get(value, &us));
92 fail_unless(us == 65535);
93 eina_value_flush(value);
94
95 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT));
96 fail_unless(eina_value_set(value, 4000000000U));
97 fail_unless(eina_value_get(value, &ui));
98 fail_unless(ui == 4000000000U);
99 eina_value_flush(value);
100
101 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG));
102 fail_unless(eina_value_set(value, 3000000001U));
103 fail_unless(eina_value_get(value, &ul));
104 fail_unless(ul == 3000000001U);
105 eina_value_flush(value);
106
107 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64));
108 fail_unless(eina_value_set(value, 0x1122334455667788));
109 fail_unless(eina_value_get(value, &u64));
110 fail_unless(u64 == 0x1122334455667788);
111 eina_value_flush(value);
112
113 /* floating point */
114 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT));
115 fail_unless(eina_value_set(value, 0.1234));
116 fail_unless(eina_value_get(value, &f));
117 fail_unless(CHECK_FP(0.1234, f));
118 eina_value_flush(value);
119
120 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE));
121 fail_unless(eina_value_set(value, 34567.8));
122 fail_unless(eina_value_get(value, &d));
123 fail_unless(CHECK_FP(34567.8, d));
124 eina_value_flush(value);
125
126 eina_value_free(value);
127 eina_shutdown();
128}
129END_TEST
130
131START_TEST(eina_value_test_compare)
132{
133 Eina_Value *a, *b;
134
135 eina_init();
136
137 a = eina_value_new(EINA_VALUE_TYPE_CHAR);
138 fail_unless(a != NULL);
139 b = eina_value_new(EINA_VALUE_TYPE_CHAR);
140 fail_unless(b != NULL);
141
142 fail_unless(eina_value_set(a, 123));
143 fail_unless(eina_value_set(b, 123));
144 fail_unless(eina_value_compare(a, b) == 0);
145 fail_unless(eina_value_set(a, -10));
146 fail_unless(eina_value_set(b, 123));
147 fail_unless(eina_value_compare(a, b) < 0);
148 fail_unless(eina_value_set(a, 123));
149 fail_unless(eina_value_set(b, 10));
150 fail_unless(eina_value_compare(a, b) > 0);
151 eina_value_flush(a);
152 eina_value_flush(b);
153
154 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_SHORT));
155 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_SHORT));
156 fail_unless(eina_value_set(a, 1230));
157 fail_unless(eina_value_set(b, 1230));
158 fail_unless(eina_value_compare(a, b) == 0);
159 fail_unless(eina_value_set(a, -100));
160 fail_unless(eina_value_set(b, 1230));
161 fail_unless(eina_value_compare(a, b) < 0);
162 fail_unless(eina_value_set(a, 1230));
163 fail_unless(eina_value_set(b, -100));
164 fail_unless(eina_value_compare(a, b) > 0);
165 eina_value_flush(a);
166 eina_value_flush(b);
167
168 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_INT));
169 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_INT));
170 fail_unless(eina_value_set(a, 300000));
171 fail_unless(eina_value_set(b, 300000));
172 fail_unless(eina_value_compare(a, b) == 0);
173 fail_unless(eina_value_set(a, -100));
174 fail_unless(eina_value_set(b, 300000));
175 fail_unless(eina_value_compare(a, b) < 0);
176 fail_unless(eina_value_set(a, 300000));
177 fail_unless(eina_value_set(b, -100));
178 fail_unless(eina_value_compare(a, b) > 0);
179 eina_value_flush(a);
180 eina_value_flush(b);
181
182 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_LONG));
183 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_LONG));
184 fail_unless(eina_value_set(a, 300000L));
185 fail_unless(eina_value_set(b, 300000L));
186 fail_unless(eina_value_compare(a, b) == 0);
187 fail_unless(eina_value_set(a, -100L));
188 fail_unless(eina_value_set(b, 300000L));
189 fail_unless(eina_value_compare(a, b) < 0);
190 fail_unless(eina_value_set(a, 300000L));
191 fail_unless(eina_value_set(b, -100L));
192 fail_unless(eina_value_compare(a, b) > 0);
193 eina_value_flush(a);
194 eina_value_flush(b);
195
196 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_INT64));
197 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_INT64));
198 fail_unless(eina_value_set(a, (int64_t)800000));
199 fail_unless(eina_value_set(b, (int64_t)800000));
200 fail_unless(eina_value_compare(a, b) == 0);
201 fail_unless(eina_value_set(a, (int64_t)-100));
202 fail_unless(eina_value_set(b, (int64_t)8000000));
203 fail_unless(eina_value_compare(a, b) < 0);
204 fail_unless(eina_value_set(a, (int64_t)8000000));
205 fail_unless(eina_value_set(b, (int64_t)-100));
206 fail_unless(eina_value_compare(a, b) > 0);
207 eina_value_flush(a);
208 eina_value_flush(b);
209
210 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UCHAR));
211 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UCHAR));
212 fail_unless(eina_value_set(a, 123));
213 fail_unless(eina_value_set(b, 123));
214 fail_unless(eina_value_compare(a, b) == 0);
215 fail_unless(eina_value_set(a, 10));
216 fail_unless(eina_value_set(b, 123));
217 fail_unless(eina_value_compare(a, b) < 0);
218 fail_unless(eina_value_set(a, 123));
219 fail_unless(eina_value_set(b, 10));
220 fail_unless(eina_value_compare(a, b) > 0);
221 eina_value_flush(a);
222 eina_value_flush(b);
223
224 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_USHORT));
225 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_USHORT));
226 fail_unless(eina_value_set(a, 1230));
227 fail_unless(eina_value_set(b, 1230));
228 fail_unless(eina_value_compare(a, b) == 0);
229 fail_unless(eina_value_set(a, 100));
230 fail_unless(eina_value_set(b, 1230));
231 fail_unless(eina_value_compare(a, b) < 0);
232 fail_unless(eina_value_set(a, 1230));
233 fail_unless(eina_value_set(b, 100));
234 fail_unless(eina_value_compare(a, b) > 0);
235 eina_value_flush(a);
236 eina_value_flush(b);
237
238 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UINT));
239 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UINT));
240 fail_unless(eina_value_set(a, 300000));
241 fail_unless(eina_value_set(b, 300000));
242 fail_unless(eina_value_compare(a, b) == 0);
243 fail_unless(eina_value_set(a, 100));
244 fail_unless(eina_value_set(b, 300000));
245 fail_unless(eina_value_compare(a, b) < 0);
246 fail_unless(eina_value_set(a, 300000));
247 fail_unless(eina_value_set(b, 100));
248 fail_unless(eina_value_compare(a, b) > 0);
249 eina_value_flush(a);
250 eina_value_flush(b);
251
252 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_ULONG));
253 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_ULONG));
254 fail_unless(eina_value_set(a, 300000UL));
255 fail_unless(eina_value_set(b, 300000UL));
256 fail_unless(eina_value_compare(a, b) == 0);
257 fail_unless(eina_value_set(a, 100UL));
258 fail_unless(eina_value_set(b, 300000UL));
259 fail_unless(eina_value_compare(a, b) < 0);
260 fail_unless(eina_value_set(a, 300000UL));
261 fail_unless(eina_value_set(b, 100UL));
262 fail_unless(eina_value_compare(a, b) > 0);
263 eina_value_flush(a);
264 eina_value_flush(b);
265
266 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_UINT64));
267 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_UINT64));
268 fail_unless(eina_value_set(a, (uint64_t)8000000));
269 fail_unless(eina_value_set(b, (uint64_t)8000000));
270 fail_unless(eina_value_compare(a, b) == 0);
271 fail_unless(eina_value_set(a, (uint64_t)100));
272 fail_unless(eina_value_set(b, (uint64_t)8000000));
273 fail_unless(eina_value_compare(a, b) < 0);
274 fail_unless(eina_value_set(a, (uint64_t)8000000));
275 fail_unless(eina_value_set(b, (uint64_t)100));
276 fail_unless(eina_value_compare(a, b) > 0);
277 eina_value_flush(a);
278 eina_value_flush(b);
279
280 fail_unless(eina_value_setup(a, EINA_VALUE_TYPE_STRING));
281 fail_unless(eina_value_setup(b, EINA_VALUE_TYPE_STRING));
282 fail_unless(eina_value_set(a, "aaa"));
283 fail_unless(eina_value_set(b, "aaa"));
284 fail_unless(eina_value_compare(a, b) == 0);
285 fail_unless(eina_value_set(a, "abc"));
286 fail_unless(eina_value_set(b, "acd"));
287 fail_unless(eina_value_compare(a, b) < 0);
288 fail_unless(eina_value_set(a, "acd"));
289 fail_unless(eina_value_set(b, "abc"));
290 fail_unless(eina_value_compare(a, b) > 0);
291 eina_value_flush(a);
292 eina_value_flush(b);
293
294 fail_unless(eina_value_array_setup(a, EINA_VALUE_TYPE_CHAR, 0));
295 fail_unless(eina_value_array_setup(b, EINA_VALUE_TYPE_CHAR, 0));
296 fail_unless(eina_value_compare(a, b) == 0);
297
298 fail_unless(eina_value_array_append(a, 1));
299 fail_unless(eina_value_array_append(a, 2));
300 fail_unless(eina_value_array_append(a, 3));
301
302 fail_unless(eina_value_array_append(b, 1));
303 fail_unless(eina_value_array_append(b, 2));
304 fail_unless(eina_value_array_append(b, 3));
305
306 fail_unless(eina_value_compare(a, b) == 0);
307
308 fail_unless(eina_value_array_set(a, 0, 0));
309 fail_unless(eina_value_compare(a, b) < 0);
310
311 fail_unless(eina_value_array_set(a, 0, 10));
312 fail_unless(eina_value_compare(a, b) > 0);
313
314 fail_unless(eina_value_array_set(a, 0, 1));
315
316 fail_unless(eina_value_array_set(b, 0, 0));
317 fail_unless(eina_value_compare(a, b) > 0);
318
319 fail_unless(eina_value_array_set(b, 0, 10));
320 fail_unless(eina_value_compare(a, b) < 0);
321
322 fail_unless(eina_value_array_set(b, 0, 1));
323 fail_unless(eina_value_compare(a, b) == 0);
324
325 /* bigger arrays are greater */
326 fail_unless(eina_value_array_append(b, 0));
327 fail_unless(eina_value_compare(a, b) < 0);
328
329 fail_unless(eina_value_array_append(a, 0));
330 fail_unless(eina_value_array_append(a, 0));
331 fail_unless(eina_value_compare(a, b) > 0);
332
333 /* bigger arrays are greater, unless an element says otherwise */
334 fail_unless(eina_value_array_set(b, 0, 10));
335 fail_unless(eina_value_compare(a, b) < 0);
336
337 eina_value_flush(a);
338 eina_value_flush(b);
339
340 fail_unless(eina_value_list_setup(a, EINA_VALUE_TYPE_CHAR));
341 fail_unless(eina_value_list_setup(b, EINA_VALUE_TYPE_CHAR));
342 fail_unless(eina_value_compare(a, b) == 0);
343
344 fail_unless(eina_value_list_append(a, 1));
345 fail_unless(eina_value_list_append(a, 2));
346 fail_unless(eina_value_list_append(a, 3));
347
348 fail_unless(eina_value_list_append(b, 1));
349 fail_unless(eina_value_list_append(b, 2));
350 fail_unless(eina_value_list_append(b, 3));
351
352 fail_unless(eina_value_compare(a, b) == 0);
353
354 fail_unless(eina_value_list_set(a, 0, 0));
355 fail_unless(eina_value_compare(a, b) < 0);
356
357 fail_unless(eina_value_list_set(a, 0, 10));
358 fail_unless(eina_value_compare(a, b) > 0);
359
360 fail_unless(eina_value_list_set(a, 0, 1));
361
362 fail_unless(eina_value_list_set(b, 0, 0));
363 fail_unless(eina_value_compare(a, b) > 0);
364
365 fail_unless(eina_value_list_set(b, 0, 10));
366 fail_unless(eina_value_compare(a, b) < 0);
367
368 fail_unless(eina_value_list_set(b, 0, 1));
369 fail_unless(eina_value_compare(a, b) == 0);
370
371 /* bigger lists are greater */
372 fail_unless(eina_value_list_append(b, 0));
373 fail_unless(eina_value_compare(a, b) < 0);
374
375 fail_unless(eina_value_list_append(a, 0));
376 fail_unless(eina_value_list_append(a, 0));
377 fail_unless(eina_value_compare(a, b) > 0);
378
379 /* bigger lists are greater, unless an element says otherwise */
380 fail_unless(eina_value_list_set(b, 0, 10));
381 fail_unless(eina_value_compare(a, b) < 0);
382
383 eina_value_flush(a);
384 eina_value_flush(b);
385
386 fail_unless(eina_value_hash_setup(a, EINA_VALUE_TYPE_CHAR, 0));
387 fail_unless(eina_value_hash_setup(b, EINA_VALUE_TYPE_CHAR, 0));
388 fail_unless(eina_value_compare(a, b) == 0);
389
390 fail_unless(eina_value_hash_set(a, "abc", 1));
391 fail_unless(eina_value_hash_set(a, "xyz", 2));
392 fail_unless(eina_value_hash_set(a, "hello", 3));
393
394 fail_unless(eina_value_hash_set(b, "abc", 1));
395 fail_unless(eina_value_hash_set(b, "xyz", 2));
396 fail_unless(eina_value_hash_set(b, "hello", 3));
397
398 fail_unless(eina_value_compare(a, b) == 0);
399
400 fail_unless(eina_value_hash_set(a, "abc", 0));
401 fail_unless(eina_value_compare(a, b) < 0);
402
403 fail_unless(eina_value_hash_set(a, "abc", 10));
404 fail_unless(eina_value_compare(a, b) > 0);
405
406 fail_unless(eina_value_hash_set(a, "abc", 1));
407
408 fail_unless(eina_value_hash_set(b, "abc", 0));
409 fail_unless(eina_value_compare(a, b) > 0);
410
411 fail_unless(eina_value_hash_set(b, "abc", 10));
412 fail_unless(eina_value_compare(a, b) < 0);
413
414 fail_unless(eina_value_hash_set(b, "abc", 1));
415 fail_unless(eina_value_compare(a, b) == 0);
416
417 /* bigger hashs are greater */
418 fail_unless(eina_value_hash_set(b,"newkey", 0));
419 fail_unless(eina_value_compare(a, b) < 0);
420
421 fail_unless(eina_value_hash_set(a, "newkey", 0));
422 fail_unless(eina_value_hash_set(a, "onemorenewkey", 0));
423 fail_unless(eina_value_compare(a, b) > 0);
424
425 /* bigger hashs are greater, unless an element says otherwise */
426 fail_unless(eina_value_hash_set(b, "abc", 10));
427 fail_unless(eina_value_compare(a, b) < 0);
428
429 eina_value_free(a);
430 eina_value_free(b);
431 eina_shutdown();
432}
433END_TEST
434
435START_TEST(eina_value_test_string)
436{
437 Eina_Value *value;
438 const char *s;
439
440 eina_init();
441
442 value = eina_value_new(EINA_VALUE_TYPE_STRING);
443 fail_unless(value != NULL);
444 fail_unless(eina_value_set(value, "hello world!"));
445 fail_unless(eina_value_get(value, &s));
446 fail_unless(strcmp(s, "hello world!") == 0);
447
448 fail_unless(eina_value_set(value, "eina-value"));
449 fail_unless(eina_value_get(value, &s));
450 fail_unless(strcmp(s, "eina-value") == 0);
451
452 eina_value_flush(value);
453 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
454
455 fail_unless(eina_value_set(value, "profusion"));
456 fail_unless(eina_value_get(value, &s));
457 fail_unless(strcmp(s, "profusion") == 0);
458
459 eina_value_free(value);
460 eina_shutdown();
461}
462END_TEST
463
464START_TEST(eina_value_test_pvariant)
465{
466 Eina_Value *value;
467 char c, in_c;
468 short s, in_s;
469 int i, in_i;
470 long l, in_l;
471 int64_t i64, in_i64;
472 unsigned char uc, in_uc;
473 unsigned short us, in_us;
474 unsigned int ui, in_ui;
475 unsigned long ul, in_ul;
476 uint64_t u64, in_u64;
477 float f, in_f;
478 double d, in_d;
479 const char *str, *in_str;
480
481 eina_init();
482
483 value = eina_value_new(EINA_VALUE_TYPE_CHAR);
484 fail_unless(value != NULL);
485 in_c = 'x';
486 fail_unless(eina_value_pset(value, &in_c));
487 fail_unless(eina_value_pget(value, &c));
488 fail_unless(c == 'x');
489 eina_value_flush(value);
490
491 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT));
492 in_s = 300;
493 fail_unless(eina_value_pset(value, &in_s));
494 fail_unless(eina_value_pget(value, &s));
495 fail_unless(s == 300);
496 eina_value_flush(value);
497
498 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT));
499 in_i = -12345;
500 fail_unless(eina_value_pset(value, &in_i));
501 fail_unless(eina_value_pget(value, &i));
502 fail_unless(i == -12345);
503 eina_value_flush(value);
504
505 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG));
506 in_l = 0xb33f;
507 fail_unless(eina_value_pset(value, &in_l));
508 fail_unless(eina_value_pget(value, &l));
509 fail_unless(l == 0xb33f);
510 eina_value_flush(value);
511
512 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64));
513 in_i64 = 0x0011223344556677;
514 fail_unless(eina_value_pset(value, &in_i64));
515 fail_unless(eina_value_pget(value, &i64));
516 fail_unless(i64 == 0x0011223344556677);
517 eina_value_flush(value);
518
519 /* unsigned: */
520
521 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR));
522 in_uc = 200;
523 fail_unless(eina_value_pset(value, &in_uc));
524 fail_unless(eina_value_pget(value, &uc));
525 fail_unless(uc == 200);
526 eina_value_flush(value);
527
528 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT));
529 in_us = 65535;
530 fail_unless(eina_value_pset(value, &in_us));
531 fail_unless(eina_value_pget(value, &us));
532 fail_unless(us == 65535);
533 eina_value_flush(value);
534
535 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT));
536 in_ui = 4000000000U;
537 fail_unless(eina_value_pset(value, &in_ui));
538 fail_unless(eina_value_pget(value, &ui));
539 fail_unless(ui == 4000000000U);
540 eina_value_flush(value);
541
542 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG));
543 in_ul = 3000000001U;
544 fail_unless(eina_value_pset(value, &in_ul));
545 fail_unless(eina_value_pget(value, &ul));
546 fail_unless(ul == 3000000001U);
547 eina_value_flush(value);
548
549 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64));
550 in_u64 = 0x1122334455667788;
551 fail_unless(eina_value_pset(value, &in_u64));
552 fail_unless(eina_value_pget(value, &u64));
553 fail_unless(u64 == 0x1122334455667788);
554 eina_value_flush(value);
555
556 /* floating point */
557 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT));
558 in_f = 0.1234;
559 fail_unless(eina_value_pset(value, &in_f));
560 fail_unless(eina_value_pget(value, &f));
561 fail_unless(CHECK_FP(0.1234, f));
562 eina_value_flush(value);
563
564 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE));
565 in_d = 34567.8;
566 fail_unless(eina_value_pset(value, &in_d));
567 fail_unless(eina_value_pget(value, &d));
568 fail_unless(CHECK_FP(34567.8, d));
569 eina_value_flush(value);
570
571 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
572 in_str = "hello world!";
573 fail_unless(eina_value_pset(value, &in_str));
574 fail_unless(eina_value_pget(value, &str));
575 fail_unless(strcmp(str, "hello world!") == 0);
576
577 in_str = "eina-value";
578 fail_unless(eina_value_pset(value, &in_str));
579 fail_unless(eina_value_pget(value, &str));
580 fail_unless(strcmp(str, "eina-value") == 0);
581
582 eina_value_flush(value);
583 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
584
585 in_str = "profusion";
586 fail_unless(eina_value_pset(value, &in_str));
587 fail_unless(eina_value_pget(value, &str));
588 fail_unless(strcmp(str, "profusion") == 0);
589
590 eina_value_free(value);
591 eina_shutdown();
592}
593END_TEST
594
595START_TEST(eina_value_test_to_string)
596{
597 Eina_Value *value;
598 char c, in_c;
599 short s, in_s;
600 int i, in_i;
601 long l, in_l;
602 int64_t i64, in_i64;
603 unsigned char uc, in_uc;
604 unsigned short us, in_us;
605 unsigned int ui, in_ui;
606 unsigned long ul, in_ul;
607 uint64_t u64, in_u64;
608 float f, in_f;
609 double d, in_d;
610 const char *str, *in_str;
611 char *out;
612 char buf[256];
613
614 eina_init();
615
616 value = eina_value_new(EINA_VALUE_TYPE_CHAR);
617 fail_unless(value != NULL);
618 in_c = 'x';
619 fail_unless(eina_value_pset(value, &in_c));
620 fail_unless(eina_value_pget(value, &c));
621 fail_unless(c == 'x');
622 snprintf(buf, sizeof(buf), "%hhd", in_c);
623 out = eina_value_to_string(value);
624 fail_unless(out != NULL);
625 fail_unless(strcmp(buf, out) == 0);
626 free(out);
627 eina_value_flush(value);
628
629 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_SHORT));
630 in_s = 300;
631 fail_unless(eina_value_pset(value, &in_s));
632 fail_unless(eina_value_pget(value, &s));
633 fail_unless(s == 300);
634 snprintf(buf, sizeof(buf), "%hd", in_s);
635 out = eina_value_to_string(value);
636 fail_unless(out != NULL);
637 fail_unless(strcmp(buf, out) == 0);
638 free(out);
639 eina_value_flush(value);
640
641 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT));
642 in_i = -12345;
643 fail_unless(eina_value_pset(value, &in_i));
644 fail_unless(eina_value_pget(value, &i));
645 fail_unless(i == -12345);
646 snprintf(buf, sizeof(buf), "%d", in_i);
647 out = eina_value_to_string(value);
648 fail_unless(out != NULL);
649 fail_unless(strcmp(buf, out) == 0);
650 free(out);
651 eina_value_flush(value);
652
653 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_LONG));
654 in_l = 0xb33f;
655 fail_unless(eina_value_pset(value, &in_l));
656 fail_unless(eina_value_pget(value, &l));
657 fail_unless(l == 0xb33f);
658 snprintf(buf, sizeof(buf), "%ld", in_l);
659 out = eina_value_to_string(value);
660 fail_unless(out != NULL);
661 fail_unless(strcmp(buf, out) == 0);
662 free(out);
663 eina_value_flush(value);
664
665 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_INT64));
666 in_i64 = 0x0011223344556677;
667 fail_unless(eina_value_pset(value, &in_i64));
668 fail_unless(eina_value_pget(value, &i64));
669 fail_unless(i64 == 0x0011223344556677);
670 snprintf(buf, sizeof(buf), "%"PRId64, in_i64);
671 out = eina_value_to_string(value);
672 fail_unless(out != NULL);
673 fail_unless(strcmp(buf, out) == 0);
674 free(out);
675 eina_value_flush(value);
676
677 /* unsigned: */
678
679 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UCHAR));
680 in_uc = 200;
681 fail_unless(eina_value_pset(value, &in_uc));
682 fail_unless(eina_value_pget(value, &uc));
683 fail_unless(uc == 200);
684 snprintf(buf, sizeof(buf), "%hhu", in_uc);
685 out = eina_value_to_string(value);
686 fail_unless(out != NULL);
687 fail_unless(strcmp(buf, out) == 0);
688 free(out);
689 eina_value_flush(value);
690
691 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_USHORT));
692 in_us = 65535;
693 fail_unless(eina_value_pset(value, &in_us));
694 fail_unless(eina_value_pget(value, &us));
695 fail_unless(us == 65535);
696 snprintf(buf, sizeof(buf), "%hu", in_us);
697 out = eina_value_to_string(value);
698 fail_unless(out != NULL);
699 fail_unless(strcmp(buf, out) == 0);
700 free(out);
701 eina_value_flush(value);
702
703 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT));
704 in_ui = 4000000000U;
705 fail_unless(eina_value_pset(value, &in_ui));
706 fail_unless(eina_value_pget(value, &ui));
707 fail_unless(ui == 4000000000U);
708 snprintf(buf, sizeof(buf), "%u", in_ui);
709 out = eina_value_to_string(value);
710 fail_unless(out != NULL);
711 fail_unless(strcmp(buf, out) == 0);
712 free(out);
713 eina_value_flush(value);
714
715 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_ULONG));
716 in_ul = 3000000001U;
717 fail_unless(eina_value_pset(value, &in_ul));
718 fail_unless(eina_value_pget(value, &ul));
719 fail_unless(ul == 3000000001U);
720 snprintf(buf, sizeof(buf), "%lu", in_ul);
721 out = eina_value_to_string(value);
722 fail_unless(out != NULL);
723 fail_unless(strcmp(buf, out) == 0);
724 free(out);
725 eina_value_flush(value);
726
727 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_UINT64));
728 in_u64 = 0x1122334455667788;
729 fail_unless(eina_value_pset(value, &in_u64));
730 fail_unless(eina_value_pget(value, &u64));
731 fail_unless(u64 == 0x1122334455667788);
732 snprintf(buf, sizeof(buf), "%"PRIu64, in_u64);
733 out = eina_value_to_string(value);
734 fail_unless(out != NULL);
735 fail_unless(strcmp(buf, out) == 0);
736 free(out);
737 eina_value_flush(value);
738
739 /* floating point */
740 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_FLOAT));
741 in_f = 0.1234;
742 fail_unless(eina_value_pset(value, &in_f));
743 fail_unless(eina_value_pget(value, &f));
744 fail_unless(CHECK_FP(0.1234, f));
745 snprintf(buf, sizeof(buf), "%g", in_f);
746 out = eina_value_to_string(value);
747 fail_unless(out != NULL);
748 fail_unless(strncmp(buf, out, 6) == 0); /* stupid float... */
749 free(out);
750 eina_value_flush(value);
751
752 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_DOUBLE));
753 in_d = 34567.8;
754 fail_unless(eina_value_pset(value, &in_d));
755 fail_unless(eina_value_pget(value, &d));
756 fail_unless(CHECK_FP(34567.8, d));
757 snprintf(buf, sizeof(buf), "%g", in_d);
758 out = eina_value_to_string(value);
759 fail_unless(out != NULL);
760 fail_unless(strncmp(buf, out, 7) == 0); /* stupid double... */
761 free(out);
762 eina_value_flush(value);
763
764 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
765 in_str = "hello world!";
766 fail_unless(eina_value_pset(value, &in_str));
767 fail_unless(eina_value_pget(value, &str));
768 fail_unless(strcmp(str, "hello world!") == 0);
769 out = eina_value_to_string(value);
770 fail_unless(out != NULL);
771 fail_unless(strcmp(in_str, out) == 0);
772 free(out);
773
774 in_str = "eina-value";
775 fail_unless(eina_value_pset(value, &in_str));
776 fail_unless(eina_value_pget(value, &str));
777 fail_unless(strcmp(str, "eina-value") == 0);
778 out = eina_value_to_string(value);
779 fail_unless(out != NULL);
780 fail_unless(strcmp(in_str, out) == 0);
781 free(out);
782
783 eina_value_flush(value);
784 fail_unless(eina_value_setup(value, EINA_VALUE_TYPE_STRING));
785
786 in_str = "profusion";
787 fail_unless(eina_value_pset(value, &in_str));
788 fail_unless(eina_value_pget(value, &str));
789 fail_unless(strcmp(str, "profusion") == 0);
790 out = eina_value_to_string(value);
791 fail_unless(out != NULL);
792 fail_unless(strcmp(in_str, out) == 0);
793 free(out);
794
795 eina_value_free(value);
796 eina_shutdown();
797}
798END_TEST
799
800START_TEST(eina_value_test_convert_char)
801{
802 Eina_Value *value, conv;
803 char c;
804 short s;
805 int i;
806 long l;
807 int64_t i64;
808 unsigned char uc;
809 unsigned short us;
810 unsigned int ui;
811 unsigned long ul;
812 uint64_t u64;
813 float f;
814 double d;
815 const char *str;
816
817 eina_init();
818
819 value = eina_value_new(EINA_VALUE_TYPE_CHAR);
820 fail_unless(value != NULL);
821
822 fail_unless(eina_value_set(value, 123));
823
824 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR));
825 fail_unless(eina_value_convert(value, &conv));
826 fail_unless(eina_value_get(&conv, &uc));
827 fail_unless(uc == 123);
828 eina_value_flush(&conv);
829
830 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT));
831 fail_unless(eina_value_convert(value, &conv));
832 fail_unless(eina_value_get(&conv, &us));
833 fail_unless(us == 123);
834 eina_value_flush(&conv);
835
836 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT));
837 fail_unless(eina_value_convert(value, &conv));
838 fail_unless(eina_value_get(&conv, &ui));
839 fail_unless(ui == 123);
840 eina_value_flush(&conv);
841
842 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG));
843 fail_unless(eina_value_convert(value, &conv));
844 fail_unless(eina_value_get(&conv, &ul));
845 fail_unless(ul == 123);
846 eina_value_flush(&conv);
847
848 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64));
849 fail_unless(eina_value_convert(value, &conv));
850 fail_unless(eina_value_get(&conv, &u64));
851 fail_unless(u64 == 123);
852 eina_value_flush(&conv);
853
854 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR));
855 fail_unless(eina_value_convert(value, &conv));
856 fail_unless(eina_value_get(&conv, &c));
857 fail_unless(c == 123);
858 eina_value_flush(&conv);
859
860 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_SHORT));
861 fail_unless(eina_value_convert(value, &conv));
862 fail_unless(eina_value_get(&conv, &s));
863 fail_unless(s == 123);
864 eina_value_flush(&conv);
865
866 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT));
867 fail_unless(eina_value_convert(value, &conv));
868 fail_unless(eina_value_get(&conv, &i));
869 fail_unless(i == 123);
870 eina_value_flush(&conv);
871
872 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_LONG));
873 fail_unless(eina_value_convert(value, &conv));
874 fail_unless(eina_value_get(&conv, &l));
875 fail_unless(l == 123);
876 eina_value_flush(&conv);
877
878 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT64));
879 fail_unless(eina_value_convert(value, &conv));
880 fail_unless(eina_value_get(&conv, &i64));
881 fail_unless(i64 == 123);
882 eina_value_flush(&conv);
883
884 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_FLOAT));
885 fail_unless(eina_value_convert(value, &conv));
886 fail_unless(eina_value_get(&conv, &f));
887 fail_unless(CHECK_FP(f, 123));
888 eina_value_flush(&conv);
889
890 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_DOUBLE));
891 fail_unless(eina_value_convert(value, &conv));
892 fail_unless(eina_value_get(&conv, &d));
893 fail_unless(CHECK_FP(d, 123));
894 eina_value_flush(&conv);
895
896 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_STRING));
897 fail_unless(eina_value_convert(value, &conv));
898 fail_unless(eina_value_get(&conv, &str));
899 fail_unless(str != NULL);
900 fail_unless(strcmp(str, "123") == 0);
901 eina_value_flush(&conv);
902
903 /* negative tests */
904 fail_unless(eina_value_set(value, -123));
905
906 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR));
907 fail_if(eina_value_convert(value, &conv));
908 eina_value_flush(&conv);
909
910 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT));
911 fail_if(eina_value_convert(value, &conv));
912 eina_value_flush(&conv);
913
914 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT));
915 fail_if(eina_value_convert(value, &conv));
916 eina_value_flush(&conv);
917
918 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG));
919 fail_if(eina_value_convert(value, &conv));
920 eina_value_flush(&conv);
921
922 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64));
923 fail_if(eina_value_convert(value, &conv));
924 eina_value_flush(&conv);
925
926 eina_value_free(value);
927 eina_shutdown();
928}
929END_TEST
930
931START_TEST(eina_value_test_convert_uchar)
932{
933 Eina_Value *value, conv;
934 char c;
935 short s;
936 int i;
937 long l;
938 int64_t i64;
939 unsigned char uc;
940 unsigned short us;
941 unsigned int ui;
942 unsigned long ul;
943 uint64_t u64;
944 float f;
945 double d;
946 const char *str;
947
948 eina_init();
949
950 value = eina_value_new(EINA_VALUE_TYPE_UCHAR);
951 fail_unless(value != NULL);
952
953 fail_unless(eina_value_set(value, 31));
954
955 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UCHAR));
956 fail_unless(eina_value_convert(value, &conv));
957 fail_unless(eina_value_get(&conv, &uc));
958 fail_unless(uc == 31);
959 eina_value_flush(&conv);
960
961 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_USHORT));
962 fail_unless(eina_value_convert(value, &conv));
963 fail_unless(eina_value_get(&conv, &us));
964 fail_unless(us == 31);
965 eina_value_flush(&conv);
966
967 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT));
968 fail_unless(eina_value_convert(value, &conv));
969 fail_unless(eina_value_get(&conv, &ui));
970 fail_unless(ui == 31);
971 eina_value_flush(&conv);
972
973 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_ULONG));
974 fail_unless(eina_value_convert(value, &conv));
975 fail_unless(eina_value_get(&conv, &ul));
976 fail_unless(ul == 31);
977 eina_value_flush(&conv);
978
979 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_UINT64));
980 fail_unless(eina_value_convert(value, &conv));
981 fail_unless(eina_value_get(&conv, &u64));
982 fail_unless(u64 == 31);
983 eina_value_flush(&conv);
984
985 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR));
986 fail_unless(eina_value_convert(value, &conv));
987 fail_unless(eina_value_get(&conv, &c));
988 fail_unless(c == 31);
989 eina_value_flush(&conv);
990
991 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_SHORT));
992 fail_unless(eina_value_convert(value, &conv));
993 fail_unless(eina_value_get(&conv, &s));
994 fail_unless(s == 31);
995 eina_value_flush(&conv);
996
997 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT));
998 fail_unless(eina_value_convert(value, &conv));
999 fail_unless(eina_value_get(&conv, &i));
1000 fail_unless(i == 31);
1001 eina_value_flush(&conv);
1002
1003 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_LONG));
1004 fail_unless(eina_value_convert(value, &conv));
1005 fail_unless(eina_value_get(&conv, &l));
1006 fail_unless(l == 31);
1007 eina_value_flush(&conv);
1008
1009 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_INT64));
1010 fail_unless(eina_value_convert(value, &conv));
1011 fail_unless(eina_value_get(&conv, &i64));
1012 fail_unless(i64 == 31);
1013 eina_value_flush(&conv);
1014
1015 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_FLOAT));
1016 fail_unless(eina_value_convert(value, &conv));
1017 fail_unless(eina_value_get(&conv, &f));
1018 fail_unless(CHECK_FP(f, 31));
1019 eina_value_flush(&conv);
1020
1021 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_DOUBLE));
1022 fail_unless(eina_value_convert(value, &conv));
1023 fail_unless(eina_value_get(&conv, &d));
1024 fail_unless(CHECK_FP(d, 31));
1025 eina_value_flush(&conv);
1026
1027 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_STRING));
1028 fail_unless(eina_value_convert(value, &conv));
1029 fail_unless(eina_value_get(&conv, &str));
1030 fail_unless(str != NULL);
1031 fail_unless(strcmp(str, "31") == 0);
1032 eina_value_flush(&conv);
1033
1034 /* negative tests */
1035 fail_unless(eina_value_set(value, 200));
1036
1037 fail_unless(eina_value_setup(&conv, EINA_VALUE_TYPE_CHAR));
1038 fail_if(eina_value_convert(value, &conv));
1039 eina_value_flush(&conv);
1040
1041 eina_value_free(value);
1042 eina_shutdown();
1043}
1044END_TEST
1045
1046
1047START_TEST(eina_value_test_array)
1048{
1049 Eina_Value *value, other;
1050 Eina_Value_Array desc;
1051 Eina_Inarray *inarray;
1052 char c;
1053 char buf[1024];
1054 char *str;
1055
1056 eina_init();
1057
1058 value = eina_value_array_new(EINA_VALUE_TYPE_CHAR, 0);
1059 fail_unless(value != NULL);
1060
1061 fail_unless(eina_value_array_append(value, 'k'));
1062 fail_unless(eina_value_array_append(value, '-'));
1063 fail_unless(eina_value_array_append(value, 's'));
1064
1065 fail_unless(eina_value_array_get(value, 0, &c));
1066 fail_unless(c == 'k');
1067 fail_unless(eina_value_array_get(value, 1, &c));
1068 fail_unless(c == '-');
1069 fail_unless(eina_value_array_get(value, 2, &c));
1070 fail_unless(c == 's');
1071
1072 fail_unless(eina_value_array_insert(value, 0, '!'));
1073 fail_unless(eina_value_array_get(value, 0, &c));
1074 fail_unless(c == '!');
1075 fail_unless(eina_value_array_get(value, 1, &c));
1076 fail_unless(c == 'k');
1077 fail_unless(eina_value_array_get(value, 2, &c));
1078 fail_unless(c == '-');
1079 fail_unless(eina_value_array_get(value, 3, &c));
1080 fail_unless(c == 's');
1081
1082 fail_unless(eina_value_array_set(value, 0, '*'));
1083 fail_unless(eina_value_array_get(value, 0, &c));
1084 fail_unless(c == '*');
1085 fail_unless(eina_value_array_get(value, 1, &c));
1086 fail_unless(c == 'k');
1087 fail_unless(eina_value_array_get(value, 2, &c));
1088 fail_unless(c == '-');
1089 fail_unless(eina_value_array_get(value, 3, &c));
1090 fail_unless(c == 's');
1091
1092 snprintf(buf, sizeof(buf), "[%hhd, %hhd, %hhd, %hhd]",
1093 '*', 'k', '-', 's');
1094
1095 str = eina_value_to_string(value);
1096 fail_unless(str != NULL);
1097 fail_unless(strcmp(str, buf) == 0);
1098 free(str);
1099
1100 eina_value_flush(value);
1101 fail_unless(eina_value_array_setup(value, EINA_VALUE_TYPE_STRINGSHARE, 2));
1102
1103 fail_unless(eina_value_array_append(value, "Enlightenment.org"));
1104 fail_unless(eina_value_array_append(value, "X11"));
1105 fail_unless(eina_value_array_append(value, "Pants"));
1106 fail_unless(eina_value_array_append(value, "on!!!"));
1107 fail_unless(eina_value_array_append(value, "k-s"));
1108
1109 str = eina_value_to_string(value);
1110 fail_unless(str != NULL);
1111 fail_unless(strcmp(str, "[Enlightenment.org, X11, Pants, on!!!, k-s]") == 0);
1112 free(str);
1113
1114 eina_value_flush(value);
1115 fail_unless(eina_value_array_setup(value, EINA_VALUE_TYPE_CHAR, 0));
1116 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR));
1117
1118 fail_unless(eina_value_set(&other, 100));
1119 fail_unless(eina_value_get(&other, &c));
1120 fail_unless(c == 100);
1121
1122 fail_unless(eina_value_convert(&other, value));
1123 str = eina_value_to_string(value);
1124 fail_unless(str != NULL);
1125 fail_unless(strcmp(str, "[100]") == 0);
1126 free(str);
1127
1128 fail_unless(eina_value_array_set(value, 0, 33));
1129 fail_unless(eina_value_convert(value, &other));
1130 fail_unless(eina_value_get(&other, &c));
1131 fail_unless(c == 33);
1132
1133 inarray = eina_inarray_new(sizeof(char), 0);
1134 fail_unless(inarray != NULL);
1135 c = 11;
1136 fail_unless(eina_inarray_append(inarray, &c) >= 0);
1137 c = 21;
1138 fail_unless(eina_inarray_append(inarray, &c) >= 0);
1139 c = 31;
1140 fail_unless(eina_inarray_append(inarray, &c) >= 0);
1141 desc.subtype = EINA_VALUE_TYPE_CHAR;
1142 desc.step = 0;
1143 desc.array = inarray; /* will be adopted and freed by value */
1144 fail_unless(eina_value_set(value, desc)); /* manually configure */
1145 fail_unless(eina_value_array_get(value, 0, &c));
1146 fail_unless(c == 11);
1147 fail_unless(eina_value_array_get(value, 1, &c));
1148 fail_unless(c == 21);
1149 fail_unless(eina_value_array_get(value, 2, &c));
1150 fail_unless(c == 31);
1151
1152 eina_value_free(value);
1153 eina_shutdown();
1154}
1155END_TEST
1156
1157START_TEST(eina_value_test_list)
1158{
1159 Eina_Value *value, other;
1160 Eina_Value_List desc;
1161 char c;
1162 char buf[1024];
1163 char *str;
1164 const char *s;
1165
1166 eina_init();
1167
1168 value = eina_value_list_new(EINA_VALUE_TYPE_CHAR);
1169 fail_unless(value != NULL);
1170
1171 fail_unless(eina_value_list_append(value, 'k'));
1172 fail_unless(eina_value_list_append(value, '-'));
1173 fail_unless(eina_value_list_append(value, 's'));
1174
1175 fail_unless(eina_value_list_get(value, 0, &c));
1176 fail_unless(c == 'k');
1177 fail_unless(eina_value_list_get(value, 1, &c));
1178 fail_unless(c == '-');
1179 fail_unless(eina_value_list_get(value, 2, &c));
1180 fail_unless(c == 's');
1181
1182 fail_unless(eina_value_list_insert(value, 0, '!'));
1183 fail_unless(eina_value_list_get(value, 0, &c));
1184 fail_unless(c == '!');
1185 fail_unless(eina_value_list_get(value, 1, &c));
1186 fail_unless(c == 'k');
1187 fail_unless(eina_value_list_get(value, 2, &c));
1188 fail_unless(c == '-');
1189 fail_unless(eina_value_list_get(value, 3, &c));
1190 fail_unless(c == 's');
1191
1192 fail_unless(eina_value_list_set(value, 0, '*'));
1193 fail_unless(eina_value_list_get(value, 0, &c));
1194 fail_unless(c == '*');
1195 fail_unless(eina_value_list_get(value, 1, &c));
1196 fail_unless(c == 'k');
1197 fail_unless(eina_value_list_get(value, 2, &c));
1198 fail_unless(c == '-');
1199 fail_unless(eina_value_list_get(value, 3, &c));
1200 fail_unless(c == 's');
1201
1202 snprintf(buf, sizeof(buf), "[%hhd, %hhd, %hhd, %hhd]",
1203 '*', 'k', '-', 's');
1204
1205 str = eina_value_to_string(value);
1206 fail_unless(str != NULL);
1207 fail_unless(strcmp(str, buf) == 0);
1208 free(str);
1209
1210 eina_value_flush(value);
1211 fail_unless(eina_value_list_setup(value, EINA_VALUE_TYPE_STRINGSHARE));
1212
1213 fail_unless(eina_value_list_append(value, "Enlightenment.org"));
1214 fail_unless(eina_value_list_append(value, "X11"));
1215 fail_unless(eina_value_list_append(value, "Pants"));
1216 fail_unless(eina_value_list_append(value, "on!!!"));
1217 fail_unless(eina_value_list_append(value, "k-s"));
1218
1219 str = eina_value_to_string(value);
1220 fail_unless(str != NULL);
1221 fail_unless(strcmp(str, "[Enlightenment.org, X11, Pants, on!!!, k-s]") == 0);
1222 free(str);
1223
1224 eina_value_flush(value);
1225 fail_unless(eina_value_list_setup(value, EINA_VALUE_TYPE_CHAR));
1226 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR));
1227
1228 fail_unless(eina_value_set(&other, 100));
1229 fail_unless(eina_value_get(&other, &c));
1230 fail_unless(c == 100);
1231
1232 fail_unless(eina_value_convert(&other, value));
1233 str = eina_value_to_string(value);
1234 fail_unless(str != NULL);
1235 fail_unless(strcmp(str, "[100]") == 0);
1236 free(str);
1237
1238 fail_unless(eina_value_list_set(value, 0, 33));
1239 fail_unless(eina_value_convert(value, &other));
1240 fail_unless(eina_value_get(&other, &c));
1241 fail_unless(c == 33);
1242
1243 desc.subtype = EINA_VALUE_TYPE_STRING;
1244 desc.list = NULL;
1245 desc.list = eina_list_append(desc.list, strdup("hello"));
1246 desc.list = eina_list_append(desc.list, strdup("world"));
1247 desc.list = eina_list_append(desc.list, strdup("eina"));
1248 fail_unless(eina_list_count(desc.list) == 3);
1249 fail_unless(eina_value_set(value, desc));
1250 fail_unless(eina_value_list_get(value, 0, &s));
1251 fail_unless(s != NULL);
1252 fail_unless(strcmp(s, "hello") == 0);
1253 fail_unless(eina_value_list_get(value, 1, &s));
1254 fail_unless(s != NULL);
1255 fail_unless(strcmp(s, "world") == 0);
1256 fail_unless(eina_value_list_get(value, 2, &s));
1257 fail_unless(s != NULL);
1258 fail_unless(strcmp(s, "eina") == 0);
1259
1260 eina_value_free(value);
1261 eina_shutdown();
1262}
1263END_TEST
1264
1265START_TEST(eina_value_test_hash)
1266{
1267 Eina_Value *value, other;
1268 Eina_Value_Hash desc;
1269 char c;
1270 char buf[1024];
1271 char **ptr;
1272 char *str;
1273 const char *s;
1274
1275 eina_init();
1276
1277 value = eina_value_hash_new(EINA_VALUE_TYPE_CHAR, 0);
1278 fail_unless(value != NULL);
1279
1280 fail_unless(eina_value_hash_set(value, "first", 'k'));
1281 fail_unless(eina_value_hash_set(value, "second", '-'));
1282 fail_unless(eina_value_hash_set(value, "third", 's'));
1283
1284 fail_unless(eina_value_hash_get(value, "first", &c));
1285 fail_unless(c == 'k');
1286 fail_unless(eina_value_hash_get(value, "second", &c));
1287 fail_unless(c == '-');
1288 fail_unless(eina_value_hash_get(value, "third", &c));
1289 fail_unless(c == 's');
1290
1291 fail_unless(eina_value_hash_set(value, "first", '!'));
1292 fail_unless(eina_value_hash_get(value, "first", &c));
1293 fail_unless(c == '!');
1294 fail_unless(eina_value_hash_get(value, "second", &c));
1295 fail_unless(c == '-');
1296 fail_unless(eina_value_hash_get(value, "third", &c));
1297 fail_unless(c == 's');
1298
1299 puts("testing hash to string -- may fail due hash algorithm changes!");
1300
1301 /* watchout, this is the order I got -- hash algorithm changes may change
1302 * the order!
1303 */
1304 snprintf(buf, sizeof(buf), "{first: %hhd, second: %hhd, third: %hhd}",
1305 '!', '-', 's');
1306
1307 str = eina_value_to_string(value);
1308 fail_unless(str != NULL);
1309 printf("want: %s\n", buf);
1310 printf("got.: %s\n", str);
1311 fail_unless(strcmp(str, buf) == 0);
1312 free(str);
1313
1314 eina_value_flush(value);
1315 fail_unless(eina_value_hash_setup(value, EINA_VALUE_TYPE_STRINGSHARE, 0));
1316
1317 fail_unless(eina_value_hash_set(value, "a", "Enlightenment.org"));
1318 fail_unless(eina_value_hash_set(value, "b", "X11"));
1319 fail_unless(eina_value_hash_set(value, "c", "Pants"));
1320 fail_unless(eina_value_hash_set(value, "d", "on!!!"));
1321 fail_unless(eina_value_hash_set(value, "e", "k-s"));
1322
1323 /* watchout, this is the order I got -- hash algorithm changes may change
1324 * the order!
1325 */
1326 strcpy(buf, "{e: k-s, d: on!!!, a: Enlightenment.org, b: X11, c: Pants}");
1327
1328 str = eina_value_to_string(value);
1329 fail_unless(str != NULL);
1330 printf("want: %s\n", buf);
1331 printf("got.: %s\n", str);
1332 fail_unless(strcmp(str, buf) == 0);
1333 free(str);
1334
1335 eina_value_flush(value);
1336 fail_unless(eina_value_hash_setup(value, EINA_VALUE_TYPE_CHAR, 0));
1337 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR));
1338
1339 fail_unless(eina_value_set(&other, 100));
1340 fail_unless(eina_value_get(&other, &c));
1341 fail_unless(c == 100);
1342
1343 fail_unless(eina_value_hash_set(value, "first", 33));
1344 fail_unless(eina_value_convert(value, &other));
1345 fail_unless(eina_value_get(&other, &c));
1346 fail_unless(c == 33);
1347
1348 desc.subtype = EINA_VALUE_TYPE_STRING;
1349 desc.buckets_power_size = 0;
1350 desc.hash = eina_hash_string_small_new(NULL);
1351 fail_unless(desc.hash != NULL);
1352 /* watch out hash pointer is to a size of subtype->value_size! */
1353 ptr = malloc(sizeof(char *));
1354 *ptr = strdup("there");
1355 fail_unless(eina_hash_add(desc.hash, "hi", ptr));
1356 ptr = malloc(sizeof(char *));
1357 *ptr = strdup("y");
1358 fail_unless(eina_hash_add(desc.hash, "x", ptr));
1359
1360 fail_unless(eina_value_set(value, desc));
1361
1362 fail_unless(eina_value_hash_get(value, "hi", &s));
1363 fail_unless(s != NULL);
1364 fail_unless(strcmp(s, "there") == 0);
1365
1366 fail_unless(eina_value_hash_get(value, "x", &s));
1367 fail_unless(s != NULL);
1368 fail_unless(strcmp(s, "y") == 0);
1369
1370 eina_value_free(value);
1371 eina_shutdown();
1372}
1373END_TEST
1374
1375
1376START_TEST(eina_value_test_timeval)
1377{
1378 Eina_Value *value, other;
1379 struct timeval itv, otv;
1380 char c;
1381 char *str;
1382
1383 eina_init();
1384
1385 value = eina_value_new(EINA_VALUE_TYPE_TIMEVAL);
1386 fail_unless(value != NULL);
1387
1388 itv.tv_sec = 1;
1389 itv.tv_usec = 123;
1390 fail_unless(eina_value_set(value, itv));
1391 fail_unless(eina_value_get(value, &otv));
1392 fail_unless(memcmp(&itv, &otv, sizeof(struct timeval)) == 0);
1393
1394 itv.tv_sec = 3;
1395 itv.tv_usec = -1;
1396 fail_unless(eina_value_set(value, itv));
1397 fail_unless(eina_value_get(value, &otv));
1398 itv.tv_sec = 2;
1399 itv.tv_usec = 999999;
1400 fail_unless(memcmp(&itv, &otv, sizeof(struct timeval)) == 0);
1401
1402 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_CHAR));
1403 fail_unless(eina_value_convert(value, &other));
1404 fail_unless(eina_value_get(&other, &c));
1405 fail_unless(c == 2);
1406 eina_value_flush(&other);
1407
1408 itv.tv_sec = 12345;
1409 itv.tv_usec = 6789;
1410 fail_unless(eina_value_set(value, itv));
1411 str = eina_value_to_string(value);
1412 fail_unless(str != NULL);
1413 fail_unless(strcmp(str, "12345.006789") == 0);
1414 free(str);
1415
1416 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_TIMEVAL));
1417 fail_unless(eina_value_set(&other, itv));
1418 fail_unless(eina_value_compare(value, &other) == 0);
1419
1420 itv.tv_sec++;
1421 fail_unless(eina_value_set(&other, itv));
1422 fail_unless(eina_value_compare(value, &other) < 0);
1423
1424 itv.tv_sec -= 2;
1425 fail_unless(eina_value_set(&other, itv));
1426 fail_unless(eina_value_compare(value, &other) > 0);
1427
1428 itv.tv_sec++;
1429 fail_unless(eina_value_set(&other, itv));
1430 fail_unless(eina_value_compare(value, &other) == 0);
1431
1432 itv.tv_usec++;
1433 fail_unless(eina_value_set(&other, itv));
1434 fail_unless(eina_value_compare(value, &other) < 0);
1435
1436 itv.tv_usec -= 2;
1437 fail_unless(eina_value_set(&other, itv));
1438 fail_unless(eina_value_compare(value, &other) > 0);
1439
1440 itv.tv_usec++;
1441 fail_unless(eina_value_set(&other, itv));
1442 fail_unless(eina_value_compare(value, &other) == 0);
1443
1444 eina_value_flush(&other);
1445
1446
1447 eina_value_free(value);
1448 eina_shutdown();
1449}
1450END_TEST
1451
1452
1453START_TEST(eina_value_test_blob)
1454{
1455 Eina_Value *value, other;
1456 Eina_Value_Blob in, out;
1457 unsigned char blob[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1458 int i = 0x11223344;
1459 char *str;
1460
1461 eina_init();
1462
1463 value = eina_value_new(EINA_VALUE_TYPE_BLOB);
1464 fail_unless(value != NULL);
1465
1466 in.ops = NULL;
1467 in.memory = blob;
1468 in.size = sizeof(blob);
1469 fail_unless(eina_value_set(value, in));
1470 fail_unless(eina_value_get(value, &out));
1471 fail_unless(out.memory == blob);
1472 fail_unless(out.size == sizeof(blob));
1473 fail_unless(memcmp(&in, &out, sizeof(Eina_Value_Blob)) == 0);
1474
1475 str = eina_value_to_string(value);
1476 fail_unless(str != NULL);
1477 fail_unless(strcmp(str, "BLOB(10, [01 02 03 04 05 06 07 08 09 0a])") == 0);
1478 free(str);
1479
1480 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_INT));
1481 fail_unless(eina_value_set(&other, i));
1482 fail_unless(eina_value_convert(&other, value));
1483 fail_unless(eina_value_get(value, &out));
1484
1485 fail_unless(out.memory != NULL);
1486 fail_unless(out.size == sizeof(int));
1487 fail_unless(memcmp(&i, out.memory, sizeof(int)) == 0);
1488
1489 eina_value_flush(&other);
1490
1491 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_STRING));
1492 fail_unless(eina_value_set(&other, "hi there!"));
1493 fail_unless(eina_value_convert(&other, value));
1494 fail_unless(eina_value_get(value, &out));
1495 fail_unless(out.memory != NULL);
1496 fail_unless(out.size == sizeof("hi there!"));
1497 fail_unless(strcmp(out.memory, "hi there!") == 0);
1498
1499 str = eina_value_to_string(value);
1500 fail_unless(str != NULL);
1501 fail_unless(strcmp(str, "BLOB(10, [68 69 20 74 68 65 72 65 21 00])") == 0);
1502 free(str);
1503
1504 eina_value_flush(&other);
1505
1506 fail_unless(eina_value_array_setup(&other, EINA_VALUE_TYPE_CHAR, 0));
1507 fail_unless(eina_value_array_append(&other, 0xa));
1508 fail_unless(eina_value_array_append(&other, 0xb));
1509 fail_unless(eina_value_array_append(&other, 0xc));
1510 fail_unless(eina_value_convert(&other, value));
1511 fail_unless(eina_value_get(value, &out));
1512 fail_unless(out.memory != NULL);
1513 fail_unless(out.size == 3);
1514
1515 str = eina_value_to_string(value);
1516 fail_unless(str != NULL);
1517 fail_unless(strcmp(str, "BLOB(3, [0a 0b 0c])") == 0);
1518 free(str);
1519
1520 eina_value_flush(&other);
1521
1522 fail_unless(eina_value_setup(&other, EINA_VALUE_TYPE_BLOB));
1523 fail_unless(eina_value_set(&other, in));
1524 fail_unless(eina_value_convert(value, &other));
1525 fail_unless(eina_value_get(&other, &out));
1526 fail_unless(out.memory != NULL);
1527 fail_unless(out.size == 3);
1528
1529 str = eina_value_to_string(&other);
1530 fail_unless(str != NULL);
1531 fail_unless(strcmp(str, "BLOB(3, [0a 0b 0c])") == 0);
1532 free(str);
1533
1534 eina_value_flush(&other);
1535
1536 eina_value_free(value);
1537 eina_shutdown();
1538}
1539END_TEST
1540
1541
1542START_TEST(eina_value_test_struct)
1543{
1544 struct mybigst {
1545 int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, x;
1546 };
1547 const Eina_Value_Struct_Member mybigst_members[] = {
1548 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, a),
1549 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, b),
1550 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, c),
1551 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, d),
1552 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, e),
1553 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, f),
1554 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, g),
1555 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, h),
1556 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, i),
1557 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, j),
1558 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, k),
1559 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, l),
1560 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, m),
1561 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, n),
1562 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, o),
1563 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, p),
1564 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, q),
1565 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, r),
1566 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, s),
1567 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, t),
1568 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, u),
1569 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, v),
1570 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct mybigst, x),
1571 EINA_VALUE_STRUCT_MEMBER_SENTINEL
1572 };
1573 const Eina_Value_Struct_Desc mybigst_desc = {
1574 EINA_VALUE_STRUCT_DESC_VERSION,
1575 EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH,
1576 mybigst_members, 23, sizeof(struct mybigst)
1577 };
1578 struct myst {
1579 int i;
1580 char c;
1581 };
1582 const Eina_Value_Struct_Member myst_members[] = {
1583 {"i", EINA_VALUE_TYPE_INT, 0},
1584 {"c", EINA_VALUE_TYPE_CHAR, 4},
1585 {NULL, NULL, 0}
1586 };
1587 const Eina_Value_Struct_Desc myst_desc = {
1588 EINA_VALUE_STRUCT_DESC_VERSION,
1589 NULL, myst_members, 2, sizeof(struct myst)
1590 };
1591 Eina_Value *value, other;
1592 int i;
1593 char c;
1594 char *str;
1595
1596 eina_init();
1597
1598 value = eina_value_struct_new(&myst_desc);
1599 fail_unless(value != NULL);
1600
1601 fail_unless(eina_value_struct_set(value, "i", 5678));
1602 fail_unless(eina_value_struct_set(value, "c", 0xf));
1603
1604 fail_unless(eina_value_struct_get(value, "i", &i));
1605 fail_unless(i == 5678);
1606 fail_unless(eina_value_struct_get(value, "c", &c));
1607 fail_unless(c == 0xf);
1608
1609 str = eina_value_to_string(value);
1610 fail_unless(str != NULL);
1611 fail_unless(strcmp(str, "{i: 5678, c: 15}") == 0);
1612 free(str);
1613
1614 fail_if(eina_value_struct_get(value, "x", 1234));
1615
1616 i = 0x11223344;
1617 fail_unless(eina_value_struct_pset(value, "i", &i));
1618 i = -1;
1619 fail_unless(eina_value_struct_pget(value, "i", &i));
1620 fail_unless(i == 0x11223344);
1621
1622 fail_unless(eina_value_copy(value, &other));
1623 str = eina_value_to_string(&other);
1624 fail_unless(str != NULL);
1625 fail_unless(strcmp(str, "{i: 287454020, c: 15}") == 0);
1626 free(str);
1627
1628 eina_value_flush(&other);
1629
1630 fail_unless(eina_value_struct_setup(&other, &mybigst_desc));
1631 fail_unless(eina_value_struct_set(&other, "a", 1) );
1632 fail_unless(eina_value_struct_set(&other, "b", 2));
1633 fail_unless(eina_value_struct_set(&other, "c", 3));
1634 fail_unless(eina_value_struct_set(&other, "d", 4));
1635 fail_unless(eina_value_struct_set(&other, "e", 5));
1636 fail_unless(eina_value_struct_set(&other, "f", 6));
1637 fail_unless(eina_value_struct_set(&other, "g", 7));
1638 fail_unless(eina_value_struct_set(&other, "h", 8));
1639 fail_unless(eina_value_struct_set(&other, "i", 9));
1640 fail_unless(eina_value_struct_set(&other, "j", 10));
1641 fail_unless(eina_value_struct_set(&other, "k", 12));
1642 fail_unless(eina_value_struct_set(&other, "l", 13));
1643 fail_unless(eina_value_struct_set(&other, "m", 14));
1644 fail_unless(eina_value_struct_set(&other, "n", 15));
1645 fail_unless(eina_value_struct_set(&other, "o", 16));
1646 fail_unless(eina_value_struct_set(&other, "p", 17));
1647 fail_unless(eina_value_struct_set(&other, "q", 18));
1648 fail_unless(eina_value_struct_set(&other, "r", 19));
1649 fail_unless(eina_value_struct_set(&other, "s", 20));
1650 fail_unless(eina_value_struct_set(&other, "t", 21));
1651 fail_unless(eina_value_struct_set(&other, "u", 22));
1652 fail_unless(eina_value_struct_set(&other, "v", 23));
1653 fail_unless(eina_value_struct_set(&other, "x", 24));
1654
1655 fail_unless(eina_value_struct_get(&other, "a", &i));
1656 fail_unless(i == 1);
1657 fail_unless(eina_value_struct_get(&other, "b", &i));
1658 fail_unless(i == 2);
1659 fail_unless(eina_value_struct_get(&other, "c", &i));
1660 fail_unless(i == 3);
1661 fail_unless(eina_value_struct_get(&other, "d", &i));
1662 fail_unless(i == 4);
1663 fail_unless(eina_value_struct_get(&other, "e", &i));
1664 fail_unless(i == 5);
1665 fail_unless(eina_value_struct_get(&other, "f", &i));
1666 fail_unless(i == 6);
1667 fail_unless(eina_value_struct_get(&other, "g", &i));
1668 fail_unless(i == 7);
1669 fail_unless(eina_value_struct_get(&other, "h", &i));
1670 fail_unless(i == 8);
1671 fail_unless(eina_value_struct_get(&other, "i", &i));
1672 fail_unless(i == 9);
1673 fail_unless(eina_value_struct_get(&other, "j", &i));
1674 fail_unless(i == 10);
1675 fail_unless(eina_value_struct_get(&other, "k", &i));
1676 fail_unless(i == 12);
1677 fail_unless(eina_value_struct_get(&other, "l", &i));
1678 fail_unless(i == 13);
1679 fail_unless(eina_value_struct_get(&other, "m", &i));
1680 fail_unless(i == 14);
1681 fail_unless(eina_value_struct_get(&other, "n", &i));
1682 fail_unless(i == 15);
1683 fail_unless(eina_value_struct_get(&other, "o", &i));
1684 fail_unless(i == 16);
1685 fail_unless(eina_value_struct_get(&other, "p", &i));
1686 fail_unless(i == 17);
1687 fail_unless(eina_value_struct_get(&other, "q", &i));
1688 fail_unless(i == 18);
1689 fail_unless(eina_value_struct_get(&other, "r", &i));
1690 fail_unless(i == 19);
1691 fail_unless(eina_value_struct_get(&other, "s", &i));
1692 fail_unless(i == 20);
1693 fail_unless(eina_value_struct_get(&other, "t", &i));
1694 fail_unless(i == 21);
1695 fail_unless(eina_value_struct_get(&other, "u", &i));
1696 fail_unless(i == 22);
1697 fail_unless(eina_value_struct_get(&other, "v", &i));
1698 fail_unless(i == 23);
1699 fail_unless(eina_value_struct_get(&other, "x", &i));
1700 fail_unless(i == 24);
1701
1702 str = eina_value_to_string(&other);
1703 fail_unless(str != NULL);
1704 fail_unless(strcmp(str, "{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10, k: 12, l: 13, m: 14, n: 15, o: 16, p: 17, q: 18, r: 19, s: 20, t: 21, u: 22, v: 23, x: 24}") == 0);
1705 free(str);
1706
1707 eina_value_free(value);
1708 eina_shutdown();
1709}
1710END_TEST
1711
1712
1713START_TEST(eina_value_test_array_of_struct)
1714{
1715 struct myst {
1716 int a, b, c;
1717 const char *s;
1718 };
1719 const Eina_Value_Struct_Member myst_members[] = {
1720 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, a),
1721 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, b),
1722 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_INT, struct myst, c),
1723 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_STRING, struct myst, s),
1724 EINA_VALUE_STRUCT_MEMBER_SENTINEL
1725 };
1726 const Eina_Value_Struct_Desc myst_desc = {
1727 EINA_VALUE_STRUCT_DESC_VERSION,
1728 EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH,
1729 myst_members, 4, sizeof(struct myst)
1730 };
1731 Eina_Value *value;
1732 char *str;
1733 int i;
1734
1735 eina_init();
1736
1737 value = eina_value_array_new(EINA_VALUE_TYPE_STRUCT, 0);
1738 fail_unless(value != NULL);
1739
1740 for (i = 0; i < 10; i++)
1741 {
1742 Eina_Value_Struct desc;
1743 struct myst *st;
1744 char buf[64];
1745
1746 snprintf(buf, sizeof(buf), "item%02d", i);
1747 st = malloc(sizeof(struct myst));
1748 fail_unless(st != NULL);
1749 st->a = i;
1750 st->b = i * 10;
1751 st->c = i * 100;
1752 st->s = strdup(buf);
1753 fail_unless(st->s != NULL);
1754
1755 desc.desc = &myst_desc;
1756 desc.memory = st;
1757 fail_unless(eina_value_array_append(value, desc));
1758 }
1759
1760 str = eina_value_to_string(value);
1761 fail_unless(str != NULL);
1762 fail_unless(strcmp(str, "["
1763 "{a: 0, b: 0, c: 0, s: item00}, "
1764 "{a: 1, b: 10, c: 100, s: item01}, "
1765 "{a: 2, b: 20, c: 200, s: item02}, "
1766 "{a: 3, b: 30, c: 300, s: item03}, "
1767 "{a: 4, b: 40, c: 400, s: item04}, "
1768 "{a: 5, b: 50, c: 500, s: item05}, "
1769 "{a: 6, b: 60, c: 600, s: item06}, "
1770 "{a: 7, b: 70, c: 700, s: item07}, "
1771 "{a: 8, b: 80, c: 800, s: item08}, "
1772 "{a: 9, b: 90, c: 900, s: item09}"
1773 "]") == 0);
1774 free(str);
1775
1776 eina_value_free(value);
1777 eina_shutdown();
1778}
1779END_TEST
1780
1781void
1782eina_test_value(TCase *tc)
1783{
1784 tcase_add_test(tc, eina_value_test_simple);
1785 tcase_add_test(tc, eina_value_test_string);
1786 tcase_add_test(tc, eina_value_test_pvariant);
1787 tcase_add_test(tc, eina_value_test_compare);
1788 tcase_add_test(tc, eina_value_test_to_string);
1789 tcase_add_test(tc, eina_value_test_convert_char);
1790 tcase_add_test(tc, eina_value_test_convert_uchar);
1791 // TODO: other converters...
1792 tcase_add_test(tc, eina_value_test_array);
1793 tcase_add_test(tc, eina_value_test_list);
1794 tcase_add_test(tc, eina_value_test_hash);
1795 tcase_add_test(tc, eina_value_test_timeval);
1796 tcase_add_test(tc, eina_value_test_blob);
1797 tcase_add_test(tc, eina_value_test_struct);
1798 tcase_add_test(tc, eina_value_test_array_of_struct);
1799}
diff --git a/libraries/eina/src/tests/evas_list.c b/libraries/eina/src/tests/evas_list.c
index 55e301f..3df15ed 100644
--- a/libraries/eina/src/tests/evas_list.c
+++ b/libraries/eina/src/tests/evas_list.c
@@ -962,7 +962,7 @@ evas_list_sort(Evas_List *list, int size, int (*func)(void *, void *))
962 Evas_List *last; 962 Evas_List *last;
963 unsigned int list_number; 963 unsigned int list_number;
964 unsigned int middle; 964 unsigned int middle;
965 int list_size; 965 unsigned int list_size;
966 966
967 if (!list || !func) 967 if (!list || !func)
968 return NULL; 968 return NULL;
diff --git a/libraries/eina/src/tests/evas_mempool.c b/libraries/eina/src/tests/evas_mempool.c
index fbc48fa..7098214 100644
--- a/libraries/eina/src/tests/evas_mempool.c
+++ b/libraries/eina/src/tests/evas_mempool.c
@@ -56,7 +56,7 @@ _evas_mp_pool_free(Pool *p)
56} 56}
57 57
58void * 58void *
59evas_mempool_malloc(Evas_Mempool *pool, int size) 59evas_mempool_malloc(Evas_Mempool *pool, int size __UNUSED__)
60{ 60{
61#ifdef NOPOOL 61#ifdef NOPOOL
62 return malloc(size); 62 return malloc(size);