aboutsummaryrefslogtreecommitdiffstats
path: root/src/bindings/ecore_js/ecore_js_throttle.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/ecore_js/ecore_js_throttle.cc')
-rw-r--r--src/bindings/ecore_js/ecore_js_throttle.cc63
1 files changed, 63 insertions, 0 deletions
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..830a40fec6
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_throttle.cc
@@ -0,0 +1,63 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+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());
+}
+
+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());
+}
+
+}
+
+EAPI
+void register_ecore_throttle(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_throttle_adjust(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_throttle_adjust"));
+ register_throttle_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_throttle_get"));
+}
+
+} } } // namespace efl { namespace js {