summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-04 17:19:39 -0300
committerVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-04 21:54:08 -0300
commitb299a3489e221d8b134c2e3711e4141a4875c9da (patch)
tree614b87c8a1c15500ee49d23bf50b67f11a9e27ab
parentaf229750c5070544cb874e8b20532731c73910e4 (diff)
Initial bindings for Ecore_Animator
-rw-r--r--src/Makefile_Ecore_Js.am6
-rw-r--r--src/bindings/ecore_js/ecore_js_animator.cc639
-rw-r--r--src/bindings/ecore_js/ecore_js_animator.hh122
-rw-r--r--src/tests/ecore_js/ecore_js_suite.cc100
-rwxr-xr-xsrc/tests/ecore_js/ecore_js_suite.js16
5 files changed, 881 insertions, 2 deletions
diff --git a/src/Makefile_Ecore_Js.am b/src/Makefile_Ecore_Js.am
index 7d3f831..96d6afa 100644
--- a/src/Makefile_Ecore_Js.am
+++ b/src/Makefile_Ecore_Js.am
@@ -26,7 +26,8 @@ bindings/ecore_js/ecore_js_mainloop.cc \
26bindings/ecore_js/ecore_js_timer.cc \ 26bindings/ecore_js/ecore_js_timer.cc \
27bindings/ecore_js/ecore_js_event.cc \ 27bindings/ecore_js/ecore_js_event.cc \
28bindings/ecore_js/ecore_js_job.cc \ 28bindings/ecore_js/ecore_js_job.cc \
29bindings/ecore_js/ecore_js_idle.cc 29bindings/ecore_js/ecore_js_idle.cc \
30bindings/ecore_js/ecore_js_animator.cc
30 31
31ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \ 32ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
32-DTESTS_WD=\"`pwd`\" \ 33-DTESTS_WD=\"`pwd`\" \
@@ -48,7 +49,8 @@ bindings/ecore_js/ecore_js_mainloop.hh \
48bindings/ecore_js/ecore_js_timer.hh \ 49bindings/ecore_js/ecore_js_timer.hh \
49bindings/ecore_js/ecore_js_event.hh \ 50bindings/ecore_js/ecore_js_event.hh \
50bindings/ecore_js/ecore_js_job.hh \ 51bindings/ecore_js/ecore_js_job.hh \
51bindings/ecore_js/ecore_js_idle.hh 52bindings/ecore_js/ecore_js_idle.hh \
53bindings/ecore_js/ecore_js_animator.hh
52 54
53### Unit tests 55### Unit tests
54 56
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 0000000..19ae5c3
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_animator.cc
@@ -0,0 +1,639 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <ecore_js_animator.hh>
6#include <Ecore.h>
7
8namespace efl { namespace ecore { namespace js {
9
10static Ecore_Animator* extract_animator(v8::Local<v8::Object> object)
11{
12 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
13 return reinterpret_cast<Ecore_Animator*>(ptr);
14}
15
16static v8::Local<v8::Object> wrap_animator(Ecore_Animator *animator,
17 v8::Isolate *isolate)
18{
19 using v8::Boolean;
20 using v8::String;
21 using v8::ObjectTemplate;
22 using v8::FunctionTemplate;
23
24 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
25 obj_tpl->SetInternalFieldCount(1);
26 auto ret = obj_tpl->NewInstance();
27
28 auto del = [](compatibility_callback_info_type info)
29 -> compatibility_return_type {
30 if (info.Length() != 0)
31 return compatibility_return();
32
33 ecore_animator_del(extract_animator(info.This()));
34 };
35
36 auto freeze = [](compatibility_callback_info_type info)
37 -> compatibility_return_type {
38 if (info.Length() != 0)
39 return compatibility_return();
40
41 ecore_animator_freeze(extract_animator(info.This()));
42 };
43
44 auto thaw = [](compatibility_callback_info_type info)
45 -> compatibility_return_type {
46 if (info.Length() != 0)
47 return compatibility_return();
48
49 ecore_animator_thaw(extract_animator(info.This()));
50 };
51
52 ret->Set(compatibility_new<String>(isolate, "del"),
53 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
54 ret->Set(compatibility_new<String>(isolate, "freeze"),
55 compatibility_new<FunctionTemplate>(isolate, freeze)
56 ->GetFunction());
57 ret->Set(compatibility_new<String>(isolate, "thaw"),
58 compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
59
60 ret->SetInternalField(0, compatibility_new<v8::External>(isolate,
61 animator));
62
63 return ret;
64}
65
66EAPI
67void register_pos_map_linear(v8::Isolate *isolate,
68 v8::Handle<v8::Object> global,
69 v8::Handle<v8::String> name)
70{
71 using v8::Integer;
72
73 global->Set(name,
74 compatibility_new<Integer>(isolate, ECORE_POS_MAP_LINEAR));
75}
76
77EAPI
78void register_pos_map_accelerate(v8::Isolate *isolate,
79 v8::Handle<v8::Object> global,
80 v8::Handle<v8::String> name)
81{
82 using v8::Integer;
83
84 global->Set(name,
85 compatibility_new<Integer>(isolate, ECORE_POS_MAP_ACCELERATE));
86}
87
88EAPI
89void register_pos_map_decelerate(v8::Isolate *isolate,
90 v8::Handle<v8::Object> global,
91 v8::Handle<v8::String> name)
92{
93 using v8::Integer;
94
95 global->Set(name,
96 compatibility_new<Integer>(isolate, ECORE_POS_MAP_DECELERATE));
97}
98
99EAPI
100void register_pos_map_sinusoidal(v8::Isolate *isolate,
101 v8::Handle<v8::Object> global,
102 v8::Handle<v8::String> name)
103{
104 using v8::Integer;
105
106 global->Set(name,
107 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SINUSOIDAL));
108}
109
110EAPI
111void register_pos_map_accelerate_factor(v8::Isolate *isolate,
112 v8::Handle<v8::Object> global,
113 v8::Handle<v8::String> name)
114{
115 using v8::Integer;
116
117 global->Set(name,
118 compatibility_new<Integer>(isolate,
119 ECORE_POS_MAP_ACCELERATE_FACTOR));
120}
121
122EAPI
123void register_pos_map_decelerate_factor(v8::Isolate *isolate,
124 v8::Handle<v8::Object> global,
125 v8::Handle<v8::String> name)
126{
127 using v8::Integer;
128
129 global->Set(name,
130 compatibility_new<Integer>(isolate,
131 ECORE_POS_MAP_DECELERATE_FACTOR));
132}
133
134EAPI
135void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
136 v8::Handle<v8::Object> global,
137 v8::Handle<v8::String> name)
138{
139 using v8::Integer;
140
141 global->Set(name,
142 compatibility_new<Integer>(isolate,
143 ECORE_POS_MAP_SINUSOIDAL_FACTOR));
144}
145
146EAPI
147void register_pos_map_divisor_interp(v8::Isolate *isolate,
148 v8::Handle<v8::Object> global,
149 v8::Handle<v8::String> name)
150{
151 using v8::Integer;
152
153 global->Set(name,
154 compatibility_new<Integer>(isolate,
155 ECORE_POS_MAP_DIVISOR_INTERP));
156}
157
158EAPI
159void register_pos_map_bounce(v8::Isolate *isolate,
160 v8::Handle<v8::Object> global,
161 v8::Handle<v8::String> name)
162{
163 using v8::Integer;
164
165 global->Set(name,
166 compatibility_new<Integer>(isolate, ECORE_POS_MAP_BOUNCE));
167}
168
169EAPI
170void register_pos_map_spring(v8::Isolate *isolate,
171 v8::Handle<v8::Object> global,
172 v8::Handle<v8::String> name)
173{
174 using v8::Integer;
175
176 global->Set(name,
177 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SPRING));
178}
179
180EAPI
181void register_pos_map_cubic_bezier(v8::Isolate *isolate,
182 v8::Handle<v8::Object> global,
183 v8::Handle<v8::String> name)
184{
185 using v8::Integer;
186
187 global->Set(name,
188 compatibility_new<Integer>(isolate,
189 ECORE_POS_MAP_CUBIC_BEZIER));
190}
191
192EAPI
193void register_animator_source_timer(v8::Isolate *isolate,
194 v8::Handle<v8::Object> global,
195 v8::Handle<v8::String> name)
196{
197 using v8::Integer;
198
199 global->Set(name,
200 compatibility_new<Integer>(isolate,
201 ECORE_ANIMATOR_SOURCE_TIMER));
202}
203
204EAPI
205void register_animator_source_custom(v8::Isolate *isolate,
206 v8::Handle<v8::Object> global,
207 v8::Handle<v8::String> name)
208{
209 using v8::Integer;
210
211 global->Set(name,
212 compatibility_new<Integer>(isolate,
213 ECORE_ANIMATOR_SOURCE_CUSTOM));
214}
215
216EAPI
217void register_animator_frametime_set(v8::Isolate *isolate,
218 v8::Handle<v8::Object> global,
219 v8::Handle<v8::String> name)
220{
221 using v8::FunctionTemplate;
222
223 auto f = [](compatibility_callback_info_type args)
224 -> compatibility_return_type {
225 if (args.Length() != 1 || !args[0]->IsNumber())
226 return compatibility_return();
227
228 ecore_animator_frametime_set(args[0]->NumberValue());
229 };
230
231 global->Set(name,
232 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
233}
234
235EAPI
236void register_animator_frametime_get(v8::Isolate *isolate,
237 v8::Handle<v8::Object> global,
238 v8::Handle<v8::String> name)
239{
240 using v8::Number;
241 using v8::FunctionTemplate;
242
243 auto f = [](compatibility_callback_info_type args)
244 -> compatibility_return_type {
245 if (args.Length() != 0)
246 return compatibility_return();
247
248 auto isolate = args.GetIsolate();
249 auto ret = ecore_animator_frametime_get();
250 return compatibility_return(compatibility_new<Number>(isolate, ret),
251 args);
252 };
253
254 global->Set(name,
255 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
256}
257
258EAPI
259void register_animator_pos_map(v8::Isolate *isolate,
260 v8::Handle<v8::Object> global,
261 v8::Handle<v8::String> name)
262{
263 using v8::Number;
264 using v8::FunctionTemplate;
265
266 auto f = [](compatibility_callback_info_type args)
267 -> compatibility_return_type {
268 if (args.Length() != 4 || !args[0]->IsNumber() || !args[1]->IsNumber()
269 || !args[2]->IsNumber() || !args[3]->IsNumber())
270 return compatibility_return();
271
272 Ecore_Pos_Map map;
273
274 switch ((int)(args[1]->NumberValue())) {
275 case ECORE_POS_MAP_LINEAR:
276 map = ECORE_POS_MAP_LINEAR;
277 break;
278 case ECORE_POS_MAP_ACCELERATE:
279 map = ECORE_POS_MAP_ACCELERATE;
280 break;
281 case ECORE_POS_MAP_DECELERATE:
282 map = ECORE_POS_MAP_DECELERATE;
283 break;
284 case ECORE_POS_MAP_SINUSOIDAL:
285 map = ECORE_POS_MAP_SINUSOIDAL;
286 break;
287 case ECORE_POS_MAP_ACCELERATE_FACTOR:
288 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
289 break;
290 case ECORE_POS_MAP_DECELERATE_FACTOR:
291 map = ECORE_POS_MAP_DECELERATE_FACTOR;
292 break;
293 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
294 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
295 break;
296 case ECORE_POS_MAP_DIVISOR_INTERP:
297 map = ECORE_POS_MAP_DIVISOR_INTERP;
298 break;
299 case ECORE_POS_MAP_BOUNCE:
300 map = ECORE_POS_MAP_BOUNCE;
301 break;
302 case ECORE_POS_MAP_SPRING:
303 map = ECORE_POS_MAP_SPRING;
304 break;
305 case ECORE_POS_MAP_CUBIC_BEZIER:
306 map = ECORE_POS_MAP_CUBIC_BEZIER;
307 break;
308 default:
309 return compatibility_return();
310 }
311
312 auto isolate = args.GetIsolate();
313 auto ret = ecore_animator_pos_map(args[0]->NumberValue(), map,
314 args[2]->NumberValue(),
315 args[3]->NumberValue());
316 return compatibility_return(compatibility_new<Number>(isolate, ret),
317 args);
318 };
319
320 global->Set(name,
321 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
322}
323
324EAPI
325void register_animator_pos_map_n(v8::Isolate *isolate,
326 v8::Handle<v8::Object> global,
327 v8::Handle<v8::String> name)
328{
329 using v8::Number;
330 using v8::NumberObject;
331 using v8::FunctionTemplate;
332 using v8::Array;
333
334 auto f = [](compatibility_callback_info_type args)
335 -> compatibility_return_type {
336 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
337 || !args[2]->IsArray())
338 return compatibility_return();
339
340 Ecore_Pos_Map map;
341
342 switch ((int)(args[1]->NumberValue())) {
343 case ECORE_POS_MAP_LINEAR:
344 map = ECORE_POS_MAP_LINEAR;
345 break;
346 case ECORE_POS_MAP_ACCELERATE:
347 map = ECORE_POS_MAP_ACCELERATE;
348 break;
349 case ECORE_POS_MAP_DECELERATE:
350 map = ECORE_POS_MAP_DECELERATE;
351 break;
352 case ECORE_POS_MAP_SINUSOIDAL:
353 map = ECORE_POS_MAP_SINUSOIDAL;
354 break;
355 case ECORE_POS_MAP_ACCELERATE_FACTOR:
356 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
357 break;
358 case ECORE_POS_MAP_DECELERATE_FACTOR:
359 map = ECORE_POS_MAP_DECELERATE_FACTOR;
360 break;
361 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
362 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
363 break;
364 case ECORE_POS_MAP_DIVISOR_INTERP:
365 map = ECORE_POS_MAP_DIVISOR_INTERP;
366 break;
367 case ECORE_POS_MAP_BOUNCE:
368 map = ECORE_POS_MAP_BOUNCE;
369 break;
370 case ECORE_POS_MAP_SPRING:
371 map = ECORE_POS_MAP_SPRING;
372 break;
373 case ECORE_POS_MAP_CUBIC_BEZIER:
374 map = ECORE_POS_MAP_CUBIC_BEZIER;
375 break;
376 default:
377 return compatibility_return();
378 }
379
380 std::vector<double> v;
381 {
382 auto array = Array::Cast(*args[2]);
383 auto s = array->Length();
384 v.reserve(s);
385 for (decltype(s) i = 0;i != s;++i) {
386 auto e = array->Get(i);
387 if (!e->IsNumber())
388 return compatibility_return();
389
390 v.push_back(e->NumberValue());
391 }
392 }
393
394 auto isolate = args.GetIsolate();
395 auto ret = ecore_animator_pos_map_n(args[0]->NumberValue(), map,
396 v.size(), v.data());
397 return compatibility_return(compatibility_new<Number>(isolate, ret),
398 args);
399 };
400
401 global->Set(name,
402 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
403}
404
405EAPI
406void register_animator_source_set(v8::Isolate *isolate,
407 v8::Handle<v8::Object> global,
408 v8::Handle<v8::String> name)
409{
410 using v8::FunctionTemplate;
411
412 auto f = [](compatibility_callback_info_type args)
413 -> compatibility_return_type {
414 if (args.Length() != 1 || !args[0]->IsNumber())
415 return compatibility_return();
416
417 Ecore_Animator_Source source;
418
419 switch ((int)(args[0]->NumberValue())) {
420 case ECORE_ANIMATOR_SOURCE_TIMER:
421 source = ECORE_ANIMATOR_SOURCE_TIMER;
422 break;
423 case ECORE_ANIMATOR_SOURCE_CUSTOM:
424 source = ECORE_ANIMATOR_SOURCE_CUSTOM;
425 break;
426 default:
427 return compatibility_return();
428 }
429
430 ecore_animator_source_set(source);
431 };
432
433 global->Set(name,
434 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
435}
436
437EAPI
438void register_animator_source_get(v8::Isolate *isolate,
439 v8::Handle<v8::Object> global,
440 v8::Handle<v8::String> name)
441{
442 using v8::Integer;
443 using v8::FunctionTemplate;
444
445 auto f = [](compatibility_callback_info_type args)
446 -> compatibility_return_type {
447 if (args.Length() != 0)
448 return compatibility_return();
449
450 auto isolate = args.GetIsolate();
451 auto ret = ecore_animator_source_get();
452 return compatibility_return(compatibility_new<Integer>(isolate, ret),
453 args);
454 };
455
456 global->Set(name,
457 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
458}
459
460static
461compatibility_persistent<v8::Value> animator_custom_source_tick_begin_cb_data;
462static
463compatibility_persistent<v8::Value> animator_custom_source_tick_end_cb_data;
464
465EAPI void
466register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
467 v8::Handle<v8::Object>
468 global,
469 v8::Handle<v8::String>
470 name)
471{
472 using v8::FunctionCallbackInfo;
473 using v8::Value;
474 using v8::FunctionTemplate;
475
476 auto f = [](compatibility_callback_info_type args) {
477 if (args.Length() != 1 || !args[0]->IsFunction())
478 return compatibility_return();
479
480 animator_custom_source_tick_begin_cb_data
481 = compatibility_persistent<Value>(args.GetIsolate(), args[0]);
482 ecore_animator_custom_source_tick_begin_callback_set([](void*) {
483 using v8::Function;
484 using v8::Undefined;
485 using v8::Isolate;
486
487 auto isolate = Isolate::GetCurrent();
488 Function::Cast(*animator_custom_source_tick_begin_cb_data
489 .handle())->Call(Undefined(isolate), 0, NULL);
490 }, NULL);
491 };
492
493 global->Set(name,
494 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
495}
496
497EAPI void
498register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
499 v8::Handle<v8::Object>
500 global,
501 v8::Handle<v8::String>
502 name)
503{
504 using v8::FunctionCallbackInfo;
505 using v8::Value;
506 using v8::FunctionTemplate;
507
508 auto f = [](compatibility_callback_info_type args) {
509 if (args.Length() != 1 || !args[0]->IsFunction())
510 return compatibility_return();
511
512 animator_custom_source_tick_end_cb_data
513 = compatibility_persistent<Value>(args.GetIsolate(), args[0]);
514 ecore_animator_custom_source_tick_end_callback_set([](void*) {
515 using v8::Function;
516 using v8::Undefined;
517 using v8::Isolate;
518
519 auto isolate = Isolate::GetCurrent();
520 Function::Cast(*animator_custom_source_tick_end_cb_data
521 .handle())->Call(Undefined(isolate), 0, NULL);
522 }, NULL);
523 };
524
525 global->Set(name,
526 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
527}
528
529EAPI void
530register_animator_custom_tick(v8::Isolate *isolate,
531 v8::Handle<v8::Object> global,
532 v8::Handle<v8::String> name)
533{
534 using v8::FunctionCallbackInfo;
535 using v8::Value;
536 using v8::FunctionTemplate;
537
538 auto f = [](compatibility_callback_info_type args) {
539 if (args.Length() != 0)
540 return compatibility_return();
541
542 ecore_animator_custom_tick();
543 };
544
545 global->Set(name,
546 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
547}
548
549EAPI
550void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
551 v8::Handle<v8::String> name)
552{
553 using v8::Local;
554 using v8::Value;
555 using v8::Undefined;
556 using v8::Function;
557 using v8::FunctionTemplate;
558
559 auto f = [](compatibility_callback_info_type args)
560 -> compatibility_return_type {
561 if (args.Length() != 1 || !args[0]->IsFunction())
562 return compatibility_return();
563
564 auto isolate = args.GetIsolate();
565 auto f = new compatibility_persistent<Value>(isolate, args[0]);
566
567 auto cb = [](void *data) -> Eina_Bool {
568 auto persistent
569 = reinterpret_cast<compatibility_persistent<Value>*>(data);
570 auto closure = Function::Cast(*persistent->handle());
571
572 auto ret = closure->Call(Undefined(v8::Isolate::GetCurrent()), 0,
573 NULL);
574 auto bret = ret->IsBoolean() && ret->BooleanValue();
575
576 if (!bret)
577 delete persistent;
578
579 return bret ? EINA_TRUE : EINA_FALSE;
580 };
581
582 auto ret = ecore_animator_add(cb, f);
583 return compatibility_return(wrap_animator(ret, isolate), args);
584 };
585
586 global->Set(name,
587 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
588}
589
590EAPI
591void register_animator_timeline_add(v8::Isolate *isolate,
592 v8::Handle<v8::Object> global,
593 v8::Handle<v8::String> name)
594{
595 using v8::Handle;
596 using v8::Local;
597 using v8::Value;
598 using v8::Undefined;
599 using v8::Function;
600 using v8::FunctionTemplate;
601 using v8::Number;
602
603 auto f = [](compatibility_callback_info_type args)
604 -> compatibility_return_type {
605 if (args.Length() != 2 || !args[0]->IsNumber()
606 || !args[1]->IsFunction()) {
607 return compatibility_return();
608 }
609
610 compatibility_persistent<Value> *f
611 = new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
612
613 auto cb = [](void *data, double pos) -> Eina_Bool {
614 auto persistent
615 = reinterpret_cast<compatibility_persistent<Value>*>(data);
616 auto closure = Function::Cast(*persistent->handle());
617 auto isolate = v8::Isolate::GetCurrent();
618
619 Handle<Value> args = compatibility_new<Number>(isolate, pos);
620
621 auto ret = closure->Call(Undefined(isolate), 1, &args);
622 auto bret = ret->IsBoolean() && ret->BooleanValue();
623
624 if (!bret)
625 delete persistent;
626
627 return bret ? EINA_TRUE : EINA_FALSE;
628 };
629
630 auto ret = ecore_animator_timeline_add(args[0]->NumberValue(), cb, f);
631 return compatibility_return(wrap_animator(ret, args.GetIsolate()),
632 args);
633 };
634
635 global->Set(name,
636 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
637}
638
639} } } // namespace efl { namespace js {
diff --git a/src/bindings/ecore_js/ecore_js_animator.hh b/src/bindings/ecore_js/ecore_js_animator.hh
new file mode 100644
index 0000000..6a8167f
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_animator.hh
@@ -0,0 +1,122 @@
1#ifndef ECORE_JS_ANIMATOR_HH
2#define ECORE_JS_ANIMATOR_HH
3
4#include <Eina.hh>
5#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
6
7#include <eina_js_compatibility.hh>
8
9namespace efl { namespace ecore { namespace js {
10
11using ::efl::eina::js::compatibility_new;
12using ::efl::eina::js::compatibility_return_type;
13using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
18
19void register_pos_map_linear(v8::Isolate *isolate,
20 v8::Handle<v8::Object> global,
21 v8::Handle<v8::String> name);
22
23void register_pos_map_accelerate(v8::Isolate *isolate,
24 v8::Handle<v8::Object> global,
25 v8::Handle<v8::String> name);
26
27void register_pos_map_decelerate(v8::Isolate *isolate,
28 v8::Handle<v8::Object> global,
29 v8::Handle<v8::String> name);
30
31void register_pos_map_sinusoidal(v8::Isolate *isolate,
32 v8::Handle<v8::Object> global,
33 v8::Handle<v8::String> name);
34
35void register_pos_map_accelerate_factor(v8::Isolate *isolate,
36 v8::Handle<v8::Object> global,
37 v8::Handle<v8::String> name);
38
39void register_pos_map_decelerate_factor(v8::Isolate *isolate,
40 v8::Handle<v8::Object> global,
41 v8::Handle<v8::String> name);
42
43void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
44 v8::Handle<v8::Object> global,
45 v8::Handle<v8::String> name);
46
47void register_pos_map_divisor_interp(v8::Isolate *isolate,
48 v8::Handle<v8::Object> global,
49 v8::Handle<v8::String> name);
50
51void register_pos_map_bounce(v8::Isolate *isolate,
52 v8::Handle<v8::Object> global,
53 v8::Handle<v8::String> name);
54
55void register_pos_map_spring(v8::Isolate *isolate,
56 v8::Handle<v8::Object> global,
57 v8::Handle<v8::String> name);
58
59void register_pos_map_cubic_bezier(v8::Isolate *isolate,
60 v8::Handle<v8::Object> global,
61 v8::Handle<v8::String> name);
62
63void register_animator_source_timer(v8::Isolate *isolate,
64 v8::Handle<v8::Object> global,
65 v8::Handle<v8::String> name);
66
67void register_animator_source_custom(v8::Isolate *isolate,
68 v8::Handle<v8::Object> global,
69 v8::Handle<v8::String> name);
70
71void register_animator_frametime_set(v8::Isolate *isolate,
72 v8::Handle<v8::Object> global,
73 v8::Handle<v8::String> name);
74
75void register_animator_frametime_get(v8::Isolate *isolate,
76 v8::Handle<v8::Object> global,
77 v8::Handle<v8::String> name);
78
79void register_animator_pos_map(v8::Isolate *isolate,
80 v8::Handle<v8::Object> global,
81 v8::Handle<v8::String> name);
82
83void register_animator_pos_map_n(v8::Isolate *isolate,
84 v8::Handle<v8::Object> global,
85 v8::Handle<v8::String> name);
86
87void register_animator_source_set(v8::Isolate *isolate,
88 v8::Handle<v8::Object> global,
89 v8::Handle<v8::String> name);
90
91void register_animator_source_get(v8::Isolate *isolate,
92 v8::Handle<v8::Object> global,
93 v8::Handle<v8::String> name);
94
95void
96register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
97 v8::Handle<v8::Object>
98 global,
99 v8::Handle<v8::String>
100 name);
101
102void
103register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
104 v8::Handle<v8::Object>
105 global,
106 v8::Handle<v8::String>
107 name);
108
109void register_animator_custom_tick(v8::Isolate *isolate,
110 v8::Handle<v8::Object> global,
111 v8::Handle<v8::String> name);
112
113void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
114 v8::Handle<v8::String> name);
115
116void register_animator_timeline_add(v8::Isolate *isolate,
117 v8::Handle<v8::Object> global,
118 v8::Handle<v8::String> name);
119
120} } } // namespace efl { namespace ecore { namespace js {
121
122#endif /* ECORE_JS_ANIMATOR_HH */
diff --git a/src/tests/ecore_js/ecore_js_suite.cc b/src/tests/ecore_js/ecore_js_suite.cc
index 2eb0c6c..ba143e7 100644
--- a/src/tests/ecore_js/ecore_js_suite.cc
+++ b/src/tests/ecore_js/ecore_js_suite.cc
@@ -19,6 +19,7 @@
19#include <ecore_js_event.hh> 19#include <ecore_js_event.hh>
20#include <ecore_js_job.hh> 20#include <ecore_js_job.hh>
21#include <ecore_js_idle.hh> 21#include <ecore_js_idle.hh>
22#include <ecore_js_animator.hh>
22 23
23const char* ToCString(const v8::String::Utf8Value& value) { 24const char* ToCString(const v8::String::Utf8Value& value) {
24 return *value ? *value : "<string conversion failed>"; 25 return *value ? *value : "<string conversion failed>";
@@ -268,6 +269,105 @@ void test_setup(v8::Handle<v8::Object> exports)
268 compatibility_new<String>(isolate, 269 compatibility_new<String>(isolate,
269 "ecore_idle_exiter_add")); 270 "ecore_idle_exiter_add"));
270 271
272 // animator
273 register_pos_map_linear(isolate, exports,
274 compatibility_new<String>(isolate,
275 "ECORE_POS_MAP_LINEAR"));
276 register_pos_map_accelerate(isolate, exports,
277 compatibility_new<String>(isolate,
278 "ECORE_POS_MAP"
279 "_ACCELERATE"));
280 register_pos_map_decelerate(isolate, exports,
281 compatibility_new<String>(isolate,
282 "ECORE_POS_MAP"
283 "_DECELERATE"));
284 register_pos_map_sinusoidal(isolate, exports,
285 compatibility_new<String>(isolate,
286 "ECORE_POS_MAP"
287 "_SINUSOIDAL"));
288 register_pos_map_accelerate_factor(isolate, exports,
289 compatibility_new<String>(isolate,
290 "ECORE_POS_MAP"
291 "_ACCELERATE"
292 "_FACTOR"));
293 register_pos_map_decelerate_factor(isolate, exports,
294 compatibility_new<String>(isolate,
295 "ECORE_POS_MAP"
296 "_DECELERATE"
297 "_FACTOR"));
298 register_pos_map_sinusoidal_factor(isolate, exports,
299 compatibility_new<String>(isolate,
300 "ECORE_POS_MAP"
301 "_SINUSOIDAL"
302 "_FACTOR"));
303 register_pos_map_divisor_interp(isolate, exports,
304 compatibility_new<String>(isolate,
305 "ECORE_POS_MAP"
306 "_DIVISOR_INTERP"));
307 register_pos_map_bounce(isolate, exports,
308 compatibility_new<String>(isolate,
309 "ECORE_POS_MAP_BOUNCE"));
310 register_pos_map_spring(isolate, exports,
311 compatibility_new<String>(isolate,
312 "ECORE_POS_MAP_SPRING"));
313 register_pos_map_cubic_bezier(isolate, exports,
314 compatibility_new<String>(isolate,
315 "ECORE_POS_MAP_CUBIC"
316 "_BEZIER"));
317 register_animator_source_timer(isolate, exports,
318 compatibility_new<String>(isolate,
319 "ECORE_ANIMATOR"
320 "_SOURCE_TIMER"));
321 register_animator_source_custom(isolate, exports,
322 compatibility_new<String>(isolate,
323 "ECORE_ANIMATOR"
324 "_SOURCE_CUSTOM"));
325 register_animator_frametime_set(isolate, exports,
326 compatibility_new<String>(isolate,
327 "ecore_animator"
328 "_frametime_set"));
329 register_animator_frametime_get(isolate, exports,
330 compatibility_new<String>(isolate,
331 "ecore_animator"
332 "_frametime_get"));
333 register_animator_pos_map(isolate, exports,
334 compatibility_new<String>(isolate,
335 "ecore_animator_pos"
336 "_map"));
337 register_animator_pos_map_n(isolate, exports,
338 compatibility_new<String>(isolate,
339 "ecore_animator_pos_map"
340 "_n"));
341 register_animator_source_set(isolate, exports,
342 compatibility_new<String>(isolate,
343 "ecore_animator_source"
344 "_set"));
345 register_animator_source_get(isolate, exports,
346 compatibility_new<String>(isolate,
347 "ecore_animator_source"
348 "_get"));
349 register_animator_custom_source_tick_begin_callback_set
350 (isolate, exports,
351 compatibility_new<String>(isolate,
352 "ecore_animator_custom_source_tick_begin"
353 "_callback_set"));
354 register_animator_custom_source_tick_end_callback_set
355 (isolate, exports,
356 compatibility_new<String>(isolate,
357 "ecore_animator_custom_source_tick_end"
358 "_callback_set"));
359 register_animator_custom_tick(isolate, exports,
360 compatibility_new<String>(isolate,
361 "ecore_animator"
362 "_custom_tick"));
363 register_animator_add(isolate, exports,
364 compatibility_new<String>(isolate,
365 "ecore_animator_add"));
366 register_animator_timeline_add(isolate, exports,
367 compatibility_new<String>(isolate,
368 "ecore_animator"
369 "_timeline_add"));
370
271 std::cerr << __LINE__ << std::endl; 371 std::cerr << __LINE__ << std::endl;
272} 372}
273 373
diff --git a/src/tests/ecore_js/ecore_js_suite.js b/src/tests/ecore_js/ecore_js_suite.js
index 5baa294..e471bf4 100755
--- a/src/tests/ecore_js/ecore_js_suite.js
+++ b/src/tests/ecore_js/ecore_js_suite.js
@@ -256,6 +256,22 @@ assert(captured[2] === 3);
256assert(captured[3] === 1); 256assert(captured[3] === 1);
257assert(captured[4] === 5); 257assert(captured[4] === 5);
258 258
259// Ecore animator
260
261suite.ecore_animator_frametime_set(1);
262assert(suite.ecore_animator_frametime_get() === 1);
263suite.ecore_animator_frametime_set(1 / 50);
264assert(suite.ecore_animator_frametime_get() === (1 / 50));
265
266assert(suite.ecore_animator_pos_map(0.5, suite.ECORE_POS_MAP_LINEAR, 0, 0)
267 === 0.5);
268
269suite.ecore_animator_source_set(suite.ECORE_ANIMATOR_SOURCE_CUSTOM);
270assert(suite.ecore_animator_source_get()
271 === suite.ECORE_ANIMATOR_SOURCE_CUSTOM);
272suite.ecore_animator_source_set(suite.ECORE_ANIMATOR_SOURCE_TIMER);
273assert(suite.ecore_animator_source_get() === suite.ECORE_ANIMATOR_SOURCE_TIMER);
274
259// Ecore shutdown 275// Ecore shutdown
260 276
261suite.ecore_shutdown(); 277suite.ecore_shutdown();