aboutsummaryrefslogtreecommitdiffstats
path: root/src/bindings/eina_cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/eina_cxx')
-rw-r--r--src/bindings/eina_cxx/Eina.hh1
-rw-r--r--src/bindings/eina_cxx/eina_accessor.hh5
-rw-r--r--src/bindings/eina_cxx/eina_array.hh250
-rw-r--r--src/bindings/eina_cxx/eina_clone_allocators.hh3
-rw-r--r--src/bindings/eina_cxx/eina_function.hh26
-rw-r--r--src/bindings/eina_cxx/eina_integer_sequence.hh2
-rw-r--r--src/bindings/eina_cxx/eina_list.hh14
-rw-r--r--src/bindings/eina_cxx/eina_logical.hh34
-rw-r--r--src/bindings/eina_cxx/eina_pp.hh8
-rw-r--r--src/bindings/eina_cxx/eina_ptrarray.hh16
-rw-r--r--src/bindings/eina_cxx/eina_ptrlist.hh79
-rw-r--r--src/bindings/eina_cxx/eina_range_types.hh58
-rw-r--r--src/bindings/eina_cxx/eina_tuple.hh60
-rw-r--r--src/bindings/eina_cxx/eina_tuple_c.hh24
-rw-r--r--src/bindings/eina_cxx/eina_type_traits.hh16
15 files changed, 536 insertions, 60 deletions
diff --git a/src/bindings/eina_cxx/Eina.hh b/src/bindings/eina_cxx/Eina.hh
index d12b0c930f..8f5462892e 100644
--- a/src/bindings/eina_cxx/Eina.hh
+++ b/src/bindings/eina_cxx/Eina.hh
@@ -22,6 +22,7 @@
#include <eina_log.hh>
#include <eina_optional.hh>
#include <eina_integer_sequence.hh>
+#include <eina_pp.hh>
/**
* @page eina_cxx_main Eina C++ (BETA)
diff --git a/src/bindings/eina_cxx/eina_accessor.hh b/src/bindings/eina_cxx/eina_accessor.hh
index b867f14248..d084918ca8 100644
--- a/src/bindings/eina_cxx/eina_accessor.hh
+++ b/src/bindings/eina_cxx/eina_accessor.hh
@@ -114,7 +114,10 @@ struct accessor_common_base
* @warning It is important to take care when using it, since the
* handle will be automatically release upon object destruction.
*/
- Eina_Accessor* native_handle() const;
+ Eina_Accessor* native_handle() const
+ {
+ return _impl;
+ }
/**
* @brief Swap content between both objects.
diff --git a/src/bindings/eina_cxx/eina_array.hh b/src/bindings/eina_cxx/eina_array.hh
index eb9e5578aa..d352de5ab7 100644
--- a/src/bindings/eina_cxx/eina_array.hh
+++ b/src/bindings/eina_cxx/eina_array.hh
@@ -32,6 +32,8 @@ public:
typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator for this container. */
typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for reverse iterator for this container. */
+ typedef typename _base_type::native_handle_type native_handle_type;
+
using _base_type::_base_type;
using _base_type::clear;
using _base_type::size;
@@ -59,6 +61,7 @@ public:
using _base_type::ciend;
using _base_type::swap;
using _base_type::max_size;
+ using _base_type::release_native_handle;
using _base_type::native_handle;
friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs)
@@ -131,6 +134,101 @@ struct _ptr_eo_array_iterator : _ptr_array_iterator<Eo>
using _base_type::native_handle;
};
+/**
+ * @internal
+ */
+struct _eo_array_access_traits : _ptr_array_access_traits
+{
+ template <typename T>
+ struct iterator
+ {
+ typedef _ptr_eo_array_iterator<T> type;
+ };
+ template <typename T>
+ struct const_iterator : iterator<T const> {};
+
+ template <typename T>
+ static T& back(Eina_Array* array)
+ {
+ return *static_cast<T*>(static_cast<void*>(array->data[size<T>(array)-1]));
+ }
+ template <typename T>
+ static T const& back(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::back<T>(const_cast<Eina_Array*>(array));
+ }
+ template <typename T>
+ static T& front(Eina_Array* array)
+ {
+ return *static_cast<T*>(static_cast<void*>(array->data[0]));
+ }
+ template <typename T>
+ static T const& front(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::front<T>(const_cast<Eina_Array*>(array));
+ }
+ template <typename T>
+ static typename iterator<T>::type begin(Eina_Array* array)
+ {
+ return _ptr_eo_array_iterator<T>(array->data);
+ }
+ template <typename T>
+ static typename iterator<T>::type end(Eina_Array* array)
+ {
+ return _ptr_eo_array_iterator<T>(array->data + size<T>(array));
+ }
+ template <typename T>
+ static typename const_iterator<T>::type begin(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::begin<T>(const_cast<Eina_Array*>(array));
+ }
+ template <typename T>
+ static typename const_iterator<T>::type end(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::end<T>(const_cast<Eina_Array*>(array));
+ }
+ template <typename T>
+ static std::reverse_iterator<typename iterator<T>::type> rbegin(Eina_Array* array)
+ {
+ return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::end<T>(array));
+ }
+ template <typename T>
+ static std::reverse_iterator<typename iterator<T>::type> rend(Eina_Array* array)
+ {
+ return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::begin<T>(array));
+ }
+ template <typename T>
+ static std::reverse_iterator<typename const_iterator<T>::type> rbegin(Eina_Array const* array)
+ {
+ return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::end<T>(array));
+ }
+ template <typename T>
+ static std::reverse_iterator<typename const_iterator<T>::type> rend(Eina_Array const* array)
+ {
+ return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::begin<T>(array));
+ }
+ template <typename T>
+ static typename const_iterator<T>::type cbegin(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::begin<T>(array);
+ }
+ template <typename T>
+ static typename const_iterator<T>::type cend(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::end<T>(array);
+ }
+ template <typename T>
+ static std::reverse_iterator<typename const_iterator<T>::type> crbegin(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::rbegin<T>(array);
+ }
+ template <typename T>
+ static std::reverse_iterator<typename const_iterator<T>::type> crend(Eina_Array const* array)
+ {
+ return _eo_array_access_traits::rend<T>(array);
+ }
+};
+
template <typename T, typename CloneAllocator>
class array<T, CloneAllocator, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type>
: ptr_array<Eo, typename std::conditional
@@ -156,7 +254,9 @@ public:
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
- explicit array(Eina_Array* handle)
+ typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */
+
+ explicit array(native_handle_type handle)
: _base_type(handle) {}
array(clone_allocator_type alloc) : _base_type(alloc) {}
array() {}
@@ -318,6 +418,7 @@ public:
using _base_type::swap;
using _base_type::max_size;
+ using _base_type::release_native_handle;
using _base_type::native_handle;
friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs)
@@ -331,7 +432,154 @@ bool operator!=(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> co
{
return !(lhs == rhs);
}
+
+template <typename T, typename Enable = void>
+class range_array : range_ptr_array<T>
+{
+ typedef range_ptr_array<T> _base_type;
+public:
+ typedef typename _base_type::value_type value_type;
+ typedef typename _base_type::reference reference;
+ typedef typename _base_type::const_reference const_reference;
+ typedef typename _base_type::const_iterator const_iterator;
+ typedef typename _base_type::iterator iterator;
+ typedef typename _base_type::pointer pointer;
+ typedef typename _base_type::const_pointer const_pointer;
+ typedef typename _base_type::size_type size_type;
+ typedef typename _base_type::difference_type difference_type;
+
+ typedef typename _base_type::reverse_iterator reverse_iterator;
+ typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
+
+ typedef typename _base_type::native_handle_type native_handle_type;
+
+ range_array& operator=(range_array&& other) = default;
+
+ using _base_type::_base_type;
+ using _base_type::size;
+ using _base_type::empty;
+ using _base_type::back;
+ using _base_type::front;
+ using _base_type::begin;
+ using _base_type::end;
+ using _base_type::rbegin;
+ using _base_type::rend;
+ using _base_type::cbegin;
+ using _base_type::cend;
+ using _base_type::crbegin;
+ using _base_type::crend;
+ using _base_type::release_native_handle;
+ using _base_type::native_handle;
+};
+
+template <typename T>
+class range_array<T, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type>
+ : range_ptr_array<Eo>
+{
+ typedef range_ptr_array<Eo> _base_type;
+ typedef range_array<T> _self_type;
+public:
+ typedef T value_type;
+ typedef value_type& reference;
+ typedef value_type const& const_reference;
+ typedef _ptr_eo_array_iterator<value_type const> const_iterator;
+ typedef _ptr_eo_array_iterator<value_type> iterator;
+ typedef value_type* pointer;
+ typedef value_type const* const_pointer;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ typedef typename _base_type::native_handle_type native_handle_type;
+
+ explicit range_array(native_handle_type handle)
+ : _base_type(handle) {}
+ range_array() {}
+ range_array(range_array<T> const& other)
+ : _base_type(other.native_handle())
+ {
+ }
+ range_array<T>& operator=(range_array<T>const& other)
+ {
+ _base_type::_handle = other._handle;
+ return *this;
+ }
+ range_array& operator=(range_array&& other) = default;
+ range_array(range_array&& other) = default;
+ using _base_type::size;
+ using _base_type::empty;
+
+ reference front()
+ {
+ return _eo_array_access_traits::front<value_type>(native_handle());
+ }
+ reference back()
+ {
+ return _eo_array_access_traits::back<value_type>(native_handle());
+ }
+ const_reference front() const { return const_cast<_self_type*>(this)->front(); }
+ const_reference back() const { return const_cast<_self_type*>(this)->back(); }
+ iterator begin()
+ {
+ return _eo_array_access_traits::begin<value_type>(native_handle());
+ }
+ iterator end()
+ {
+ return _eo_array_access_traits::end<value_type>(native_handle());
+ }
+ const_iterator begin() const
+ {
+ return const_cast<_self_type*>(this)->begin();
+ }
+ const_iterator end() const
+ {
+ return const_cast<_self_type*>(this)->end();
+ }
+ const_iterator cbegin() const
+ {
+ return begin();
+ }
+ const_iterator cend() const
+ {
+ return end();
+ }
+ reverse_iterator rbegin()
+ {
+ return _eo_array_access_traits::rbegin<value_type>(native_handle());
+ }
+ reverse_iterator rend()
+ {
+ return _eo_array_access_traits::rend<value_type>(native_handle());
+ }
+ const_reverse_iterator rbegin() const
+ {
+ return const_cast<_self_type*>(this)->rbegin();
+ }
+ const_reverse_iterator rend() const
+ {
+ return const_cast<_self_type*>(this)->rend();
+ }
+ const_reverse_iterator crbegin() const
+ {
+ return rbegin();
+ }
+ const_reverse_iterator crend() const
+ {
+ return rend();
+ }
+ using _base_type::swap;
+ using _base_type::release_native_handle;
+ using _base_type::native_handle;
+
+ friend bool operator==(range_array<T> const& rhs, range_array<T> const& lhs)
+ {
+ return rhs.size() == lhs.size() && std::equal(rhs.begin(), rhs.end(), lhs.begin());
+ }
+};
+
} }
#endif
diff --git a/src/bindings/eina_cxx/eina_clone_allocators.hh b/src/bindings/eina_cxx/eina_clone_allocators.hh
index 824d6d6ce9..76ff620f98 100644
--- a/src/bindings/eina_cxx/eina_clone_allocators.hh
+++ b/src/bindings/eina_cxx/eina_clone_allocators.hh
@@ -154,7 +154,8 @@ struct malloc_clone_allocator
template <typename T>
static void deallocate_clone(T const* p)
{
- static_assert(std::is_pod<T>::value, "malloc_clone_allocator can only be used with POD types");
+ static_assert(std::is_pod<T>::value || std::is_void<T>::value
+ , "malloc_clone_allocator can only be used with POD types");
std::free(const_cast<T*>(p));
}
};
diff --git a/src/bindings/eina_cxx/eina_function.hh b/src/bindings/eina_cxx/eina_function.hh
new file mode 100644
index 0000000000..cef6da5a43
--- /dev/null
+++ b/src/bindings/eina_cxx/eina_function.hh
@@ -0,0 +1,26 @@
+#ifndef EFL_EINA_FUNCTION_HH
+#define EFL_EINA_FUNCTION_HH
+
+namespace efl { namespace eina { namespace _mpl {
+
+template <typename T>
+struct function_params;
+
+template <typename R, typename... P>
+struct function_params<R(*)(P...)>
+{
+ typedef std::tuple<P...> type;
+};
+
+template <typename T>
+struct function_return;
+
+template <typename R, typename... P>
+struct function_return<R(*)(P...)>
+{
+ typedef R type;
+};
+
+} } }
+
+#endif
diff --git a/src/bindings/eina_cxx/eina_integer_sequence.hh b/src/bindings/eina_cxx/eina_integer_sequence.hh
index 854bb8f3d0..f99c871c34 100644
--- a/src/bindings/eina_cxx/eina_integer_sequence.hh
+++ b/src/bindings/eina_cxx/eina_integer_sequence.hh
@@ -1,6 +1,8 @@
#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH
#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH
+#include <cstdlib>
+
/**
* @addtogroup Eina_Cxx_Data_Types_Group
*
diff --git a/src/bindings/eina_cxx/eina_list.hh b/src/bindings/eina_cxx/eina_list.hh
index 760ada3963..1221867c7b 100644
--- a/src/bindings/eina_cxx/eina_list.hh
+++ b/src/bindings/eina_cxx/eina_list.hh
@@ -190,6 +190,8 @@ public:
typedef typename _base_type::reverse_iterator reverse_iterator;
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
+ using _base_type::native_handle_type;
+
list& operator=(list&& other) = default;
list(list&& other) = default;
list() = default;
@@ -224,6 +226,7 @@ public:
using _base_type::max_size;
using _base_type::native_handle;
using _base_type::accessor;
+ using _base_type::release_native_handle;
};
template <typename T, typename CloneAllocator>
@@ -251,7 +254,9 @@ public:
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- explicit list(Eina_List* handle)
+ using _base_type::native_handle_type;
+
+ explicit list(typename _self_type::native_handle_type handle)
: _base_type(handle) {}
list(clone_allocator_type alloc) : _base_type(alloc) {}
list() {}
@@ -295,6 +300,7 @@ public:
using _base_type::get_clone_allocator;
using _base_type::pop_back;
using _base_type::pop_front;
+ using _base_type::release_native_handle;
void push_back(const_reference w)
{
@@ -464,6 +470,8 @@ public:
typedef typename _base_type::reverse_iterator reverse_iterator;
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
+ using _base_type::native_handle_type;
+
using _base_type::_base_type;
using _base_type::size;
using _base_type::empty;
@@ -501,9 +509,9 @@ public:
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef typename _base_type::native_handle_type native_handle_type;
+ using _base_type::native_handle_type;
- explicit range_list(native_handle_type handle)
+ explicit range_list(typename _self_type::native_handle_type handle)
: _base_type(handle) {}
range_list() {}
range_list(range_list<T> const& other)
diff --git a/src/bindings/eina_cxx/eina_logical.hh b/src/bindings/eina_cxx/eina_logical.hh
new file mode 100644
index 0000000000..d53d3541ad
--- /dev/null
+++ b/src/bindings/eina_cxx/eina_logical.hh
@@ -0,0 +1,34 @@
+#ifndef EFL_EINA_LOGICAL_HH
+#define EFL_EINA_LOGICAL_HH
+
+#include <type_traits>
+
+namespace efl { namespace eina { namespace _mpl {
+
+template <bool... N>
+struct or_;
+
+template <>
+struct or_<> : std::integral_constant<bool, false> {};
+
+template <bool B>
+struct or_<B> : std::integral_constant<bool, B> {};
+
+template <bool B1, bool B2, bool... Bs>
+struct or_<B1, B2, Bs...> : std::integral_constant<bool, B1 || B2 || or_<Bs...>::value> {};
+
+template <bool... N>
+struct and_;
+
+template <>
+struct and_<> : std::integral_constant<bool, true> {};
+
+template <bool B>
+struct and_<B> : std::integral_constant<bool, B> {};
+
+template <bool B1, bool B2, bool... Bs>
+struct and_<B1, B2, Bs...> : std::integral_constant<bool, B1 && B2 && and_<Bs...>::value> {};
+
+} } }
+
+#endif
diff --git a/src/bindings/eina_cxx/eina_pp.hh b/src/bindings/eina_cxx/eina_pp.hh
new file mode 100644
index 0000000000..22a6a22ef7
--- /dev/null
+++ b/src/bindings/eina_cxx/eina_pp.hh
@@ -0,0 +1,8 @@
+
+#ifndef EINA_PP_HH
+#define EINA_PP_HH
+
+#define EINA_STRINGIZE_IMPL(x) #x
+#define EINA_STRINGIZE(x) EINA_STRINGIZE_IMPL(x)
+
+#endif
diff --git a/src/bindings/eina_cxx/eina_ptrarray.hh b/src/bindings/eina_cxx/eina_ptrarray.hh
index 2f40627ce9..f47202ebb5 100644
--- a/src/bindings/eina_cxx/eina_ptrarray.hh
+++ b/src/bindings/eina_cxx/eina_ptrarray.hh
@@ -295,10 +295,12 @@ struct range_ptr_array : _range_template<T, _ptr_array_access_traits>
typedef _range_template<T, _ptr_array_access_traits> _base_type; /**< Type for the base class. */
typedef typename _base_type::value_type value_type; /**< The type of each element. */
+ typedef typename _base_type::native_handle_type native_handle_type;
+
/**
* @brief Creates a range from a native Eina array handle.
*/
- range_ptr_array(Eina_Array* array)
+ range_ptr_array(native_handle_type array)
: _base_type(array)
{}
@@ -391,7 +393,7 @@ struct _ptr_array_common_base
/**
* @internal
*/
- T* _new_clone(T const& a)
+ T* _new_clone(typename container_value_type<T>::type const& a)
{
return _get_clone_allocator().allocate_clone(a);
}
@@ -402,6 +404,7 @@ struct _ptr_array_common_base
struct _ptr_array_impl : CloneAllocator
{
_ptr_array_impl() : _array( ::eina_array_new(32u) ) {}
+ _ptr_array_impl(Eina_Array* array) : _array(array) {}
_ptr_array_impl(CloneAllocator allocator)
: clone_allocator_type(allocator), _array( ::eina_array_new(32u)) {}
@@ -449,6 +452,8 @@ public:
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
+ typedef Eina_Array* native_handle_type;
+
/**
* @brief Default constructor. Create an empty array.
*
@@ -1210,6 +1215,13 @@ public:
*/
size_type max_size() const { return -1; }
+ Eina_Array* release_native_handle()
+ {
+ Eina_Array* tmp = this->_impl._array;
+ this->_impl._array = ::eina_array_new(32u);
+ return tmp;
+ }
+
/**
* @brief Get a handle for the wrapped Eina_Array.
* @return Handle for the native Eina array.
diff --git a/src/bindings/eina_cxx/eina_ptrlist.hh b/src/bindings/eina_cxx/eina_ptrlist.hh
index 2f18d10ffb..f7254b1ef2 100644
--- a/src/bindings/eina_cxx/eina_ptrlist.hh
+++ b/src/bindings/eina_cxx/eina_ptrlist.hh
@@ -9,6 +9,7 @@
#include <eina_eo_concrete_fwd.hh>
#include <eina_iterator.hh>
#include <eina_throw.hh>
+#include <eina_range_types.hh>
#include <memory>
#include <iterator>
@@ -370,7 +371,7 @@ struct _ptr_list_common_base
/**
* @internal
*/
- T* _new_clone(T const& a)
+ T* _new_clone(typename container_value_type<T>::type const& a)
{
return _get_clone_allocator().allocate_clone(a);
}
@@ -413,11 +414,12 @@ class ptr_list : protected _ptr_list_common_base<T, CloneAllocator>
{
typedef _ptr_list_common_base<T, CloneAllocator> _base_type; /**< Type for the base class. */
public:
- typedef T value_type; /**< The type of each element. */
- typedef T& reference; /**< Type for a reference to an element. */
- typedef T const& const_reference; /**< Type for a constant reference to an element. */
- typedef _ptr_list_iterator<T const> const_iterator; /**< Type for a iterator for this container. */
- typedef _ptr_list_iterator<T> iterator; /**< Type for a constant iterator for this container. */
+ typedef typename container_value_type<T>::type
+ value_type; /**< The type of each element. */
+ typedef value_type& reference; /**< Type for a reference to an element. */
+ typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
+ typedef _ptr_list_iterator<value_type const> const_iterator; /**< Type for a iterator for this container. */
+ typedef _ptr_list_iterator<value_type> iterator; /**< Type for a constant iterator for this container. */
typedef T* pointer; /**< Type for a pointer to an element. */
typedef T const* const_pointer; /**< Type for a constant pointer for an element. */
typedef std::size_t size_type; /**< Type for size information. */
@@ -427,6 +429,8 @@ public:
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
+ typedef Eina_List* native_handle_type;
+
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
/**
@@ -554,7 +558,7 @@ public:
*/
std::size_t size() const
{
- return _ptr_list_access_traits::size<T>(this->_impl._list);
+ return _ptr_list_access_traits::size<value_type>(this->_impl._list);
}
/**
@@ -566,7 +570,7 @@ public:
*/
bool empty() const
{
- return _ptr_list_access_traits::empty<T>(this->_impl._list);
+ return _ptr_list_access_traits::empty<value_type>(this->_impl._list);
}
/**
@@ -940,7 +944,7 @@ public:
*/
value_type& back()
{
- return _ptr_list_access_traits::back<T>(this->_impl._list);
+ return _ptr_list_access_traits::back<value_type>(this->_impl._list);
}
/**
@@ -952,7 +956,7 @@ public:
*/
value_type const& back() const
{
- return _ptr_list_access_traits::back<T>(this->_impl._list);
+ return _ptr_list_access_traits::back<value_type>(this->_impl._list);
}
/**
@@ -961,7 +965,7 @@ public:
*/
value_type& front()
{
- return _ptr_list_access_traits::front<T>(this->_impl._list);
+ return _ptr_list_access_traits::front<value_type>(this->_impl._list);
}
/**
@@ -973,7 +977,7 @@ public:
*/
value_type const& front() const
{
- return _ptr_list_access_traits::front<T>(this->_impl._list);
+ return _ptr_list_access_traits::front<value_type>(this->_impl._list);
}
/**
@@ -985,7 +989,7 @@ public:
*/
const_iterator begin() const
{
- return _ptr_list_access_traits::cbegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
}
/**
@@ -997,7 +1001,7 @@ public:
*/
const_iterator end() const
{
- return _ptr_list_access_traits::cend<T>(this->_impl._list);
+ return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
}
/**
@@ -1010,7 +1014,7 @@ public:
*/
iterator begin()
{
- return _ptr_list_access_traits::begin<T>(this->_impl._list);
+ return _ptr_list_access_traits::begin<value_type>(this->_impl._list);
}
/**
@@ -1026,7 +1030,7 @@ public:
*/
iterator end()
{
- return _ptr_list_access_traits::end<T>(this->_impl._list);
+ return _ptr_list_access_traits::end<value_type>(this->_impl._list);
}
/**
@@ -1038,7 +1042,7 @@ public:
*/
const_reverse_iterator rbegin() const
{
- return _ptr_list_access_traits::rbegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
}
/**
@@ -1050,7 +1054,7 @@ public:
*/
const_reverse_iterator rend() const
{
- return _ptr_list_access_traits::rend<T>(this->_impl._list);
+ return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
}
/**
@@ -1063,7 +1067,7 @@ public:
*/
reverse_iterator rbegin()
{
- return _ptr_list_access_traits::rbegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
}
/**
@@ -1080,7 +1084,7 @@ public:
*/
reverse_iterator rend()
{
- return _ptr_list_access_traits::rend<T>(this->_impl._list);
+ return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
}
/**
@@ -1093,7 +1097,7 @@ public:
*/
const_iterator cbegin() const
{
- return _ptr_list_access_traits::cbegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
}
/**
@@ -1106,7 +1110,7 @@ public:
*/
const_iterator cend() const
{
- return _ptr_list_access_traits::cend<T>(this->_impl._list);
+ return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
}
/**
@@ -1119,7 +1123,7 @@ public:
*/
const_reverse_iterator crbegin() const
{
- return _ptr_list_access_traits::crbegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::crbegin<value_type>(this->_impl._list);
}
/**
@@ -1132,7 +1136,7 @@ public:
*/
const_reverse_iterator crend() const
{
- return _ptr_list_access_traits::crend<T>(this->_impl._list);
+ return _ptr_list_access_traits::crend<value_type>(this->_impl._list);
}
/**
@@ -1143,9 +1147,9 @@ public:
* the first element of the list. If the list is empty the returned
* iterator is the same as the one returned by @ref iend().
*/
- eina::iterator<T> ibegin()
+ eina::iterator<value_type> ibegin()
{
- return _ptr_list_access_traits::ibegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
}
/**
@@ -1160,9 +1164,9 @@ public:
* @note Note that attempting to access this position causes undefined
* behavior.
*/
- eina::iterator<T> iend()
+ eina::iterator<value_type> iend()
{
- return _ptr_list_access_traits::iend<T>(this->_impl._list);
+ return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
}
/**
@@ -1174,7 +1178,7 @@ public:
*/
eina::iterator<T const> ibegin() const
{
- return _ptr_list_access_traits::ibegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
}
/**
@@ -1186,7 +1190,7 @@ public:
*/
eina::iterator<T const> iend() const
{
- return _ptr_list_access_traits::iend<T>(this->_impl._list);
+ return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
}
/**
@@ -1199,7 +1203,7 @@ public:
*/
eina::iterator<T const> cibegin() const
{
- return _ptr_list_access_traits::cibegin<T>(this->_impl._list);
+ return _ptr_list_access_traits::cibegin<value_type>(this->_impl._list);
}
/**
@@ -1212,7 +1216,7 @@ public:
*/
eina::iterator<T const> ciend() const
{
- return _ptr_list_access_traits::ciend<T>(this->_impl._list);
+ return _ptr_list_access_traits::ciend<value_type>(this->_impl._list);
}
/**
@@ -1230,6 +1234,13 @@ public:
*/
size_type max_size() const { return -1; }
+ Eina_List* release_native_handle()
+ {
+ Eina_List* tmp = this->_impl._list;
+ this->_impl._list = 0;
+ return tmp;
+ }
+
/**
* @brief Get a handle for the wrapped @c Eina_List.
* @return Handle for the native Eina list.
@@ -1275,9 +1286,9 @@ public:
* @brief Get a @ref eina::accessor for the list.
* @return <tt>eina::accessor</tt> to the list.
*/
- eina::accessor<T> accessor()
+ eina::accessor<value_type> accessor()
{
- return eina::accessor<T>(eina_list_accessor_new(this->_impl._list));
+ return eina::accessor<value_type>(eina_list_accessor_new(this->_impl._list));
}
};
diff --git a/src/bindings/eina_cxx/eina_range_types.hh b/src/bindings/eina_cxx/eina_range_types.hh
index 844e2ef4cc..313ca05cd9 100644
--- a/src/bindings/eina_cxx/eina_range_types.hh
+++ b/src/bindings/eina_cxx/eina_range_types.hh
@@ -22,11 +22,12 @@ namespace efl { namespace eina {
template <typename T, typename Traits>
struct _const_range_template
{
- typedef typename Traits::template const_iterator<T>::type const_iterator; /**< Type for constant iterator to the range. */
- typedef typename Traits::template iterator<T>::type iterator; /**< Type for iterator to the range. */
- typedef T value_type; /**< The type of each element. */
- typedef T& reference; /**< Type for a reference to an element. */
- typedef T const& const_reference; /**< Type for a constant reference to an element. */
+ typedef typename container_value_type<T>::type
+ value_type; /**< The type of each element. */
+ typedef typename Traits::template const_iterator<value_type>::type const_iterator; /**< Type for constant iterator to the range. */
+ typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for iterator to the range. */
+ typedef value_type& reference; /**< Type for a reference to an element. */
+ typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
typedef T* pointer; /**< Type for a pointer to an element. */
typedef T const* const_pointer; /**< Type for a constant pointer to an element. */
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator to the range. */
@@ -50,6 +51,17 @@ struct _const_range_template
: _handle(handle) {}
/**
+ * @brief Release the handle of the native Eina container.
+ * @return Handle for the native Eina container.
+ */
+ native_handle_type release_native_handle()
+ {
+ auto h = _handle;
+ _handle = nullptr;
+ return h;
+ }
+
+ /**
* @brief Get a constant handle for the native Eina container.
* @return Constant handle for the native Eina container.
*/
@@ -241,10 +253,13 @@ void swap(_const_range_template<T, Traits>& lhs, _const_range_template<T, Traits
template <typename T, typename Traits>
struct _mutable_range_template : _const_range_template<T, Traits>
{
- typedef T value_type; /**< The type of each element. */
- typedef typename Traits::template iterator<T>::type iterator; /**< Type for a iterator to the range. */
+ typedef typename container_value_type<T>::type
+ value_type; /**< The type of each element. */
+ typedef value_type& reference_type;
+ typedef value_type const& const_reference_type;
+ typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for a iterator to the range. */
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for constant reverse iterator to the range. */
- typedef typename Traits::template native_handle<T>::type native_handle_type; /**< Type for the native handle of the container. */
+ typedef typename Traits::template native_handle<value_type>::type native_handle_type; /**< Type for the native handle of the container. */
typedef _const_range_template<T, Traits> _base_type; /**< Type for the base class. */
/**
@@ -254,6 +269,17 @@ struct _mutable_range_template : _const_range_template<T, Traits>
: _base_type(handle) {}
/**
+ * @brief Release the handle of the native Eina container.
+ * @return Handle for the native Eina container.
+ */
+ native_handle_type release_native_handle()
+ {
+ auto h = _handle;
+ _handle = nullptr;
+ return h;
+ }
+
+ /**
* @brief Get a constant handle for the native Eina container.
* @return Constant handle for the native Eina container.
*/
@@ -266,7 +292,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
* @brief Get a reference to the last element.
* @return Reference to the last element of the range.
*/
- value_type& back() const
+ reference_type back() const
{
return Traits::template back<value_type>(native_handle());
}
@@ -275,7 +301,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
* @brief Get a reference to the first element.
* @return Reference to the first element of the range.
*/
- value_type& front() const
+ reference_type front() const
{
return Traits::template front<value_type>(native_handle());
}
@@ -355,11 +381,12 @@ protected:
template <typename T, typename Traits>
struct _range_template : private std::conditional
<std::is_const<T>::value
- , _const_range_template<typename std::remove_const<T>::type, Traits>
- , _mutable_range_template<T, Traits> >::type
+ , _const_range_template<typename nonconst_container_value_type<T>::type, Traits>
+ , _mutable_range_template<typename nonconst_container_value_type<T>::type, Traits>
+ >::type
{
typedef std::integral_constant<bool, !std::is_const<T>::value> is_mutable; /**< Type that specifies if the elements can be modified. */
- typedef typename std::remove_const<T>::type value_type; /**< The type of each element. */
+ typedef typename nonconst_container_value_type<T>::type value_type; /**< The type of each element. */
typedef typename std::conditional<is_mutable::value, _mutable_range_template<value_type, Traits>
, _const_range_template<value_type, Traits> >::type _base_type; /**< Type for the base class. */
typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */
@@ -368,9 +395,9 @@ struct _range_template : private std::conditional
typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
typedef value_type* pointer; /**< Type for a pointer to an element. */
typedef value_type const* const_pointer; /**< Type for a constant pointer to an element. */
- typedef typename Traits::template const_iterator<T>::type const_iterator; /**< Type for constant iterator to the range. */
+ typedef typename Traits::template const_iterator<value_type>::type const_iterator; /**< Type for constant iterator to the range. */
typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for constant reverse iterator to the range. */
- typedef typename Traits::template iterator<T>::type iterator; /**< Type for iterator to the range. */
+ typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for iterator to the range. */
typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator to the range. */
typedef typename _base_type::size_type size_type; /**< Type for size information. */
typedef typename _base_type::difference_type difference_type; /**< Type to represent the distance between two iterators. */
@@ -388,6 +415,7 @@ struct _range_template : private std::conditional
: _base_type(handle)
{}
+ using _base_type::release_native_handle;
using _base_type::native_handle;
using _base_type::back;
using _base_type::front;
diff --git a/src/bindings/eina_cxx/eina_tuple.hh b/src/bindings/eina_cxx/eina_tuple.hh
index f0f22d9cae..45545c3702 100644
--- a/src/bindings/eina_cxx/eina_tuple.hh
+++ b/src/bindings/eina_cxx/eina_tuple.hh
@@ -1,6 +1,11 @@
#ifndef EFL_EINA_EINA_TUPLE_HH_
#define EFL_EINA_EINA_TUPLE_HH_
+#include <eina_integer_sequence.hh>
+#include <eina_logical.hh>
+
+#include <tuple>
+
namespace efl { namespace eina { namespace _mpl {
template <typename A, typename... Args>
@@ -21,15 +26,64 @@ struct push_front<C<Args...>, AArgs...>
typedef C<Args..., AArgs...> type;
};
-template <typename A>
+template <typename A, std::size_t N = 1>
struct pop_front;
-
+
template <template <typename...> class C, typename T, typename... Args>
-struct pop_front<C<T, Args...> >
+struct pop_front<C<T, Args...>, 1>
{
typedef C<Args...> type;
};
+template <typename A, std::size_t N>
+struct pop_front : pop_front<typename pop_front<A, 1>::type, N-1>
+{
+};
+
+template <typename T, typename F, std::size_t... I>
+void for_each_impl(T&& t, F&& f, eina::index_sequence<I...>)
+{
+ std::initializer_list<int> l = { (f(std::get<I>(t)), 0)...};
+ static_cast<void>(l);
+}
+
+template <typename T, typename F>
+void for_each(T&& t, F&& f)
+{
+ _mpl::for_each_impl(t, f, eina::make_index_sequence
+ <std::tuple_size<typename std::remove_reference<T>::type>::value>());
+}
+
+template <typename T, typename Transform>
+struct tuple_transform;
+
+template <typename...T, typename Transform>
+struct tuple_transform<std::tuple<T...>, Transform>
+{
+ typedef std::tuple<typename Transform::template apply<T>::type...> type;
+};
+
+template <typename T, typename Tuple>
+struct tuple_contains;
+
+
+
+template <typename T, typename...Ts>
+struct tuple_contains<T, std::tuple<Ts...> >
+ : _mpl::or_<std::is_same<T, Ts>::value...>
+{
+};
+
+template <typename T, typename Tuple>
+struct tuple_find : std::integral_constant<int, -1> {};
+
+template <typename T, typename... Ts>
+struct tuple_find<T, std::tuple<T, Ts...> > : std::integral_constant<std::size_t, 0> {};
+
+template <typename T, typename T1, typename... Ts>
+struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant
+ <std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {};
+
} } }
#endif
diff --git a/src/bindings/eina_cxx/eina_tuple_c.hh b/src/bindings/eina_cxx/eina_tuple_c.hh
new file mode 100644
index 0000000000..64d67c49a9
--- /dev/null
+++ b/src/bindings/eina_cxx/eina_tuple_c.hh
@@ -0,0 +1,24 @@
+#ifndef EFL_EINA_EINA_TUPLE_C_HH_
+#define EFL_EINA_EINA_TUPLE_C_HH_
+
+#include <tuple>
+
+namespace efl { namespace eina { namespace _mpl {
+
+template <typename T, T... Ts>
+using tuple_c = std::tuple<std::integral_constant<T, Ts>...>;
+
+template <typename T, T... Ts>
+constexpr std::size_t tuple_c_size(tuple_c<T, Ts...> const&)
+{
+ return sizeof...(Ts);
+}
+
+constexpr std::size_t tuple_c_size(std::tuple<> const&)
+{
+ return 0;
+}
+
+} } }
+
+#endif
diff --git a/src/bindings/eina_cxx/eina_type_traits.hh b/src/bindings/eina_cxx/eina_type_traits.hh
index 9e8628ad90..ff8bfbbff9 100644
--- a/src/bindings/eina_cxx/eina_type_traits.hh
+++ b/src/bindings/eina_cxx/eina_type_traits.hh
@@ -64,6 +64,22 @@ struct if_ : if_c<U::value, T, F>
{
};
+template <typename T>
+struct container_value_type
+{
+ typedef typename std::conditional<
+ std::is_void<T>::value
+ , T*, T>::type type;
+};
+
+template <typename T>
+struct nonconst_container_value_type
+{
+ typedef typename std::conditional<
+ std::is_void<T>::value
+ , T*, typename std::remove_const<T>::type>::type type;
+};
+
/**
* @}
*/