summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-03 01:27:33 -0300
committerVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-03 01:27:33 -0300
commit5de5e8f9f8017d734358b0b65cf5a4ab2a6c8e01 (patch)
tree61777b780c5c17115bfd6a8007bfb67d1139aa9c
parent77ffb055a15aee55ba2a84e890955433ce697cb2 (diff)
[ecore_js] refactor: persistent_with_isolate_t -> compatibility_persi...
-rw-r--r--src/bindings/ecore_js/ecore_js_event.cc139
-rw-r--r--src/bindings/ecore_js/ecore_js_event.hh1
-rw-r--r--src/bindings/ecore_js/ecore_js_idle.cc72
-rw-r--r--src/bindings/ecore_js/ecore_js_idle.hh1
-rw-r--r--src/bindings/ecore_js/ecore_js_job.cc26
-rw-r--r--src/bindings/ecore_js/ecore_js_job.hh1
-rw-r--r--src/bindings/ecore_js/ecore_js_mainloop.cc48
-rw-r--r--src/bindings/ecore_js/ecore_js_mainloop.hh1
-rw-r--r--src/bindings/ecore_js/ecore_js_timer.cc38
-rw-r--r--src/bindings/ecore_js/ecore_js_timer.hh1
10 files changed, 127 insertions, 201 deletions
diff --git a/src/bindings/ecore_js/ecore_js_event.cc b/src/bindings/ecore_js/ecore_js_event.cc
index f9c35cb..1a5fa8e 100644
--- a/src/bindings/ecore_js/ecore_js_event.cc
+++ b/src/bindings/ecore_js/ecore_js_event.cc
@@ -7,18 +7,6 @@
7 7
8namespace efl { namespace ecore { namespace js { 8namespace efl { namespace ecore { namespace js {
9 9
10struct persistent_with_isolate_t
11{
12 template<class S>
13 persistent_with_isolate_t(v8::Isolate *isolate, v8::Handle<S> that)
14 : isolate(isolate)
15 , persistent(isolate, that)
16 {}
17
18 v8::Isolate *isolate;
19 v8::Persistent<v8::Value> persistent;
20};
21
22static Ecore_Event *extract_event(v8::Local<v8::Object> object) 10static Ecore_Event *extract_event(v8::Local<v8::Object> object)
23{ 11{
24 return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0); 12 return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0);
@@ -63,6 +51,7 @@ static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
63 using v8::String; 51 using v8::String;
64 using v8::ObjectTemplate; 52 using v8::ObjectTemplate;
65 using v8::FunctionTemplate; 53 using v8::FunctionTemplate;
54 using v8::Value;
66 55
67 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate); 56 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
68 obj_tpl->SetInternalFieldCount(1); 57 obj_tpl->SetInternalFieldCount(1);
@@ -75,7 +64,7 @@ static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
75 64
76 auto p = ecore_event_handler_del(extract_event_handler(info.This())); 65 auto p = ecore_event_handler_del(extract_event_handler(info.This()));
77 66
78 delete reinterpret_cast<persistent_with_isolate_t*>(p); 67 delete reinterpret_cast<compatibility_persistent<Value>*>(p);
79 }; 68 };
80 69
81 ret->Set(compatibility_new<String>(isolate, "del"), 70 ret->Set(compatibility_new<String>(isolate, "del"),
@@ -98,6 +87,7 @@ static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
98 using v8::String; 87 using v8::String;
99 using v8::ObjectTemplate; 88 using v8::ObjectTemplate;
100 using v8::FunctionTemplate; 89 using v8::FunctionTemplate;
90 using v8::Value;
101 91
102 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate); 92 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
103 obj_tpl->SetInternalFieldCount(1); 93 obj_tpl->SetInternalFieldCount(1);
@@ -109,7 +99,7 @@ static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
109 return compatibility_return(); 99 return compatibility_return();
110 100
111 auto p = ecore_event_filter_del(extract_event_filter(info.This())); 101 auto p = ecore_event_filter_del(extract_event_filter(info.This()));
112 delete[] reinterpret_cast<persistent_with_isolate_t*>(p); 102 delete[] reinterpret_cast<compatibility_persistent<Value>*>(p);
113 }; 103 };
114 104
115 ret->Set(compatibility_new<String>(isolate, "del"), 105 ret->Set(compatibility_new<String>(isolate, "del"),
@@ -297,18 +287,17 @@ void register_event_handler_add(v8::Isolate *isolate,
297 287
298 auto isolate = args.GetIsolate(); 288 auto isolate = args.GetIsolate();
299 289
300 auto p = new persistent_with_isolate_t(isolate, args[1]); 290 auto p = new compatibility_persistent<Value>(isolate, args[1]);
301 291
302 auto cb = [](void *d, int type, void */*event*/) -> Eina_Bool { 292 auto cb = [](void *d, int type, void */*event*/) -> Eina_Bool {
303 auto persistent = reinterpret_cast<persistent_with_isolate_t*>(d); 293 auto persistent
304 auto value = Local<Value>::New(persistent->isolate, 294 = reinterpret_cast<compatibility_persistent<Value>*>(d);
305 persistent->persistent); 295 auto closure = Function::Cast(*persistent->handle());
306 auto closure = Function::Cast(*value);
307 296
308 Handle<Value> args = compatibility_new<Integer>(persistent->isolate, 297 auto isolate = persistent->GetIsolate();
309 type); 298 Handle<Value> args = compatibility_new<Integer>(isolate, type);
310 299
311 auto ret = closure->Call(Undefined(persistent->isolate), 1, &args); 300 auto ret = closure->Call(Undefined(isolate), 1, &args);
312 auto bret = ret->IsBoolean() && ret->BooleanValue(); 301 auto bret = ret->IsBoolean() && ret->BooleanValue();
313 302
314 return bret ? EINA_TRUE : EINA_FALSE; 303 return bret ? EINA_TRUE : EINA_FALSE;
@@ -343,54 +332,49 @@ void register_event_filter_add(v8::Isolate *isolate,
343 332
344 auto isolate = args.GetIsolate(); 333 auto isolate = args.GetIsolate();
345 334
346 auto p = new persistent_with_isolate_t[3]{{isolate, args[0]}, 335 auto p = new compatibility_persistent<Value>[3]{{isolate, args[0]},
347 {isolate, args[1]}, 336 {isolate, args[1]},
348 {isolate, args[2]}}; 337 {isolate, args[2]}};
349 338
350 auto start_cb = [](void *data) -> void* { 339 auto start_cb = [](void *data) -> void* {
351 auto p = reinterpret_cast<persistent_with_isolate_t*>(data); 340 auto p = reinterpret_cast<compatibility_persistent<Value>*>(data);
352 auto value = Local<Value>::New(p->isolate, p->persistent); 341 auto isolate = p->GetIsolate();
353 auto closure = Function::Cast(*value); 342 auto closure = Function::Cast(*p->handle());
354 343
355 auto ret = closure->Call(Undefined(p->isolate), 0, NULL); 344 auto ret = closure->Call(Undefined(isolate), 0, NULL);
356 return new persistent_with_isolate_t{p->isolate, ret}; 345 return new compatibility_persistent<Value>{isolate, ret};
357 }; 346 };
358 347
359 auto filter_cb = [](void *data, void *loop_data, int type, 348 auto filter_cb = [](void *data, void *loop_data, int type,
360 void */*event*/) -> Eina_Bool { 349 void */*event*/) -> Eina_Bool {
361 typedef persistent_with_isolate_t p_t; 350 typedef compatibility_persistent<Value> p_t;
362 351
363 auto p = reinterpret_cast<p_t*>(data) + 1; 352 auto p = reinterpret_cast<p_t*>(data) + 1;
364 auto value = Local<Value>::New(p->isolate, p->persistent); 353 auto isolate = p->GetIsolate();
365 auto closure = Function::Cast(*value); 354 auto closure = Function::Cast(*p->handle());
366 355
367 Handle<Value> args[2]{ 356 Handle<Value> args[2]{
368 [loop_data]() { 357 reinterpret_cast<p_t*>(loop_data)->handle(),
369 auto ret = reinterpret_cast<p_t*>(loop_data); 358 compatibility_new<Integer>(isolate, type)
370 return Local<Value>::New(ret->isolate, ret->persistent);
371 }(),
372 compatibility_new<Integer>(p->isolate, type)
373 }; 359 };
374 360
375 auto ret = closure->Call(Undefined(p->isolate), 2, args); 361 auto ret = closure->Call(Undefined(isolate), 2, args);
376 auto bret = ret->IsBoolean() && ret->BooleanValue(); 362 auto bret = ret->IsBoolean() && ret->BooleanValue();
377 363
378 return bret ? EINA_TRUE : EINA_FALSE; 364 return bret ? EINA_TRUE : EINA_FALSE;
379 }; 365 };
380 366
381 auto end_cb = [](void *user_data, void *func_data) -> void { 367 auto end_cb = [](void *user_data, void *func_data) -> void {
382 typedef persistent_with_isolate_t p_t; 368 typedef compatibility_persistent<Value> p_t;
383 369
384 auto loop_data = std::unique_ptr<p_t>(reinterpret_cast<p_t*> 370 auto loop_data = std::unique_ptr<p_t>(reinterpret_cast<p_t*>
385 (func_data)); 371 (func_data));
386 auto p = reinterpret_cast<p_t*>(user_data) + 2; 372 auto p = reinterpret_cast<p_t*>(user_data) + 2;
387 auto value = Local<Value>::New(p->isolate, p->persistent); 373 auto closure = Function::Cast(*p->handle());
388 auto closure = Function::Cast(*value);
389 374
390 Handle<Value> args = Local<Value>::New(loop_data->isolate, 375 Handle<Value> args = p->handle();
391 loop_data->persistent);
392 376
393 closure->Call(Undefined(p->isolate), 1, &args); 377 closure->Call(Undefined(p->GetIsolate()), 1, &args);
394 }; 378 };
395 379
396 auto ret = ecore_event_filter_add(start_cb, filter_cb, end_cb, p); 380 auto ret = ecore_event_filter_add(start_cb, filter_cb, end_cb, p);
@@ -541,29 +525,28 @@ void register_event_signal_user_handler_add(v8::Isolate *isolate,
541 525
542 auto isolate = args.GetIsolate(); 526 auto isolate = args.GetIsolate();
543 527
544 auto p = new persistent_with_isolate_t(isolate, args[0]); 528 auto p = new compatibility_persistent<Value>(isolate, args[0]);
545 529
546 auto cb = [](void *d, int type, void *event) -> Eina_Bool { 530 auto cb = [](void *d, int type, void *event) -> Eina_Bool {
547 auto p = reinterpret_cast<persistent_with_isolate_t*>(d); 531 auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
548 auto value = Local<Value>::New(p->isolate, p->persistent); 532 auto isolate = p->GetIsolate();
549 auto closure = Function::Cast(*value); 533 auto closure = Function::Cast(*p->handle());
550 534
551 auto wrapped_event = compatibility_new<Object>(p->isolate); 535 auto wrapped_event = compatibility_new<Object>(isolate);
552 536
553 { 537 {
554 auto n 538 auto n
555 = reinterpret_cast<Ecore_Event_Signal_User*>(event)->number; 539 = reinterpret_cast<Ecore_Event_Signal_User*>(event)->number;
556 wrapped_event->Set(compatibility_new<String>(p->isolate, 540 wrapped_event->Set(compatibility_new<String>(isolate, "number"),
557 "number"), 541 compatibility_new<Integer>(isolate, n));
558 compatibility_new<Integer>(p->isolate, n));
559 } 542 }
560 543
561 Handle<Value> args[2]{ 544 Handle<Value> args[2]{
562 compatibility_new<Integer>(p->isolate, type), 545 compatibility_new<Integer>(isolate, type),
563 wrapped_event 546 wrapped_event
564 }; 547 };
565 548
566 auto ret = closure->Call(Undefined(p->isolate), 2, args); 549 auto ret = closure->Call(Undefined(isolate), 2, args);
567 auto bret = ret->IsBoolean() && ret->BooleanValue(); 550 auto bret = ret->IsBoolean() && ret->BooleanValue();
568 551
569 return bret ? EINA_TRUE : EINA_FALSE; 552 return bret ? EINA_TRUE : EINA_FALSE;
@@ -599,14 +582,14 @@ void register_event_signal_exit_handler_add(v8::Isolate *isolate,
599 582
600 auto isolate = args.GetIsolate(); 583 auto isolate = args.GetIsolate();
601 584
602 auto p = new persistent_with_isolate_t(isolate, args[0]); 585 auto p = new compatibility_persistent<Value>(isolate, args[0]);
603 586
604 auto cb = [](void *d, int type, void *ev) -> Eina_Bool { 587 auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
605 auto p = reinterpret_cast<persistent_with_isolate_t*>(d); 588 auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
606 auto value = Local<Value>::New(p->isolate, p->persistent); 589 auto isolate = p->GetIsolate();
607 auto closure = Function::Cast(*value); 590 auto closure = Function::Cast(*p->handle());
608 591
609 auto wrapped_event = compatibility_new<Object>(p->isolate); 592 auto wrapped_event = compatibility_new<Object>(isolate);
610 593
611 { 594 {
612 auto event = reinterpret_cast<Ecore_Event_Signal_Exit*>(ev); 595 auto event = reinterpret_cast<Ecore_Event_Signal_Exit*>(ev);
@@ -614,26 +597,24 @@ void register_event_signal_exit_handler_add(v8::Isolate *isolate,
614 auto quit = event->quit; 597 auto quit = event->quit;
615 auto terminate = event->terminate; 598 auto terminate = event->terminate;
616 599
617 wrapped_event->Set(compatibility_new<String>(p->isolate, 600 wrapped_event->Set(compatibility_new<String>(isolate,
618 "interrupt"), 601 "interrupt"),
619 compatibility_new<Boolean>(p->isolate, 602 compatibility_new<Boolean>(isolate,
620 interrupt)); 603 interrupt));
621 wrapped_event->Set(compatibility_new<String>(p->isolate, 604 wrapped_event->Set(compatibility_new<String>(isolate, "quit"),
622 "quit"), 605 compatibility_new<Boolean>(isolate, quit));
623 compatibility_new<Boolean>(p->isolate, 606 wrapped_event->Set(compatibility_new<String>(isolate,
624 quit));
625 wrapped_event->Set(compatibility_new<String>(p->isolate,
626 "terminate"), 607 "terminate"),
627 compatibility_new<Boolean>(p->isolate, 608 compatibility_new<Boolean>(isolate,
628 terminate)); 609 terminate));
629 } 610 }
630 611
631 Handle<Value> args[2]{ 612 Handle<Value> args[2]{
632 compatibility_new<Integer>(p->isolate, type), 613 compatibility_new<Integer>(isolate, type),
633 wrapped_event 614 wrapped_event
634 }; 615 };
635 616
636 auto ret = closure->Call(Undefined(p->isolate), 2, args); 617 auto ret = closure->Call(Undefined(isolate), 2, args);
637 auto bret = ret->IsBoolean() && ret->BooleanValue(); 618 auto bret = ret->IsBoolean() && ret->BooleanValue();
638 619
639 return bret ? EINA_TRUE : EINA_FALSE; 620 return bret ? EINA_TRUE : EINA_FALSE;
@@ -668,28 +649,28 @@ void register_event_signal_realtime_handler_add(v8::Isolate *isolate,
668 649
669 auto isolate = args.GetIsolate(); 650 auto isolate = args.GetIsolate();
670 651
671 auto p = new persistent_with_isolate_t(isolate, args[0]); 652 auto p = new compatibility_persistent<Value>(isolate, args[0]);
672 653
673 auto cb = [](void *d, int type, void *ev) -> Eina_Bool { 654 auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
674 auto p = reinterpret_cast<persistent_with_isolate_t*>(d); 655 auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
675 auto value = Local<Value>::New(p->isolate, p->persistent); 656 auto isolate = p->GetIsolate();
676 auto closure = Function::Cast(*value); 657 auto closure = Function::Cast(*p->handle());
677 658
678 auto wrapped_event = compatibility_new<Object>(p->isolate); 659 auto wrapped_event = compatibility_new<Object>(isolate);
679 660
680 { 661 {
681 auto n 662 auto n
682 = reinterpret_cast<Ecore_Event_Signal_Realtime*>(ev)->num; 663 = reinterpret_cast<Ecore_Event_Signal_Realtime*>(ev)->num;
683 wrapped_event->Set(compatibility_new<String>(p->isolate, "num"), 664 wrapped_event->Set(compatibility_new<String>(isolate, "num"),
684 compatibility_new<Integer>(p->isolate, n)); 665 compatibility_new<Integer>(isolate, n));
685 } 666 }
686 667
687 Handle<Value> args[2]{ 668 Handle<Value> args[2]{
688 compatibility_new<Integer>(p->isolate, type), 669 compatibility_new<Integer>(isolate, type),
689 wrapped_event 670 wrapped_event
690 }; 671 };
691 672
692 auto ret = closure->Call(Undefined(p->isolate), 2, args); 673 auto ret = closure->Call(Undefined(isolate), 2, args);
693 auto bret = ret->IsBoolean() && ret->BooleanValue(); 674 auto bret = ret->IsBoolean() && ret->BooleanValue();
694 675
695 return bret ? EINA_TRUE : EINA_FALSE; 676 return bret ? EINA_TRUE : EINA_FALSE;
diff --git a/src/bindings/ecore_js/ecore_js_event.hh b/src/bindings/ecore_js/ecore_js_event.hh
index e9f4e60..e7300ef 100644
--- a/src/bindings/ecore_js/ecore_js_event.hh
+++ b/src/bindings/ecore_js/ecore_js_event.hh
@@ -14,6 +14,7 @@ using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return; 14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field; 15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field; 16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
17 18
18void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global, 19void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
19 v8::Handle<v8::String> name); 20 v8::Handle<v8::String> name);
diff --git a/src/bindings/ecore_js/ecore_js_idle.cc b/src/bindings/ecore_js/ecore_js_idle.cc
index 8cfffc0..68848d2 100644
--- a/src/bindings/ecore_js/ecore_js_idle.cc
+++ b/src/bindings/ecore_js/ecore_js_idle.cc
@@ -7,18 +7,6 @@
7 7
8namespace efl { namespace ecore { namespace js { 8namespace efl { namespace ecore { namespace js {
9 9
10struct persistent_with_isolate_t
11{
12 template<class S>
13 persistent_with_isolate_t(v8::Isolate *isolate, v8::Handle<S> that)
14 : isolate(isolate)
15 , persistent(isolate, that)
16 {}
17
18 v8::Isolate *isolate;
19 v8::Persistent<v8::Value> persistent;
20};
21
22static Ecore_Idler* extract_idler(v8::Local<v8::Object> object) 10static Ecore_Idler* extract_idler(v8::Local<v8::Object> object)
23{ 11{
24 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value(); 12 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
@@ -139,16 +127,15 @@ void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
139 if (args.Length() != 1 || !args[0]->IsFunction()) 127 if (args.Length() != 1 || !args[0]->IsFunction())
140 return compatibility_return(); 128 return compatibility_return();
141 129
142 persistent_with_isolate_t *f 130 compatibility_persistent<Value> *f
143 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 131 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
144 auto ret = ecore_idler_add([](void *data) -> Eina_Bool { 132 auto ret = ecore_idler_add([](void *data) -> Eina_Bool {
145 persistent_with_isolate_t *persistent 133 compatibility_persistent<Value> *persistent
146 = reinterpret_cast<persistent_with_isolate_t *>(data); 134 = reinterpret_cast<compatibility_persistent<Value>*>(data);
147 auto value = Local<Value>::New(persistent->isolate, 135 auto closure = Function::Cast(*persistent->handle());
148 persistent->persistent);
149 auto closure = Function::Cast(*value);
150 136
151 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 137 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
138 NULL);
152 auto bret = ret->IsBoolean() && ret->BooleanValue(); 139 auto bret = ret->IsBoolean() && ret->BooleanValue();
153 140
154 if (!bret) 141 if (!bret)
@@ -180,16 +167,15 @@ void register_idle_enterer_add(v8::Isolate *isolate,
180 if (args.Length() != 1 || !args[0]->IsFunction()) 167 if (args.Length() != 1 || !args[0]->IsFunction())
181 return compatibility_return(); 168 return compatibility_return();
182 169
183 persistent_with_isolate_t *f 170 compatibility_persistent<Value> *f
184 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 171 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
185 auto ret = ecore_idle_enterer_add([](void *data) -> Eina_Bool { 172 auto ret = ecore_idle_enterer_add([](void *data) -> Eina_Bool {
186 persistent_with_isolate_t *persistent 173 compatibility_persistent<Value> *persistent
187 = reinterpret_cast<persistent_with_isolate_t *>(data); 174 = reinterpret_cast<compatibility_persistent<Value>*>(data);
188 auto value = Local<Value>::New(persistent->isolate, 175 auto closure = Function::Cast(*persistent->handle());
189 persistent->persistent);
190 auto closure = Function::Cast(*value);
191 176
192 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 177 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
178 NULL);
193 auto bret = ret->IsBoolean() && ret->BooleanValue(); 179 auto bret = ret->IsBoolean() && ret->BooleanValue();
194 180
195 if (!bret) 181 if (!bret)
@@ -222,16 +208,15 @@ void register_idle_enterer_before_add(v8::Isolate *isolate,
222 if (args.Length() != 1 || !args[0]->IsFunction()) 208 if (args.Length() != 1 || !args[0]->IsFunction())
223 return compatibility_return(); 209 return compatibility_return();
224 210
225 persistent_with_isolate_t *f 211 compatibility_persistent<Value> *f
226 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 212 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
227 auto ret = ecore_idle_enterer_before_add([](void *data) -> Eina_Bool { 213 auto ret = ecore_idle_enterer_before_add([](void *data) -> Eina_Bool {
228 persistent_with_isolate_t *persistent 214 compatibility_persistent<Value> *persistent
229 = reinterpret_cast<persistent_with_isolate_t *>(data); 215 = reinterpret_cast<compatibility_persistent<Value>*>(data);
230 auto value = Local<Value>::New(persistent->isolate, 216 auto closure = Function::Cast(*persistent->handle());
231 persistent->persistent);
232 auto closure = Function::Cast(*value);
233 217
234 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 218 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
219 NULL);
235 auto bret = ret->IsBoolean() && ret->BooleanValue(); 220 auto bret = ret->IsBoolean() && ret->BooleanValue();
236 221
237 if (!bret) 222 if (!bret)
@@ -264,16 +249,15 @@ void register_idle_exiter_add(v8::Isolate *isolate,
264 if (args.Length() != 1 || !args[0]->IsFunction()) 249 if (args.Length() != 1 || !args[0]->IsFunction())
265 return compatibility_return(); 250 return compatibility_return();
266 251
267 persistent_with_isolate_t *f 252 compatibility_persistent<Value> *f
268 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 253 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
269 auto ret = ecore_idle_exiter_add([](void *data) -> Eina_Bool { 254 auto ret = ecore_idle_exiter_add([](void *data) -> Eina_Bool {
270 persistent_with_isolate_t *persistent 255 compatibility_persistent<Value> *persistent
271 = reinterpret_cast<persistent_with_isolate_t *>(data); 256 = reinterpret_cast<compatibility_persistent<Value>*>(data);
272 auto value = Local<Value>::New(persistent->isolate, 257 auto closure = Function::Cast(*persistent->handle());
273 persistent->persistent);
274 auto closure = Function::Cast(*value);
275 258
276 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 259 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
260 NULL);
277 auto bret = ret->IsBoolean() && ret->BooleanValue(); 261 auto bret = ret->IsBoolean() && ret->BooleanValue();
278 262
279 if (!bret) 263 if (!bret)
diff --git a/src/bindings/ecore_js/ecore_js_idle.hh b/src/bindings/ecore_js/ecore_js_idle.hh
index 9b7f513..09c45ec 100644
--- a/src/bindings/ecore_js/ecore_js_idle.hh
+++ b/src/bindings/ecore_js/ecore_js_idle.hh
@@ -14,6 +14,7 @@ using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return; 14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field; 15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field; 16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
17 18
18void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global, 19void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
19 v8::Handle<v8::String> name); 20 v8::Handle<v8::String> name);
diff --git a/src/bindings/ecore_js/ecore_js_job.cc b/src/bindings/ecore_js/ecore_js_job.cc
index 456561a..558aa3a 100644
--- a/src/bindings/ecore_js/ecore_js_job.cc
+++ b/src/bindings/ecore_js/ecore_js_job.cc
@@ -7,18 +7,6 @@
7 7
8namespace efl { namespace ecore { namespace js { 8namespace efl { namespace ecore { namespace js {
9 9
10struct persistent_with_isolate_t
11{
12 template<class S>
13 persistent_with_isolate_t(v8::Isolate *isolate, v8::Handle<S> that)
14 : isolate(isolate)
15 , persistent(isolate, that)
16 {}
17
18 v8::Isolate *isolate;
19 v8::Persistent<v8::Value> persistent;
20};
21
22static Ecore_Job* extract_job(v8::Local<v8::Object> object) 10static Ecore_Job* extract_job(v8::Local<v8::Object> object)
23{ 11{
24 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value(); 12 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
@@ -67,16 +55,14 @@ void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
67 if (args.Length() != 1 || !args[0]->IsFunction()) 55 if (args.Length() != 1 || !args[0]->IsFunction())
68 return compatibility_return(); 56 return compatibility_return();
69 57
70 persistent_with_isolate_t *f 58 compatibility_persistent<Value> *f
71 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 59 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
72 auto ret = ecore_job_add([](void *data) { 60 auto ret = ecore_job_add([](void *data) {
73 persistent_with_isolate_t *persistent 61 compatibility_persistent<Value> *persistent
74 = reinterpret_cast<persistent_with_isolate_t *>(data); 62 = reinterpret_cast<compatibility_persistent<Value>*>(data);
75 auto value = Local<Value>::New(persistent->isolate, 63 auto closure = Function::Cast(*persistent->handle());
76 persistent->persistent);
77 auto closure = Function::Cast(*value);
78 64
79 closure->Call(Undefined(persistent->isolate), 0, NULL); 65 closure->Call(Undefined(persistent->GetIsolate()), 0, NULL);
80 66
81 delete persistent; 67 delete persistent;
82 }, f); 68 }, f);
diff --git a/src/bindings/ecore_js/ecore_js_job.hh b/src/bindings/ecore_js/ecore_js_job.hh
index f950062..6ed0323 100644
--- a/src/bindings/ecore_js/ecore_js_job.hh
+++ b/src/bindings/ecore_js/ecore_js_job.hh
@@ -14,6 +14,7 @@ using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return; 14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field; 15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field; 16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
17 18
18void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global, 19void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
19 v8::Handle<v8::String> name); 20 v8::Handle<v8::String> name);
diff --git a/src/bindings/ecore_js/ecore_js_mainloop.cc b/src/bindings/ecore_js/ecore_js_mainloop.cc
index 1924e86..0d0ab24 100644
--- a/src/bindings/ecore_js/ecore_js_mainloop.cc
+++ b/src/bindings/ecore_js/ecore_js_mainloop.cc
@@ -7,18 +7,6 @@
7 7
8namespace efl { namespace ecore { namespace js { 8namespace efl { namespace ecore { namespace js {
9 9
10struct persistent_with_isolate_t
11{
12 template<class S>
13 persistent_with_isolate_t(v8::Isolate *isolate, v8::Handle<S> that)
14 : isolate(isolate)
15 , persistent(isolate, that)
16 {}
17
18 v8::Isolate *isolate;
19 v8::Persistent<v8::Value> persistent;
20};
21
22EAPI 10EAPI
23void register_callback_cancel(v8::Isolate *isolate, 11void register_callback_cancel(v8::Isolate *isolate,
24 v8::Handle<v8::Object> global, 12 v8::Handle<v8::Object> global,
@@ -202,16 +190,14 @@ void register_mainloop_thread_safe_call_async(v8::Isolate *isolate,
202 if (args.Length() != 1 || !args[0]->IsFunction()) 190 if (args.Length() != 1 || !args[0]->IsFunction())
203 return compatibility_return(); 191 return compatibility_return();
204 192
205 persistent_with_isolate_t *f 193 compatibility_persistent<Value> *f
206 = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 194 = new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
207 ecore_main_loop_thread_safe_call_async([](void *data) { 195 ecore_main_loop_thread_safe_call_async([](void *data) {
208 persistent_with_isolate_t *persistent 196 compatibility_persistent<Value> *persistent
209 = reinterpret_cast<persistent_with_isolate_t *>(data); 197 = reinterpret_cast<compatibility_persistent<Value>*>(data);
210 auto value = Local<Value>::New(persistent->isolate, 198 auto closure = Function::Cast(*persistent->handle());
211 persistent->persistent);
212 auto closure = Function::Cast(*value);
213 199
214 closure->Call(Undefined(persistent->isolate), 0, NULL); 200 closure->Call(Undefined(persistent->GetIsolate()), 0, NULL);
215 201
216 delete persistent; 202 delete persistent;
217 }, f); 203 }, f);
@@ -238,25 +224,23 @@ void register_mainloop_thread_safe_call_sync(v8::Isolate *isolate,
238 if (args.Length() != 1 || !args[0]->IsFunction()) 224 if (args.Length() != 1 || !args[0]->IsFunction())
239 return compatibility_return(); 225 return compatibility_return();
240 226
241 auto f = new persistent_with_isolate_t(args.GetIsolate(), args[0]); 227 auto f = new compatibility_persistent<Value>(args.GetIsolate(),
228 args[0]);
242 void *data = ecore_main_loop_thread_safe_call_sync([](void *data) { 229 void *data = ecore_main_loop_thread_safe_call_sync([](void *data) {
243 persistent_with_isolate_t *persistent 230 compatibility_persistent<Value> *persistent
244 = reinterpret_cast<persistent_with_isolate_t*>(data); 231 = reinterpret_cast<compatibility_persistent<Value>*>(data);
245 auto value = Local<Value>::New(persistent->isolate, 232 auto isolate = persistent->GetIsolate();
246 persistent->persistent); 233 auto closure = Function::Cast(*persistent->handle());
247 auto closure = Function::Cast(*value); 234 auto res = closure->Call(Undefined(isolate), 0, NULL);
248 auto res = closure->Call(Undefined(persistent->isolate), 0, 235 void *ret = new compatibility_persistent<Value>(isolate, res);
249 NULL);
250 void *ret = new persistent_with_isolate_t(persistent->isolate,
251 res);
252 236
253 delete persistent; 237 delete persistent;
254 238
255 return ret; 239 return ret;
256 }, f); 240 }, f);
257 241
258 auto ret = reinterpret_cast<persistent_with_isolate_t*>(data); 242 auto ret = reinterpret_cast<compatibility_persistent<Value>*>(data);
259 auto value = Local<Value>::New(ret->isolate, ret->persistent); 243 auto value = ret->handle();
260 244
261 delete ret; 245 delete ret;
262 246
diff --git a/src/bindings/ecore_js/ecore_js_mainloop.hh b/src/bindings/ecore_js/ecore_js_mainloop.hh
index 968f13f..6dd192d 100644
--- a/src/bindings/ecore_js/ecore_js_mainloop.hh
+++ b/src/bindings/ecore_js/ecore_js_mainloop.hh
@@ -14,6 +14,7 @@ using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return; 14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field; 15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field; 16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
17 18
18void register_callback_cancel(v8::Isolate *isolate, 19void register_callback_cancel(v8::Isolate *isolate,
19 v8::Handle<v8::Object> global, 20 v8::Handle<v8::Object> global,
diff --git a/src/bindings/ecore_js/ecore_js_timer.cc b/src/bindings/ecore_js/ecore_js_timer.cc
index 26cb26d..6294dd5 100644
--- a/src/bindings/ecore_js/ecore_js_timer.cc
+++ b/src/bindings/ecore_js/ecore_js_timer.cc
@@ -9,18 +9,6 @@
9 9
10namespace efl { namespace ecore { namespace js { 10namespace efl { namespace ecore { namespace js {
11 11
12struct persistent_with_isolate_t
13{
14 template<class S>
15 persistent_with_isolate_t(v8::Isolate *isolate, v8::Handle<S> that)
16 : isolate(isolate)
17 , persistent(isolate, that)
18 {}
19
20 v8::Isolate *isolate;
21 v8::Persistent<v8::Value> persistent;
22};
23
24static Ecore_Timer* extract_timer(v8::Local<v8::Object> object) 12static Ecore_Timer* extract_timer(v8::Local<v8::Object> object)
25{ 13{
26 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value(); 14 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
@@ -179,17 +167,16 @@ void register_timer_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
179 return compatibility_return(); 167 return compatibility_return();
180 } 168 }
181 169
182 persistent_with_isolate_t *f 170 compatibility_persistent<Value> *f
183 = new persistent_with_isolate_t(args.GetIsolate(), args[1]); 171 = new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
184 172
185 auto cb = [](void *data) -> Eina_Bool { 173 auto cb = [](void *data) -> Eina_Bool {
186 auto persistent 174 auto persistent
187 = reinterpret_cast<persistent_with_isolate_t *>(data); 175 = reinterpret_cast<compatibility_persistent<Value>*>(data);
188 auto value = Local<Value>::New(persistent->isolate, 176 auto closure = Function::Cast(*persistent->handle());
189 persistent->persistent);
190 auto closure = Function::Cast(*value);
191 177
192 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 178 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
179 NULL);
193 auto bret = ret->IsBoolean() && ret->BooleanValue(); 180 auto bret = ret->IsBoolean() && ret->BooleanValue();
194 181
195 if (!bret) 182 if (!bret)
@@ -224,17 +211,16 @@ void register_timer_loop_add(v8::Isolate *isolate,
224 return compatibility_return(); 211 return compatibility_return();
225 } 212 }
226 213
227 persistent_with_isolate_t *f 214 compatibility_persistent<Value> *f
228 = new persistent_with_isolate_t(args.GetIsolate(), args[1]); 215 = new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
229 216
230 auto cb = [](void *d) -> Eina_Bool { 217 auto cb = [](void *d) -> Eina_Bool {
231 auto persistent 218 auto persistent
232 = reinterpret_cast<persistent_with_isolate_t *>(d); 219 = reinterpret_cast<compatibility_persistent<Value>*>(d);
233 auto value = Local<Value>::New(persistent->isolate, 220 auto closure = Function::Cast(*persistent->handle());
234 persistent->persistent);
235 auto closure = Function::Cast(*value);
236 221
237 auto ret = closure->Call(Undefined(persistent->isolate), 0, NULL); 222 auto ret = closure->Call(Undefined(persistent->GetIsolate()), 0,
223 NULL);
238 auto bret = ret->IsBoolean() && ret->BooleanValue(); 224 auto bret = ret->IsBoolean() && ret->BooleanValue();
239 225
240 if (!bret) 226 if (!bret)
diff --git a/src/bindings/ecore_js/ecore_js_timer.hh b/src/bindings/ecore_js/ecore_js_timer.hh
index e1e65e1..e13457e 100644
--- a/src/bindings/ecore_js/ecore_js_timer.hh
+++ b/src/bindings/ecore_js/ecore_js_timer.hh
@@ -14,6 +14,7 @@ using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return; 14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field; 15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field; 16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
17 18
18void register_timer_precision_get(v8::Isolate *isolate, 19void register_timer_precision_get(v8::Isolate *isolate,
19 v8::Handle<v8::Object> global, 20 v8::Handle<v8::Object> global,