summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-05 14:41:38 -0300
committerVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-05 14:41:38 -0300
commit1f5fadd9d512519eb31e76c88c5f3aaff6ea3094 (patch)
tree79fc866406c178b3f4431b2cb22c0fb3189e4995
parentebe77260c5e75ffdfa1dd98ce6759b102bb8a7d6 (diff)
Initial binding for Ecore_Throttle
-rw-r--r--src/Makefile_Ecore_Js.am6
-rw-r--r--src/bindings/ecore_js/ecore_js_throttle.cc51
-rw-r--r--src/bindings/ecore_js/ecore_js_throttle.hh27
-rw-r--r--src/tests/ecore_js/ecore_js_suite.cc9
-rwxr-xr-xsrc/tests/ecore_js/ecore_js_suite.js7
5 files changed, 98 insertions, 2 deletions
diff --git a/src/Makefile_Ecore_Js.am b/src/Makefile_Ecore_Js.am
index bf4d594..2a69862 100644
--- a/src/Makefile_Ecore_Js.am
+++ b/src/Makefile_Ecore_Js.am
@@ -28,7 +28,8 @@ bindings/ecore_js/ecore_js_event.cc \
28bindings/ecore_js/ecore_js_job.cc \ 28bindings/ecore_js/ecore_js_job.cc \
29bindings/ecore_js/ecore_js_idle.cc \ 29bindings/ecore_js/ecore_js_idle.cc \
30bindings/ecore_js/ecore_js_animator.cc \ 30bindings/ecore_js/ecore_js_animator.cc \
31bindings/ecore_js/ecore_js_poller.cc 31bindings/ecore_js/ecore_js_poller.cc \
32bindings/ecore_js/ecore_js_throttle.cc
32 33
33ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \ 34ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
34-DTESTS_WD=\"`pwd`\" \ 35-DTESTS_WD=\"`pwd`\" \
@@ -52,7 +53,8 @@ bindings/ecore_js/ecore_js_event.hh \
52bindings/ecore_js/ecore_js_job.hh \ 53bindings/ecore_js/ecore_js_job.hh \
53bindings/ecore_js/ecore_js_idle.hh \ 54bindings/ecore_js/ecore_js_idle.hh \
54bindings/ecore_js/ecore_js_animator.hh \ 55bindings/ecore_js/ecore_js_animator.hh \
55bindings/ecore_js/ecore_js_poller.hh 56bindings/ecore_js/ecore_js_poller.hh \
57bindings/ecore_js/ecore_js_throttle.hh
56 58
57### Unit tests 59### Unit tests
58 60
diff --git a/src/bindings/ecore_js/ecore_js_throttle.cc b/src/bindings/ecore_js/ecore_js_throttle.cc
new file mode 100644
index 0000000..144527a
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_throttle.cc
@@ -0,0 +1,51 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <ecore_js_throttle.hh>
6#include <Ecore.h>
7
8namespace efl { namespace ecore { namespace js {
9
10EAPI
11void register_throttle_adjust(v8::Isolate *isolate,
12 v8::Handle<v8::Object> global,
13 v8::Handle<v8::String> name)
14{
15 using v8::FunctionTemplate;
16
17 auto f = [](compatibility_callback_info_type args)
18 -> compatibility_return_type {
19 if (args.Length() != 1 || !args[0]->IsNumber())
20 return compatibility_return();
21
22 ecore_throttle_adjust(args[0]->NumberValue());
23 };
24
25 global->Set(name,
26 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
27}
28
29EAPI
30void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
31 v8::Handle<v8::String> name)
32{
33 using v8::Number;
34 using v8::FunctionTemplate;
35
36 auto f = [](compatibility_callback_info_type args)
37 -> compatibility_return_type {
38 if (args.Length() != 0)
39 return compatibility_return();
40
41 auto isolate = args.GetIsolate();
42 auto ret = ecore_throttle_get();
43 return compatibility_return(compatibility_new<Number>(isolate, ret),
44 args);
45 };
46
47 global->Set(name,
48 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
49}
50
51} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_throttle.hh b/src/bindings/ecore_js/ecore_js_throttle.hh
new file mode 100644
index 0000000..25d3c97
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_throttle.hh
@@ -0,0 +1,27 @@
1#ifndef ECORE_JS_THROTTLE_HH
2#define ECORE_JS_THROTTLE_HH
3
4#include <Eina.hh>
5#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
6
7#include <eina_js_compatibility.hh>
8
9namespace efl { namespace ecore { namespace js {
10
11using ::efl::eina::js::compatibility_new;
12using ::efl::eina::js::compatibility_return_type;
13using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17
18void register_throttle_adjust(v8::Isolate *isolate,
19 v8::Handle<v8::Object> global,
20 v8::Handle<v8::String> name);
21
22void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
23 v8::Handle<v8::String> name);
24
25} } } // namespace efl { namespace ecore { namespace js {
26
27#endif /* ECORE_JS_THROTTLE_HH */
diff --git a/src/tests/ecore_js/ecore_js_suite.cc b/src/tests/ecore_js/ecore_js_suite.cc
index bb37413..528fec0 100644
--- a/src/tests/ecore_js/ecore_js_suite.cc
+++ b/src/tests/ecore_js/ecore_js_suite.cc
@@ -21,6 +21,7 @@
21#include <ecore_js_idle.hh> 21#include <ecore_js_idle.hh>
22#include <ecore_js_animator.hh> 22#include <ecore_js_animator.hh>
23#include <ecore_js_poller.hh> 23#include <ecore_js_poller.hh>
24#include <ecore_js_throttle.hh>
24 25
25const char* ToCString(const v8::String::Utf8Value& value) { 26const char* ToCString(const v8::String::Utf8Value& value) {
26 return *value ? *value : "<string conversion failed>"; 27 return *value ? *value : "<string conversion failed>";
@@ -385,6 +386,14 @@ void test_setup(v8::Handle<v8::Object> exports)
385 register_poller_add(isolate, exports, 386 register_poller_add(isolate, exports,
386 compatibility_new<String>(isolate, "ecore_poller_add")); 387 compatibility_new<String>(isolate, "ecore_poller_add"));
387 388
389 // throttle
390 register_throttle_adjust(isolate, exports,
391 compatibility_new<String>(isolate,
392 "ecore_throttle_adjust"));
393 register_throttle_get(isolate, exports,
394 compatibility_new<String>(isolate,
395 "ecore_throttle_get"));
396
388 std::cerr << __LINE__ << std::endl; 397 std::cerr << __LINE__ << std::endl;
389} 398}
390 399
diff --git a/src/tests/ecore_js/ecore_js_suite.js b/src/tests/ecore_js/ecore_js_suite.js
index 5ab2b5e..1f11113 100755
--- a/src/tests/ecore_js/ecore_js_suite.js
+++ b/src/tests/ecore_js/ecore_js_suite.js
@@ -279,6 +279,13 @@ assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 42);
279suite.ecore_poller_poll_interval_set(suite.ECORE_POLLER_CORE, 2); 279suite.ecore_poller_poll_interval_set(suite.ECORE_POLLER_CORE, 2);
280assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 2); 280assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 2);
281 281
282// Ecore throttle
283
284suite.ecore_throttle_adjust(3);
285assert(suite.ecore_throttle_get() === 3);
286suite.ecore_throttle_adjust(-3);
287assert(suite.ecore_throttle_get() === 0);
288
282// Ecore shutdown 289// Ecore shutdown
283 290
284suite.ecore_shutdown(); 291suite.ecore_shutdown();