aboutsummaryrefslogtreecommitdiffstats
path: root/src/bindings/ecore_js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/ecore_js')
-rw-r--r--src/bindings/ecore_js/Ecore_Js.hh58
-rw-r--r--src/bindings/ecore_js/ecore_js_animator.cc728
-rw-r--r--src/bindings/ecore_js/ecore_js_event.cc772
-rw-r--r--src/bindings/ecore_js/ecore_js_file.cc1457
-rw-r--r--src/bindings/ecore_js/ecore_js_idle.cc294
-rw-r--r--src/bindings/ecore_js/ecore_js_init.cc77
-rw-r--r--src/bindings/ecore_js/ecore_js_job.cc83
-rw-r--r--src/bindings/ecore_js/ecore_js_mainloop.cc207
-rw-r--r--src/bindings/ecore_js/ecore_js_poller.cc190
-rw-r--r--src/bindings/ecore_js/ecore_js_throttle.cc63
-rw-r--r--src/bindings/ecore_js/ecore_js_timer.cc263
-rw-r--r--src/bindings/ecore_js/ecore_js_timer.hh38
12 files changed, 4230 insertions, 0 deletions
diff --git a/src/bindings/ecore_js/Ecore_Js.hh b/src/bindings/ecore_js/Ecore_Js.hh
new file mode 100644
index 0000000000..3f877f3fc8
--- /dev/null
+++ b/src/bindings/ecore_js/Ecore_Js.hh
@@ -0,0 +1,58 @@
+
+#ifndef EFL_ECORE_JS_HH
+#define EFL_ECORE_JS_HH
+
+#include <Ecore.hh>
+#include <Ecore_File.h>
+#include <Eina_Js.hh>
+
+#ifdef EAPI
+# undef EAPI
+#endif
+
+#ifdef _WIN32
+# ifdef EFL_ECORE_JS_BUILD
+# ifdef DLL_EXPORT
+# define EAPI __declspec(dllexport)
+# else
+# define EAPI
+# endif /* ! DLL_EXPORT */
+# else
+# define EAPI __declspec(dllimport)
+# endif /* ! EFL_ECORE_BUILD */
+#else
+# ifdef __GNUC__
+# if __GNUC__ >= 4
+# define EAPI __attribute__ ((visibility("default")))
+# else
+# define EAPI
+# endif
+# else
+# define EAPI
+# endif
+#endif /* ! _WIN32 */
+
+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;
+
+EAPI void register_ecore_animator(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_event(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
+EAPI void register_ecore_file(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
+EAPI void register_ecore_idle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_job(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_mainloop(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_poller(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_throttle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+EAPI void register_ecore_timer(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+
+EAPI void register_ecore(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
+
+} } }
+
+#endif
diff --git a/src/bindings/ecore_js/ecore_js_animator.cc b/src/bindings/ecore_js/ecore_js_animator.cc
new file mode 100644
index 0000000000..52f8576dee
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_animator.cc
@@ -0,0 +1,728 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+static Ecore_Animator* extract_animator(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Animator*>(ptr);
+}
+
+static v8::Local<v8::Object> wrap_animator(Ecore_Animator *animator,
+ v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_animator_del(extract_animator(info.This()));
+ return compatibility_return();
+ };
+
+ auto freeze = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_animator_freeze(extract_animator(info.This()));
+ return compatibility_return();
+ };
+
+ auto thaw = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_animator_thaw(extract_animator(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "freeze"),
+ compatibility_new<FunctionTemplate>(isolate, freeze)
+ ->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "thaw"),
+ compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<v8::External>(isolate,
+ animator));
+
+ return ret;
+}
+
+void register_pos_map_linear(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_LINEAR));
+}
+
+void register_pos_map_accelerate(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_ACCELERATE));
+}
+
+void register_pos_map_decelerate(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_DECELERATE));
+}
+
+void register_pos_map_sinusoidal(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_SINUSOIDAL));
+}
+
+void register_pos_map_accelerate_factor(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_POS_MAP_ACCELERATE_FACTOR));
+}
+
+void register_pos_map_decelerate_factor(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_POS_MAP_DECELERATE_FACTOR));
+}
+
+void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_POS_MAP_SINUSOIDAL_FACTOR));
+}
+
+void register_pos_map_divisor_interp(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_POS_MAP_DIVISOR_INTERP));
+}
+
+void register_pos_map_bounce(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_BOUNCE));
+}
+
+void register_pos_map_spring(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POS_MAP_SPRING));
+}
+
+void register_pos_map_cubic_bezier(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_POS_MAP_CUBIC_BEZIER));
+}
+
+void register_animator_source_timer(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_ANIMATOR_SOURCE_TIMER));
+}
+
+void register_animator_source_custom(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_ANIMATOR_SOURCE_CUSTOM));
+}
+
+void register_animator_frametime_set(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_animator_frametime_set(args[0]->NumberValue());
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_frametime_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_animator_frametime_get();
+ return compatibility_return(compatibility_new<Number>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_pos_map(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() != 4 || !args[0]->IsNumber() || !args[1]->IsNumber()
+ || !args[2]->IsNumber() || !args[3]->IsNumber())
+ return compatibility_return();
+
+ Ecore_Pos_Map map;
+
+ switch ((int)(args[1]->NumberValue())) {
+ case ECORE_POS_MAP_LINEAR:
+ map = ECORE_POS_MAP_LINEAR;
+ break;
+ case ECORE_POS_MAP_ACCELERATE:
+ map = ECORE_POS_MAP_ACCELERATE;
+ break;
+ case ECORE_POS_MAP_DECELERATE:
+ map = ECORE_POS_MAP_DECELERATE;
+ break;
+ case ECORE_POS_MAP_SINUSOIDAL:
+ map = ECORE_POS_MAP_SINUSOIDAL;
+ break;
+ case ECORE_POS_MAP_ACCELERATE_FACTOR:
+ map = ECORE_POS_MAP_ACCELERATE_FACTOR;
+ break;
+ case ECORE_POS_MAP_DECELERATE_FACTOR:
+ map = ECORE_POS_MAP_DECELERATE_FACTOR;
+ break;
+ case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
+ map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
+ break;
+ case ECORE_POS_MAP_DIVISOR_INTERP:
+ map = ECORE_POS_MAP_DIVISOR_INTERP;
+ break;
+ case ECORE_POS_MAP_BOUNCE:
+ map = ECORE_POS_MAP_BOUNCE;
+ break;
+ case ECORE_POS_MAP_SPRING:
+ map = ECORE_POS_MAP_SPRING;
+ break;
+ case ECORE_POS_MAP_CUBIC_BEZIER:
+ map = ECORE_POS_MAP_CUBIC_BEZIER;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_animator_pos_map(args[0]->NumberValue(), map,
+ args[2]->NumberValue(),
+ args[3]->NumberValue());
+ return compatibility_return(compatibility_new<Number>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_pos_map_n(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Number;
+ using v8::NumberObject;
+ using v8::FunctionTemplate;
+ using v8::Array;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
+ || !args[2]->IsArray())
+ return compatibility_return();
+
+ Ecore_Pos_Map map;
+
+ switch ((int)(args[1]->NumberValue())) {
+ case ECORE_POS_MAP_LINEAR:
+ map = ECORE_POS_MAP_LINEAR;
+ break;
+ case ECORE_POS_MAP_ACCELERATE:
+ map = ECORE_POS_MAP_ACCELERATE;
+ break;
+ case ECORE_POS_MAP_DECELERATE:
+ map = ECORE_POS_MAP_DECELERATE;
+ break;
+ case ECORE_POS_MAP_SINUSOIDAL:
+ map = ECORE_POS_MAP_SINUSOIDAL;
+ break;
+ case ECORE_POS_MAP_ACCELERATE_FACTOR:
+ map = ECORE_POS_MAP_ACCELERATE_FACTOR;
+ break;
+ case ECORE_POS_MAP_DECELERATE_FACTOR:
+ map = ECORE_POS_MAP_DECELERATE_FACTOR;
+ break;
+ case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
+ map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
+ break;
+ case ECORE_POS_MAP_DIVISOR_INTERP:
+ map = ECORE_POS_MAP_DIVISOR_INTERP;
+ break;
+ case ECORE_POS_MAP_BOUNCE:
+ map = ECORE_POS_MAP_BOUNCE;
+ break;
+ case ECORE_POS_MAP_SPRING:
+ map = ECORE_POS_MAP_SPRING;
+ break;
+ case ECORE_POS_MAP_CUBIC_BEZIER:
+ map = ECORE_POS_MAP_CUBIC_BEZIER;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ std::vector<double> v;
+ {
+ auto array = Array::Cast(*args[2]);
+ auto s = array->Length();
+ v.reserve(s);
+ for (decltype(s) i = 0;i != s;++i) {
+ auto e = array->Get(i);
+ if (!e->IsNumber())
+ return compatibility_return();
+
+ v.push_back(e->NumberValue());
+ }
+ }
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_animator_pos_map_n(args[0]->NumberValue(), map,
+ v.size(), v.data());
+ return compatibility_return(compatibility_new<Number>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_source_set(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_Animator_Source source;
+
+ switch ((int)(args[0]->NumberValue())) {
+ case ECORE_ANIMATOR_SOURCE_TIMER:
+ source = ECORE_ANIMATOR_SOURCE_TIMER;
+ break;
+ case ECORE_ANIMATOR_SOURCE_CUSTOM:
+ source = ECORE_ANIMATOR_SOURCE_CUSTOM;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ ecore_animator_source_set(source);
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_source_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_animator_source_get();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+static
+efl::eina::js::global_ref<v8::Value> animator_custom_source_tick_begin_cb_data;
+static
+efl::eina::js::global_ref<v8::Value> animator_custom_source_tick_end_cb_data;
+
+void
+register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object>
+ global,
+ v8::Handle<v8::String>
+ name)
+{
+ using v8::FunctionCallbackInfo;
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args) {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ animator_custom_source_tick_begin_cb_data
+ = efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ ecore_animator_custom_source_tick_begin_callback_set([](void*) {
+ using v8::Function;
+ using v8::Undefined;
+ using v8::Isolate;
+
+ auto o = animator_custom_source_tick_begin_cb_data.handle();
+ Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ }, NULL);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void
+register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object>
+ global,
+ v8::Handle<v8::String>
+ name)
+{
+ using v8::FunctionCallbackInfo;
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args) {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ efl::eina::js::global_ref<v8::Value>* data
+ = new efl::eina::js::global_ref<v8::Value>(args.GetIsolate(), args[0]);
+ ecore_animator_custom_source_tick_end_callback_set([](void* data) {
+ using v8::Function;
+ using v8::Undefined;
+ using v8::Isolate;
+
+ efl::eina::js::global_ref<v8::Value>*
+ d = static_cast<efl::eina::js::global_ref<v8::Value>*>(data);
+ auto o = d->handle();
+ Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ d->dispose();
+ delete d;
+ }, data);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void
+register_animator_custom_tick(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::FunctionCallbackInfo;
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args) {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ ecore_animator_custom_tick();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto f = new efl::eina::js::global_ref<Value>(isolate, args[0]);
+
+ auto cb = [](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_animator_add(cb, f);
+ return compatibility_return(wrap_animator(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_animator_timeline_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Handle;
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+ using v8::Number;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber()
+ || !args[1]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
+
+ auto cb = [](void *data, double pos) -> Eina_Bool {
+ auto persistent
+ = reinterpret_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+ auto isolate = v8::Isolate::GetCurrent();
+
+ Handle<Value> args = compatibility_new<Number>(isolate, pos);
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_animator_timeline_add(args[0]->NumberValue(), cb, f);
+ return compatibility_return(wrap_animator(ret, args.GetIsolate()),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_ecore_animator(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
+{
+ register_pos_map_linear(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP_LINEAR"));
+ register_pos_map_accelerate(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_ACCELERATE"));
+ register_pos_map_decelerate(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_DECELERATE"));
+ register_pos_map_sinusoidal(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_SINUSOIDAL"));
+ register_pos_map_accelerate_factor(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_ACCELERATE"
+ "_FACTOR"));
+ register_pos_map_decelerate_factor(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_DECELERATE"
+ "_FACTOR"));
+ register_pos_map_sinusoidal_factor(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_SINUSOIDAL"
+ "_FACTOR"));
+ register_pos_map_divisor_interp(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP"
+ "_DIVISOR_INTERP"));
+ register_pos_map_bounce(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP_BOUNCE"));
+ register_pos_map_spring(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP_SPRING"));
+ register_pos_map_cubic_bezier(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POS_MAP_CUBIC"
+ "_BEZIER"));
+ register_animator_source_timer(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_ANIMATOR"
+ "_SOURCE_TIMER"));
+ register_animator_source_custom(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_ANIMATOR"
+ "_SOURCE_CUSTOM"));
+ register_animator_frametime_set(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator"
+ "_frametime_set"));
+ register_animator_frametime_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator"
+ "_frametime_get"));
+ register_animator_pos_map(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_pos"
+ "_map"));
+ register_animator_pos_map_n(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_pos_map"
+ "_n"));
+ register_animator_source_set(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_source"
+ "_set"));
+ register_animator_source_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_source"
+ "_get"));
+ register_animator_custom_source_tick_begin_callback_set
+ (isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_custom_source_tick_begin"
+ "_callback_set"));
+ register_animator_custom_source_tick_end_callback_set
+ (isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_custom_source_tick_end"
+ "_callback_set"));
+ register_animator_custom_tick(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator"
+ "_custom_tick"));
+ register_animator_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator_add"));
+ register_animator_timeline_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_animator"
+ "_timeline_add"));
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_event.cc b/src/bindings/ecore_js/ecore_js_event.cc
new file mode 100644
index 0000000000..a086d989d6
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_event.cc
@@ -0,0 +1,772 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+static Ecore_Event *extract_event(v8::Local<v8::Object> object)
+{
+ return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0);
+}
+
+static v8::Local<v8::Object> wrap_event(Ecore_Event *event,
+ v8::Isolate *isolate)
+{
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_event_del(extract_event(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ compatibility_set_pointer_internal_field(ret, 0, event);
+
+ return ret;
+}
+
+static Ecore_Event_Handler *extract_event_handler(v8::Local<v8::Object> object)
+{
+ return compatibility_get_pointer_internal_field<Ecore_Event_Handler*>
+ (object, 0);
+}
+
+static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
+ v8::Isolate *isolate)
+{
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+ using v8::Value;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ auto p = ecore_event_handler_del(extract_event_handler(info.This()));
+
+ delete static_cast<efl::eina::js::global_ref<Value>*>(p);
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ compatibility_set_pointer_internal_field(ret, 0, handler);
+
+ return ret;
+}
+
+static Ecore_Event_Filter *extract_event_filter(v8::Local<v8::Object> object)
+{
+ return compatibility_get_pointer_internal_field<Ecore_Event_Filter*>
+ (object, 0);
+}
+
+static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
+ v8::Isolate *isolate)
+{
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+ using v8::Value;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ auto p = ecore_event_filter_del(extract_event_filter(info.This()));
+ delete[] static_cast<efl::eina::js::global_ref<Value>*>(p);
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ compatibility_set_pointer_internal_field(ret, 0, filter);
+
+ return ret;
+}
+
+EAPI
+void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_NONE));
+}
+
+EAPI
+void register_event_signal_user(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_USER));
+}
+
+EAPI
+void register_event_signal_hup(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_HUP));
+}
+
+EAPI
+void register_event_signal_exit(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_EXIT));
+}
+
+EAPI
+void register_event_signal_power(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_POWER));
+}
+
+EAPI
+void register_event_signal_realtime(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_EVENT_SIGNAL_REALTIME));
+}
+
+EAPI
+void register_event_memory_state(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_MEMORY_STATE));
+}
+
+EAPI
+void register_event_power_state(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_EVENT_POWER_STATE));
+}
+
+EAPI
+void register_event_locale_changed(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_EVENT_LOCALE_CHANGED));
+}
+
+EAPI
+void register_event_hostname_changed(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_EVENT_HOSTNAME_CHANGED));
+}
+
+EAPI
+void register_event_system_timedate_changed(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_EVENT_SYSTEM_TIMEDATE_CHANGED));
+}
+
+EAPI
+void register_event_type_new(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_event_type_new();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_add(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();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_event_add(args[0]->NumberValue(), NULL, NULL, NULL);
+ return compatibility_return(wrap_event(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_handler_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::Value;
+ using v8::Function;
+ using v8::Handle;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber()
+ || !args[1]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto isolate = args.GetIsolate();
+
+ auto p = new efl::eina::js::global_ref<Value>(isolate, args[1]);
+
+ auto cb = [](void *d, int type, void */*event*/) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(d);
+ auto o = persistent->handle();
+
+ auto isolate = v8::Isolate::GetCurrent();
+ Handle<Value> args = compatibility_new<Integer>(isolate, type);
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_event_handler_add(args[0]->Int32Value(), cb, p);
+ return compatibility_return(wrap_event_handler(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_filter_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::Value;
+ using v8::Function;
+ using v8::Handle;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 3 || !args[0]->IsFunction()
+ || !args[1]->IsFunction() || !args[2]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto isolate = args.GetIsolate();
+
+ auto p = new efl::eina::js::global_ref<Value>[3]{{isolate, args[0]},
+ {isolate, args[1]},
+ {isolate, args[2]}};
+
+ auto start_cb = [](void *data) -> void* {
+ auto p = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto isolate = v8::Isolate::GetCurrent();
+ auto o = p->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ return new efl::eina::js::global_ref<Value>{isolate, ret};
+ };
+
+ auto filter_cb = [](void *data, void *loop_data, int type,
+ void */*event*/) -> Eina_Bool {
+ typedef efl::eina::js::global_ref<Value> p_t;
+
+ auto p = static_cast<p_t*>(data) + 1;
+ auto isolate = v8::Isolate::GetCurrent();
+ auto o = p->handle();
+
+ Handle<Value> args[2]{
+ static_cast<p_t*>(loop_data)->handle(),
+ compatibility_new<Integer>(isolate, type)
+ };
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto end_cb = [](void *user_data, void *func_data) -> void {
+ typedef efl::eina::js::global_ref<Value> p_t;
+
+ auto loop_data = std::unique_ptr<p_t>(static_cast<p_t*>
+ (func_data));
+ auto p = static_cast<p_t*>(user_data) + 2;
+ auto o = p->handle();
+
+ Handle<Value> args = p->handle();
+
+ Function::Cast(*o)->Call(o->ToObject(), 1, &args);
+ };
+
+ auto ret = ecore_event_filter_add(start_cb, filter_cb, end_cb, p);
+ return compatibility_return(wrap_event_filter(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_current_type_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_event_current_type_get();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_memory_state_normal(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_NORMAL));
+}
+
+EAPI
+void register_memory_state_low(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_LOW));
+}
+
+EAPI
+void register_power_state_mains(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POWER_STATE_MAINS));
+}
+
+EAPI
+void register_power_state_battery(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POWER_STATE_BATTERY));
+}
+
+EAPI
+void register_power_state_low(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ global->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_POWER_STATE_LOW));
+}
+
+EAPI
+void register_memory_state_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_memory_state_get();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_power_state_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_power_state_get();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_signal_user_handler_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::Value;
+ using v8::Object;
+ using v8::Function;
+ using v8::Handle;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+
+ auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
+
+ auto cb = [](void *d, int type, void *event) -> Eina_Bool {
+ auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
+ auto isolate = v8::Isolate::GetCurrent();
+ auto o = p->handle();
+
+ auto wrapped_event = compatibility_new<Object>(isolate);
+
+ {
+ auto n
+ = reinterpret_cast<Ecore_Event_Signal_User*>(event)->number;
+ wrapped_event->Set(compatibility_new<String>(isolate, "number"),
+ compatibility_new<Integer>(isolate, n));
+ }
+
+ Handle<Value> args[2]{
+ compatibility_new<Integer>(isolate, type),
+ wrapped_event
+ };
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, cb, p);
+ return compatibility_return(wrap_event_handler(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_signal_exit_handler_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::Boolean;
+ using v8::String;
+ using v8::Value;
+ using v8::Object;
+ using v8::Function;
+ using v8::Handle;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+
+ auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
+
+ auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
+ auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
+ auto isolate = v8::Isolate::GetCurrent();
+ auto o = p->handle();
+
+ auto wrapped_event = compatibility_new<Object>(isolate);
+
+ {
+ auto event = reinterpret_cast<Ecore_Event_Signal_Exit*>(ev);
+ auto interrupt = event->interrupt;
+ auto quit = event->quit;
+ auto terminate = event->terminate;
+
+ wrapped_event->Set(compatibility_new<String>(isolate,
+ "interrupt"),
+ compatibility_new<Boolean>(isolate,
+ interrupt));
+ wrapped_event->Set(compatibility_new<String>(isolate, "quit"),
+ compatibility_new<Boolean>(isolate, quit));
+ wrapped_event->Set(compatibility_new<String>(isolate,
+ "terminate"),
+ compatibility_new<Boolean>(isolate,
+ terminate));
+ }
+
+ Handle<Value> args[2]{
+ compatibility_new<Integer>(isolate, type),
+ wrapped_event
+ };
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, cb, p);
+ return compatibility_return(wrap_event_handler(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_event_signal_realtime_handler_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::Value;
+ using v8::Object;
+ using v8::Function;
+ using v8::Handle;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+
+ auto p = new efl::eina::js::global_ref<Value>(isolate, args[0]);
+
+ auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
+ auto p = static_cast<efl::eina::js::global_ref<Value>*>(d);
+ auto isolate = v8::Isolate::GetCurrent();
+ auto o = p->handle();
+
+ auto wrapped_event = compatibility_new<Object>(isolate);
+
+ {
+ auto n
+ = reinterpret_cast<Ecore_Event_Signal_Realtime*>(ev)->num;
+ wrapped_event->Set(compatibility_new<String>(isolate, "num"),
+ compatibility_new<Integer>(isolate, n));
+ }
+
+ Handle<Value> args[2]{
+ compatibility_new<Integer>(isolate, type),
+ wrapped_event
+ };
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_REALTIME, cb, p);
+ return compatibility_return(wrap_event_handler(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_ecore_event(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
+{
+ register_event_none(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_EVENT_NONE"));
+ register_event_signal_user(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_SIGNAL_USER"));
+ register_event_signal_hup(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_SIGNAL_HUP"));
+ register_event_signal_exit(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_SIGNAL_EXIT"));
+ register_event_signal_power(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_SIGNAL_POWER"));
+ register_event_signal_realtime(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_SIGNAL_REALTIME"));
+ register_event_memory_state(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_MEMORY_STATE"));
+ register_event_power_state(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_POWER_STATE"));
+ register_event_locale_changed(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_LOCALE_CHANGED"));
+ register_event_hostname_changed(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_EVENT_HOSTNAME_CHANGED"));
+ register_event_system_timedate_changed(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ECORE_EVENT_SYSTEM_TIMEDATE"
+ "_CHANGED"));
+ register_event_type_new(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_event_type_new"));
+ register_event_add(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_event_add"));
+ register_event_handler_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_event_handler_add"));
+ register_event_filter_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_event_filter_add"));
+ register_event_current_type_get(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_event_current_type_get"));
+ register_memory_state_normal(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_MEMORY_STATE_NORMAL"));
+ register_memory_state_low(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_MEMORY_STATE_LOW"));
+ register_power_state_mains(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_POWER_STATE_MAINS"));
+ register_power_state_battery(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_POWER_STATE_BATTERY"));
+ register_power_state_low(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_POWER_STATE_LOW"));
+ register_event_signal_user_handler_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_event_signal_user_handler"
+ "_add"));
+ register_event_signal_exit_handler_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_event_signal_exit_handler"
+ "_add"));
+ register_event_signal_realtime_handler_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_event_signal_realtime"
+ "_handler_add"));
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_file.cc b/src/bindings/ecore_js/ecore_js_file.cc
new file mode 100644
index 0000000000..eea300f8dd
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_file.cc
@@ -0,0 +1,1457 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+#include <memory>
+#include <cstdlib>
+
+#include <unistd.h>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+Ecore_File_Monitor* extract_monitor(v8::Local<v8::Object> object)
+{
+ return compatibility_get_pointer_internal_field<Ecore_File_Monitor*>(object,
+ 0);
+}
+
+v8::Local<v8::Object> wrap_monitor(Ecore_File_Monitor *monitor,
+ v8::Isolate *isolate)
+{
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_file_monitor_del(extract_monitor(info.This()));
+ return compatibility_return();
+ };
+
+ auto path_get = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ auto ret = ecore_file_monitor_path_get(extract_monitor(info.This()));
+ return compatibility_return(compatibility_new<String>(info.GetIsolate(),
+ ret),
+ info);
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "path_get"),
+ compatibility_new<FunctionTemplate>(isolate, path_get)
+ ->GetFunction());
+
+ compatibility_set_pointer_internal_field(ret, 0, monitor);
+
+ return ret;
+}
+
+static Ecore_File_Download_Job *extract_download_job(v8::Local<v8::Object> o)
+{
+ return compatibility_get_pointer_internal_field<Ecore_File_Download_Job*>
+ (o, 0);
+}
+
+static
+v8::Local<v8::Object> wrap_download_job(Ecore_File_Download_Job *download_job,
+ v8::Isolate *isolate)
+{
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto abort = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_file_download_abort(extract_download_job(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "abort"),
+ compatibility_new<FunctionTemplate>(isolate, abort)
+ ->GetFunction());
+
+ compatibility_set_pointer_internal_field(ret, 0, download_job);
+
+ return ret;
+}
+
+void register_file_event_none(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_FILE_EVENT_NONE));
+}
+
+void register_file_event_created_file(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_EVENT_CREATED_FILE));
+}
+
+void register_file_event_created_directory(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_EVENT_CREATED_DIRECTORY));
+}
+
+void register_file_event_deleted_file(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_EVENT_DELETED_FILE));
+}
+
+void register_file_event_deleted_directory(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_EVENT_DELETED_DIRECTORY));
+}
+
+void register_file_event_deleted_self(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_EVENT_DELETED_SELF));
+}
+
+void register_file_event_modified(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_FILE_EVENT_MODIFIED));
+}
+
+void register_file_event_closed(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_FILE_EVENT_CLOSED));
+}
+
+void register_file_progress_continue(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate,
+ ECORE_FILE_PROGRESS_CONTINUE));
+}
+
+void register_file_progress_abort(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ exports->Set(name,
+ compatibility_new<Integer>(isolate, ECORE_FILE_PROGRESS_ABORT));
+}
+
+void register_file_init(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_file_init();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ 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_file_shutdown();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mod_time(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Date;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+
+ /* TODO: be less ofensive on the comment below once the documentation of
+ `ecore_file_mod_time` is fixed. I'm planning to submit a patch. */
+ /* `ecore_file_mod_time` returns "the time of the last data
+ modification", which is one of the most useless descriptions of a
+ function I ever found. The return type is `long long`, but looking at
+ the implementation, I see the value is the number of seconds since
+ the Epoch.
+
+ v8's `Date` constructor takes the number of milliseconds since the
+ Epoch represented as a `double`. */
+ double ret = ecore_file_mod_time(*String::Utf8Value(args[0]));
+ ret *= 1000;
+
+ return compatibility_return(compatibility_new<Date>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_size(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_size(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_exists(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_exists(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_is_dir(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_is_dir(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mkdir(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_mkdir(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mkdirs(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::Array;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsArray())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ std::vector<std::string> dirs_data;
+ std::vector<const char*> dirs;
+ {
+ auto array = Array::Cast(*args[0]);
+ auto s = array->Length();
+ dirs_data.reserve(s);
+ dirs.reserve(s + 1);
+ for (decltype(s) i = 0;i != s;++i) {
+ auto e = array->Get(i);
+ if (!e->IsString())
+ return compatibility_return();
+
+ dirs_data.push_back(*String::Utf8Value(e));
+ dirs.push_back(dirs_data.back().data());
+ }
+ }
+ dirs.push_back(NULL);
+ auto ret = ecore_file_mkdirs(dirs.data());
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mksubdirs(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::Array;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsArray())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ std::vector<std::string> subdirs_data;
+ std::vector<const char*> subdirs;
+ {
+ auto array = Array::Cast(*args[1]);
+ auto s = array->Length();
+ subdirs_data.reserve(s);
+ subdirs.reserve(s + 1);
+ for (decltype(s) i = 0;i != s;++i) {
+ auto e = array->Get(i);
+ if (!e->IsString())
+ return compatibility_return();
+
+ subdirs_data.push_back(*String::Utf8Value(e));
+ subdirs.push_back(subdirs_data.back().data());
+ }
+ }
+ subdirs.push_back(NULL);
+ auto ret = ecore_file_mksubdirs(*String::Utf8Value(args[0]),
+ subdirs.data());
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_rmdir(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_rmdir(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_unlink(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_unlink(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_remove(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_remove(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_recursive_rm(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_recursive_rm(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mkpath(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_mkpath(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mkpaths(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::Array;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsArray())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ std::vector<std::string> paths_data;
+ std::vector<const char*> paths;
+ {
+ auto array = Array::Cast(*args[0]);
+ auto s = array->Length();
+ paths_data.reserve(s);
+ paths.reserve(s + 1);
+ for (decltype(s) i = 0;i != s;++i) {
+ auto e = array->Get(i);
+ if (!e->IsString())
+ return compatibility_return();
+
+ paths_data.push_back(*String::Utf8Value(e));
+ paths.push_back(paths_data.back().data());
+ }
+ }
+ paths.push_back(NULL);
+ auto ret = ecore_file_mkpaths(paths.data());
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_cp(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_cp(*String::Utf8Value(args[0]),
+ *String::Utf8Value(args[1]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mv(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_mv(*String::Utf8Value(args[0]),
+ *String::Utf8Value(args[1]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_symlink(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_symlink(*String::Utf8Value(args[0]),
+ *String::Utf8Value(args[1]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_realpath(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto rp = guard_t(ecore_file_realpath(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, rp ? rp.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_file_get(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ String::Utf8Value str(args[0]);
+ auto ret = ecore_file_file_get(*str);
+ return compatibility_return(compatibility_new<String>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_dir_get(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto d = guard_t(ecore_file_dir_get(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, d ? d.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_can_read(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_can_read(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_can_write(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_can_write(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_can_exec(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_can_exec(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_readlink(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto l = guard_t(ecore_file_readlink(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, l ? l.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_ls(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Array;
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<Eina_List, Eina_List*(*)(Eina_List*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto list = guard_t(ecore_file_ls(*String::Utf8Value(args[0])),
+ eina_list_free);
+ auto ret = compatibility_new<Array>(isolate);
+ {
+ uint32_t idx = 0;
+ for (Eina_List *l = list.get() ; l ; l = eina_list_next(l)) {
+ /* Not using idiomatic RAII here because it'd be a fake safety,
+ given that remaining objects would leak if an exception is
+ throw. It shouldn't be a problem because v8 doesn't use
+ exceptions (nor idiomatic C++). */
+ auto data = reinterpret_cast<char*>(eina_list_data_get(l));
+ ret->Set(idx++, compatibility_new<String>(isolate, data));
+ free(data);
+ }
+ }
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_app_exe_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto e = guard_t(ecore_file_app_exe_get(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, e ? e.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_escape_name(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto n = guard_t(ecore_file_escape_name(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, n ? n.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_strip_ext(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<char, void(*)(char*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto n = guard_t(ecore_file_strip_ext(*String::Utf8Value(args[0])),
+ [](char *str) { free(str); });
+ auto ret = compatibility_new<String>(isolate, n ? n.get() : "");
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_dir_is_empty(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_dir_is_empty(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_monitor_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::Integer;
+ using v8::FunctionTemplate;
+ using v8::Handle;
+ using v8::Value;
+ using v8::Function;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString()
+ || !args[1]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
+
+ auto cb = [](void *data, Ecore_File_Monitor *em, Ecore_File_Event event,
+ const char *path) {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto isolate = v8::Isolate::GetCurrent();
+
+ Handle<Value> args[3] = {
+ wrap_monitor(em, isolate),
+ compatibility_new<Integer>(isolate, event),
+ compatibility_new<String>(isolate, path)
+ };
+
+ Function::Cast(*o)->Call(o->ToObject(), 3, args);
+
+ persistent->dispose();
+ delete persistent;
+ };
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_monitor_add(*String::Utf8Value(args[0]), cb, f);
+ return compatibility_return(wrap_monitor(ret, isolate), args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_path_dir_exists(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ Eina_Bool ret = ecore_file_path_dir_exists(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret == EINA_TRUE ? true : false),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_app_installed(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_file_app_installed(*String::Utf8Value(args[0]));
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_app_list(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Array;
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<Eina_List, Eina_List*(*)(Eina_List*)> guard_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto list = guard_t(ecore_file_app_list(), eina_list_free);
+ auto ret = compatibility_new<Array>(isolate);
+ {
+ uint32_t idx = 0;
+ for (Eina_List *l = list.get() ; l ; l = eina_list_next(l)) {
+ /* Not using idiomatic RAII here because it'd be a fake safety,
+ given that remaining objects would leak if an exception is
+ throw. It shouldn't be a problem because v8 doesn't use
+ exceptions (nor idiomatic C++). */
+ auto data = reinterpret_cast<char*>(eina_list_data_get(l));
+ ret->Set(idx++, compatibility_new<String>(isolate, data));
+ free(data);
+ }
+ }
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_download(v8::Isolate *isolate, v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::Integer;
+ using v8::String;
+ using v8::Object;
+ using v8::Function;
+ using v8::Value;
+ using v8::Handle;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+
+ typedef unique_ptr<Eina_Hash, void(*)(Eina_Hash*)> guard_t;
+ typedef efl::eina::js::global_ref<Value> persistent_t;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if ((args.Length() != 4 && args.Length() != 5) || !args[0]->IsString()
+ || !args[1]->IsString() || !args[2]->IsFunction()
+ || !args[3]->IsFunction()
+ || (args.Length() == 5 && !args[4]->IsObject()))
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+
+ auto cb_data = unique_ptr<persistent_t[]>(new persistent_t[2]);
+ cb_data[0] = persistent_t(isolate, args[2]);
+ cb_data[1] = persistent_t(isolate, args[3]);
+
+ String::Utf8Value url(args[0]);
+ String::Utf8Value dst(args[1]);
+ auto completion_cb = [](void *data, const char *file, int status) {
+ auto persistent = reinterpret_cast<persistent_t*>(data);
+ auto o = persistent->handle();
+
+ auto isolate = v8::Isolate::GetCurrent();
+
+ Handle<Value> args[2] = {
+ compatibility_new<String>(isolate, file),
+ compatibility_new<Integer>(isolate, status)
+ };
+
+ Function::Cast(*o)->Call(o->ToObject(), 2, args);
+
+ delete[] persistent;
+ };
+ auto progress_cb = [](void *data, const char *file, long int dltotal,
+ long int dlnow, long int ultotal,
+ long int ulnow) -> int {
+ auto persistent = reinterpret_cast<persistent_t*>(data) + 1;
+ auto o = persistent->handle();
+
+ auto isolate = v8::Isolate::GetCurrent();
+
+ Handle<Value> args[5] = {
+ compatibility_new<String>(isolate, file),
+ compatibility_new<Integer>(isolate, dltotal),
+ compatibility_new<Integer>(isolate, dlnow),
+ compatibility_new<Integer>(isolate, ultotal),
+ compatibility_new<Integer>(isolate, ulnow)
+ };
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 5, args);
+ auto iret = ret->IsNumber() ? int(ret->NumberValue()) : 0;
+ if (iret != ECORE_FILE_PROGRESS_CONTINUE)
+ delete[] (persistent - 1);
+
+ return iret;
+ };
+ Ecore_File_Download_Job *job_ret = NULL;
+ auto ret = compatibility_new<Object>(isolate);
+ bool bret;
+
+ if (args.Length() == 4) {
+ bret = ecore_file_download(*url, *dst, completion_cb, progress_cb,
+ cb_data.get(), &job_ret);
+ } else {
+ auto headers = guard_t(eina_hash_string_djb2_new(free),
+ eina_hash_free);
+ auto js_headers = Object::Cast(*args[4]);
+ auto keys = js_headers->GetOwnPropertyNames();
+ for (uint32_t i = 0;i != keys->Length();++i) {
+ auto key = keys->CloneElementAt(i);
+ if (!key->IsString())
+ return compatibility_return();
+
+ auto value = js_headers->Get(key);
+ if (!value->IsString())
+ return compatibility_return();
+
+ eina_hash_add(headers.get(), *String::Utf8Value(key),
+ strdup(*String::Utf8Value(value)));
+ }
+ bret = ecore_file_download_full(*url, *dst, completion_cb,
+ progress_cb, cb_data.get(),
+ &job_ret, headers.get());
+ }
+ if (bret)
+ cb_data.release();
+
+ ret->Set(compatibility_new<String>(isolate, "ok"),
+ compatibility_new<Boolean>(isolate, bret));
+
+ if (job_ret) {
+ ret->Set(compatibility_new<String>(isolate, "job"),
+ wrap_download_job(job_ret, isolate));
+ }
+
+ return compatibility_return(ret, args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_download_abort_all(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ ecore_file_download_abort_all();
+ return compatibility_return();
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_download_protocol_available(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ String::Utf8Value protocol(args[0]);
+ auto ret = ecore_file_download_protocol_available(*protocol);
+ return compatibility_return(compatibility_new<Boolean>(isolate, ret),
+ args);
+ };
+
+ exports->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_mkstemp(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ v8::String::Utf8Value buffer(args[0]);
+ char* buf = (char*)malloc(std::strlen(*buffer)+1);
+ struct free_buf
+ {
+ free_buf(char* p) : p(p) {}
+ ~free_buf() { free(p); }
+ char* p;
+ } free_buf_(buf);
+ std::strcpy(buf, *buffer);
+ int fd = mkstemp(buf);
+
+ if(fd > 0)
+ {
+ close(fd);
+
+ return compatibility_return(compatibility_new<v8::String>(nullptr, buf), args);
+ }
+ else
+ return compatibility_return();
+ };
+ exports->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_file_environment_tmp(v8::Isolate *isolate,
+ v8::Handle<v8::Object> exports,
+ v8::Handle<v8::String> name)
+{
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+
+ return compatibility_return(compatibility_new<v8::String>(nullptr, eina_environment_tmp_get()), args);
+ };
+ exports->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+}
+
+EAPI
+void register_ecore_file(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
+{
+ register_file_event_none(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT_NONE"));
+ register_file_event_created_file(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT"
+ "_CREATED_FILE"));
+ register_file_event_created_directory(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ECORE_FILE_EVENT_CREATED_DIRECTORY"));
+ register_file_event_deleted_file(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT"
+ "_DELETED_FILE"));
+ register_file_event_deleted_directory(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ECORE_FILE_EVENT_DELETED_DIRECTORY"));
+ register_file_event_deleted_self(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT"
+ "_DELETED_SELF"));
+ register_file_event_modified(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT"
+ "_MODIFIED"));
+ register_file_event_closed(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ECORE_FILE_EVENT"
+ "_CLOSED"));
+ register_file_progress_continue(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_FILE_PROGRESS_CONTINUE"));
+ register_file_progress_abort(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_FILE_PROGRESS_ABORT"));
+ register_file_init(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_init"));
+ register_file_shutdown(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_shutdown"));
+ register_file_mod_time(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_mod_time"));
+ register_file_size(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_size"));
+ register_file_exists(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_exists"));
+ register_file_is_dir(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_is_dir"));
+ register_file_mkdir(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_mkdir"));
+ register_file_mkdirs(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_mkdirs"));
+ register_file_mksubdirs(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_mksubdirs"));
+ register_file_rmdir(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_rmdir"));
+ register_file_unlink(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_unlink"));
+ register_file_remove(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_remove"));
+ register_file_recursive_rm(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_recursive_rm"));
+ register_file_mkpath(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_mkpath"));
+ register_file_mkpaths(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_mkpaths"));
+ register_file_cp(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_cp"));
+ register_file_mv(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_mv"));
+ register_file_symlink(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_symlink"));
+ register_file_realpath(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_realpath"));
+ register_file_file_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_file_get"));
+ register_file_dir_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_dir_get"));
+ register_file_can_read(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_can_read"));
+ register_file_can_write(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_can_write"));
+ register_file_can_exec(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_can_exec"));
+ register_file_readlink(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_readlink"));
+ register_file_ls(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_file_ls"));
+ register_file_app_exe_get(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_app_exe_get"));
+ register_file_escape_name(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_escape_name"));
+ register_file_strip_ext(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_strip_ext"));
+ register_file_dir_is_empty(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_dir_is_empty"));
+ register_file_monitor_add(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_monitor_add"));
+ register_file_path_dir_exists(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_path_dir_exists"));
+ register_file_app_installed(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_app_installed"));
+ register_file_app_list(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_app_list"));
+ register_file_download(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_file_download"));
+ register_file_download_abort_all(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_file_download_abort_all"));
+ register_file_download_protocol_available(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_file_download_protocol"
+ "_available"));
+ register_file_mkstemp(isolate, exports,
+ compatibility_new<v8::String>(isolate, "mkstemp"));
+ register_file_environment_tmp(isolate, exports,
+ compatibility_new<v8::String>(isolate, "environment_tmp"));
+}
+
+} } } // namespace efl { namespace ecore { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_idle.cc b/src/bindings/ecore_js/ecore_js_idle.cc
new file mode 100644
index 0000000000..293cef2f45
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_idle.cc
@@ -0,0 +1,294 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+static Ecore_Idler* extract_idler(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Idler*>(ptr);
+}
+
+static
+v8::Local<v8::Object> wrap_idler(Ecore_Idler *idler, v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_idler_del(extract_idler(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<v8::External>(isolate, idler));
+
+ return ret;
+}
+
+static Ecore_Idle_Enterer* extract_idle_enterer(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Idle_Enterer*>(ptr);
+}
+
+static v8::Local<v8::Object> wrap_idle_enterer(Ecore_Idle_Enterer *idle_enterer,
+ v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+ using v8::External;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_idle_enterer_del(extract_idle_enterer(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ ret->SetInternalField(0,
+ compatibility_new<External>(isolate, idle_enterer));
+
+ return ret;
+}
+
+static Ecore_Idle_Exiter* extract_idle_exiter(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Idle_Exiter*>(ptr);
+}
+
+static v8::Local<v8::Object> wrap_idle_exiter(Ecore_Idle_Exiter *idle_exiter,
+ v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+ using v8::External;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_idle_exiter_del(extract_idle_exiter(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<External>(isolate, idle_exiter));
+
+ return ret;
+}
+
+void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ auto ret = ecore_idler_add([](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ }, f);
+
+ return compatibility_return(wrap_idler(ret, args.GetIsolate()), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_idle_enterer_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ auto ret = ecore_idle_enterer_add([](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ }, f);
+
+ return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_idle_enterer_before_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ auto ret = ecore_idle_enterer_before_add([](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ }, f);
+
+ return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_idle_exiter_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ auto ret = ecore_idle_exiter_add([](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ }, f);
+
+ return compatibility_return(wrap_idle_exiter(ret, args.GetIsolate()),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_ecore_idle(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_idler_add(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_idler_add"));
+ register_idle_enterer_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_idle_enterer"
+ "_add"));
+ register_idle_enterer_before_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_idle"
+ "_enterer_before"
+ "_add"));
+ register_idle_exiter_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_idle_exiter_add"));
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_init.cc b/src/bindings/ecore_js/ecore_js_init.cc
new file mode 100644
index 0000000000..724d16ae17
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_init.cc
@@ -0,0 +1,77 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+void register_init(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto init = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ::ecore_init();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, init)
+ ->GetFunction());
+}
+
+void register_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto shutdown = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_shutdown();
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, shutdown)
+ ->GetFunction());
+}
+
+}
+
+EAPI
+void register_ecore(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ efl::ecore::js::register_init(isolate, exports,
+ efl::eina::js::compatibility_new<v8::String>
+ (isolate, "ecore_init"));
+ efl::ecore::js::register_shutdown(isolate, exports,
+ efl::eina::js::compatibility_new<v8::String>
+ (isolate, "ecore_shutdown"));
+ register_ecore_animator(isolate, exports);
+ register_ecore_event(isolate, exports);
+ register_ecore_file(isolate, exports);
+ register_ecore_idle(isolate, exports);
+ register_ecore_job(isolate, exports);
+ register_ecore_mainloop(isolate, exports);
+ register_ecore_poller(isolate, exports);
+ register_ecore_throttle(isolate, exports);
+ register_ecore_timer(isolate, exports);
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_job.cc b/src/bindings/ecore_js/ecore_js_job.cc
new file mode 100644
index 0000000000..4ec438aaaf
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_job.cc
@@ -0,0 +1,83 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+static Ecore_Job* extract_job(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Job*>(ptr);
+}
+
+static v8::Local<v8::Object> wrap_job(Ecore_Job *job, v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_job_del(extract_job(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<v8::External>(isolate, job));
+
+ return ret;
+}
+
+EAPI
+void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
+ auto ret = ecore_job_add([](void *data) {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+
+ persistent->dispose();
+ delete persistent;
+ }, f);
+
+ return compatibility_return(wrap_job(ret, args.GetIsolate()), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_ecore_job(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_job_add(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_job_add"));
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_mainloop.cc b/src/bindings/ecore_js/ecore_js_mainloop.cc
new file mode 100644
index 0000000000..180b35f0f6
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_mainloop.cc
@@ -0,0 +1,207 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+void register_callback_cancel(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ global->Set(name, compatibility_new<Boolean>(isolate,
+ bool{ECORE_CALLBACK_CANCEL}));
+}
+
+void register_callback_renew(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ global->Set(name, compatibility_new<Boolean>(isolate,
+ bool{ECORE_CALLBACK_RENEW}));
+}
+
+void register_callback_pass_on(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ global->Set(name, compatibility_new<Boolean>(isolate,
+ bool{ECORE_CALLBACK_PASS_ON}));
+}
+
+void register_callback_done(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ global->Set(name, compatibility_new<Boolean>(isolate,
+ bool{ECORE_CALLBACK_DONE}));
+}
+
+void register_mainloop_iterate(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ ecore_main_loop_iterate();
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_mainloop_iterate_may_block(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ auto ret = ecore_main_loop_iterate_may_block(args[0]->NumberValue());
+ return compatibility_return(compatibility_new<Integer>
+ (args.GetIsolate(), ret), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_mainloop_begin(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ ecore_main_loop_begin();
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_mainloop_quit(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ ecore_main_loop_quit();
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_mainloop_animator_ticked_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto ret = ecore_main_loop_animator_ticked_get();
+ return compatibility_return(compatibility_new<Boolean>
+ (args.GetIsolate(), ret), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_mainloop_nested_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto ret = ecore_main_loop_nested_get();
+ return compatibility_return(compatibility_new<Boolean>
+ (args.GetIsolate(), ret), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+}
+
+EAPI
+void register_ecore_mainloop(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_callback_cancel(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_CALLBACK_CANCEL"));
+ register_callback_renew(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_CALLBACK_RENEW"));
+ register_callback_pass_on(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_CALLBACK_PASS_ON"));
+ register_callback_done(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ECORE_CALLBACK_DONE"));
+ register_mainloop_iterate(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_mainloop_iterate"));
+ register_mainloop_iterate_may_block(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_mainloop_iterate_may_block"));
+ register_mainloop_begin(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_mainloop_begin"));
+ register_mainloop_quit(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_mainloop_quit"));
+ register_mainloop_animator_ticked_get(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate,
+ "ecore_mainlop_animator_ticked_get"));
+ register_mainloop_nested_get(isolate, exports,
+ compatibility_new<v8::String>
+ (isolate, "ecore_mainloop_nested_get"));
+}
+
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_poller.cc b/src/bindings/ecore_js/ecore_js_poller.cc
new file mode 100644
index 0000000000..e3bfbc843a
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_poller.cc
@@ -0,0 +1,190 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+Ecore_Poller* extract_poller(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Poller*>(ptr);
+}
+
+v8::Local<v8::Object> wrap_poller(Ecore_Poller *poller,
+ v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_poller_del(extract_poller(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<v8::External>(isolate, poller));
+
+ return ret;
+}
+
+void register_poller_core(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+
+ global->Set(name, compatibility_new<Integer>(isolate, ECORE_POLLER_CORE));
+}
+
+void register_poller_poll_interval_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
+ return compatibility_return();
+
+ Ecore_Poller_Type type;
+
+ switch ((int)(args[0]->NumberValue())) {
+ case ECORE_POLLER_CORE:
+ type = ECORE_POLLER_CORE;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ ecore_poller_poll_interval_set(type, args[1]->NumberValue());
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_poller_poll_interval_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ Ecore_Poller_Type type;
+
+ switch ((int)(args[0]->NumberValue())) {
+ case ECORE_POLLER_CORE:
+ type = ECORE_POLLER_CORE;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ auto isolate = args.GetIsolate();
+ auto ret = ecore_poller_poll_interval_get(type);
+ return compatibility_return(compatibility_new<Integer>(isolate, ret),
+ args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_poller_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Integer;
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::Isolate;
+ using v8::Function;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
+ || !args[2]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ Ecore_Poller_Type type;
+
+ switch ((int)(args[0]->NumberValue())) {
+ case ECORE_POLLER_CORE:
+ type = ECORE_POLLER_CORE;
+ break;
+ default:
+ return compatibility_return();
+ }
+
+ auto isolate = args.GetIsolate();
+ auto f = new efl::eina::js::global_ref<Value>(isolate, args[2]);
+
+ auto cb = [](void *data) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_poller_add(type, args[1]->NumberValue(), cb, f);
+ return compatibility_return(wrap_poller(ret, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+}
+
+EAPI
+void register_ecore_poller(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_poller_core(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ECORE_POLLER_CORE"));
+ register_poller_poll_interval_set(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_poller"
+ "_poll_interval"
+ "_set"));
+ register_poller_poll_interval_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_poller"
+ "_poll_interval"
+ "_get"));
+ register_poller_add(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_poller_add"));
+}
+
+} } } // namespace efl { namespace js {
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 {
diff --git a/src/bindings/ecore_js/ecore_js_timer.cc b/src/bindings/ecore_js/ecore_js_timer.cc
new file mode 100644
index 0000000000..38a3e51fac
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_timer.cc
@@ -0,0 +1,263 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Ecore_Js.hh>
+
+#include <memory>
+#include <cstdlib>
+
+namespace efl { namespace ecore { namespace js {
+
+namespace {
+
+Ecore_Timer* extract_timer(v8::Local<v8::Object> object)
+{
+ auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
+ return reinterpret_cast<Ecore_Timer*>(ptr);
+}
+
+v8::Local<v8::Object> wrap_timer(Ecore_Timer *timer,
+ v8::Isolate *isolate)
+{
+ using v8::Boolean;
+ using v8::String;
+ using v8::ObjectTemplate;
+ using v8::FunctionTemplate;
+
+ auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+ obj_tpl->SetInternalFieldCount(1);
+ auto ret = obj_tpl->NewInstance();
+
+ auto del = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_timer_del(extract_timer(info.This()));
+ return compatibility_return();
+ };
+
+ auto freeze = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_timer_freeze(extract_timer(info.This()));
+ return compatibility_return();
+ };
+
+ auto freeze_get = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ auto ret = ecore_timer_freeze_get(extract_timer(info.This()));
+ return compatibility_return(compatibility_new<Boolean>
+ (info.GetIsolate(), bool(ret)),
+ info);
+ };
+
+ auto thaw = [](compatibility_callback_info_type info)
+ -> compatibility_return_type {
+ if (info.Length() != 0)
+ return compatibility_return();
+
+ ecore_timer_thaw(extract_timer(info.This()));
+ return compatibility_return();
+ };
+
+ ret->Set(compatibility_new<String>(isolate, "del"),
+ compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "freeze"),
+ compatibility_new<FunctionTemplate>(isolate, freeze)
+ ->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "freeze_get"),
+ compatibility_new<FunctionTemplate>(isolate, freeze_get)
+ ->GetFunction());
+ ret->Set(compatibility_new<String>(isolate, "thaw"),
+ compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
+
+ ret->SetInternalField(0, compatibility_new<v8::External>(isolate, timer));
+
+ return ret;
+}
+
+void register_timer_precision_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 ret = ecore_timer_precision_get();
+ return compatibility_return(compatibility_new<Number>
+ (args.GetIsolate(), ret), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_timer_precision_set(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_timer_precision_set(args[0]->NumberValue());
+ return compatibility_return();
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_timer_dump(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::String;
+ using v8::FunctionTemplate;
+ using std::unique_ptr;
+ using std::free;
+ using std::unique_ptr;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ auto dump = unique_ptr<char, void(*)(char*)>(ecore_timer_dump(),
+ [](char *str) {
+ free(str);
+ });
+ auto ret = (dump
+ ? compatibility_new<String>(args.GetIsolate(), dump.get())
+ : compatibility_new<String>(args.GetIsolate(), ""));
+
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_timer_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber()
+ || !args[1]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
+
+ auto cb = [](void *data) -> Eina_Bool {
+ auto persistent = reinterpret_cast<efl::eina::js::global_ref<Value>*>(data);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_timer_add(args[0]->NumberValue(), cb, f);
+ return compatibility_return(wrap_timer(ret, args.GetIsolate()), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+void register_timer_loop_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Local;
+ using v8::Value;
+ using v8::Undefined;
+ using v8::Function;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber()
+ || !args[1]->IsFunction()) {
+ return compatibility_return();
+ }
+
+ auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
+
+ auto cb = [](void *d) -> Eina_Bool {
+ auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(d);
+ auto o = persistent->handle();
+
+ auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
+ auto bret = ret->IsBoolean() && ret->BooleanValue();
+
+ if (!bret)
+ {
+ persistent->dispose();
+ delete persistent;
+ }
+
+ return bret ? EINA_TRUE : EINA_FALSE;
+ };
+
+ auto ret = ecore_timer_loop_add(args[0]->NumberValue(), cb, f);
+
+ return compatibility_return(wrap_timer(ret, args.GetIsolate()), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+}
+
+EAPI
+void register_ecore_timer(v8::Isolate *isolate,v8::Handle<v8::Object> exports)
+{
+ register_timer_precision_get(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_timer_precision"
+ "_get"));
+ register_timer_precision_set(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_timer_precision"
+ "_set"));
+ register_timer_dump(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_timer_dump"));
+ register_timer_add(isolate, exports,
+ compatibility_new<v8::String>(isolate, "ecore_timer_add"));
+ register_timer_loop_add(isolate, exports,
+ compatibility_new<v8::String>(isolate,
+ "ecore_timer_loop_add"));
+}
+
+} } } // namespace efl { namespace ecore { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_timer.hh b/src/bindings/ecore_js/ecore_js_timer.hh
new file mode 100644
index 0000000000..e002587ee4
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_timer.hh
@@ -0,0 +1,38 @@
+#ifndef ECORE_JS_TIMER_HH
+#define ECORE_JS_TIMER_HH
+
+#include <Eina.hh>
+
+#include <Eina_Js.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;
+using ::efl::eina::js::compatibility_persistent;
+
+void register_timer_precision_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+void register_timer_precision_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+void register_timer_dump(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+void register_timer_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+void register_timer_loop_add(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name);
+
+} } } // namespace efl::js
+
+#endif /* ECORE_JS_TIMER_HH */