summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-09-01 15:08:49 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-12-23 23:59:40 -0200
commita3db1dddd3ba67c81118f7f2c0bc753dc8aac551 (patch)
tree233ee1be7bfa299bff560207135d20940c4e411f /src/bindings
parent1a3cb45f1cc7fdf8d481879e6bd7349d9cb0b3fa (diff)
efl-js: JavaScript Eolian binding
To configure efl sources with bindings to use in nodejs add ––with-js=nodejs in configure flags to generate node files $ configure --with-js=nodejs and compile normally with: $ make $ make install To use, you have to require efl: efl = require('efl') The bindings is divided in two parts: generated and manually written. The generation uses the Eolian library for parsing Eo files and generate C++ code that is compiled against V8 interpreter library to create a efl.node file that can be required in a node.js instance. @feature
Diffstat (limited to 'src/bindings')
-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
-rw-r--r--src/bindings/eldbus_cxx/eldbus_freedesktop.hh1
-rw-r--r--src/bindings/eo_cxx/eo_concrete.hh7
-rw-r--r--src/bindings/js/ecore_js/Ecore_Js.hh58
-rw-r--r--src/bindings/js/ecore_js/ecore_js_animator.cc608
-rw-r--r--src/bindings/js/ecore_js/ecore_js_event.cc772
-rw-r--r--src/bindings/js/ecore_js/ecore_js_idle.cc294
-rw-r--r--src/bindings/js/ecore_js/ecore_js_init.cc76
-rw-r--r--src/bindings/js/ecore_js/ecore_js_job.cc83
-rw-r--r--src/bindings/js/ecore_js/ecore_js_mainloop.cc207
-rw-r--r--src/bindings/js/ecore_js/ecore_js_poller.cc190
-rw-r--r--src/bindings/js/ecore_js/ecore_js_throttle.cc63
-rw-r--r--src/bindings/js/ecore_js/ecore_js_timer.cc232
-rw-r--r--src/bindings/js/ecore_js/ecore_js_timer.hh38
-rw-r--r--src/bindings/js/efl_js/Efl_Js.hh30
-rw-r--r--src/bindings/js/efl_js/efl_js.cc241
-rw-r--r--src/bindings/js/eina_js/Eina_Js.hh50
-rw-r--r--src/bindings/js/eina_js/eina_js_accessor.cc34
-rw-r--r--src/bindings/js/eina_js/eina_js_accessor.hh87
-rw-r--r--src/bindings/js/eina_js/eina_js_array.hh119
-rw-r--r--src/bindings/js/eina_js/eina_js_compatibility.cc12
-rw-r--r--src/bindings/js/eina_js/eina_js_compatibility.hh918
-rw-r--r--src/bindings/js/eina_js/eina_js_container.cc495
-rw-r--r--src/bindings/js/eina_js/eina_js_container.hh351
-rw-r--r--src/bindings/js/eina_js/eina_js_error.cc24
-rw-r--r--src/bindings/js/eina_js/eina_js_error.hh25
-rw-r--r--src/bindings/js/eina_js/eina_js_get_value.hh449
-rw-r--r--src/bindings/js/eina_js/eina_js_get_value_from_c.hh261
-rw-r--r--src/bindings/js/eina_js/eina_js_iterator.cc32
-rw-r--r--src/bindings/js/eina_js/eina_js_iterator.hh81
-rw-r--r--src/bindings/js/eina_js/eina_js_list.hh132
-rw-r--r--src/bindings/js/eina_js/eina_js_log.cc742
-rw-r--r--src/bindings/js/eina_js/eina_js_log.hh133
-rw-r--r--src/bindings/js/eina_js/eina_js_node.hh14
-rw-r--r--src/bindings/js/eina_js/eina_js_value.cc132
-rw-r--r--src/bindings/js/eina_js/eina_js_value.hh142
-rw-r--r--src/bindings/js/eio_js/Eio_Js.hh44
-rw-r--r--src/bindings/js/eio_js/eio_js.cc1756
-rw-r--r--src/bindings/js/eldbus_js/Eldbus_Js.hh48
-rw-r--r--src/bindings/js/eldbus_js/eldbus_js_connection.cc543
-rw-r--r--src/bindings/js/eldbus_js/eldbus_js_core.cc183
-rw-r--r--src/bindings/js/eldbus_js/eldbus_js_message.cc103
-rw-r--r--src/bindings/js/eldbus_js/eldbus_js_object_mapper.cc100
-rw-r--r--src/bindings/js/eldbus_js/eldbus_js_util.hh836
-rw-r--r--src/bindings/js/eo_js/Eo_Js.hh15
-rw-r--r--src/bindings/js/eo_js/eo_js_call_function.hh288
-rw-r--r--src/bindings/js/eo_js/eo_js_construct_from_eo.hh39
-rw-r--r--src/bindings/js/eo_js/eo_js_constructor.hh136
-rw-r--r--src/bindings/js/eo_js/eo_js_direction.hh12
-rw-r--r--src/bindings/js/eo_js/eo_js_event.hh126
-rw-r--r--src/bindings/js/eo_js/eo_js_namespace.hh24
-rw-r--r--src/bindings/js/eo_js/eo_js_struct.hh106
-rw-r--r--src/bindings/js/ethumb_js/Ethumb_Js.hh48
-rw-r--r--src/bindings/js/ethumb_js/ethumb_js_client.cc571
68 files changed, 12646 insertions, 61 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 @@
22#include <eina_log.hh> 22#include <eina_log.hh>
23#include <eina_optional.hh> 23#include <eina_optional.hh>
24#include <eina_integer_sequence.hh> 24#include <eina_integer_sequence.hh>
25#include <eina_pp.hh>
25 26
26/** 27/**
27 * @page eina_cxx_main Eina C++ (BETA) 28 * @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
114 * @warning It is important to take care when using it, since the 114 * @warning It is important to take care when using it, since the
115 * handle will be automatically release upon object destruction. 115 * handle will be automatically release upon object destruction.
116 */ 116 */
117 Eina_Accessor* native_handle() const; 117 Eina_Accessor* native_handle() const
118 {
119 return _impl;
120 }
118 121
119 /** 122 /**
120 * @brief Swap content between both objects. 123 * @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:
32 typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator for this container. */ 32 typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator for this container. */
33 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for reverse iterator for this container. */ 33 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for reverse iterator for this container. */
34 34
35 typedef typename _base_type::native_handle_type native_handle_type;
36
35 using _base_type::_base_type; 37 using _base_type::_base_type;
36 using _base_type::clear; 38 using _base_type::clear;
37 using _base_type::size; 39 using _base_type::size;
@@ -59,6 +61,7 @@ public:
59 using _base_type::ciend; 61 using _base_type::ciend;
60 using _base_type::swap; 62 using _base_type::swap;
61 using _base_type::max_size; 63 using _base_type::max_size;
64 using _base_type::release_native_handle;
62 using _base_type::native_handle; 65 using _base_type::native_handle;
63 66
64 friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs) 67 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>
131 using _base_type::native_handle; 134 using _base_type::native_handle;
132}; 135};
133 136
137/**
138 * @internal
139 */
140struct _eo_array_access_traits : _ptr_array_access_traits
141{
142 template <typename T>
143 struct iterator
144 {
145 typedef _ptr_eo_array_iterator<T> type;
146 };
147 template <typename T>
148 struct const_iterator : iterator<T const> {};
149
150 template <typename T>
151 static T& back(Eina_Array* array)
152 {
153 return *static_cast<T*>(static_cast<void*>(array->data[size<T>(array)-1]));
154 }
155 template <typename T>
156 static T const& back(Eina_Array const* array)
157 {
158 return _eo_array_access_traits::back<T>(const_cast<Eina_Array*>(array));
159 }
160 template <typename T>
161 static T& front(Eina_Array* array)
162 {
163 return *static_cast<T*>(static_cast<void*>(array->data[0]));
164 }
165 template <typename T>
166 static T const& front(Eina_Array const* array)
167 {
168 return _eo_array_access_traits::front<T>(const_cast<Eina_Array*>(array));
169 }
170 template <typename T>
171 static typename iterator<T>::type begin(Eina_Array* array)
172 {
173 return _ptr_eo_array_iterator<T>(array->data);
174 }
175 template <typename T>
176 static typename iterator<T>::type end(Eina_Array* array)
177 {
178 return _ptr_eo_array_iterator<T>(array->data + size<T>(array));
179 }
180 template <typename T>
181 static typename const_iterator<T>::type begin(Eina_Array const* array)
182 {
183 return _eo_array_access_traits::begin<T>(const_cast<Eina_Array*>(array));
184 }
185 template <typename T>
186 static typename const_iterator<T>::type end(Eina_Array const* array)
187 {
188 return _eo_array_access_traits::end<T>(const_cast<Eina_Array*>(array));
189 }
190 template <typename T>
191 static std::reverse_iterator<typename iterator<T>::type> rbegin(Eina_Array* array)
192 {
193 return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::end<T>(array));
194 }
195 template <typename T>
196 static std::reverse_iterator<typename iterator<T>::type> rend(Eina_Array* array)
197 {
198 return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::begin<T>(array));
199 }
200 template <typename T>
201 static std::reverse_iterator<typename const_iterator<T>::type> rbegin(Eina_Array const* array)
202 {
203 return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::end<T>(array));
204 }
205 template <typename T>
206 static std::reverse_iterator<typename const_iterator<T>::type> rend(Eina_Array const* array)
207 {
208 return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::begin<T>(array));
209 }
210 template <typename T>
211 static typename const_iterator<T>::type cbegin(Eina_Array const* array)
212 {
213 return _eo_array_access_traits::begin<T>(array);
214 }
215 template <typename T>
216 static typename const_iterator<T>::type cend(Eina_Array const* array)
217 {
218 return _eo_array_access_traits::end<T>(array);
219 }
220 template <typename T>
221 static std::reverse_iterator<typename const_iterator<T>::type> crbegin(Eina_Array const* array)
222 {
223 return _eo_array_access_traits::rbegin<T>(array);
224 }
225 template <typename T>
226 static std::reverse_iterator<typename const_iterator<T>::type> crend(Eina_Array const* array)
227 {
228 return _eo_array_access_traits::rend<T>(array);
229 }
230};
231
134template <typename T, typename CloneAllocator> 232template <typename T, typename CloneAllocator>
135class array<T, CloneAllocator, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type> 233class array<T, CloneAllocator, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type>
136 : ptr_array<Eo, typename std::conditional 234 : ptr_array<Eo, typename std::conditional
@@ -156,7 +254,9 @@ public:
156 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */ 254 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
157 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */ 255 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
158 256
159 explicit array(Eina_Array* handle) 257 typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */
258
259 explicit array(native_handle_type handle)
160 : _base_type(handle) {} 260 : _base_type(handle) {}
161 array(clone_allocator_type alloc) : _base_type(alloc) {} 261 array(clone_allocator_type alloc) : _base_type(alloc) {}
162 array() {} 262 array() {}
@@ -318,6 +418,7 @@ public:
318 418
319 using _base_type::swap; 419 using _base_type::swap;
320 using _base_type::max_size; 420 using _base_type::max_size;
421 using _base_type::release_native_handle;
321 using _base_type::native_handle; 422 using _base_type::native_handle;
322 423
323 friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs) 424 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
331{ 432{
332 return !(lhs == rhs); 433 return !(lhs == rhs);
333} 434}
435
436template <typename T, typename Enable = void>
437class range_array : range_ptr_array<T>
438{
439 typedef range_ptr_array<T> _base_type;
440public:
441 typedef typename _base_type::value_type value_type;
442 typedef typename _base_type::reference reference;
443 typedef typename _base_type::const_reference const_reference;
444 typedef typename _base_type::const_iterator const_iterator;
445 typedef typename _base_type::iterator iterator;
446 typedef typename _base_type::pointer pointer;
447 typedef typename _base_type::const_pointer const_pointer;
448 typedef typename _base_type::size_type size_type;
449 typedef typename _base_type::difference_type difference_type;
450
451 typedef typename _base_type::reverse_iterator reverse_iterator;
452 typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
453
454 typedef typename _base_type::native_handle_type native_handle_type;
455
456 range_array& operator=(range_array&& other) = default;
457
458 using _base_type::_base_type;
459 using _base_type::size;
460 using _base_type::empty;
461 using _base_type::back;
462 using _base_type::front;
463 using _base_type::begin;
464 using _base_type::end;
465 using _base_type::rbegin;
466 using _base_type::rend;
467 using _base_type::cbegin;
468 using _base_type::cend;
469 using _base_type::crbegin;
470 using _base_type::crend;
471 using _base_type::release_native_handle;
472 using _base_type::native_handle;
473};
474
475template <typename T>
476class range_array<T, typename std::enable_if<std::is_base_of<::efl::eo::concrete, T>::value>::type>
477 : range_ptr_array<Eo>
478{
479 typedef range_ptr_array<Eo> _base_type;
480 typedef range_array<T> _self_type;
481public:
482 typedef T value_type;
483 typedef value_type& reference;
484 typedef value_type const& const_reference;
485 typedef _ptr_eo_array_iterator<value_type const> const_iterator;
486 typedef _ptr_eo_array_iterator<value_type> iterator;
487 typedef value_type* pointer;
488 typedef value_type const* const_pointer;
489 typedef std::size_t size_type;
490 typedef std::ptrdiff_t difference_type;
491
492 typedef std::reverse_iterator<iterator> reverse_iterator;
493 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
494
495 typedef typename _base_type::native_handle_type native_handle_type;
496
497 explicit range_array(native_handle_type handle)
498 : _base_type(handle) {}
499 range_array() {}
500 range_array(range_array<T> const& other)
501 : _base_type(other.native_handle())
502 {
503 }
504 range_array<T>& operator=(range_array<T>const& other)
505 {
506 _base_type::_handle = other._handle;
507 return *this;
508 }
509 range_array& operator=(range_array&& other) = default;
510 range_array(range_array&& other) = default;
334 511
512 using _base_type::size;
513 using _base_type::empty;
514
515 reference front()
516 {
517 return _eo_array_access_traits::front<value_type>(native_handle());
518 }
519 reference back()
520 {
521 return _eo_array_access_traits::back<value_type>(native_handle());
522 }
523 const_reference front() const { return const_cast<_self_type*>(this)->front(); }
524 const_reference back() const { return const_cast<_self_type*>(this)->back(); }
525 iterator begin()
526 {
527 return _eo_array_access_traits::begin<value_type>(native_handle());
528 }
529 iterator end()
530 {
531 return _eo_array_access_traits::end<value_type>(native_handle());
532 }
533 const_iterator begin() const
534 {
535 return const_cast<_self_type*>(this)->begin();
536 }
537 const_iterator end() const
538 {
539 return const_cast<_self_type*>(this)->end();
540 }
541 const_iterator cbegin() const
542 {
543 return begin();
544 }
545 const_iterator cend() const
546 {
547 return end();
548 }
549 reverse_iterator rbegin()
550 {
551 return _eo_array_access_traits::rbegin<value_type>(native_handle());
552 }
553 reverse_iterator rend()
554 {
555 return _eo_array_access_traits::rend<value_type>(native_handle());
556 }
557 const_reverse_iterator rbegin() const
558 {
559 return const_cast<_self_type*>(this)->rbegin();
560 }
561 const_reverse_iterator rend() const
562 {
563 return const_cast<_self_type*>(this)->rend();
564 }
565 const_reverse_iterator crbegin() const
566 {
567 return rbegin();
568 }
569 const_reverse_iterator crend() const
570 {
571 return rend();
572 }
573 using _base_type::swap;
574 using _base_type::release_native_handle;
575 using _base_type::native_handle;
576
577 friend bool operator==(range_array<T> const& rhs, range_array<T> const& lhs)
578 {
579 return rhs.size() == lhs.size() && std::equal(rhs.begin(), rhs.end(), lhs.begin());
580 }
581};
582
335} } 583} }
336 584
337#endif 585#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
154 template <typename T> 154 template <typename T>
155 static void deallocate_clone(T const* p) 155 static void deallocate_clone(T const* p)
156 { 156 {
157 static_assert(std::is_pod<T>::value, "malloc_clone_allocator can only be used with POD types"); 157 static_assert(std::is_pod<T>::value || std::is_void<T>::value
158 , "malloc_clone_allocator can only be used with POD types");
158 std::free(const_cast<T*>(p)); 159 std::free(const_cast<T*>(p));
159 } 160 }
160}; 161};
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 @@
1#ifndef EFL_EINA_FUNCTION_HH
2#define EFL_EINA_FUNCTION_HH
3
4namespace efl { namespace eina { namespace _mpl {
5
6template <typename T>
7struct function_params;
8
9template <typename R, typename... P>
10struct function_params<R(*)(P...)>
11{
12 typedef std::tuple<P...> type;
13};
14
15template <typename T>
16struct function_return;
17
18template <typename R, typename... P>
19struct function_return<R(*)(P...)>
20{
21 typedef R type;
22};
23
24} } }
25
26#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 @@
1#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH 1#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH
2#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH 2#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH
3 3
4#include <cstdlib>
5
4/** 6/**
5 * @addtogroup Eina_Cxx_Data_Types_Group 7 * @addtogroup Eina_Cxx_Data_Types_Group
6 * 8 *
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:
190 typedef typename _base_type::reverse_iterator reverse_iterator; 190 typedef typename _base_type::reverse_iterator reverse_iterator;
191 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; 191 typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
192 192
193 using _base_type::native_handle_type;
194
193 list& operator=(list&& other) = default; 195 list& operator=(list&& other) = default;
194 list(list&& other) = default; 196 list(list&& other) = default;
195 list() = default; 197 list() = default;
@@ -224,6 +226,7 @@ public:
224 using _base_type::max_size; 226 using _base_type::max_size;
225 using _base_type::native_handle; 227 using _base_type::native_handle;
226 using _base_type::accessor; 228 using _base_type::accessor;
229 using _base_type::release_native_handle;
227}; 230};
228 231
229template <typename T, typename CloneAllocator> 232template <typename T, typename CloneAllocator>
@@ -251,7 +254,9 @@ public:
251 typedef std::reverse_iterator<iterator> reverse_iterator; 254 typedef std::reverse_iterator<iterator> reverse_iterator;
252 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 255 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
253 256
254 explicit list(Eina_List* handle) 257 using _base_type::native_handle_type;
258
259 explicit list(typename _self_type::native_handle_type handle)
255 : _base_type(handle) {} 260 : _base_type(handle) {}
256 list(clone_allocator_type alloc) : _base_type(alloc) {} 261 list(clone_allocator_type alloc) : _base_type(alloc) {}
257 list() {} 262 list() {}
@@ -295,6 +300,7 @@ public:
295 using _base_type::get_clone_allocator; 300 using _base_type::get_clone_allocator;
296 using _base_type::pop_back; 301 using _base_type::pop_back;
297 using _base_type::pop_front; 302 using _base_type::pop_front;
303 using _base_type::release_native_handle;
298 304
299 void push_back(const_reference w) 305 void push_back(const_reference w)
300 { 306 {
@@ -464,6 +470,8 @@ public:
464 typedef typename _base_type::reverse_iterator reverse_iterator; 470 typedef typename _base_type::reverse_iterator reverse_iterator;
465 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; 471 typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
466 472
473 using _base_type::native_handle_type;
474
467 using _base_type::_base_type; 475 using _base_type::_base_type;
468 using _base_type::size; 476 using _base_type::size;
469 using _base_type::empty; 477 using _base_type::empty;
@@ -501,9 +509,9 @@ public:
501 typedef std::reverse_iterator<iterator> reverse_iterator; 509 typedef std::reverse_iterator<iterator> reverse_iterator;
502 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 510 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
503 511
504 typedef typename _base_type::native_handle_type native_handle_type; 512 using _base_type::native_handle_type;
505 513
506 explicit range_list(native_handle_type handle) 514 explicit range_list(typename _self_type::native_handle_type handle)
507 : _base_type(handle) {} 515 : _base_type(handle) {}
508 range_list() {} 516 range_list() {}
509 range_list(range_list<T> const& other) 517 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 @@
1#ifndef EFL_EINA_LOGICAL_HH
2#define EFL_EINA_LOGICAL_HH
3
4#include <type_traits>
5
6namespace efl { namespace eina { namespace _mpl {
7
8template <bool... N>
9struct or_;
10
11template <>
12struct or_<> : std::integral_constant<bool, false> {};
13
14template <bool B>
15struct or_<B> : std::integral_constant<bool, B> {};
16
17template <bool B1, bool B2, bool... Bs>
18struct or_<B1, B2, Bs...> : std::integral_constant<bool, B1 || B2 || or_<Bs...>::value> {};
19
20template <bool... N>
21struct and_;
22
23template <>
24struct and_<> : std::integral_constant<bool, true> {};
25
26template <bool B>
27struct and_<B> : std::integral_constant<bool, B> {};
28
29template <bool B1, bool B2, bool... Bs>
30struct and_<B1, B2, Bs...> : std::integral_constant<bool, B1 && B2 && and_<Bs...>::value> {};
31
32} } }
33
34#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 @@
1
2#ifndef EINA_PP_HH
3#define EINA_PP_HH
4
5#define EINA_STRINGIZE_IMPL(x) #x
6#define EINA_STRINGIZE(x) EINA_STRINGIZE_IMPL(x)
7
8#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>
295 typedef _range_template<T, _ptr_array_access_traits> _base_type; /**< Type for the base class. */ 295 typedef _range_template<T, _ptr_array_access_traits> _base_type; /**< Type for the base class. */
296 typedef typename _base_type::value_type value_type; /**< The type of each element. */ 296 typedef typename _base_type::value_type value_type; /**< The type of each element. */
297 297
298 typedef typename _base_type::native_handle_type native_handle_type;
299
298 /** 300 /**
299 * @brief Creates a range from a native Eina array handle. 301 * @brief Creates a range from a native Eina array handle.
300 */ 302 */
301 range_ptr_array(Eina_Array* array) 303 range_ptr_array(native_handle_type array)
302 : _base_type(array) 304 : _base_type(array)
303 {} 305 {}
304 306
@@ -391,7 +393,7 @@ struct _ptr_array_common_base
391 /** 393 /**
392 * @internal 394 * @internal
393 */ 395 */
394 T* _new_clone(T const& a) 396 T* _new_clone(typename container_value_type<T>::type const& a)
395 { 397 {
396 return _get_clone_allocator().allocate_clone(a); 398 return _get_clone_allocator().allocate_clone(a);
397 } 399 }
@@ -402,6 +404,7 @@ struct _ptr_array_common_base
402 struct _ptr_array_impl : CloneAllocator 404 struct _ptr_array_impl : CloneAllocator
403 { 405 {
404 _ptr_array_impl() : _array( ::eina_array_new(32u) ) {} 406 _ptr_array_impl() : _array( ::eina_array_new(32u) ) {}
407 _ptr_array_impl(Eina_Array* array) : _array(array) {}
405 _ptr_array_impl(CloneAllocator allocator) 408 _ptr_array_impl(CloneAllocator allocator)
406 : clone_allocator_type(allocator), _array( ::eina_array_new(32u)) {} 409 : clone_allocator_type(allocator), _array( ::eina_array_new(32u)) {}
407 410
@@ -449,6 +452,8 @@ public:
449 452
450 typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr; 453 typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
451 454
455 typedef Eina_Array* native_handle_type;
456
452 /** 457 /**
453 * @brief Default constructor. Create an empty array. 458 * @brief Default constructor. Create an empty array.
454 * 459 *
@@ -1210,6 +1215,13 @@ public:
1210 */ 1215 */
1211 size_type max_size() const { return -1; } 1216 size_type max_size() const { return -1; }
1212 1217
1218 Eina_Array* release_native_handle()
1219 {
1220 Eina_Array* tmp = this->_impl._array;
1221 this->_impl._array = ::eina_array_new(32u);
1222 return tmp;
1223 }
1224
1213 /** 1225 /**
1214 * @brief Get a handle for the wrapped Eina_Array. 1226 * @brief Get a handle for the wrapped Eina_Array.
1215 * @return Handle for the native Eina array. 1227 * @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 @@
9#include <eina_eo_concrete_fwd.hh> 9#include <eina_eo_concrete_fwd.hh>
10#include <eina_iterator.hh> 10#include <eina_iterator.hh>
11#include <eina_throw.hh> 11#include <eina_throw.hh>
12#include <eina_range_types.hh>
12 13
13#include <memory> 14#include <memory>
14#include <iterator> 15#include <iterator>
@@ -370,7 +371,7 @@ struct _ptr_list_common_base
370 /** 371 /**
371 * @internal 372 * @internal
372 */ 373 */
373 T* _new_clone(T const& a) 374 T* _new_clone(typename container_value_type<T>::type const& a)
374 { 375 {
375 return _get_clone_allocator().allocate_clone(a); 376 return _get_clone_allocator().allocate_clone(a);
376 } 377 }
@@ -413,11 +414,12 @@ class ptr_list : protected _ptr_list_common_base<T, CloneAllocator>
413{ 414{
414 typedef _ptr_list_common_base<T, CloneAllocator> _base_type; /**< Type for the base class. */ 415 typedef _ptr_list_common_base<T, CloneAllocator> _base_type; /**< Type for the base class. */
415public: 416public:
416 typedef T value_type; /**< The type of each element. */ 417 typedef typename container_value_type<T>::type
417 typedef T& reference; /**< Type for a reference to an element. */ 418 value_type; /**< The type of each element. */
418 typedef T const& const_reference; /**< Type for a constant reference to an element. */ 419 typedef value_type& reference; /**< Type for a reference to an element. */
419 typedef _ptr_list_iterator<T const> const_iterator; /**< Type for a iterator for this container. */ 420 typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
420 typedef _ptr_list_iterator<T> iterator; /**< Type for a constant iterator for this container. */ 421 typedef _ptr_list_iterator<value_type const> const_iterator; /**< Type for a iterator for this container. */
422 typedef _ptr_list_iterator<value_type> iterator; /**< Type for a constant iterator for this container. */
421 typedef T* pointer; /**< Type for a pointer to an element. */ 423 typedef T* pointer; /**< Type for a pointer to an element. */
422 typedef T const* const_pointer; /**< Type for a constant pointer for an element. */ 424 typedef T const* const_pointer; /**< Type for a constant pointer for an element. */
423 typedef std::size_t size_type; /**< Type for size information. */ 425 typedef std::size_t size_type; /**< Type for size information. */
@@ -427,6 +429,8 @@ public:
427 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */ 429 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
428 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */ 430 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
429 431
432 typedef Eina_List* native_handle_type;
433
430 typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr; 434 typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
431 435
432 /** 436 /**
@@ -554,7 +558,7 @@ public:
554 */ 558 */
555 std::size_t size() const 559 std::size_t size() const
556 { 560 {
557 return _ptr_list_access_traits::size<T>(this->_impl._list); 561 return _ptr_list_access_traits::size<value_type>(this->_impl._list);
558 } 562 }
559 563
560 /** 564 /**
@@ -566,7 +570,7 @@ public:
566 */ 570 */
567 bool empty() const 571 bool empty() const
568 { 572 {
569 return _ptr_list_access_traits::empty<T>(this->_impl._list); 573 return _ptr_list_access_traits::empty<value_type>(this->_impl._list);
570 } 574 }
571 575
572 /** 576 /**
@@ -940,7 +944,7 @@ public:
940 */ 944 */
941 value_type& back() 945 value_type& back()
942 { 946 {
943 return _ptr_list_access_traits::back<T>(this->_impl._list); 947 return _ptr_list_access_traits::back<value_type>(this->_impl._list);
944 } 948 }
945 949
946 /** 950 /**
@@ -952,7 +956,7 @@ public:
952 */ 956 */
953 value_type const& back() const 957 value_type const& back() const
954 { 958 {
955 return _ptr_list_access_traits::back<T>(this->_impl._list); 959 return _ptr_list_access_traits::back<value_type>(this->_impl._list);
956 } 960 }
957 961
958 /** 962 /**
@@ -961,7 +965,7 @@ public:
961 */ 965 */
962 value_type& front() 966 value_type& front()
963 { 967 {
964 return _ptr_list_access_traits::front<T>(this->_impl._list); 968 return _ptr_list_access_traits::front<value_type>(this->_impl._list);
965 } 969 }
966 970
967 /** 971 /**
@@ -973,7 +977,7 @@ public:
973 */ 977 */
974 value_type const& front() const 978 value_type const& front() const
975 { 979 {
976 return _ptr_list_access_traits::front<T>(this->_impl._list); 980 return _ptr_list_access_traits::front<value_type>(this->_impl._list);
977 } 981 }
978 982
979 /** 983 /**
@@ -985,7 +989,7 @@ public:
985 */ 989 */
986 const_iterator begin() const 990 const_iterator begin() const
987 { 991 {
988 return _ptr_list_access_traits::cbegin<T>(this->_impl._list); 992 return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
989 } 993 }
990 994
991 /** 995 /**
@@ -997,7 +1001,7 @@ public:
997 */ 1001 */
998 const_iterator end() const 1002 const_iterator end() const
999 { 1003 {
1000 return _ptr_list_access_traits::cend<T>(this->_impl._list); 1004 return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
1001 } 1005 }
1002 1006
1003 /** 1007 /**
@@ -1010,7 +1014,7 @@ public:
1010 */ 1014 */
1011 iterator begin() 1015 iterator begin()
1012 { 1016 {
1013 return _ptr_list_access_traits::begin<T>(this->_impl._list); 1017 return _ptr_list_access_traits::begin<value_type>(this->_impl._list);
1014 } 1018 }
1015 1019
1016 /** 1020 /**
@@ -1026,7 +1030,7 @@ public:
1026 */ 1030 */
1027 iterator end() 1031 iterator end()
1028 { 1032 {
1029 return _ptr_list_access_traits::end<T>(this->_impl._list); 1033 return _ptr_list_access_traits::end<value_type>(this->_impl._list);
1030 } 1034 }
1031 1035
1032 /** 1036 /**
@@ -1038,7 +1042,7 @@ public:
1038 */ 1042 */
1039 const_reverse_iterator rbegin() const 1043 const_reverse_iterator rbegin() const
1040 { 1044 {
1041 return _ptr_list_access_traits::rbegin<T>(this->_impl._list); 1045 return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
1042 } 1046 }
1043 1047
1044 /** 1048 /**
@@ -1050,7 +1054,7 @@ public:
1050 */ 1054 */
1051 const_reverse_iterator rend() const 1055 const_reverse_iterator rend() const
1052 { 1056 {
1053 return _ptr_list_access_traits::rend<T>(this->_impl._list); 1057 return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
1054 } 1058 }
1055 1059
1056 /** 1060 /**
@@ -1063,7 +1067,7 @@ public:
1063 */ 1067 */
1064 reverse_iterator rbegin() 1068 reverse_iterator rbegin()
1065 { 1069 {
1066 return _ptr_list_access_traits::rbegin<T>(this->_impl._list); 1070 return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
1067 } 1071 }
1068 1072
1069 /** 1073 /**
@@ -1080,7 +1084,7 @@ public:
1080 */ 1084 */
1081 reverse_iterator rend() 1085 reverse_iterator rend()
1082 { 1086 {
1083 return _ptr_list_access_traits::rend<T>(this->_impl._list); 1087 return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
1084 } 1088 }
1085 1089
1086 /** 1090 /**
@@ -1093,7 +1097,7 @@ public:
1093 */ 1097 */
1094 const_iterator cbegin() const 1098 const_iterator cbegin() const
1095 { 1099 {
1096 return _ptr_list_access_traits::cbegin<T>(this->_impl._list); 1100 return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
1097 } 1101 }
1098 1102
1099 /** 1103 /**
@@ -1106,7 +1110,7 @@ public:
1106 */ 1110 */
1107 const_iterator cend() const 1111 const_iterator cend() const
1108 { 1112 {
1109 return _ptr_list_access_traits::cend<T>(this->_impl._list); 1113 return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
1110 } 1114 }
1111 1115
1112 /** 1116 /**
@@ -1119,7 +1123,7 @@ public:
1119 */ 1123 */
1120 const_reverse_iterator crbegin() const 1124 const_reverse_iterator crbegin() const
1121 { 1125 {
1122 return _ptr_list_access_traits::crbegin<T>(this->_impl._list); 1126 return _ptr_list_access_traits::crbegin<value_type>(this->_impl._list);
1123 } 1127 }
1124 1128
1125 /** 1129 /**
@@ -1132,7 +1136,7 @@ public:
1132 */ 1136 */
1133 const_reverse_iterator crend() const 1137 const_reverse_iterator crend() const
1134 { 1138 {
1135 return _ptr_list_access_traits::crend<T>(this->_impl._list); 1139 return _ptr_list_access_traits::crend<value_type>(this->_impl._list);
1136 } 1140 }
1137 1141
1138 /** 1142 /**
@@ -1143,9 +1147,9 @@ public:
1143 * the first element of the list. If the list is empty the returned 1147 * the first element of the list. If the list is empty the returned
1144 * iterator is the same as the one returned by @ref iend(). 1148 * iterator is the same as the one returned by @ref iend().
1145 */ 1149 */
1146 eina::iterator<T> ibegin() 1150 eina::iterator<value_type> ibegin()
1147 { 1151 {
1148 return _ptr_list_access_traits::ibegin<T>(this->_impl._list); 1152 return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
1149 } 1153 }
1150 1154
1151 /** 1155 /**
@@ -1160,9 +1164,9 @@ public:
1160 * @note Note that attempting to access this position causes undefined 1164 * @note Note that attempting to access this position causes undefined
1161 * behavior. 1165 * behavior.
1162 */ 1166 */
1163 eina::iterator<T> iend() 1167 eina::iterator<value_type> iend()
1164 { 1168 {
1165 return _ptr_list_access_traits::iend<T>(this->_impl._list); 1169 return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
1166 } 1170 }
1167 1171
1168 /** 1172 /**
@@ -1174,7 +1178,7 @@ public:
1174 */ 1178 */
1175 eina::iterator<T const> ibegin() const 1179 eina::iterator<T const> ibegin() const
1176 { 1180 {
1177 return _ptr_list_access_traits::ibegin<T>(this->_impl._list); 1181 return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
1178 } 1182 }
1179 1183
1180 /** 1184 /**
@@ -1186,7 +1190,7 @@ public:
1186 */ 1190 */
1187 eina::iterator<T const> iend() const 1191 eina::iterator<T const> iend() const
1188 { 1192 {
1189 return _ptr_list_access_traits::iend<T>(this->_impl._list); 1193 return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
1190 } 1194 }
1191 1195
1192 /** 1196 /**
@@ -1199,7 +1203,7 @@ public:
1199 */ 1203 */
1200 eina::iterator<T const> cibegin() const 1204 eina::iterator<T const> cibegin() const
1201 { 1205 {
1202 return _ptr_list_access_traits::cibegin<T>(this->_impl._list); 1206 return _ptr_list_access_traits::cibegin<value_type>(this->_impl._list);
1203 } 1207 }
1204 1208
1205 /** 1209 /**
@@ -1212,7 +1216,7 @@ public:
1212 */ 1216 */
1213 eina::iterator<T const> ciend() const 1217 eina::iterator<T const> ciend() const
1214 { 1218 {
1215 return _ptr_list_access_traits::ciend<T>(this->_impl._list); 1219 return _ptr_list_access_traits::ciend<value_type>(this->_impl._list);
1216 } 1220 }
1217 1221
1218 /** 1222 /**
@@ -1230,6 +1234,13 @@ public:
1230 */ 1234 */
1231 size_type max_size() const { return -1; } 1235 size_type max_size() const { return -1; }
1232 1236
1237 Eina_List* release_native_handle()
1238 {
1239 Eina_List* tmp = this->_impl._list;
1240 this->_impl._list = 0;
1241 return tmp;
1242 }
1243
1233 /** 1244 /**
1234 * @brief Get a handle for the wrapped @c Eina_List. 1245 * @brief Get a handle for the wrapped @c Eina_List.
1235 * @return Handle for the native Eina list. 1246 * @return Handle for the native Eina list.
@@ -1275,9 +1286,9 @@ public:
1275 * @brief Get a @ref eina::accessor for the list. 1286 * @brief Get a @ref eina::accessor for the list.
1276 * @return <tt>eina::accessor</tt> to the list. 1287 * @return <tt>eina::accessor</tt> to the list.
1277 */ 1288 */
1278 eina::accessor<T> accessor() 1289 eina::accessor<value_type> accessor()
1279 { 1290 {
1280 return eina::accessor<T>(eina_list_accessor_new(this->_impl._list)); 1291 return eina::accessor<value_type>(eina_list_accessor_new(this->_impl._list));
1281 } 1292 }
1282}; 1293};
1283 1294
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 {
22template <typename T, typename Traits> 22template <typename T, typename Traits>
23struct _const_range_template 23struct _const_range_template
24{ 24{
25 typedef typename Traits::template const_iterator<T>::type const_iterator; /**< Type for constant iterator to the range. */ 25 typedef typename container_value_type<T>::type
26 typedef typename Traits::template iterator<T>::type iterator; /**< Type for iterator to the range. */ 26 value_type; /**< The type of each element. */
27 typedef T value_type; /**< The type of each element. */ 27 typedef typename Traits::template const_iterator<value_type>::type const_iterator; /**< Type for constant iterator to the range. */
28 typedef T& reference; /**< Type for a reference to an element. */ 28 typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for iterator to the range. */
29 typedef T const& const_reference; /**< Type for a constant reference to an element. */ 29 typedef value_type& reference; /**< Type for a reference to an element. */
30 typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
30 typedef T* pointer; /**< Type for a pointer to an element. */ 31 typedef T* pointer; /**< Type for a pointer to an element. */
31 typedef T const* const_pointer; /**< Type for a constant pointer to an element. */ 32 typedef T const* const_pointer; /**< Type for a constant pointer to an element. */
32 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator to the range. */ 33 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator to the range. */
@@ -50,6 +51,17 @@ struct _const_range_template
50 : _handle(handle) {} 51 : _handle(handle) {}
51 52
52 /** 53 /**
54 * @brief Release the handle of the native Eina container.
55 * @return Handle for the native Eina container.
56 */
57 native_handle_type release_native_handle()
58 {
59 auto h = _handle;
60 _handle = nullptr;
61 return h;
62 }
63
64 /**
53 * @brief Get a constant handle for the native Eina container. 65 * @brief Get a constant handle for the native Eina container.
54 * @return Constant handle for the native Eina container. 66 * @return Constant handle for the native Eina container.
55 */ 67 */
@@ -241,10 +253,13 @@ void swap(_const_range_template<T, Traits>& lhs, _const_range_template<T, Traits
241template <typename T, typename Traits> 253template <typename T, typename Traits>
242struct _mutable_range_template : _const_range_template<T, Traits> 254struct _mutable_range_template : _const_range_template<T, Traits>
243{ 255{
244 typedef T value_type; /**< The type of each element. */ 256 typedef typename container_value_type<T>::type
245 typedef typename Traits::template iterator<T>::type iterator; /**< Type for a iterator to the range. */ 257 value_type; /**< The type of each element. */
258 typedef value_type& reference_type;
259 typedef value_type const& const_reference_type;
260 typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for a iterator to the range. */
246 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for constant reverse iterator to the range. */ 261 typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for constant reverse iterator to the range. */
247 typedef typename Traits::template native_handle<T>::type native_handle_type; /**< Type for the native handle of the container. */ 262 typedef typename Traits::template native_handle<value_type>::type native_handle_type; /**< Type for the native handle of the container. */
248 typedef _const_range_template<T, Traits> _base_type; /**< Type for the base class. */ 263 typedef _const_range_template<T, Traits> _base_type; /**< Type for the base class. */
249 264
250 /** 265 /**
@@ -254,6 +269,17 @@ struct _mutable_range_template : _const_range_template<T, Traits>
254 : _base_type(handle) {} 269 : _base_type(handle) {}
255 270
256 /** 271 /**
272 * @brief Release the handle of the native Eina container.
273 * @return Handle for the native Eina container.
274 */
275 native_handle_type release_native_handle()
276 {
277 auto h = _handle;
278 _handle = nullptr;
279 return h;
280 }
281
282 /**
257 * @brief Get a constant handle for the native Eina container. 283 * @brief Get a constant handle for the native Eina container.
258 * @return Constant handle for the native Eina container. 284 * @return Constant handle for the native Eina container.
259 */ 285 */
@@ -266,7 +292,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
266 * @brief Get a reference to the last element. 292 * @brief Get a reference to the last element.
267 * @return Reference to the last element of the range. 293 * @return Reference to the last element of the range.
268 */ 294 */
269 value_type& back() const 295 reference_type back() const
270 { 296 {
271 return Traits::template back<value_type>(native_handle()); 297 return Traits::template back<value_type>(native_handle());
272 } 298 }
@@ -275,7 +301,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
275 * @brief Get a reference to the first element. 301 * @brief Get a reference to the first element.
276 * @return Reference to the first element of the range. 302 * @return Reference to the first element of the range.
277 */ 303 */
278 value_type& front() const 304 reference_type front() const
279 { 305 {
280 return Traits::template front<value_type>(native_handle()); 306 return Traits::template front<value_type>(native_handle());
281 } 307 }
@@ -355,11 +381,12 @@ protected:
355template <typename T, typename Traits> 381template <typename T, typename Traits>
356struct _range_template : private std::conditional 382struct _range_template : private std::conditional
357 <std::is_const<T>::value 383 <std::is_const<T>::value
358 , _const_range_template<typename std::remove_const<T>::type, Traits> 384 , _const_range_template<typename nonconst_container_value_type<T>::type, Traits>
359 , _mutable_range_template<T, Traits> >::type 385 , _mutable_range_template<typename nonconst_container_value_type<T>::type, Traits>
386 >::type
360{ 387{
361 typedef std::integral_constant<bool, !std::is_const<T>::value> is_mutable; /**< Type that specifies if the elements can be modified. */ 388 typedef std::integral_constant<bool, !std::is_const<T>::value> is_mutable; /**< Type that specifies if the elements can be modified. */
362 typedef typename std::remove_const<T>::type value_type; /**< The type of each element. */ 389 typedef typename nonconst_container_value_type<T>::type value_type; /**< The type of each element. */
363 typedef typename std::conditional<is_mutable::value, _mutable_range_template<value_type, Traits> 390 typedef typename std::conditional<is_mutable::value, _mutable_range_template<value_type, Traits>
364 , _const_range_template<value_type, Traits> >::type _base_type; /**< Type for the base class. */ 391 , _const_range_template<value_type, Traits> >::type _base_type; /**< Type for the base class. */
365 typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */ 392 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
368 typedef value_type const& const_reference; /**< Type for a constant reference to an element. */ 395 typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
369 typedef value_type* pointer; /**< Type for a pointer to an element. */ 396 typedef value_type* pointer; /**< Type for a pointer to an element. */
370 typedef value_type const* const_pointer; /**< Type for a constant pointer to an element. */ 397 typedef value_type const* const_pointer; /**< Type for a constant pointer to an element. */
371 typedef typename Traits::template const_iterator<T>::type const_iterator; /**< Type for constant iterator to the range. */ 398 typedef typename Traits::template const_iterator<value_type>::type const_iterator; /**< Type for constant iterator to the range. */
372 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for constant reverse iterator to the range. */ 399 typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for constant reverse iterator to the range. */
373 typedef typename Traits::template iterator<T>::type iterator; /**< Type for iterator to the range. */ 400 typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for iterator to the range. */
374 typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator to the range. */ 401 typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator to the range. */
375 typedef typename _base_type::size_type size_type; /**< Type for size information. */ 402 typedef typename _base_type::size_type size_type; /**< Type for size information. */
376 typedef typename _base_type::difference_type difference_type; /**< Type to represent the distance between two iterators. */ 403 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
388 : _base_type(handle) 415 : _base_type(handle)
389 {} 416 {}
390 417
418 using _base_type::release_native_handle;
391 using _base_type::native_handle; 419 using _base_type::native_handle;
392 using _base_type::back; 420 using _base_type::back;
393 using _base_type::front; 421 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 @@
1#ifndef EFL_EINA_EINA_TUPLE_HH_ 1#ifndef EFL_EINA_EINA_TUPLE_HH_
2#define EFL_EINA_EINA_TUPLE_HH_ 2#define EFL_EINA_EINA_TUPLE_HH_
3 3
4#include <eina_integer_sequence.hh>
5#include <eina_logical.hh>
6
7#include <tuple>
8
4namespace efl { namespace eina { namespace _mpl { 9namespace efl { namespace eina { namespace _mpl {
5 10
6template <typename A, typename... Args> 11template <typename A, typename... Args>
@@ -21,15 +26,64 @@ struct push_front<C<Args...>, AArgs...>
21 typedef C<Args..., AArgs...> type; 26 typedef C<Args..., AArgs...> type;
22}; 27};
23 28
24template <typename A> 29template <typename A, std::size_t N = 1>
25struct pop_front; 30struct pop_front;
26 31
27template <template <typename...> class C, typename T, typename... Args> 32template <template <typename...> class C, typename T, typename... Args>
28struct pop_front<C<T, Args...> > 33struct pop_front<C<T, Args...>, 1>
29{ 34{
30 typedef C<Args...> type; 35 typedef C<Args...> type;
31}; 36};
32 37
38template <typename A, std::size_t N>
39struct pop_front : pop_front<typename pop_front<A, 1>::type, N-1>
40{
41};
42
43template <typename T, typename F, std::size_t... I>
44void for_each_impl(T&& t, F&& f, eina::index_sequence<I...>)
45{
46 std::initializer_list<int> l = { (f(std::get<I>(t)), 0)...};
47 static_cast<void>(l);
48}
49
50template <typename T, typename F>
51void for_each(T&& t, F&& f)
52{
53 _mpl::for_each_impl(t, f, eina::make_index_sequence
54 <std::tuple_size<typename std::remove_reference<T>::type>::value>());
55}
56
57template <typename T, typename Transform>
58struct tuple_transform;
59
60template <typename...T, typename Transform>
61struct tuple_transform<std::tuple<T...>, Transform>
62{
63 typedef std::tuple<typename Transform::template apply<T>::type...> type;
64};
65
66template <typename T, typename Tuple>
67struct tuple_contains;
68
69
70
71template <typename T, typename...Ts>
72struct tuple_contains<T, std::tuple<Ts...> >
73 : _mpl::or_<std::is_same<T, Ts>::value...>
74{
75};
76
77template <typename T, typename Tuple>
78struct tuple_find : std::integral_constant<int, -1> {};
79
80template <typename T, typename... Ts>
81struct tuple_find<T, std::tuple<T, Ts...> > : std::integral_constant<std::size_t, 0> {};
82
83template <typename T, typename T1, typename... Ts>
84struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant
85 <std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {};
86
33} } } 87} } }
34 88
35#endif 89#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 @@
1#ifndef EFL_EINA_EINA_TUPLE_C_HH_
2#define EFL_EINA_EINA_TUPLE_C_HH_
3
4#include <tuple>
5
6namespace efl { namespace eina { namespace _mpl {
7
8template <typename T, T... Ts>
9using tuple_c = std::tuple<std::integral_constant<T, Ts>...>;
10
11template <typename T, T... Ts>
12constexpr std::size_t tuple_c_size(tuple_c<T, Ts...> const&)
13{
14 return sizeof...(Ts);
15}
16
17constexpr std::size_t tuple_c_size(std::tuple<> const&)
18{
19 return 0;
20}
21
22} } }
23
24#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>
64{ 64{
65}; 65};
66 66
67template <typename T>
68struct container_value_type
69{
70 typedef typename std::conditional<
71 std::is_void<T>::value
72 , T*, T>::type type;
73};
74
75template <typename T>
76struct nonconst_container_value_type
77{
78 typedef typename std::conditional<
79 std::is_void<T>::value
80 , T*, typename std::remove_const<T>::type>::type type;
81};
82
67/** 83/**
68 * @} 84 * @}
69 */ 85 */
diff --git a/src/bindings/eldbus_cxx/eldbus_freedesktop.hh b/src/bindings/eldbus_cxx/eldbus_freedesktop.hh
index e44b9b228d..4af8c58e30 100644
--- a/src/bindings/eldbus_cxx/eldbus_freedesktop.hh
+++ b/src/bindings/eldbus_cxx/eldbus_freedesktop.hh
@@ -11,7 +11,6 @@ namespace efl { namespace eldbus { namespace _detail {
11template <typename Callback, typename... Ins> 11template <typename Callback, typename... Ins>
12void _callback_wrapper(void* data, Eldbus_Message const* message, Eldbus_Pending* pending) 12void _callback_wrapper(void* data, Eldbus_Message const* message, Eldbus_Pending* pending)
13{ 13{
14 std::cout << "_callback_wrapper" << std::endl;
15 Callback* callback(static_cast<Callback*>(data)); 14 Callback* callback(static_cast<Callback*>(data));
16 15
17 const char* errname, *errmsg; 16 const char* errname, *errmsg;
diff --git a/src/bindings/eo_cxx/eo_concrete.hh b/src/bindings/eo_cxx/eo_concrete.hh
index 9e328b1d92..c975bbc5e3 100644
--- a/src/bindings/eo_cxx/eo_concrete.hh
+++ b/src/bindings/eo_cxx/eo_concrete.hh
@@ -187,6 +187,13 @@ struct concrete
187 Eo* _eo_raw; ///< The opaque <em>EO Object</em>. 187 Eo* _eo_raw; ///< The opaque <em>EO Object</em>.
188}; 188};
189 189
190template<class CharT, class Traits>
191inline std::basic_ostream<CharT, Traits>&
192operator<<(std::basic_ostream<CharT, Traits>& os, concrete const& eo)
193{
194 return os << eo._eo_ptr();
195}
196
190inline bool operator==(concrete const& lhs, concrete const& rhs) 197inline bool operator==(concrete const& lhs, concrete const& rhs)
191{ 198{
192 return lhs._eo_ptr() == rhs._eo_ptr(); 199 return lhs._eo_ptr() == rhs._eo_ptr();
diff --git a/src/bindings/js/ecore_js/Ecore_Js.hh b/src/bindings/js/ecore_js/Ecore_Js.hh
new file mode 100644
index 0000000000..3f877f3fc8
--- /dev/null
+++ b/src/bindings/js/ecore_js/Ecore_Js.hh
@@ -0,0 +1,58 @@
1
2#ifndef EFL_ECORE_JS_HH
3#define EFL_ECORE_JS_HH
4
5#include <Ecore.hh>
6#include <Ecore_File.h>
7#include <Eina_Js.hh>
8
9#ifdef EAPI
10# undef EAPI
11#endif
12
13#ifdef _WIN32
14# ifdef EFL_ECORE_JS_BUILD
15# ifdef DLL_EXPORT
16# define EAPI __declspec(dllexport)
17# else
18# define EAPI
19# endif /* ! DLL_EXPORT */
20# else
21# define EAPI __declspec(dllimport)
22# endif /* ! EFL_ECORE_BUILD */
23#else
24# ifdef __GNUC__
25# if __GNUC__ >= 4
26# define EAPI __attribute__ ((visibility("default")))
27# else
28# define EAPI
29# endif
30# else
31# define EAPI
32# endif
33#endif /* ! _WIN32 */
34
35namespace efl { namespace ecore { namespace js {
36
37using ::efl::eina::js::compatibility_new;
38using ::efl::eina::js::compatibility_return_type;
39using ::efl::eina::js::compatibility_callback_info_type;
40using ::efl::eina::js::compatibility_return;
41using ::efl::eina::js::compatibility_get_pointer_internal_field;
42using ::efl::eina::js::compatibility_set_pointer_internal_field;
43
44EAPI void register_ecore_animator(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
45EAPI void register_ecore_event(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
46EAPI void register_ecore_file(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
47EAPI void register_ecore_idle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
48EAPI void register_ecore_job(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
49EAPI void register_ecore_mainloop(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
50EAPI void register_ecore_poller(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
51EAPI void register_ecore_throttle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
52EAPI void register_ecore_timer(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
53
54EAPI void register_ecore(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
55
56} } }
57
58#endif
diff --git a/src/bindings/js/ecore_js/ecore_js_animator.cc b/src/bindings/js/ecore_js/ecore_js_animator.cc
new file mode 100644
index 0000000000..849e4d7f34
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_animator.cc
@@ -0,0 +1,608 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Animator* extract_animator(v8::Local<v8::Object> object)
10{
11 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
12 return reinterpret_cast<Ecore_Animator*>(ptr);
13}
14
15static v8::Local<v8::Object> wrap_animator(Ecore_Animator *animator,
16 v8::Isolate *isolate)
17{
18 using v8::Boolean;
19 using v8::String;
20 using v8::ObjectTemplate;
21 using v8::FunctionTemplate;
22
23 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
24 obj_tpl->SetInternalFieldCount(1);
25 auto ret = obj_tpl->NewInstance();
26
27 auto del = [](compatibility_callback_info_type info)
28 -> compatibility_return_type {
29 if (info.Length() != 0)
30 return compatibility_return();
31
32 ecore_animator_del(extract_animator(info.This()));
33 return compatibility_return();
34 };
35
36 auto freeze = [](compatibility_callback_info_type info)
37 -> compatibility_return_type {
38 if (info.Length() != 0)
39 return compatibility_return();
40
41 ecore_animator_freeze(extract_animator(info.This()));
42 return compatibility_return();
43 };
44
45 auto thaw = [](compatibility_callback_info_type info)
46 -> compatibility_return_type {
47 if (info.Length() != 0)
48 return compatibility_return();
49
50 ecore_animator_thaw(extract_animator(info.This()));
51 return compatibility_return();
52 };
53
54 ret->Set(compatibility_new<String>(isolate, "del"),
55 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
56 ret->Set(compatibility_new<String>(isolate, "freeze"),
57 compatibility_new<FunctionTemplate>(isolate, freeze)
58 ->GetFunction());
59 ret->Set(compatibility_new<String>(isolate, "thaw"),
60 compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
61
62 ret->SetInternalField(0, compatibility_new<v8::External>(isolate,
63 animator));
64
65 return ret;
66}
67
68void register_pos_map_linear(v8::Isolate *isolate,
69 v8::Handle<v8::Object> global,
70 v8::Handle<v8::String> name)
71{
72 using v8::Integer;
73
74 global->Set(name,
75 compatibility_new<Integer>(isolate, ECORE_POS_MAP_LINEAR));
76}
77
78void register_pos_map_accelerate(v8::Isolate *isolate,
79 v8::Handle<v8::Object> global,
80 v8::Handle<v8::String> name)
81{
82 using v8::Integer;
83
84 global->Set(name,
85 compatibility_new<Integer>(isolate, ECORE_POS_MAP_ACCELERATE));
86}
87
88void register_pos_map_decelerate(v8::Isolate *isolate,
89 v8::Handle<v8::Object> global,
90 v8::Handle<v8::String> name)
91{
92 using v8::Integer;
93
94 global->Set(name,
95 compatibility_new<Integer>(isolate, ECORE_POS_MAP_DECELERATE));
96}
97
98void register_pos_map_sinusoidal(v8::Isolate *isolate,
99 v8::Handle<v8::Object> global,
100 v8::Handle<v8::String> name)
101{
102 using v8::Integer;
103
104 global->Set(name,
105 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SINUSOIDAL));
106}
107
108void register_pos_map_accelerate_factor(v8::Isolate *isolate,
109 v8::Handle<v8::Object> global,
110 v8::Handle<v8::String> name)
111{
112 using v8::Integer;
113
114 global->Set(name,
115 compatibility_new<Integer>(isolate,
116 ECORE_POS_MAP_ACCELERATE_FACTOR));
117}
118
119void register_pos_map_decelerate_factor(v8::Isolate *isolate,
120 v8::Handle<v8::Object> global,
121 v8::Handle<v8::String> name)
122{
123 using v8::Integer;
124
125 global->Set(name,
126 compatibility_new<Integer>(isolate,
127 ECORE_POS_MAP_DECELERATE_FACTOR));
128}
129
130void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
131 v8::Handle<v8::Object> global,
132 v8::Handle<v8::String> name)
133{
134 using v8::Integer;
135
136 global->Set(name,
137 compatibility_new<Integer>(isolate,
138 ECORE_POS_MAP_SINUSOIDAL_FACTOR));
139}
140
141void register_pos_map_divisor_interp(v8::Isolate *isolate,
142 v8::Handle<v8::Object> global,
143 v8::Handle<v8::String> name)
144{
145 using v8::Integer;
146
147 global->Set(name,
148 compatibility_new<Integer>(isolate,
149 ECORE_POS_MAP_DIVISOR_INTERP));
150}
151
152void register_pos_map_bounce(v8::Isolate *isolate,
153 v8::Handle<v8::Object> global,
154 v8::Handle<v8::String> name)
155{
156 using v8::Integer;
157
158 global->Set(name,
159 compatibility_new<Integer>(isolate, ECORE_POS_MAP_BOUNCE));
160}
161
162void register_pos_map_spring(v8::Isolate *isolate,
163 v8::Handle<v8::Object> global,
164 v8::Handle<v8::String> name)
165{
166 using v8::Integer;
167
168 global->Set(name,
169 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SPRING));
170}
171
172void register_pos_map_cubic_bezier(v8::Isolate *isolate,
173 v8::Handle<v8::Object> global,
174 v8::Handle<v8::String> name)
175{
176 using v8::Integer;
177
178 global->Set(name,
179 compatibility_new<Integer>(isolate,
180 ECORE_POS_MAP_CUBIC_BEZIER));
181}
182
183void register_animator_source_timer(v8::Isolate *isolate,
184 v8::Handle<v8::Object> global,
185 v8::Handle<v8::String> name)
186{
187 using v8::Integer;
188
189 global->Set(name,
190 compatibility_new<Integer>(isolate,
191 ECORE_ANIMATOR_SOURCE_TIMER));
192}
193
194void register_animator_frametime_set(v8::Isolate *isolate,
195 v8::Handle<v8::Object> global,
196 v8::Handle<v8::String> name)
197{
198 using v8::FunctionTemplate;
199
200 auto f = [](compatibility_callback_info_type args)
201 -> compatibility_return_type {
202 if (args.Length() != 1 || !args[0]->IsNumber())
203 return compatibility_return();
204
205 ecore_animator_frametime_set(args[0]->NumberValue());
206 return compatibility_return();
207 };
208
209 global->Set(name,
210 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
211}
212
213void register_animator_frametime_get(v8::Isolate *isolate,
214 v8::Handle<v8::Object> global,
215 v8::Handle<v8::String> name)
216{
217 using v8::Number;
218 using v8::FunctionTemplate;
219
220 auto f = [](compatibility_callback_info_type args)
221 -> compatibility_return_type {
222 if (args.Length() != 0)
223 return compatibility_return();
224
225 auto isolate = args.GetIsolate();
226 auto ret = ecore_animator_frametime_get();
227 return compatibility_return(compatibility_new<Number>(isolate, ret),
228 args);
229 };
230
231 global->Set(name,
232 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
233}
234
235void register_animator_pos_map(v8::Isolate *isolate,
236 v8::Handle<v8::Object> global,
237 v8::Handle<v8::String> name)
238{
239 using v8::Number;
240 using v8::FunctionTemplate;
241
242 auto f = [](compatibility_callback_info_type args)
243 -> compatibility_return_type {
244 if (args.Length() != 4 || !args[0]->IsNumber() || !args[1]->IsNumber()
245 || !args[2]->IsNumber() || !args[3]->IsNumber())
246 return compatibility_return();
247
248 Ecore_Pos_Map map;
249
250 switch ((int)(args[1]->NumberValue())) {
251 case ECORE_POS_MAP_LINEAR:
252 map = ECORE_POS_MAP_LINEAR;
253 break;
254 case ECORE_POS_MAP_ACCELERATE:
255 map = ECORE_POS_MAP_ACCELERATE;
256 break;
257 case ECORE_POS_MAP_DECELERATE:
258 map = ECORE_POS_MAP_DECELERATE;
259 break;
260 case ECORE_POS_MAP_SINUSOIDAL:
261 map = ECORE_POS_MAP_SINUSOIDAL;
262 break;
263 case ECORE_POS_MAP_ACCELERATE_FACTOR:
264 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
265 break;
266 case ECORE_POS_MAP_DECELERATE_FACTOR:
267 map = ECORE_POS_MAP_DECELERATE_FACTOR;
268 break;
269 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
270 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
271 break;
272 case ECORE_POS_MAP_DIVISOR_INTERP:
273 map = ECORE_POS_MAP_DIVISOR_INTERP;
274 break;
275 case ECORE_POS_MAP_BOUNCE:
276 map = ECORE_POS_MAP_BOUNCE;
277 break;
278 case ECORE_POS_MAP_SPRING:
279 map = ECORE_POS_MAP_SPRING;
280 break;
281 case ECORE_POS_MAP_CUBIC_BEZIER:
282 map = ECORE_POS_MAP_CUBIC_BEZIER;
283 break;
284 default:
285 return compatibility_return();
286 }
287
288 auto isolate = args.GetIsolate();
289 auto ret = ecore_animator_pos_map(args[0]->NumberValue(), map,
290 args[2]->NumberValue(),
291 args[3]->NumberValue());
292 return compatibility_return(compatibility_new<Number>(isolate, ret),
293 args);
294 };
295
296 global->Set(name,
297 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
298}
299
300void register_animator_pos_map_n(v8::Isolate *isolate,
301 v8::Handle<v8::Object> global,
302 v8::Handle<v8::String> name)
303{
304 using v8::Number;
305 using v8::NumberObject;
306 using v8::FunctionTemplate;
307 using v8::Array;
308
309 auto f = [](compatibility_callback_info_type args)
310 -> compatibility_return_type {
311 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
312 || !args[2]->IsArray())
313 return compatibility_return();
314
315 Ecore_Pos_Map map;
316
317 switch ((int)(args[1]->NumberValue())) {
318 case ECORE_POS_MAP_LINEAR:
319 map = ECORE_POS_MAP_LINEAR;
320 break;
321 case ECORE_POS_MAP_ACCELERATE:
322 map = ECORE_POS_MAP_ACCELERATE;
323 break;
324 case ECORE_POS_MAP_DECELERATE:
325 map = ECORE_POS_MAP_DECELERATE;
326 break;
327 case ECORE_POS_MAP_SINUSOIDAL:
328 map = ECORE_POS_MAP_SINUSOIDAL;
329 break;
330 case ECORE_POS_MAP_ACCELERATE_FACTOR:
331 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
332 break;
333 case ECORE_POS_MAP_DECELERATE_FACTOR:
334 map = ECORE_POS_MAP_DECELERATE_FACTOR;
335 break;
336 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
337 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
338 break;
339 case ECORE_POS_MAP_DIVISOR_INTERP:
340 map = ECORE_POS_MAP_DIVISOR_INTERP;
341 break;
342 case ECORE_POS_MAP_BOUNCE:
343 map = ECORE_POS_MAP_BOUNCE;
344 break;
345 case ECORE_POS_MAP_SPRING:
346 map = ECORE_POS_MAP_SPRING;
347 break;
348 case ECORE_POS_MAP_CUBIC_BEZIER:
349 map = ECORE_POS_MAP_CUBIC_BEZIER;
350 break;
351 default:
352 return compatibility_return();
353 }
354
355 std::vector<double> v;
356 {
357 auto array = Array::Cast(*args[2]);
358 auto s = array->Length();
359 v.reserve(s);
360 for (decltype(s) i = 0;i != s;++i) {
361 auto e = array->Get(i);
362 if (!e->IsNumber())
363 return compatibility_return();
364
365 v.push_back(e->NumberValue());
366 }
367 }
368
369 auto isolate = args.GetIsolate();
370 auto ret = ecore_animator_pos_map_n(args[0]->NumberValue(), map,
371 v.size(), v.data());
372 return compatibility_return(compatibility_new<Number>(isolate, ret),
373 args);
374 };
375
376 global->Set(name,
377 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
378}
379
380void register_animator_source_set(v8::Isolate *isolate,
381 v8::Handle<v8::Object> global,
382 v8::Handle<v8::String> name)
383{
384 using v8::FunctionTemplate;
385
386 auto f = [](compatibility_callback_info_type args)
387 -> compatibility_return_type {
388 if (args.Length() != 1 || !args[0]->IsNumber())
389 return compatibility_return();
390
391 Ecore_Animator_Source source;
392
393 switch ((int)(args[0]->NumberValue())) {
394 case ECORE_ANIMATOR_SOURCE_TIMER:
395 source = ECORE_ANIMATOR_SOURCE_TIMER;
396 break;
397 case ECORE_ANIMATOR_SOURCE_CUSTOM:
398 source = ECORE_ANIMATOR_SOURCE_CUSTOM;
399 break;
400 default:
401 return compatibility_return();
402 }
403
404 ecore_animator_source_set(source);
405 return compatibility_return();
406 };
407
408 global->Set(name,
409 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
410}
411
412void register_animator_source_get(v8::Isolate *isolate,
413 v8::Handle<v8::Object> global,
414 v8::Handle<v8::String> name)
415{
416 using v8::Integer;
417 using v8::FunctionTemplate;
418
419 auto f = [](compatibility_callback_info_type args)
420 -> compatibility_return_type {
421 if (args.Length() != 0)
422 return compatibility_return();
423
424 auto isolate = args.GetIsolate();
425 auto ret = ecore_animator_source_get();
426 return compatibility_return(compatibility_new<Integer>(isolate, ret),
427 args);
428 };
429
430 global->Set(name,
431 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
432}
433
434void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
435 v8::Handle<v8::String> name)
436{
437 using v8::Local;
438 using v8::Value;
439 using v8::Undefined;
440 using v8::Function;
441 using v8::FunctionTemplate;
442
443 auto f = [](compatibility_callback_info_type args)
444 -> compatibility_return_type {
445 if (args.Length() != 1 || !args[0]->IsFunction())
446 return compatibility_return();
447
448 auto isolate = args.GetIsolate();
449 auto f = new efl::eina::js::global_ref<Value>(isolate, args[0]);
450
451 auto cb = [](void *data) -> Eina_Bool {
452 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
453 auto o = persistent->handle();
454
455 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
456 auto bret = ret->IsBoolean() && ret->BooleanValue();
457
458 if (!bret)
459 {
460 persistent->dispose();
461 delete persistent;
462 }
463
464 return bret ? EINA_TRUE : EINA_FALSE;
465 };
466
467 auto ret = ecore_animator_add(cb, f);
468 return compatibility_return(wrap_animator(ret, isolate), args);
469 };
470
471 global->Set(name,
472 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
473}
474
475void register_animator_timeline_add(v8::Isolate *isolate,
476 v8::Handle<v8::Object> global,
477 v8::Handle<v8::String> name)
478{
479 using v8::Handle;
480 using v8::Local;
481 using v8::Value;
482 using v8::Undefined;
483 using v8::Function;
484 using v8::FunctionTemplate;
485 using v8::Number;
486
487 auto f = [](compatibility_callback_info_type args)
488 -> compatibility_return_type {
489 if (args.Length() != 2 || !args[0]->IsNumber()
490 || !args[1]->IsFunction()) {
491 return compatibility_return();
492 }
493
494 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
495
496 auto cb = [](void *data, double pos) -> Eina_Bool {
497 auto persistent
498 = reinterpret_cast<efl::eina::js::global_ref<Value>*>(data);
499 auto o = persistent->handle();
500 auto isolate = v8::Isolate::GetCurrent();
501
502 Handle<Value> args = compatibility_new<Number>(isolate, pos);
503
504 auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
505 auto bret = ret->IsBoolean() && ret->BooleanValue();
506
507 if (!bret)
508 {
509 persistent->dispose();
510 delete persistent;
511 }
512
513 return bret ? EINA_TRUE : EINA_FALSE;
514 };
515
516 auto ret = ecore_animator_timeline_add(args[0]->NumberValue(), cb, f);
517 return compatibility_return(wrap_animator(ret, args.GetIsolate()),
518 args);
519 };
520
521 global->Set(name,
522 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
523}
524
525void register_ecore_animator(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
526{
527 register_pos_map_linear(isolate, exports,
528 compatibility_new<v8::String>(isolate,
529 "ECORE_POS_MAP_LINEAR"));
530 register_pos_map_accelerate(isolate, exports,
531 compatibility_new<v8::String>(isolate,
532 "ECORE_POS_MAP"
533 "_ACCELERATE"));
534 register_pos_map_decelerate(isolate, exports,
535 compatibility_new<v8::String>(isolate,
536 "ECORE_POS_MAP"
537 "_DECELERATE"));
538 register_pos_map_sinusoidal(isolate, exports,
539 compatibility_new<v8::String>(isolate,
540 "ECORE_POS_MAP"
541 "_SINUSOIDAL"));
542 register_pos_map_accelerate_factor(isolate, exports,
543 compatibility_new<v8::String>(isolate,
544 "ECORE_POS_MAP"
545 "_ACCELERATE"
546 "_FACTOR"));
547 register_pos_map_decelerate_factor(isolate, exports,
548 compatibility_new<v8::String>(isolate,
549 "ECORE_POS_MAP"
550 "_DECELERATE"
551 "_FACTOR"));
552 register_pos_map_sinusoidal_factor(isolate, exports,
553 compatibility_new<v8::String>(isolate,
554 "ECORE_POS_MAP"
555 "_SINUSOIDAL"
556 "_FACTOR"));
557 register_pos_map_divisor_interp(isolate, exports,
558 compatibility_new<v8::String>(isolate,
559 "ECORE_POS_MAP"
560 "_DIVISOR_INTERP"));
561 register_pos_map_bounce(isolate, exports,
562 compatibility_new<v8::String>(isolate,
563 "ECORE_POS_MAP_BOUNCE"));
564 register_pos_map_spring(isolate, exports,
565 compatibility_new<v8::String>(isolate,
566 "ECORE_POS_MAP_SPRING"));
567 register_pos_map_cubic_bezier(isolate, exports,
568 compatibility_new<v8::String>(isolate,
569 "ECORE_POS_MAP_CUBIC"
570 "_BEZIER"));
571 register_animator_source_timer(isolate, exports,
572 compatibility_new<v8::String>(isolate,
573 "ECORE_ANIMATOR"
574 "_SOURCE_TIMER"));
575 register_animator_frametime_set(isolate, exports,
576 compatibility_new<v8::String>(isolate,
577 "ecore_animator"
578 "_frametime_set"));
579 register_animator_frametime_get(isolate, exports,
580 compatibility_new<v8::String>(isolate,
581 "ecore_animator"
582 "_frametime_get"));
583 register_animator_pos_map(isolate, exports,
584 compatibility_new<v8::String>(isolate,
585 "ecore_animator_pos"
586 "_map"));
587 register_animator_pos_map_n(isolate, exports,
588 compatibility_new<v8::String>(isolate,
589 "ecore_animator_pos_map"
590 "_n"));
591 register_animator_source_set(isolate, exports,
592 compatibility_new<v8::String>(isolate,
593 "ecore_animator_source"
594 "_set"));
595 register_animator_source_get(isolate, exports,
596 compatibility_new<v8::String>(isolate,
597 "ecore_animator_source"
598 "_get"));
599 register_animator_add(isolate, exports,
600 compatibility_new<v8::String>(isolate,
601 "ecore_animator_add"));
602 register_animator_timeline_add(isolate, exports,
603 compatibility_new<v8::String>(isolate,
604 "ecore_animator"
605 "_timeline_add"));
606}
607
608} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_event.cc b/src/bindings/js/ecore_js/ecore_js_event.cc
new file mode 100644
index 0000000000..a086d989d6
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_event.cc
@@ -0,0 +1,772 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Event *extract_event(v8::Local<v8::Object> object)
10{
11 return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0);
12}
13
14static v8::Local<v8::Object> wrap_event(Ecore_Event *event,
15 v8::Isolate *isolate)
16{
17 using v8::String;
18 using v8::ObjectTemplate;
19 using v8::FunctionTemplate;
20
21 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
22 obj_tpl->SetInternalFieldCount(1);
23 auto ret = obj_tpl->NewInstance();
24
25 auto del = [](compatibility_callback_info_type info)
26 -> compatibility_return_type {
27 if (info.Length() != 0)
28 return compatibility_return();
29
30 ecore_event_del(extract_event(info.This()));
31 return compatibility_return();
32 };
33
34 ret->Set(compatibility_new<String>(isolate, "del"),
35 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
36
37 compatibility_set_pointer_internal_field(ret, 0, event);
38
39 return ret;
40}
41
42static Ecore_Event_Handler *extract_event_handler(v8::Local<v8::Object> object)
43{
44 return compatibility_get_pointer_internal_field<Ecore_Event_Handler*>
45 (object, 0);
46}
47
48static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
49 v8::Isolate *isolate)
50{
51 using v8::String;
52 using v8::ObjectTemplate;
53 using v8::FunctionTemplate;
54 using v8::Value;
55
56 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
57 obj_tpl->SetInternalFieldCount(1);
58 auto ret = obj_tpl->NewInstance();
59
60 auto del = [](compatibility_callback_info_type info)
61 -> compatibility_return_type {
62 if (info.Length() != 0)
63 return compatibility_return();
64
65 auto p = ecore_event_handler_del(extract_event_handler(info.This()));
66
67 delete static_cast<efl::eina::js::global_ref<Value>*>(p);
68 return compatibility_return();
69 };
70
71 ret->Set(compatibility_new<String>(isolate, "del"),
72 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
73
74 compatibility_set_pointer_internal_field(ret, 0, handler);
75
76 return ret;
77}
78
79static Ecore_Event_Filter *extract_event_filter(v8::Local<v8::Object> object)
80{
81 return compatibility_get_pointer_internal_field<Ecore_Event_Filter*>
82 (object, 0);
83}
84
85static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
86 v8::Isolate *isolate)
87{
88 using v8::String;
89 using v8::ObjectTemplate;
90 using v8::FunctionTemplate;
91 using v8::Value;
92
93 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
94 obj_tpl->SetInternalFieldCount(1);
95 auto ret = obj_tpl->NewInstance();
96
97 auto del = [](compatibility_callback_info_type info)
98 -> compatibility_return_type {
99 if (info.Length() != 0)
100 return compatibility_return();
101
102 auto p = ecore_event_filter_del(extract_event_filter(info.This()));
103 delete[] static_cast<efl::eina::js::global_ref<Value>*>(p);
104 return compatibility_return();
105 };
106
107 ret->Set(compatibility_new<String>(isolate, "del"),
108 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
109
110 compatibility_set_pointer_internal_field(ret, 0, filter);
111
112 return ret;
113}
114
115EAPI
116void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
117 v8::Handle<v8::String> name)
118{
119 using v8::Integer;
120 global->Set(name,
121 compatibility_new<Integer>(isolate, ECORE_EVENT_NONE));
122}
123
124EAPI
125void register_event_signal_user(v8::Isolate *isolate,
126 v8::Handle<v8::Object> global,
127 v8::Handle<v8::String> name)
128{
129 using v8::Integer;
130 global->Set(name,
131 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_USER));
132}
133
134EAPI
135void register_event_signal_hup(v8::Isolate *isolate,
136 v8::Handle<v8::Object> global,
137 v8::Handle<v8::String> name)
138{
139 using v8::Integer;
140 global->Set(name,
141 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_HUP));
142}
143
144EAPI
145void register_event_signal_exit(v8::Isolate *isolate,
146 v8::Handle<v8::Object> global,
147 v8::Handle<v8::String> name)
148{
149 using v8::Integer;
150 global->Set(name,
151 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_EXIT));
152}
153
154EAPI
155void register_event_signal_power(v8::Isolate *isolate,
156 v8::Handle<v8::Object> global,
157 v8::Handle<v8::String> name)
158{
159 using v8::Integer;
160 global->Set(name,
161 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_POWER));
162}
163
164EAPI
165void register_event_signal_realtime(v8::Isolate *isolate,
166 v8::Handle<v8::Object> global,
167 v8::Handle<v8::String> name)
168{
169 using v8::Integer;
170 global->Set(name,
171 compatibility_new<Integer>(isolate,
172 ECORE_EVENT_SIGNAL_REALTIME));
173}
174
175EAPI
176void register_event_memory_state(v8::Isolate *isolate,
177 v8::Handle<v8::Object> global,
178 v8::Handle<v8::String> name)
179{
180 using v8::Integer;
181 global->Set(name,
182 compatibility_new<Integer>(isolate, ECORE_EVENT_MEMORY_STATE));
183}
184
185EAPI
186void register_event_power_state(v8::Isolate *isolate,
187 v8::Handle<v8::Object> global,
188 v8::Handle<v8::String> name)
189{
190 using v8::Integer;
191 global->Set(name,
192 compatibility_new<Integer>(isolate, ECORE_EVENT_POWER_STATE));
193}
194
195EAPI
196void register_event_locale_changed(v8::Isolate *isolate,
197 v8::Handle<v8::Object> global,
198 v8::Handle<v8::String> name)
199{
200 using v8::Integer;
201 global->Set(name,
202 compatibility_new<Integer>(isolate,
203 ECORE_EVENT_LOCALE_CHANGED));
204}
205
206EAPI
207void register_event_hostname_changed(v8::Isolate *isolate,
208 v8::Handle<v8::Object> global,
209 v8::Handle<v8::String> name)
210{
211 using v8::Integer;
212 global->Set(name,
213 compatibility_new<Integer>(isolate,
214 ECORE_EVENT_HOSTNAME_CHANGED));
215}
216
217EAPI
218void register_event_system_timedate_changed(v8::Isolate *isolate,
219 v8::Handle<v8::Object> global,
220 v8::Handle<v8::String> name)
221{
222 using v8::Integer;
223 global->Set(name,
224 compatibility_new<Integer>(isolate,
225 ECORE_EVENT_SYSTEM_TIMEDATE_CHANGED));
226}
227
228EAPI
229void register_event_type_new(v8::Isolate *isolate,
230 v8::Handle<v8::Object> global,
231 v8::Handle<v8::String> name)
232{
233 using v8::Integer;
234 using v8::FunctionTemplate;
235
236 auto f = [](compatibility_callback_info_type args)
237 -> compatibility_return_type {
238 if (args.Length() != 0)
239 return compatibility_return();
240
241 auto isolate = args.GetIsolate();
242 auto ret = ecore_event_type_new();
243 return compatibility_return(compatibility_new<Integer>(isolate, ret),
244 args);
245 };
246
247 global->Set(name,
248 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
249}
250
251EAPI
252void register_event_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
253 v8::Handle<v8::String> name)
254{
255 using v8::FunctionTemplate;
256
257 auto f = [](compatibility_callback_info_type args)
258 -> compatibility_return_type {
259 if (args.Length() != 1 || !args[0]->IsNumber())
260 return compatibility_return();
261
262 auto isolate = args.GetIsolate();
263 auto ret = ecore_event_add(args[0]->NumberValue(), NULL, NULL, NULL);
264 return compatibility_return(wrap_event(ret, isolate), args);
265 };
266
267 global->Set(name,
268 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
269}
270
271EAPI
272void register_event_handler_add(v8::Isolate *isolate,
273 v8::Handle<v8::Object> global,
274 v8::Handle<v8::String> name)
275{
276 using v8::Integer;
277 using v8::Value;
278 using v8::Function;
279 using v8::Handle;
280 using v8::Local;
281 using v8::FunctionTemplate;
282
283 auto f = [](compatibility_callback_info_type args)
284 -> compatibility_return_type {
285 if (args.Length() != 2 || !args[0]->IsNumber()
286 || !args[1]->IsFunction()) {
287 return compatibility_return();
288 }
289
290 auto isolate = args.GetIsolate();
291
292 auto p = new efl::eina::js::global_ref<Value>(isolate, args[1]);
293
294 auto cb = [](void *d, int type, void */*event*/) -> Eina_Bool {
295 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(d);
296 auto o = persistent->handle();
297
298 auto isolate = v8::Isolate::GetCurrent();
299 Handle<Value> args = compatibility_new<Integer>(isolate, type);
300
301 auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
302 auto bret = ret->IsBoolean() && ret->BooleanValue();
303
304 return bret ? EINA_TRUE : EINA_FALSE;
305 };
306
307 auto ret = ecore_event_handler_add(args[0]->Int32Value(), cb, p);
308 return compatibility_return(wrap_event_handler(ret, isolate), args);
309 };
310
311 global->Set(name,
312 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
313}
314
315EAPI
316void register_event_filter_add(v8::Isolate *isolate,
317 v8::Handle<v8::Object> global,
318 v8::Handle<v8::String> name)
319{
320 using v8::Integer;
321 using v8::Value;
322 using v8::Function;
323 using v8::Handle;
324 using v8::Local;
325 using v8::FunctionTemplate;
326
327 auto f = [](compatibility_callback_info_type args)
328 -> compatibility_return_type {
329 if (args.Length() != 3 || !args[0]->IsFunction()
330 || !args[1]->IsFunction() || !args[2]->IsFunction()) {
331 return compatibility_return();
332 }
333
334 auto isolate = args.GetIsolate();
335
336 auto p = new efl::eina::js::global_ref<Value>[3]{{isolate, args[0]},
337 {isolate, args[1]},
338 {isolate, args[2]}};
339
340 auto start_cb = [](void *data) -> void* {
341 auto p = static_cast<efl::eina::js::global_ref<Value>*>(data);
342 auto isolate = v8::Isolate::GetCurrent();
343 auto o = p->handle();
344
345 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
346 return new efl::eina::js::global_ref<Value>{isolate, ret};
347 };
348
349 auto filter_cb = [](void *data, void *loop_data, int type,
350 void */*event*/) -> Eina_Bool {
351 typedef efl::eina::js::global_ref<Value> p_t;
352
353 auto p = static_cast<p_t*>(data) + 1;
354 auto isolate = v8::Isolate::GetCurrent();
355 auto o = p->handle();
356
357 Handle<Value> args[2]{
358 static_cast<p_t*>(loop_data)->handle(),
359 compatibility_new<Integer>(isolate, type)
360 };
361
362 auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
363 auto bret = ret->IsBoolean() && ret->BooleanValue();
364
365 return bret ? EINA_TRUE : EINA_FALSE;
366 };
367
368 auto end_cb = [](void *user_data, void *func_data) -> void {
369 typedef efl::eina::js::global_ref<Value> p_t;
370
371 auto loop_data = std::unique_ptr<p_t>(static_cast<p_t*>
372 (func_data));
373 auto p = static_cast<p_t*>(user_data) + 2;
374 auto o = p->handle();
375
376 Handle<Value> args = p->handle();
377
378 Function::Cast(*o)->Call(o->ToObject(), 1, &args);
379 };
380
381 auto ret = ecore_event_filter_add(start_cb, filter_cb, end_cb, p);
382 return compatibility_return(wrap_event_filter(ret, isolate), args);
383 };
384
385 global->Set(name,
386 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
387}
388
389EAPI
390void register_event_current_type_get(v8::Isolate *isolate,
391 v8::Handle<v8::Object> global,
392 v8::Handle<v8::String> name)
393{
394 using v8::Integer;
395 using v8::FunctionTemplate;
396
397 auto f = [](compatibility_callback_info_type args)
398 -> compatibility_return_type {
399 if (args.Length() != 0)
400 return compatibility_return();
401
402 auto isolate = args.GetIsolate();
403 auto ret = ecore_event_current_type_get();
404 return compatibility_return(compatibility_new<Integer>(isolate, ret),
405 args);
406 };
407
408 global->Set(name,
409 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
410}
411
412EAPI
413void register_memory_state_normal(v8::Isolate *isolate,
414 v8::Handle<v8::Object> global,
415 v8::Handle<v8::String> name)
416{
417 using v8::Integer;
418 global->Set(name,
419 compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_NORMAL));
420}
421
422EAPI
423void register_memory_state_low(v8::Isolate *isolate,
424 v8::Handle<v8::Object> global,
425 v8::Handle<v8::String> name)
426{
427 using v8::Integer;
428 global->Set(name,
429 compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_LOW));
430}
431
432EAPI
433void register_power_state_mains(v8::Isolate *isolate,
434 v8::Handle<v8::Object> global,
435 v8::Handle<v8::String> name)
436{
437 using v8::Integer;
438 global->Set(name,
439 compatibility_new<Integer>(isolate, ECORE_POWER_STATE_MAINS));
440}
441
442EAPI
443void register_power_state_battery(v8::Isolate *isolate,
444 v8::Handle<v8::Object> global,
445 v8::Handle<v8::String> name)
446{
447 using v8::Integer;
448 global->Set(name,
449 compatibility_new<Integer>(isolate, ECORE_POWER_STATE_BATTERY));
450}
451
452EAPI
453void register_power_state_low(v8::Isolate *isolate,
454 v8::Handle<v8::Object> global,
455 v8::Handle<v8::String> name)
456{
457 using v8::Integer;
458 global->Set(name,
459 compatibility_new<Integer>(isolate, ECORE_POWER_STATE_LOW));
460}
461
462EAPI
463void register_memory_state_get(v8::Isolate *isolate,
464 v8::Handle<v8::Object> global,
465 v8::Handle<v8::String> name)
466{
467 using v8::Integer;
468 using v8::FunctionTemplate;
469
470 auto f = [](compatibility_callback_info_type args)
471 -> compatibility_return_type {
472 if (args.Length() != 0)
473 return compatibility_return();
474
475 auto isolate = args.GetIsolate();
476 auto ret = ecore_memory_state_get();
477 return compatibility_return(compatibility_new<Integer>(isolate, ret),
478 args);
479 };
480
481 global->Set(name,
482 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
483}
484
485EAPI
486void register_power_state_get(v8::Isolate *isolate,
487 v8::Handle<v8::Object> global,
488 v8::Handle<v8::String> name)
489{
490 using v8::Integer;
491 using v8::FunctionTemplate;
492
493 auto f = [](compatibility_callback_info_type args)
494 -> compatibility_return_type {
495 if (args.Length() != 0)
496 return compatibility_return();
497
498 auto isolate = args.GetIsolate();
499 auto ret = ecore_power_state_get();
500 return compatibility_return(compatibility_new<Integer>(isolate, ret),
501 args);
502 };
503
504 global->Set(name,
505 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
506}
507
508EAPI
509void register_event_signal_user_handler_add(v8::Isolate *isolate,
510 v8::Handle<v8::Object> global,
511 v8::Handle<v8::String> name)
512{
513 using v8::Integer;
514 using v8::String;
515 using v8::Value;
516 using v8::Object;
517 using v8::Function;
518 using v8::Handle;
519 using v8::Local;
520 using v8::FunctionTemplate;
521
522 auto f = [](compatibility_callback_info_type args)
523 -> compatibility_return_type {
524 if (args.Length() != 1 || !args[0]->IsFunction())
525 return compatibility_return();
526
527 auto isolate = args.GetIsolate();
528
529 auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
530
531 auto cb = [](void *d, int type, void *event) -> Eina_Bool {
532 auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
533 auto isolate = v8::Isolate::GetCurrent();
534 auto o = p->handle();
535
536 auto wrapped_event = compatibility_new<Object>(isolate);
537
538 {
539 auto n
540 = reinterpret_cast<Ecore_Event_Signal_User*>(event)->number;
541 wrapped_event->Set(compatibility_new<String>(isolate, "number"),
542 compatibility_new<Integer>(isolate, n));
543 }
544
545 Handle<Value> args[2]{
546 compatibility_new<Integer>(isolate, type),
547 wrapped_event
548 };
549
550 auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
551 auto bret = ret->IsBoolean() && ret->BooleanValue();
552
553 return bret ? EINA_TRUE : EINA_FALSE;
554 };
555
556 auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, cb, p);
557 return compatibility_return(wrap_event_handler(ret, isolate), args);
558 };
559
560 global->Set(name,
561 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
562}
563
564EAPI
565void register_event_signal_exit_handler_add(v8::Isolate *isolate,
566 v8::Handle<v8::Object> global,
567 v8::Handle<v8::String> name)
568{
569 using v8::Integer;
570 using v8::Boolean;
571 using v8::String;
572 using v8::Value;
573 using v8::Object;
574 using v8::Function;
575 using v8::Handle;
576 using v8::Local;
577 using v8::FunctionTemplate;
578
579 auto f = [](compatibility_callback_info_type args)
580 -> compatibility_return_type {
581 if (args.Length() != 1 || !args[0]->IsFunction())
582 return compatibility_return();
583
584 auto isolate = args.GetIsolate();
585
586 auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
587
588 auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
589 auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
590 auto isolate = v8::Isolate::GetCurrent();
591 auto o = p->handle();
592
593 auto wrapped_event = compatibility_new<Object>(isolate);
594
595 {
596 auto event = reinterpret_cast<Ecore_Event_Signal_Exit*>(ev);
597 auto interrupt = event->interrupt;
598 auto quit = event->quit;
599 auto terminate = event->terminate;
600
601 wrapped_event->Set(compatibility_new<String>(isolate,
602 "interrupt"),
603 compatibility_new<Boolean>(isolate,
604 interrupt));
605 wrapped_event->Set(compatibility_new<String>(isolate, "quit"),
606 compatibility_new<Boolean>(isolate, quit));
607 wrapped_event->Set(compatibility_new<String>(isolate,
608 "terminate"),
609 compatibility_new<Boolean>(isolate,
610 terminate));
611 }
612
613 Handle<Value> args[2]{
614 compatibility_new<Integer>(isolate, type),
615 wrapped_event
616 };
617
618 auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
619 auto bret = ret->IsBoolean() && ret->BooleanValue();
620
621 return bret ? EINA_TRUE : EINA_FALSE;
622 };
623
624 auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, cb, p);
625 return compatibility_return(wrap_event_handler(ret, isolate), args);
626 };
627
628 global->Set(name,
629 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
630}
631
632EAPI
633void register_event_signal_realtime_handler_add(v8::Isolate *isolate,
634 v8::Handle<v8::Object> global,
635 v8::Handle<v8::String> name)
636{
637 using v8::Integer;
638 using v8::String;
639 using v8::Value;
640 using v8::Object;
641 using v8::Function;
642 using v8::Handle;
643 using v8::Local;
644 using v8::FunctionTemplate;
645
646 auto f = [](compatibility_callback_info_type args)
647 -> compatibility_return_type {
648 if (args.Length() != 1 || !args[0]->IsFunction())
649 return compatibility_return();
650
651 auto isolate = args.GetIsolate();
652
653 auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
654
655 auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
656 auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
657 auto isolate = v8::Isolate::GetCurrent();
658 auto o = p->handle();
659
660 auto wrapped_event = compatibility_new<Object>(isolate);
661
662 {
663 auto n
664 = reinterpret_cast<Ecore_Event_Signal_Realtime*>(ev)->num;
665 wrapped_event->Set(compatibility_new<String>(isolate, "num"),
666 compatibility_new<Integer>(isolate, n));
667 }
668
669 Handle<Value> args[2]{
670 compatibility_new<Integer>(isolate, type),
671 wrapped_event
672 };
673
674 auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
675 auto bret = ret->IsBoolean() && ret->BooleanValue();
676
677 return bret ? EINA_TRUE : EINA_FALSE;
678 };
679
680 auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_REALTIME, cb, p);
681 return compatibility_return(wrap_event_handler(ret, isolate), args);
682 };
683
684 global->Set(name,
685 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
686}
687
688EAPI
689void register_ecore_event(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
690{
691 register_event_none(isolate, exports,
692 compatibility_new<v8::String>(isolate,
693 "ECORE_EVENT_NONE"));
694 register_event_signal_user(isolate, exports,
695 compatibility_new<v8::String>
696 (isolate, "ECORE_EVENT_SIGNAL_USER"));
697 register_event_signal_hup(isolate, exports,
698 compatibility_new<v8::String>
699 (isolate, "ECORE_EVENT_SIGNAL_HUP"));
700 register_event_signal_exit(isolate, exports,
701 compatibility_new<v8::String>
702 (isolate, "ECORE_EVENT_SIGNAL_EXIT"));
703 register_event_signal_power(isolate, exports,
704 compatibility_new<v8::String>
705 (isolate, "ECORE_EVENT_SIGNAL_POWER"));
706 register_event_signal_realtime(isolate, exports,
707 compatibility_new<v8::String>
708 (isolate, "ECORE_EVENT_SIGNAL_REALTIME"));
709 register_event_memory_state(isolate, exports,
710 compatibility_new<v8::String>
711 (isolate, "ECORE_EVENT_MEMORY_STATE"));
712 register_event_power_state(isolate, exports,
713 compatibility_new<v8::String>
714 (isolate, "ECORE_EVENT_POWER_STATE"));
715 register_event_locale_changed(isolate, exports,
716 compatibility_new<v8::String>
717 (isolate, "ECORE_EVENT_LOCALE_CHANGED"));
718 register_event_hostname_changed(isolate, exports,
719 compatibility_new<v8::String>
720 (isolate, "ECORE_EVENT_HOSTNAME_CHANGED"));
721 register_event_system_timedate_changed(isolate, exports,
722 compatibility_new<v8::String>
723 (isolate,
724 "ECORE_EVENT_SYSTEM_TIMEDATE"
725 "_CHANGED"));
726 register_event_type_new(isolate, exports,
727 compatibility_new<v8::String>(isolate,
728 "ecore_event_type_new"));
729 register_event_add(isolate, exports,
730 compatibility_new<v8::String>(isolate, "ecore_event_add"));
731 register_event_handler_add(isolate, exports,
732 compatibility_new<v8::String>
733 (isolate, "ecore_event_handler_add"));
734 register_event_filter_add(isolate, exports,
735 compatibility_new<v8::String>
736 (isolate, "ecore_event_filter_add"));
737 register_event_current_type_get(isolate, exports,
738 compatibility_new<v8::String>
739 (isolate, "ecore_event_current_type_get"));
740 register_memory_state_normal(isolate, exports,
741 compatibility_new<v8::String>
742 (isolate, "ECORE_MEMORY_STATE_NORMAL"));
743 register_memory_state_low(isolate, exports,
744 compatibility_new<v8::String>
745 (isolate, "ECORE_MEMORY_STATE_LOW"));
746 register_power_state_mains(isolate, exports,
747 compatibility_new<v8::String>
748 (isolate, "ECORE_POWER_STATE_MAINS"));
749 register_power_state_battery(isolate, exports,
750 compatibility_new<v8::String>
751 (isolate, "ECORE_POWER_STATE_BATTERY"));
752 register_power_state_low(isolate, exports,
753 compatibility_new<v8::String>(isolate,
754 "ECORE_POWER_STATE_LOW"));
755 register_event_signal_user_handler_add(isolate, exports,
756 compatibility_new<v8::String>
757 (isolate,
758 "ecore_event_signal_user_handler"
759 "_add"));
760 register_event_signal_exit_handler_add(isolate, exports,
761 compatibility_new<v8::String>
762 (isolate,
763 "ecore_event_signal_exit_handler"
764 "_add"));
765 register_event_signal_realtime_handler_add(isolate, exports,
766 compatibility_new<v8::String>
767 (isolate,
768 "ecore_event_signal_realtime"
769 "_handler_add"));
770}
771
772} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_idle.cc b/src/bindings/js/ecore_js/ecore_js_idle.cc
new file mode 100644
index 0000000000..293cef2f45
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_idle.cc
@@ -0,0 +1,294 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Idler* extract_idler(v8::Local<v8::Object> object)
10{
11 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
12 return reinterpret_cast<Ecore_Idler*>(ptr);
13}
14
15static
16v8::Local<v8::Object> wrap_idler(Ecore_Idler *idler, v8::Isolate *isolate)
17{
18 using v8::Boolean;
19 using v8::String;
20 using v8::ObjectTemplate;
21 using v8::FunctionTemplate;
22
23 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
24 obj_tpl->SetInternalFieldCount(1);
25 auto ret = obj_tpl->NewInstance();
26
27 auto del = [](compatibility_callback_info_type info)
28 -> compatibility_return_type {
29 if (info.Length() != 0)
30 return compatibility_return();
31
32 ecore_idler_del(extract_idler(info.This()));
33 return compatibility_return();
34 };
35
36 ret->Set(compatibility_new<String>(isolate, "del"),
37 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
38
39 ret->SetInternalField(0, compatibility_new<v8::External>(isolate, idler));
40
41 return ret;
42}
43
44static Ecore_Idle_Enterer* extract_idle_enterer(v8::Local<v8::Object> object)
45{
46 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
47 return reinterpret_cast<Ecore_Idle_Enterer*>(ptr);
48}
49
50static v8::Local<v8::Object> wrap_idle_enterer(Ecore_Idle_Enterer *idle_enterer,
51 v8::Isolate *isolate)
52{
53 using v8::Boolean;
54 using v8::String;
55 using v8::ObjectTemplate;
56 using v8::FunctionTemplate;
57 using v8::External;
58
59 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
60 obj_tpl->SetInternalFieldCount(1);
61 auto ret = obj_tpl->NewInstance();
62
63 auto del = [](compatibility_callback_info_type info)
64 -> compatibility_return_type {
65 if (info.Length() != 0)
66 return compatibility_return();
67
68 ecore_idle_enterer_del(extract_idle_enterer(info.This()));
69 return compatibility_return();
70 };
71
72 ret->Set(compatibility_new<String>(isolate, "del"),
73 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
74
75 ret->SetInternalField(0,
76 compatibility_new<External>(isolate, idle_enterer));
77
78 return ret;
79}
80
81static Ecore_Idle_Exiter* extract_idle_exiter(v8::Local<v8::Object> object)
82{
83 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
84 return reinterpret_cast<Ecore_Idle_Exiter*>(ptr);
85}
86
87static v8::Local<v8::Object> wrap_idle_exiter(Ecore_Idle_Exiter *idle_exiter,
88 v8::Isolate *isolate)
89{
90 using v8::Boolean;
91 using v8::String;
92 using v8::ObjectTemplate;
93 using v8::FunctionTemplate;
94 using v8::External;
95
96 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
97 obj_tpl->SetInternalFieldCount(1);
98 auto ret = obj_tpl->NewInstance();
99
100 auto del = [](compatibility_callback_info_type info)
101 -> compatibility_return_type {
102 if (info.Length() != 0)
103 return compatibility_return();
104
105 ecore_idle_exiter_del(extract_idle_exiter(info.This()));
106 return compatibility_return();
107 };
108
109 ret->Set(compatibility_new<String>(isolate, "del"),
110 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
111
112 ret->SetInternalField(0, compatibility_new<External>(isolate, idle_exiter));
113
114 return ret;
115}
116
117void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
118 v8::Handle<v8::String> name)
119{
120 using v8::Local;
121 using v8::Value;
122 using v8::Undefined;
123 using v8::Function;
124 using v8::FunctionTemplate;
125
126 auto f = [](compatibility_callback_info_type args)
127 -> compatibility_return_type {
128 if (args.Length() != 1 || !args[0]->IsFunction())
129 return compatibility_return();
130
131 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
132 auto ret = ecore_idler_add([](void *data) -> Eina_Bool {
133 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
134 auto o = persistent->handle();
135
136 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
137 auto bret = ret->IsBoolean() && ret->BooleanValue();
138
139 if (!bret)
140 {
141 persistent->dispose();
142 delete persistent;
143 }
144
145 return bret ? EINA_TRUE : EINA_FALSE;
146 }, f);
147
148 return compatibility_return(wrap_idler(ret, args.GetIsolate()), args);
149 };
150
151 global->Set(name,
152 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
153}
154
155void register_idle_enterer_add(v8::Isolate *isolate,
156 v8::Handle<v8::Object> global,
157 v8::Handle<v8::String> name)
158{
159 using v8::Local;
160 using v8::Value;
161 using v8::Undefined;
162 using v8::Function;
163 using v8::FunctionTemplate;
164
165 auto f = [](compatibility_callback_info_type args)
166 -> compatibility_return_type {
167 if (args.Length() != 1 || !args[0]->IsFunction())
168 return compatibility_return();
169
170 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
171 auto ret = ecore_idle_enterer_add([](void *data) -> Eina_Bool {
172 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
173 auto o = persistent->handle();
174
175 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
176 auto bret = ret->IsBoolean() && ret->BooleanValue();
177
178 if (!bret)
179 {
180 persistent->dispose();
181 delete persistent;
182 }
183
184 return bret ? EINA_TRUE : EINA_FALSE;
185 }, f);
186
187 return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
188 args);
189 };
190
191 global->Set(name,
192 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
193}
194
195void register_idle_enterer_before_add(v8::Isolate *isolate,
196 v8::Handle<v8::Object> global,
197 v8::Handle<v8::String> name)
198{
199 using v8::Local;
200 using v8::Value;
201 using v8::Undefined;
202 using v8::Function;
203 using v8::FunctionTemplate;
204
205 auto f = [](compatibility_callback_info_type args)
206 -> compatibility_return_type {
207 if (args.Length() != 1 || !args[0]->IsFunction())
208 return compatibility_return();
209
210 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
211 auto ret = ecore_idle_enterer_before_add([](void *data) -> Eina_Bool {
212 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
213 auto o = persistent->handle();
214
215 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
216 auto bret = ret->IsBoolean() && ret->BooleanValue();
217
218 if (!bret)
219 {
220 persistent->dispose();
221 delete persistent;
222 }
223
224 return bret ? EINA_TRUE : EINA_FALSE;
225 }, f);
226
227 return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
228 args);
229 };
230
231 global->Set(name,
232 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
233}
234
235void register_idle_exiter_add(v8::Isolate *isolate,
236 v8::Handle<v8::Object> global,
237 v8::Handle<v8::String> name)
238{
239 using v8::Local;
240 using v8::Value;
241 using v8::Undefined;
242 using v8::Function;
243 using v8::FunctionTemplate;
244
245 auto f = [](compatibility_callback_info_type args)
246 -> compatibility_return_type {
247 if (args.Length() != 1 || !args[0]->IsFunction())
248 return compatibility_return();
249
250 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
251 auto ret = ecore_idle_exiter_add([](void *data) -> Eina_Bool {
252 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
253 auto o = persistent->handle();
254
255 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
256 auto bret = ret->IsBoolean() && ret->BooleanValue();
257
258 if (!bret)
259 {
260 persistent->dispose();
261 delete persistent;
262 }
263
264 return bret ? EINA_TRUE : EINA_FALSE;
265 }, f);
266
267 return compatibility_return(wrap_idle_exiter(ret, args.GetIsolate()),
268 args);
269 };
270
271 global->Set(name,
272 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
273}
274
275EAPI
276void register_ecore_idle(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
277{
278 register_idler_add(isolate, exports,
279 compatibility_new<v8::String>(isolate, "ecore_idler_add"));
280 register_idle_enterer_add(isolate, exports,
281 compatibility_new<v8::String>(isolate,
282 "ecore_idle_enterer"
283 "_add"));
284 register_idle_enterer_before_add(isolate, exports,
285 compatibility_new<v8::String>(isolate,
286 "ecore_idle"
287 "_enterer_before"
288 "_add"));
289 register_idle_exiter_add(isolate, exports,
290 compatibility_new<v8::String>(isolate,
291 "ecore_idle_exiter_add"));
292}
293
294} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_init.cc b/src/bindings/js/ecore_js/ecore_js_init.cc
new file mode 100644
index 0000000000..ba2b04f842
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_init.cc
@@ -0,0 +1,76 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9namespace {
10
11void register_init(v8::Isolate *isolate, v8::Handle<v8::Object> global,
12 v8::Handle<v8::String> name)
13{
14 using v8::Integer;
15 using v8::FunctionTemplate;
16
17 auto init = [](compatibility_callback_info_type args)
18 -> compatibility_return_type {
19 if (args.Length() != 0)
20 return compatibility_return();
21
22 auto isolate = args.GetIsolate();
23 auto ret = ::ecore_init();
24 return compatibility_return(compatibility_new<Integer>(isolate, ret),
25 args);
26 };
27
28 global->Set(name,
29 compatibility_new<FunctionTemplate>(isolate, init)
30 ->GetFunction());
31}
32
33void register_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> global,
34 v8::Handle<v8::String> name)
35{
36 using v8::Integer;
37 using v8::FunctionTemplate;
38
39 auto shutdown = [](compatibility_callback_info_type args)
40 -> compatibility_return_type {
41 if (args.Length() != 0)
42 return compatibility_return();
43
44 auto isolate = args.GetIsolate();
45 auto ret = ecore_shutdown();
46 return compatibility_return(compatibility_new<Integer>(isolate, ret),
47 args);
48 };
49
50 global->Set(name,
51 compatibility_new<FunctionTemplate>(isolate, shutdown)
52 ->GetFunction());
53}
54
55}
56
57EAPI
58void register_ecore(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
59{
60 efl::ecore::js::register_init(isolate, exports,
61 efl::eina::js::compatibility_new<v8::String>
62 (isolate, "ecore_init"));
63 efl::ecore::js::register_shutdown(isolate, exports,
64 efl::eina::js::compatibility_new<v8::String>
65 (isolate, "ecore_shutdown"));
66 register_ecore_animator(isolate, exports);
67 register_ecore_event(isolate, exports);
68 register_ecore_idle(isolate, exports);
69 register_ecore_job(isolate, exports);
70 register_ecore_mainloop(isolate, exports);
71 register_ecore_poller(isolate, exports);
72 register_ecore_throttle(isolate, exports);
73 register_ecore_timer(isolate, exports);
74}
75
76} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_job.cc b/src/bindings/js/ecore_js/ecore_js_job.cc
new file mode 100644
index 0000000000..4ec438aaaf
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_job.cc
@@ -0,0 +1,83 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Job* extract_job(v8::Local<v8::Object> object)
10{
11 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
12 return reinterpret_cast<Ecore_Job*>(ptr);
13}
14
15static v8::Local<v8::Object> wrap_job(Ecore_Job *job, v8::Isolate *isolate)
16{
17 using v8::Boolean;
18 using v8::String;
19 using v8::ObjectTemplate;
20 using v8::FunctionTemplate;
21
22 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
23 obj_tpl->SetInternalFieldCount(1);
24 auto ret = obj_tpl->NewInstance();
25
26 auto del = [](compatibility_callback_info_type info)
27 -> compatibility_return_type {
28 if (info.Length() != 0)
29 return compatibility_return();
30
31 ecore_job_del(extract_job(info.This()));
32 return compatibility_return();
33 };
34
35 ret->Set(compatibility_new<String>(isolate, "del"),
36 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
37
38 ret->SetInternalField(0, compatibility_new<v8::External>(isolate, job));
39
40 return ret;
41}
42
43EAPI
44void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
45 v8::Handle<v8::String> name)
46{
47 using v8::Local;
48 using v8::Value;
49 using v8::Undefined;
50 using v8::Function;
51 using v8::FunctionTemplate;
52
53 auto f = [](compatibility_callback_info_type args)
54 -> compatibility_return_type {
55 if (args.Length() != 1 || !args[0]->IsFunction())
56 return compatibility_return();
57
58 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
59 auto ret = ecore_job_add([](void *data) {
60 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
61 auto o = persistent->handle();
62
63 Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
64
65 persistent->dispose();
66 delete persistent;
67 }, f);
68
69 return compatibility_return(wrap_job(ret, args.GetIsolate()), args);
70 };
71
72 global->Set(name,
73 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
74}
75
76EAPI
77void register_ecore_job(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
78{
79 register_job_add(isolate, exports,
80 compatibility_new<v8::String>(isolate, "ecore_job_add"));
81}
82
83} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_mainloop.cc b/src/bindings/js/ecore_js/ecore_js_mainloop.cc
new file mode 100644
index 0000000000..180b35f0f6
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_mainloop.cc
@@ -0,0 +1,207 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9namespace {
10
11void register_callback_cancel(v8::Isolate *isolate,
12 v8::Handle<v8::Object> global,
13 v8::Handle<v8::String> name)
14{
15 using v8::Boolean;
16 global->Set(name, compatibility_new<Boolean>(isolate,
17 bool{ECORE_CALLBACK_CANCEL}));
18}
19
20void register_callback_renew(v8::Isolate *isolate,
21 v8::Handle<v8::Object> global,
22 v8::Handle<v8::String> name)
23{
24 using v8::Boolean;
25 global->Set(name, compatibility_new<Boolean>(isolate,
26 bool{ECORE_CALLBACK_RENEW}));
27}
28
29void register_callback_pass_on(v8::Isolate *isolate,
30 v8::Handle<v8::Object> global,
31 v8::Handle<v8::String> name)
32{
33 using v8::Boolean;
34 global->Set(name, compatibility_new<Boolean>(isolate,
35 bool{ECORE_CALLBACK_PASS_ON}));
36}
37
38void register_callback_done(v8::Isolate *isolate, v8::Handle<v8::Object> global,
39 v8::Handle<v8::String> name)
40{
41 using v8::Boolean;
42 global->Set(name, compatibility_new<Boolean>(isolate,
43 bool{ECORE_CALLBACK_DONE}));
44}
45
46void register_mainloop_iterate(v8::Isolate *isolate,
47 v8::Handle<v8::Object> global,
48 v8::Handle<v8::String> name)
49{
50 using v8::Integer;
51 using v8::FunctionTemplate;
52
53 auto f = [](compatibility_callback_info_type args)
54 -> compatibility_return_type {
55 if (args.Length() != 0)
56 return compatibility_return();
57
58 ecore_main_loop_iterate();
59 return compatibility_return();
60 };
61
62 global->Set(name,
63 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
64}
65
66void register_mainloop_iterate_may_block(v8::Isolate *isolate,
67 v8::Handle<v8::Object> global,
68 v8::Handle<v8::String> name)
69{
70 using v8::Integer;
71 using v8::FunctionTemplate;
72
73 auto f = [](compatibility_callback_info_type args)
74 -> compatibility_return_type {
75 if (args.Length() != 1 || !args[0]->IsNumber())
76 return compatibility_return();
77
78 auto ret = ecore_main_loop_iterate_may_block(args[0]->NumberValue());
79 return compatibility_return(compatibility_new<Integer>
80 (args.GetIsolate(), ret), args);
81 };
82
83 global->Set(name,
84 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
85}
86
87void register_mainloop_begin(v8::Isolate *isolate,
88 v8::Handle<v8::Object> global,
89 v8::Handle<v8::String> name)
90{
91 using v8::Integer;
92 using v8::FunctionTemplate;
93
94 auto f = [](compatibility_callback_info_type args)
95 -> compatibility_return_type {
96 if (args.Length() != 0)
97 return compatibility_return();
98
99 ecore_main_loop_begin();
100 return compatibility_return();
101 };
102
103 global->Set(name,
104 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
105}
106
107void register_mainloop_quit(v8::Isolate *isolate, v8::Handle<v8::Object> global,
108 v8::Handle<v8::String> name)
109{
110 using v8::Integer;
111 using v8::FunctionTemplate;
112
113 auto f = [](compatibility_callback_info_type args)
114 -> compatibility_return_type {
115 if (args.Length() != 0)
116 return compatibility_return();
117
118 ecore_main_loop_quit();
119 return compatibility_return();
120 };
121
122 global->Set(name,
123 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
124}
125
126void register_mainloop_animator_ticked_get(v8::Isolate *isolate,
127 v8::Handle<v8::Object> global,
128 v8::Handle<v8::String> name)
129{
130 using v8::Boolean;
131 using v8::FunctionTemplate;
132
133 auto f = [](compatibility_callback_info_type args)
134 -> compatibility_return_type {
135 if (args.Length() != 0)
136 return compatibility_return();
137
138 auto ret = ecore_main_loop_animator_ticked_get();
139 return compatibility_return(compatibility_new<Boolean>
140 (args.GetIsolate(), ret), args);
141 };
142
143 global->Set(name,
144 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
145}
146
147void register_mainloop_nested_get(v8::Isolate *isolate,
148 v8::Handle<v8::Object> global,
149 v8::Handle<v8::String> name)
150{
151 using v8::Boolean;
152 using v8::FunctionTemplate;
153
154 auto f = [](compatibility_callback_info_type args)
155 -> compatibility_return_type {
156 if (args.Length() != 0)
157 return compatibility_return();
158
159 auto ret = ecore_main_loop_nested_get();
160 return compatibility_return(compatibility_new<Boolean>
161 (args.GetIsolate(), ret), args);
162 };
163
164 global->Set(name,
165 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
166}
167
168}
169
170EAPI
171void register_ecore_mainloop(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
172{
173 register_callback_cancel(isolate, exports,
174 compatibility_new<v8::String>
175 (isolate, "ECORE_CALLBACK_CANCEL"));
176 register_callback_renew(isolate, exports,
177 compatibility_new<v8::String>
178 (isolate, "ECORE_CALLBACK_RENEW"));
179 register_callback_pass_on(isolate, exports,
180 compatibility_new<v8::String>
181 (isolate, "ECORE_CALLBACK_PASS_ON"));
182 register_callback_done(isolate, exports,
183 compatibility_new<v8::String>
184 (isolate, "ECORE_CALLBACK_DONE"));
185 register_mainloop_iterate(isolate, exports,
186 compatibility_new<v8::String>
187 (isolate, "ecore_mainloop_iterate"));
188 register_mainloop_iterate_may_block(isolate, exports,
189 compatibility_new<v8::String>
190 (isolate,
191 "ecore_mainloop_iterate_may_block"));
192 register_mainloop_begin(isolate, exports,
193 compatibility_new<v8::String>
194 (isolate, "ecore_mainloop_begin"));
195 register_mainloop_quit(isolate, exports,
196 compatibility_new<v8::String>
197 (isolate, "ecore_mainloop_quit"));
198 register_mainloop_animator_ticked_get(isolate, exports,
199 compatibility_new<v8::String>
200 (isolate,
201 "ecore_mainlop_animator_ticked_get"));
202 register_mainloop_nested_get(isolate, exports,
203 compatibility_new<v8::String>
204 (isolate, "ecore_mainloop_nested_get"));
205}
206
207} } } // namespace efl { namespace js {
diff --git a/src/bindings/js/ecore_js/ecore_js_poller.cc b/src/bindings/js/ecore_js/ecore_js_poller.cc
new file mode 100644
index 0000000000..e3bfbc843a
--- /dev/null
+++ b/src/bindings/js/ecore_js/ecore_js_poller.cc
@@ -0,0 +1,190 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9namespace {
10
11Ecore_Poller* extract_poller(v8::Local<v8::Object> object)
12{
13 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
14 return reinterpret_cast<Ecore_Poller*>(ptr);
15}
16
17v8::Local<v8::Object> wrap_poller(Ecore_Poller *poller,
18 v8::Isolate *isolate)
19{
20 using v8::Boolean;
21 using v8::String;
22 using v8::ObjectTemplate;
23 using v8::FunctionTemplate;
24
25 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
26 obj_tpl->SetInternalFieldCount(1);
27 auto ret = obj_tpl->NewInstance();
28
29 auto del = [](compatibility_callback_info_type info)
30 -> compatibility_return_type {
31 if (info.Length() != 0)
32 return compatibility_return();
33
34 ecore_poller_del(extract_poller(info.This()));
35 return compatibility_return();
36 };
37
38 ret->Set(compatibility_new<String>(isolate, "del"),
39 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
40
41 ret->SetInternalField(0, compatibility_new<v8::External>(isolate, poller));
42
43 return ret;
44}
45
46void register_poller_core(v8::Isolate *isolate, v8::Handle<v8::Object> global,
47 v8::Handle<v8::String> name)
48{
49 using v8::Integer;
50
51 global->Set(name, compatibility_new<Integer>(isolate, ECORE_POLLER_CORE));
52}
53
54void register_poller_poll_interval_set(v8::Isolate *isolate,
55 v8::Handle<v8::Object> global,
56 v8::Handle<v8::String> name)
57{
58 using v8::Integer;
59 using v8::FunctionTemplate;
60
61 auto f = [](compatibility_callback_info_type args)
62 -> compatibility_return_type {
63 if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
64 return compatibility_return();
65
66 Ecore_Poller_Type type;
67
68 switch ((int)(args[0]->NumberValue())) {
69 case ECORE_POLLER_CORE:
70 type = ECORE_POLLER_CORE;
71 break;
72 default:
73 return compatibility_return();
74 }
75
76 ecore_poller_poll_interval_set(type, args[1]->NumberValue());
77 return compatibility_return();
78 };
79
80 global->Set(name,
81 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
82}
83
84void register_poller_poll_interval_get(v8::Isolate *isolate,
85 v8::Handle<v8::Object> global,
86 v8::Handle<v8::String> name)
87{
88 using v8::Integer;
89 using v8::FunctionTemplate;
90
91 auto f = [](compatibility_callback_info_type args)
92 -> compatibility_return_type {
93 if (args.Length() != 1 || !args[0]->IsNumber())
94 return compatibility_return();
95
96 Ecore_Poller_Type type;
97
98 switch ((int)(args[0]->NumberValue())) {
99 case ECORE_POLLER_CORE:
100 type = ECORE_POLLER_CORE;
101 break;
102 default:
103 return compatibility_return();
104 }
105
106 auto isolate = args.GetIsolate();
107 auto ret = ecore_poller_poll_interval_get(type);
108 return compatibility_return(compatibility_new<Integer>(isolate, ret),
109 args);
110 };
111
112 global->Set(name,
113 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
114}
115
116void register_poller_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
117 v8::Handle<v8::String> name)
118{
119 using v8::Integer;
120 using v8::Value;
121 using v8::FunctionTemplate;
122 using v8::Isolate;
123 using v8::Function;
124
125 auto f = [](compatibility_callback_info_type args)
126 -> compatibility_return_type {
127 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
128 || !args[2]->IsFunction()) {
129 return compatibility_return();
130 }
131
132 Ecore_Poller_Type type;