eina: add a C++ bindings to Eina @feature.

The goal of this library is to make the life of C++ developers easier
when having to manipulate Eina datatype by providing a layer to abstract
those data type in C++. Check examples for now. Documentation will come
soon, but we are pushing that rather sooner to get feedback on those bindings.

As you will notice, this library is just composed of headers. There is no .so
and we do think it is better this way. Reducing ABI and API stability issue for
applications developers who are the primary target of this binding.

Also please note that you will need to have C++11 to use this binding.

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
This commit is contained in:
Felipe Magno de Almeida 2014-02-25 17:24:32 -03:00 committed by Cedric Bail
parent ed0d7bf906
commit dc7b1cc1cf
3 changed files with 132 additions and 0 deletions

45
eina_cxx/Makefile.am Normal file
View File

@ -0,0 +1,45 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I$(top_builddir)/src/lib/efl \
-I. \
-I$(top_srcdir)/src/lib/eina \
-I$(top_builddir)/src/lib/eina \
-I$(top_srcdir)/src/lib/eina_cxx \
-I$(top_builddir)/src/lib/eina_cxx
LDADD = $(top_builddir)/src/lib/eina/libeina.la @EINA_LDFLAGS@ @USE_BOOST_SYSTEM_LIBS@ @USE_BOOST_SYSTEM_LDFLAGS@
AM_CXXFLAGS = @USE_BOOST_CPPFLAGS@
SRCS = \
eina_cxx_list_01.cc
EXTRA_PROGRAMS = \
eina_cxx_list_01 \
eina_cxx_thread_01
eina_cxx_list_01_SOURCES = \
eina_cxx_list_01.cc
eina_cxx_thread_01_SOURCES = \
eina_cxx_thread_01.cc
EXTRA_DIST = $(DATA_FILES)
examples: $(EXTRA_PROGRAMS)
clean-local:
rm -f $(EXTRA_PROGRAMS)
install-examples:
mkdir -p $(datadir)/eina/examples
$(install_sh_DATA) -c $(SRCS) $(DATA_FILES) $(datadir)/eina/examples
uninstall-local:
for f in $(SRCS) $(DATA_FILES); do \
rm -f $(datadir)/eina/examples/$$f ; \
done
if ALWAYS_BUILD_EXAMPLES
noinst_PROGRAMS = $(EXTRA_PROGRAMS)
endif

View File

@ -0,0 +1,55 @@
//Compile with:
//gcc -g eina_list_01.c -o eina_list_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.hh>
#include <iterator>
#include <algorithm>
#include <iostream>
template <typename I>
I next(I i, std::size_t n = 1u)
{
for(;n;--n)
++i;
}
int main(int argc, char **argv)
{
efl::eina::eina_init eina_init;
efl::eina::ptr_list<std::string, efl::eina::heap_copy_allocator> list;
list.push_back("tigh");
list.push_back("adar");
list.push_back("baltar");
list.push_back("roslin");
for(efl::eina::ptr_list<std::string>::const_iterator
first = list.begin(), last = list.end()
;first != last; ++first)
std::cout << *first << std::endl;
efl::eina::ptr_list<std::string>::iterator
iterator = ::next(list.begin(), 2u);
list.insert(iterator, "cain");
iterator = std::find(list.begin(), list.end(), "cain");
assert(iterator != list.end() && ::next(iterator) != list.end());
list.insert(::next(iterator), "zarek");
list.insert(list.begin(), "adama");
iterator = std::find(list.begin(), list.end(), "cain");
assert(iterator != list.end());
list.insert(iterator, "gaeta");
list.insert(::next(list.begin()), "lampkin");
for(efl::eina::ptr_list<std::string>::const_iterator
first = list.begin(), last = list.end()
;first != last; ++first)
std::cout << *first << std::endl;
}

View File

@ -0,0 +1,32 @@
//Compile with:
//gcc -g eina_list_01.c -o eina_list_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.hh>
#include <iterator>
#include <algorithm>
#include <iostream>
namespace eina = efl::eina;
void thread1(eina::mutex& m)
{
}
int main(int argc, char **argv)
{
eina::eina_init eina_init;
eina::eina_threads_init threads_init;
eina::mutex m;
eina::condition_variable c;
eina::unique_lock<eina::mutex> l(m);
eina::thread thread1(&::thread1, eina::ref(m));
thread1.join();
}