aboutsummaryrefslogtreecommitdiffstats
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
parentInitial bindings for Ecore_Poller (diff)
downloadefl-1f5fadd9d512519eb31e76c88c5f3aaff6ea3094.tar.gz
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 bf4d59497f..2a69862354 100644
--- a/src/Makefile_Ecore_Js.am
+++ b/src/Makefile_Ecore_Js.am
@@ -28,7 +28,8 @@ bindings/ecore_js/ecore_js_event.cc \
bindings/ecore_js/ecore_js_job.cc \
bindings/ecore_js/ecore_js_idle.cc \
bindings/ecore_js/ecore_js_animator.cc \
-bindings/ecore_js/ecore_js_poller.cc
+bindings/ecore_js/ecore_js_poller.cc \
+bindings/ecore_js/ecore_js_throttle.cc
ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
-DTESTS_WD=\"`pwd`\" \
@@ -52,7 +53,8 @@ bindings/ecore_js/ecore_js_event.hh \
bindings/ecore_js/ecore_js_job.hh \
bindings/ecore_js/ecore_js_idle.hh \
bindings/ecore_js/ecore_js_animator.hh \
-bindings/ecore_js/ecore_js_poller.hh
+bindings/ecore_js/ecore_js_poller.hh \
+bindings/ecore_js/ecore_js_throttle.hh
### Unit tests
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 0000000000..144527a075
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_throttle.cc
@@ -0,0 +1,51 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ecore_js_throttle.hh>
+#include <Ecore.h>
+
+namespace efl { namespace ecore { namespace js {
+
+EAPI
+void register_throttle_adjust(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ ecore_throttle_adjust(args[0]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Number;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_throttle_get();
+ return compatibility_return(compatibility_new<Number>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+} } } // 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 0000000000..25d3c97e6c
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_throttle.hh
@@ -0,0 +1,27 @@
+#ifndef ECORE_JS_THROTTLE_HH
+#define ECORE_JS_THROTTLE_HH
+
+#include <Eina.hh>
+#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
+
+#include <eina_js_compatibility.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+using ::efl::eina::js::compatibility_new;
+using ::efl::eina::js::compatibility_return_type;
+using ::efl::eina::js::compatibility_callback_info_type;
+using ::efl::eina::js::compatibility_return;
+using ::efl::eina::js::compatibility_get_pointer_internal_field;
+using ::efl::eina::js::compatibility_set_pointer_internal_field;
+
+void register_throttle_adjust(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+} } } // namespace efl { namespace ecore { namespace js {
+
+#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 bb37413b29..528fec03e3 100644
--- a/src/tests/ecore_js/ecore_js_suite.cc
+++ b/src/tests/ecore_js/ecore_js_suite.cc
@@ -21,6 +21,7 @@
#include <ecore_js_idle.hh>
#include <ecore_js_animator.hh>
#include <ecore_js_poller.hh>
+#include <ecore_js_throttle.hh>
const char* ToCString(const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
@@ -385,6 +386,14 @@ void test_setup(v8::Handle<v8::Object> exports)
register_poller_add(isolate, exports,
compatibility_new<String>(isolate, "ecore_poller_add"));
+ // throttle
+ register_throttle_adjust(isolate, exports,
+ compatibility_new<String>(isolate,
+ "ecore_throttle_adjust"));
+ register_throttle_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "ecore_throttle_get"));
+
std::cerr << __LINE__ << std::endl;
}
diff --git a/src/tests/ecore_js/ecore_js_suite.js b/src/tests/ecore_js/ecore_js_suite.js
index 5ab2b5ecb5..1f11113e19 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);
suite.ecore_poller_poll_interval_set(suite.ECORE_POLLER_CORE, 2);
assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 2);
+// Ecore throttle
+
+suite.ecore_throttle_adjust(3);
+assert(suite.ecore_throttle_get() === 3);
+suite.ecore_throttle_adjust(-3);
+assert(suite.ecore_throttle_get() === 0);
+
// Ecore shutdown
suite.ecore_shutdown();