summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am16
-rw-r--r--src/Makefile_Ecore.am10
-rw-r--r--src/Makefile_Ecore_Audio.am11
-rw-r--r--src/Makefile_Ecore_Con.am10
-rw-r--r--src/Makefile_Ecore_Js.am19
-rw-r--r--src/Makefile_Edje.am12
-rw-r--r--src/Makefile_Efl.am10
-rw-r--r--src/Makefile_Efl_Js.am319
-rw-r--r--src/Makefile_Eina_Cxx.am4
-rw-r--r--src/Makefile_Emotion.am11
-rw-r--r--src/Makefile_Eo.am10
-rw-r--r--src/Makefile_Eolian_Js.am118
-rw-r--r--src/Makefile_Eolian_Js_Helper.am18
-rw-r--r--src/Makefile_Evas.am10
-rwxr-xr-xsrc/bin/efl_js/efljslaunch139
-rw-r--r--src/bin/efl_js/efljslaunch.desktop7
-rw-r--r--src/bin/efl_js/efljslaunch.xml7
-rwxr-xr-xsrc/bin/efl_js/efljspack251
-rw-r--r--src/bin/efl_js/launcher_main.cc156
-rw-r--r--src/bin/eolian_js/.gitignore1
-rw-r--r--src/bin/eolian_js/eolian/class.hh139
-rw-r--r--src/bin/eolian_js/eolian/js/domain.hh8
-rw-r--r--src/bin/eolian_js/eolian/js/format.hh44
-rw-r--r--src/bin/eolian_js/main.cc1076
-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
-rw-r--r--src/bindings/eina_cxx/Eina.hh1
-rw-r--r--src/bindings/eina_cxx/eina_accessor.hh5
-rw-r--r--src/bindings/eina_cxx/eina_array.hh250
-rw-r--r--src/bindings/eina_cxx/eina_clone_allocators.hh3
-rw-r--r--src/bindings/eina_cxx/eina_function.hh26
-rw-r--r--src/bindings/eina_cxx/eina_integer_sequence.hh2
-rw-r--r--src/bindings/eina_cxx/eina_list.hh14
-rw-r--r--src/bindings/eina_cxx/eina_logical.hh34
-rw-r--r--src/bindings/eina_cxx/eina_pp.hh8
-rw-r--r--src/bindings/eina_cxx/eina_ptrarray.hh16
-rw-r--r--src/bindings/eina_cxx/eina_ptrlist.hh79
-rw-r--r--src/bindings/eina_cxx/eina_range_types.hh58
-rw-r--r--src/bindings/eina_cxx/eina_tuple.hh60
-rw-r--r--src/bindings/eina_cxx/eina_tuple_c.hh24
-rw-r--r--src/bindings/eina_cxx/eina_type_traits.hh16
-rw-r--r--src/bindings/eina_js/Eina_Js.hh50
-rw-r--r--src/bindings/eina_js/eina_js_accessor.cc34
-rw-r--r--src/bindings/eina_js/eina_js_accessor.hh87
-rw-r--r--src/bindings/eina_js/eina_js_array.hh119
-rw-r--r--src/bindings/eina_js/eina_js_compatibility.cc12
-rw-r--r--src/bindings/eina_js/eina_js_compatibility.hh918
-rw-r--r--src/bindings/eina_js/eina_js_container.cc495
-rw-r--r--src/bindings/eina_js/eina_js_container.hh351
-rw-r--r--src/bindings/eina_js/eina_js_error.cc24
-rw-r--r--src/bindings/eina_js/eina_js_error.hh25
-rw-r--r--src/bindings/eina_js/eina_js_get_value.hh449
-rw-r--r--src/bindings/eina_js/eina_js_get_value_from_c.hh261
-rw-r--r--src/bindings/eina_js/eina_js_iterator.cc32
-rw-r--r--src/bindings/eina_js/eina_js_iterator.hh81
-rw-r--r--src/bindings/eina_js/eina_js_list.hh132
-rw-r--r--src/bindings/eina_js/eina_js_log.cc742
-rw-r--r--src/bindings/eina_js/eina_js_log.hh133
-rw-r--r--src/bindings/eina_js/eina_js_node.hh14
-rw-r--r--src/bindings/eina_js/eina_js_value.cc132
-rw-r--r--src/bindings/eina_js/eina_js_value.hh142
-rw-r--r--src/bindings/eio_js/Eio_Js.hh44
-rw-r--r--src/bindings/eio_js/eio_js.cc1756
-rw-r--r--src/bindings/eldbus_cxx/eldbus_freedesktop.hh1
-rw-r--r--src/bindings/eldbus_js/Eldbus_Js.hh48
-rw-r--r--src/bindings/eldbus_js/eldbus_js_connection.cc543
-rw-r--r--src/bindings/eldbus_js/eldbus_js_core.cc183
-rw-r--r--src/bindings/eldbus_js/eldbus_js_message.cc103
-rw-r--r--src/bindings/eldbus_js/eldbus_js_object_mapper.cc100
-rw-r--r--src/bindings/eldbus_js/eldbus_js_util.hh836
-rw-r--r--src/bindings/eo_cxx/eo_concrete.hh7
-rw-r--r--src/bindings/eo_js/Eo_Js.hh15
-rw-r--r--src/bindings/eo_js/eo_js_call_function.hh288
-rw-r--r--src/bindings/eo_js/eo_js_construct_from_eo.hh39
-rw-r--r--src/bindings/eo_js/eo_js_constructor.hh136
-rw-r--r--src/bindings/eo_js/eo_js_direction.hh12
-rw-r--r--src/bindings/eo_js/eo_js_event.hh126
-rw-r--r--src/bindings/eo_js/eo_js_namespace.hh24
-rw-r--r--src/bindings/eo_js/eo_js_struct.hh106
-rw-r--r--src/bindings/ethumb_js/Ethumb_Js.hh48
-rw-r--r--src/bindings/ethumb_js/ethumb_js_client.cc571
-rw-r--r--src/lib/ecore/ecore.c1
-rw-r--r--src/lib/ecore/ecore_main.c525
-rw-r--r--src/lib/ecore/ecore_private.h2
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet.h11
-rw-r--r--src/lib/efl/interfaces/efl_model_base.eo2
-rw-r--r--src/lib/efl_js/Efl_Js.hh30
-rw-r--r--src/lib/efl_js/efl_js.cc243
-rw-r--r--src/lib/emotion/Emotion.h39
-rw-r--r--src/lib/emotion/emotion_smart.c1
-rw-r--r--src/lib/eo/Eo.h10
-rw-r--r--src/tests/.gitignore1
-rw-r--r--src/tests/ecore/ecore_test_ecore.c34
-rw-r--r--src/tests/ecore/ecore_test_ecore_x.c6
-rw-r--r--src/tests/efl_js/benchmark_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/benchmark_js_suite.js205
-rw-r--r--src/tests/efl_js/benchmark_object.eo24
-rw-r--r--src/tests/efl_js/benchmark_object_impl.cc110
-rw-r--r--src/tests/efl_js/ecore_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/ecore_js_suite.js438
-rw-r--r--src/tests/efl_js/eina_js_containers_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/eina_js_containers_suite.js552
-rw-r--r--src/tests/efl_js/eina_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/eina_js_suite.js415
-rw-r--r--src/tests/efl_js/eio_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/eio_js_suite.js89
-rw-r--r--src/tests/efl_js/eldbus_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/eldbus_js_suite.js114
-rw-r--r--src/tests/efl_js/ethumb_js_suite.cc7
-rwxr-xr-xsrc/tests/efl_js/ethumb_js_suite.js93
-rw-r--r--src/tests/efl_js/suite_runner.hh147
-rw-r--r--src/tests/efl_js/testproj/hello.project9
-rw-r--r--src/tests/efl_js/testproj/hello.txt1
-rw-r--r--src/tests/efl_js/testproj/main.js5
-rw-r--r--src/tests/efl_js/timer.js33
-rw-r--r--src/tests/eolian_js/constructor_method_class.eo59
-rw-r--r--src/tests/eolian_js/eolian_js_suite.cc61
-rwxr-xr-xsrc/tests/eolian_js/eolian_js_suite.js796
-rw-r--r--src/tests/eolian_js/eolian_js_test_constructor_method_impl.c147
-rw-r--r--src/tests/eolian_js/eolian_js_test_eolian_js_binding.cc44
-rw-r--r--src/tests/eolian_js/eolian_js_test_evas_box.cc151
-rw-r--r--src/tests/eolian_js/eolian_js_test_test_object_impl.c620
-rw-r--r--src/tests/eolian_js/test_object.eo305
133 files changed, 21688 insertions, 135 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ac8dc7..248711b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,7 @@ check_PROGRAMS =
15TESTS = 15TESTS =
16EXTRA_DIST = 16EXTRA_DIST =
17 17
18GENERATED_JS_BINDINGS =
18 19
19EFL_INSTALL_EXEC_HOOK= 20EFL_INSTALL_EXEC_HOOK=
20 21
@@ -76,6 +77,21 @@ include Makefile_Eio_Cxx.am
76include Makefile_Elua.am 77include Makefile_Elua.am
77include Makefile_Elocation.am 78include Makefile_Elocation.am
78 79
80if HAVE_JS
81AM_V_CP = $(am__v_CP_@AM_V@)
82am__v_CP_ = $(am__v_CP_@AM_DEFAULT_V@)
83am__v_CP_0 = @echo " CP " $@;
84CP = cp
85if EFL_ENABLE_TESTS
86if HAVE_NODEJS
87AM_TESTS_ENVIRONMENT = NODE_PATH='$(abs_builddir)/lib/efl_js:$(abs_builddir)/tests/eolian_js:$(abs_builddir)/tests/efl_js'; export NODE_PATH;
88endif
89endif
90endif
91
92include Makefile_Eolian_Js.am
93include Makefile_Efl_Js.am
94
79.PHONY: benchmark examples 95.PHONY: benchmark examples
80 96
81BENCHMARK_SUBDIRS = \ 97BENCHMARK_SUBDIRS = \
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index b7e0b6b..13e5473 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -271,3 +271,13 @@ installed_ecoreluadir = $(datadir)/elua/modules/ecore
271nodist_installed_ecorelua_DATA = $(generated_ecore_lua_all) 271nodist_installed_ecorelua_DATA = $(generated_ecore_lua_all)
272 272
273endif 273endif
274
275if HAVE_JS
276
277generated_ecore_js_bindings = $(ecore_eolian_files:%.eo=%.eo.js.cc)
278
279CLEANFILES += $(generated_ecore_js_bindings)
280
281GENERATED_JS_BINDINGS += $(generated_ecore_js_bindings)
282
283endif
diff --git a/src/Makefile_Ecore_Audio.am b/src/Makefile_Ecore_Audio.am
index ccce8f7..b500118 100644
--- a/src/Makefile_Ecore_Audio.am
+++ b/src/Makefile_Ecore_Audio.am
@@ -104,4 +104,15 @@ nodist_installed_ecoreaudiolua_DATA = $(generated_ecore_audio_lua_all)
104 104
105endif 105endif
106 106
107if HAVE_JS
108
109generated_ecore_audio_js_bindings = $(ecore_audio_eolian_files:%.eo=%.eo.js.cc)
110
111CLEANFILES += $(generated_ecore_audio_js_bindings)
112
113GENERATED_JS_BINDINGS += $(generated_ecore_audio_js_bindings)
114
107endif 115endif
116
117endif
118
diff --git a/src/Makefile_Ecore_Con.am b/src/Makefile_Ecore_Con.am
index 87ad889..544e6d9 100644
--- a/src/Makefile_Ecore_Con.am
+++ b/src/Makefile_Ecore_Con.am
@@ -143,3 +143,13 @@ installed_ecoreconluadir = $(datadir)/elua/modules/ecore_con
143nodist_installed_ecoreconlua_DATA = $(generated_ecore_con_lua_all) 143nodist_installed_ecoreconlua_DATA = $(generated_ecore_con_lua_all)
144 144
145endif 145endif
146
147if HAVE_JS
148
149generated_ecore_con_js_bindings = $(ecore_con_eolian_files:%.eo=%.eo.js.cc)
150
151CLEANFILES += $(generated_ecore_con_js_bindings)
152
153GENERATED_JS_BINDINGS += $(generated_ecore_con_js_bindings)
154
155endif
diff --git a/src/Makefile_Ecore_Js.am b/src/Makefile_Ecore_Js.am
new file mode 100644
index 0000000..3ae483c
--- /dev/null
+++ b/src/Makefile_Ecore_Js.am
@@ -0,0 +1,19 @@
1
2### Library
3
4if HAVE_JS
5installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@
6dist_installed_ecorejsheaders_DATA = \
7bindings/ecore_js/Ecore_Js.hh \
8bindings/ecore_js/ecore_js_init.hh \
9bindings/ecore_js/ecore_js_mainloop.hh \
10bindings/ecore_js/ecore_js_timer.hh \
11bindings/ecore_js/ecore_js_event.hh \
12bindings/ecore_js/ecore_js_job.hh \
13bindings/ecore_js/ecore_js_idle.hh \
14bindings/ecore_js/ecore_js_animator.hh \
15bindings/ecore_js/ecore_js_poller.hh \
16bindings/ecore_js/ecore_js_throttle.hh \
17bindings/ecore_js/ecore_js_file.hh
18endif
19
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index ca0eefc..4fa0ecf 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -130,7 +130,7 @@ if HAVE_WIN32
130USE_EDJE_BIN_LIBS = -L$(top_builddir)/src/lib/evil @USE_EDJE_LIBS@ 130USE_EDJE_BIN_LIBS = -L$(top_builddir)/src/lib/evil @USE_EDJE_LIBS@
131else 131else
132USE_EDJE_BIN_LIBS = @USE_EDJE_LIBS@ 132USE_EDJE_BIN_LIBS = @USE_EDJE_LIBS@
133endif 133endif
134 134
135bin_PROGRAMS += \ 135bin_PROGRAMS += \
136bin/edje/edje_cc \ 136bin/edje/edje_cc \
@@ -334,3 +334,13 @@ installed_edjeluadir = $(datadir)/elua/modules/edje
334nodist_installed_edjelua_DATA = $(generated_edje_lua_all) 334nodist_installed_edjelua_DATA = $(generated_edje_lua_all)
335 335
336endif 336endif
337
338if HAVE_JS
339
340generated_edje_js_bindings = $(edje_eolian_files:%.eo=%.eo.js.cc)
341
342CLEANFILES += $(generated_edje_js_bindings)
343
344GENERATED_JS_BINDINGS += $(generated_edje_js_bindings)
345
346endif
diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am
index f6b1c28..9e59bf2 100644
--- a/src/Makefile_Efl.am
+++ b/src/Makefile_Efl.am
@@ -80,6 +80,16 @@ nodist_installed_efllua_DATA = $(generated_efl_lua_all)
80 80
81endif 81endif
82 82
83if HAVE_JS
84
85generated_efl_js_bindings = $(efl_eolian_files:%.eo=%.eo.js.cc)
86
87CLEANFILES += $(generated_efl_js_bindings)
88
89GENERATED_JS_BINDINGS += $(generated_efl_js_bindings)
90
91endif
92
83### Binary 93### Binary
84 94
85bin_PROGRAMS += \ 95bin_PROGRAMS += \
diff --git a/src/Makefile_Efl_Js.am b/src/Makefile_Efl_Js.am
new file mode 100644
index 0000000..ada25b9
--- /dev/null
+++ b/src/Makefile_Efl_Js.am
@@ -0,0 +1,319 @@
1if HAVE_JS
2
3lib_LTLIBRARIES += lib/efl_js/libefl_js.la
4
5if HAVE_NODEJS
6
7lib_LTLIBRARIES += lib/efl_js/libefl_node_js.la
8
9$(top_builddir)/src/lib/efl_js/efl.node: lib/efl_js/libefl_node_js.la
10 $(AM_V_CP)$(CP) $(top_builddir)/src/lib/efl_js/.libs/libefl_node_js.so $(top_builddir)/src/lib/efl_js/efl.node
11
12eflnodedir = $(libdir)
13eflnode_DATA = $(top_builddir)/src/lib/efl_js/efl.node
14
15CLEANFILES += ${eflnodedir_DATA}
16EXTRA_DIST += ${eflnodedir_DATA}
17
18efljsmimedir = @XDG_DATA_HOME@/mime/packages
19efljsmime_DATA = bin/efl_js/efljslaunch.xml
20
21efljsdesktopdir = @XDG_DATA_HOME@/applications
22efljsdesktop_DATA = bin/efl_js/efljslaunch.desktop
23
24bin_SCRIPTS += \
25 bin/efl_js/efljslaunch \
26 bin/efl_js/efljspack
27
28else
29
30bin_PROGRAMS += bin/efl_js/eflv8js
31
32bin_efl_js_eflv8js_SOURCES = \
33 bin/efl_js/launcher_main.cc
34
35bin_efl_js_eflv8js_CPPFLAGS = \
36 -I$(top_builddir)/src/lib/efl \
37 -I$(top_srcdir)/src/lib/efl_js \
38 @CHECK_CFLAGS@ \
39 @EINA_CXX_CFLAGS@ \
40 @EO_CXX_CFLAGS@ \
41 @EMILE_CFLAGS@ \
42 @ECORE_CFLAGS@ \
43 @EET_CFLAGS@ \
44 @EO_CFLAGS@ \
45 @EFL_JS_CFLAGS@ \
46 @EINA_JS_CFLAGS@ \
47 @EO_JS_CFLAGS@
48
49bin_efl_js_eflv8js_LDFLAGS = \
50 -lv8 \
51 @EFL_JS_INTERNAL_LIBS@
52
53bin_efl_js_eflv8js_LDADD = \
54 lib/efl_js/libefl_js.la
55
56endif
57
58lib/efl_js/eolian_js_bindings.cc: $(GENERATED_JS_BINDINGS)
59 @echo @ECHO_E@ "#ifdef HAVE_CONFIG_H" > $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
60 @echo @ECHO_E@ "#include \"config.h\"" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
61 @echo @ECHO_E@ "#endif\n" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
62 @echo @ECHO_E@ "#include <Efl.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
63 @echo @ECHO_E@ "#include <Efl_Config.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
64 @echo @ECHO_E@ "#include <Ecore.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
65 @echo @ECHO_E@ "#include <Eo.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
66 @echo @ECHO_E@ "#include <Ecore_Con.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
67 @echo @ECHO_E@ "#include <Ecore_Audio.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
68 @echo @ECHO_E@ "#include <Evas.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
69 @echo @ECHO_E@ "#include <Edje.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
70 @echo @ECHO_E@ "#include <Ecore_Con_Eet.h>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
71 @echo @ECHO_E@ "#include <Emotion.h>\n" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc
72 @for i in $(GENERATED_JS_BINDINGS); do echo "#include <$$i>" >> $(top_builddir)/src/lib/efl_js/eolian_js_bindings.cc; done
73
74CLEANFILES += lib/efl_js/eolian_js_bindings.cc
75
76## Install Ecore-JS headers
77installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@
78dist_installed_ecorejsheaders_DATA = \
79bindings/ecore_js/Ecore_Js.hh
80
81## Install Eio-JS headers
82installed_eiojsheadersdir = $(includedir)/eio-js-@VMAJ@
83dist_installed_eiojsheaders_DATA = \
84bindings/eio_js/Eio_Js.hh
85
86## Install Ethumb-JS headers
87installed_ethumbjsheadersdir = $(includedir)/ethumb-js-@VMAJ@
88dist_installed_ethumbjsheaders_DATA = \
89bindings/ethumb_js/Ethumb_Js.hh
90
91## Install Eldbus-JS headers
92installed_eldbusjsheadersdir = $(includedir)/eldbus-js-@VMAJ@
93dist_installed_eldbusjsheaders_DATA = \
94bindings/eldbus_js/Eldbus_Js.hh
95
96## Install Eo-JS headers
97installed_eojsmainheadersdir = $(includedir)/eo-js-@VMAJ@
98dist_installed_eojsmainheaders_DATA = \
99bindings/eo_js/eo_js_call_function.hh \
100bindings/eo_js/eo_js_constructor.hh \
101bindings/eo_js/eo_js_direction.hh \
102bindings/eo_js/eo_js_event.hh \
103bindings/eo_js/eo_js_namespace.hh \
104bindings/eo_js/eo_js_struct.hh \
105bindings/eo_js/eo_js_construct_from_eo.hh \
106bindings/eo_js/Eo_Js.hh
107
108## Install Eina-JS headers
109installed_einajsheadersdir = $(includedir)/eina-js-@VMAJ@
110dist_installed_einajsheaders_DATA = \
111bindings/eina_js/Eina_Js.hh \
112bindings/eina_js/eina_js_accessor.hh \
113bindings/eina_js/eina_js_array.hh \
114bindings/eina_js/eina_js_compatibility.hh \
115bindings/eina_js/eina_js_container.hh \
116bindings/eina_js/eina_js_error.hh \
117bindings/eina_js/eina_js_get_value_from_c.hh \
118bindings/eina_js/eina_js_get_value.hh \
119bindings/eina_js/eina_js_iterator.hh \
120bindings/eina_js/eina_js_list.hh \
121bindings/eina_js/eina_js_log.hh \
122bindings/eina_js/eina_js_node.hh \
123bindings/eina_js/eina_js_value.hh
124
125installed_efljsheadersdir = $(includedir)/efl-js-@VMAJ@
126dist_installed_efljsheaders_DATA = \
127lib/efl_js/Efl_Js.hh
128
129lib_efl_js_libefl_js_la_SOURCES = \
130lib/efl_js/eolian_js_bindings.cc \
131bindings/eina_js/eina_js_container.cc \
132bindings/eina_js/eina_js_value.cc \
133bindings/eina_js/eina_js_error.cc \
134bindings/eina_js/eina_js_accessor.cc \
135bindings/eina_js/eina_js_log.cc \
136bindings/eina_js/eina_js_iterator.cc \
137bindings/eina_js/eina_js_compatibility.cc \
138bindings/ecore_js/ecore_js_init.cc \
139bindings/ecore_js/ecore_js_mainloop.cc \
140bindings/ecore_js/ecore_js_timer.cc \
141bindings/ecore_js/ecore_js_event.cc \
142bindings/ecore_js/ecore_js_job.cc \
143bindings/ecore_js/ecore_js_idle.cc \
144bindings/ecore_js/ecore_js_animator.cc \
145bindings/ecore_js/ecore_js_poller.cc \
146bindings/ecore_js/ecore_js_throttle.cc \
147bindings/ecore_js/ecore_js_file.cc \
148bindings/eldbus_js/eldbus_js_core.cc \
149bindings/eldbus_js/eldbus_js_connection.cc \
150bindings/eldbus_js/eldbus_js_message.cc \
151bindings/eldbus_js/eldbus_js_object_mapper.cc \
152bindings/eio_js/eio_js.cc \
153bindings/ethumb_js/ethumb_js_client.cc
154
155lib/efl_js/efl_js.cc $(lib_efl_js_libefl_js_la_SOURCES): $(generated_ecore_cxx_all) $(generated_eo_cxx_bindings) $(generated_efl_cxx_all)
156
157lib_efl_js_libefl_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
158-I$(top_srcdir)/src/lib/efl \
159-I$(top_builddir)/src/lib/efl/interfaces/ \
160-I$(top_builddir)/src/lib/evas/canvas/ \
161@EFL_JS_CFLAGS@ \
162@EO_JS_CFLAGS@ \
163@ECORE_CXX_CFLAGS@ \
164@EO_CXX_CFLAGS@ \
165@ECORE_JS_CFLAGS@ \
166@EINA_JS_CFLAGS@ \
167@ELDBUS_JS_CFLAGS@ \
168@EIO_JS_CFLAGS@ \
169@ETHUMB_JS_CFLAGS@ \
170@EINA_CXX_CFLAGS@
171lib_efl_js_libefl_js_la_LIBADD = @EFL_JS_LIBS@
172lib_efl_js_libefl_js_la_DEPENDENCIES = @EFL_JS_INTERNAL_LIBS@
173lib_efl_js_libefl_js_la_LIBTOOLFLAGS = --tag=disable-static
174
175if HAVE_NODEJS
176lib_efl_js_libefl_js_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
177
178lib_efl_js_libefl_node_js_la_SOURCES = \
179lib/efl_js/efl_js.cc
180
181lib_efl_js_libefl_node_js_la_CPPFLAGS = $(lib_efl_js_libefl_js_la_CPPFLAGS)
182lib_efl_js_libefl_node_js_la_LIBADD = $(lib_efl_js_libefl_js_la_LIBADD) lib/efl_js/libefl_js.la
183lib_efl_js_libefl_node_js_la_DEPENDENCIES = $(lib_efl_js_libefl_js_la_DEPENDENCIES) lib/efl_js/libefl_js.la
184lib_efl_js_libefl_node_js_la_LIBTOOLFLAGS = $(lib_efl_js_libefl_js_la_LIBTOOLFLAGS)
185else
186lib_efl_js_libefl_js_la_SOURCES += \
187lib/efl_js/efl_js.cc
188endif
189
190if EFL_ENABLE_TESTS
191
192SUITE_RUNNER_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
193-DTESTS_WD=\"`pwd`\" \
194-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/efl_js\" \
195-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/efl_js\" \
196-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/efl_js\" \
197@CHECK_CFLAGS@ \
198@EFL_JS_CFLAGS@ \
199@EINA_CXX_CFLAGS@ \
200@EO_CXX_CFLAGS@ \
201@EO_CFLAGS@ \
202@ECORE_CFLAGS@ \
203@ECORE_CXX_CFLAGS@ \
204@ECORE_JS_CFLAGS@ \
205@EINA_JS_CFLAGS@
206
207if HAVE_NODEJS
208TESTS += tests/efl_js/eina_js_suite.js \
209tests/efl_js/eina_js_containers_suite.js \
210tests/efl_js/ecore_js_suite.js \
211tests/efl_js/eldbus_js_suite.js \
212tests/efl_js/ethumb_js_suite.js \
213tests/efl_js/eio_js_suite.js \
214tests/efl_js/benchmark_js_suite.js
215
216check_LTLIBRARIES += tests/efl_js/libbenchmark_object.la
217
218tests/efl_js/eina_js_suite.js tests/efl_js/eina_js_containers_suite.js tests/efl_js/ecore_js_suite.js tests/efl_js/eldbus_js_suite.js tests/efl_js/eio_js_suite.js tests/efl_js/ethumb_js_suite.js: $(top_builddir)/src/lib/efl_js/efl.node
219
220tests/efl_js/benchmark_object.node: tests/efl_js/libbenchmark_object.la
221 $(AM_V_CP)$(CP) $(top_builddir)/src/tests/efl_js/.libs/libbenchmark_object.so $(top_builddir)/src/tests/efl_js/benchmark_object.node
222tests/efl_js/benchmark_js_suite.js: $(top_builddir)/src/lib/efl_js/efl.node tests/efl_js/benchmark_object.node
223
224tests_efl_js_libbenchmark_object_la_SOURCES = tests/efl_js/benchmark_object_impl.cc
225tests_efl_js_libbenchmark_object_la_CXXFLAGS = \
226-I$(top_builddir)/src/lib/efl \
227-I$(top_srcdir)/src/bindings/efl_js \
228-I$(top_builddir)/src/tests/efl_js \
229-DTESTS_WD=\"`pwd`\" \
230-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/efl_js\" \
231-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/efl_js\" \
232-DPACKAGE_DATA_DIR=\"$(datadir)/efl_js\" \
233-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/efl_js\" \
234@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ \
235@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \
236@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@
237tests_efl_js_libbenchmark_object_la_LIBADD = \
238@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
239tests_efl_js_libbenchmark_object_la_LDFLAGS = -rpath $(abs_top_builddir)/tests/eolian_js
240tests_efl_js_libbenchmark_object_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
241tests_efl_js_libbenchmark_object_la_CFLAGS = $(tests_efl_js_libbenchmark_object_la_CXXFLAGS)
242
243tests/efl_js/tests_efl_js_libbenchmark_object_la-benchmark_object_impl.l$(OBJEXT): tests/efl_js/benchmark_object.eo.js.cc tests/efl_js/benchmark_object.eo.c tests/efl_js/benchmark_object.eo.h
244else
245check_PROGRAMS += \
246tests/efl_js/eina_js_suite \
247tests/efl_js/eina_js_containers_suite \
248tests/efl_js/ecore_js_suite \
249tests/efl_js/eldbus_js_suite \
250tests/efl_js/ethumb_js_suite \
251tests/efl_js/eio_js_suite \
252tests/efl_js/benchmark_js_suite
253TESTS += tests/efl_js/eina_js_suite \
254tests/efl_js/ecore_js_suite \
255tests/efl_js/eldbus_js_suite \
256tests/efl_js/ethumb_js_suite \
257tests/efl_js/eio_js_suite \
258tests/efl_js/benchmark_js_suite
259
260tests_efl_js_eina_js_suite_SOURCES = \
261tests/efl_js/eina_js_suite.cc
262
263tests_efl_js_eina_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
264tests_efl_js_eina_js_suite_LDADD = \
265@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
266tests_efl_js_eina_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
267
268tests_efl_js_eina_js_containers_suite_SOURCES = \
269tests/efl_js/eina_js_containers_suite.cc
270
271tests_efl_js_eina_js_containers_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
272tests_efl_js_eina_js_containers_suite_LDADD = \
273@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
274tests_efl_js_eina_js_containers_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
275
276tests_efl_js_ecore_js_suite_SOURCES = \
277tests/efl_js/ecore_js_suite.cc
278
279tests_efl_js_ecore_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
280tests_efl_js_ecore_js_suite_LDADD = \
281@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
282tests_efl_js_ecore_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
283
284tests_efl_js_eldbus_js_suite_SOURCES = \
285tests/efl_js/eldbus_js_suite.cc
286
287tests_efl_js_eldbus_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
288tests_efl_js_eldbus_js_suite_LDADD = \
289@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
290tests_efl_js_eldbus_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
291
292tests_efl_js_ethumb_js_suite_SOURCES = \
293tests/efl_js/ethumb_js_suite.cc
294
295tests_efl_js_ethumb_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
296tests_efl_js_ethumb_js_suite_LDADD = \
297@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
298tests_efl_js_ethumb_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
299
300tests_efl_js_eio_js_suite_SOURCES = \
301tests/efl_js/eio_js_suite.cc
302
303tests_efl_js_eio_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
304tests_efl_js_eio_js_suite_LDADD = \
305@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
306tests_efl_js_eio_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
307
308tests_efl_js_benchmark_js_suite_SOURCES = \
309tests/efl_js/benchmark_js_suite.cc
310
311tests_efl_js_benchmark_js_suite_CXXFLAGS = $(SUITE_RUNNER_CXXFLAGS)
312tests_efl_js_benchmark_js_suite_LDADD = \
313@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
314tests_efl_js_benchmark_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
315endif
316endif
317
318
319endif
diff --git a/src/Makefile_Eina_Cxx.am b/src/Makefile_Eina_Cxx.am
index 70ef18a..e9f7c13 100644
--- a/src/Makefile_Eina_Cxx.am
+++ b/src/Makefile_Eina_Cxx.am
@@ -14,6 +14,7 @@ bindings/eina_cxx/eina_clone_allocators.hh \
14bindings/eina_cxx/eina_error.hh \ 14bindings/eina_cxx/eina_error.hh \
15bindings/eina_cxx/eina_eo_concrete_fwd.hh \ 15bindings/eina_cxx/eina_eo_concrete_fwd.hh \
16bindings/eina_cxx/eina_fold.hh \ 16bindings/eina_cxx/eina_fold.hh \
17bindings/eina_cxx/eina_function.hh \
17bindings/eina_cxx/eina_inarray.hh \ 18bindings/eina_cxx/eina_inarray.hh \
18bindings/eina_cxx/eina_inlist.hh \ 19bindings/eina_cxx/eina_inlist.hh \
19bindings/eina_cxx/eina_integer_sequence.hh \ 20bindings/eina_cxx/eina_integer_sequence.hh \
@@ -21,7 +22,9 @@ bindings/eina_cxx/eina_iterator.hh \
21bindings/eina_cxx/eina_lists_auxiliary.hh \ 22bindings/eina_cxx/eina_lists_auxiliary.hh \
22bindings/eina_cxx/eina_list.hh \ 23bindings/eina_cxx/eina_list.hh \
23bindings/eina_cxx/eina_log.hh \ 24bindings/eina_cxx/eina_log.hh \
25bindings/eina_cxx/eina_logical.hh \
24bindings/eina_cxx/eina_optional.hh \ 26bindings/eina_cxx/eina_optional.hh \
27bindings/eina_cxx/eina_pp.hh \
25bindings/eina_cxx/eina_ptrarray.hh \ 28bindings/eina_cxx/eina_ptrarray.hh \
26bindings/eina_cxx/eina_ptrlist.hh \ 29bindings/eina_cxx/eina_ptrlist.hh \
27bindings/eina_cxx/eina_range_types.hh \ 30bindings/eina_cxx/eina_range_types.hh \
@@ -31,6 +34,7 @@ bindings/eina_cxx/eina_string_view.hh \
31bindings/eina_cxx/eina_thread.hh \ 34bindings/eina_cxx/eina_thread.hh \
32bindings/eina_cxx/eina_throw.hh \ 35bindings/eina_cxx/eina_throw.hh \
33bindings/eina_cxx/eina_tuple.hh \ 36bindings/eina_cxx/eina_tuple.hh \
37bindings/eina_cxx/eina_tuple_c.hh \
34bindings/eina_cxx/eina_tuple_unwrap.hh \ 38bindings/eina_cxx/eina_tuple_unwrap.hh \
35bindings/eina_cxx/eina_type_traits.hh \ 39bindings/eina_cxx/eina_type_traits.hh \
36bindings/eina_cxx/eina_value.hh 40bindings/eina_cxx/eina_value.hh
diff --git a/src/Makefile_Emotion.am b/src/Makefile_Emotion.am
index f16a4a4..4da5224 100644
--- a/src/Makefile_Emotion.am
+++ b/src/Makefile_Emotion.am
@@ -347,3 +347,14 @@ installed_emotionluadir = $(datadir)/elua/modules/emotion
347nodist_installed_emotionlua_DATA = $(generated_emotion_lua_all) 347nodist_installed_emotionlua_DATA = $(generated_emotion_lua_all)
348 348
349endif 349endif
350
351# TODO: gives undefined reference to emotion_object_class_get()
352if HAVE_JS
353
354generated_emotion_js_bindings = $(emotion_eolian_files:%.eo=%.eo.js.cc)
355
356CLEANFILES += $(generated_emotion_js_bindings)
357
358GENERATED_JS_BINDINGS += $(generated_emotion_js_bindings)
359
360endif
diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index 57b096e..51924fe 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -197,3 +197,13 @@ endif
197 197
198 198
199EXTRA_DIST += tests/eo/eunit_tests.h lib/eo/eo_ptr_indirection.x 199EXTRA_DIST += tests/eo/eunit_tests.h lib/eo/eo_ptr_indirection.x
200
201if HAVE_JS
202
203generated_eo_js_bindings = $(eo_eolian_files:%.eo=%.eo.js.cc)
204
205CLEANFILES += $(generated_eo_js_bindings)
206
207GENERATED_JS_BINDINGS += $(generated_eo_js_bindings)
208
209endif
diff --git a/src/Makefile_Eolian_Js.am b/src/Makefile_Eolian_Js.am
new file mode 100644
index 0000000..091e4ef
--- /dev/null
+++ b/src/Makefile_Eolian_Js.am
@@ -0,0 +1,118 @@
1
2if HAVE_JS
3
4### Binary
5bin_PROGRAMS += bin/eolian_js/eolian_js
6
7bin_eolian_js_eolian_js_SOURCES = \
8 bin/eolian_js/main.cc
9
10bin_eolian_js_eolian_js_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
11-I$(top_srcdir)/src/bin/eolian_js \
12@EOLIAN_JS_CFLAGS@ \
13@EINA_CXX_CFLAGS@ \
14@EOLIAN_CXX_CFLAGS@
15
16bin_eolian_js_eolian_js_LDADD = @USE_EO_LIBS@ @USE_EOLIAN_LIBS@
17bin_eolian_js_eolian_js_DEPENDENCIES = @USE_EO_INTERNAL_LIBS@ @USE_EOLIAN_INTERNAL_LIBS@
18
19include Makefile_Eolian_Js_Helper.am
20
21### Unit tests
22
23if EFL_ENABLE_TESTS
24if HAVE_NODEJS
25
26TESTS += tests/eolian_js/eolian_js_suite.js
27
28check_LTLIBRARIES += tests/eolian_js/libeolian_js_suite.la
29
30tests/eolian_js/eolian_js_suite.js: tests/eolian_js/eolian_js_suite_mod.node
31tests/eolian_js/eolian_js_suite_mod.node: tests/eolian_js/libeolian_js_suite.la
32 $(AM_V_CP)$(CP) $(top_builddir)/src/tests/eolian_js/.libs/libeolian_js_suite.so $(top_builddir)/src/tests/eolian_js/eolian_js_suite_mod.node
33
34tests_eolian_js_libeolian_js_suite_la_SOURCES = \
35tests/eolian_js/eolian_js_suite.cc \
36tests/eolian_js/eolian_js_test_eolian_js_binding.cc \
37tests/eolian_js/eolian_js_test_constructor_method_impl.c \
38tests/eolian_js/eolian_js_test_test_object_impl.c
39
40tests_eolian_js_libeolian_js_suite_la_CXXFLAGS = \
41-I$(top_builddir)/src/lib/efl \
42-I$(top_srcdir)/src/bin/eolian_js \
43-I$(top_builddir)/src/tests/eolian_js \
44-DTESTS_WD=\"`pwd`\" \
45-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_js\" \
46-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_js\" \
47-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \
48-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_js\" \
49@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ \
50@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \
51@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@
52tests_eolian_js_libeolian_js_suite_la_LIBADD = \
53@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@
54tests_eolian_js_libeolian_js_suite_la_LDFLAGS = -rpath $(abs_top_builddir)/tests/eolian_js
55tests_eolian_js_libeolian_js_suite_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ #@USE_EFL_JS_INTERNAL_LIBS@
56tests_eolian_js_libeolian_js_suite_la_CFLAGS = $(tests_eolian_js_libeolian_js_suite_la_CXXFLAGS)
57
58# if compiler_o_lo == yes, lo, otherwise $(OBJEXT)
59
60tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_eolian_js_binding.l$(OBJEXT): tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.h tests/eolian_js/test_object.eo.js.cc tests/eolian_js/test_object.eo.h
61tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_constructor_method_impl.l$(OBJEXT): tests/eolian_js/constructor_method_class.eo.c
62tests/eolian_js/tests_eolian_js_libeolian_js_suite_la-eolian_js_test_test_object_impl.l$(OBJEXT): tests/eolian_js/test_object.eo.c
63
64CLEANFILES += \
65tests/eolian_js/constructor_method_class.eo.js.cc \
66tests/eolian_js/constructor_method_class.eo.c \
67tests/eolian_js/constructor_method_class.eo.h \
68tests/eolian_js/test_object.eo.js.cc \
69tests/eolian_js/test_object.eo.c \
70tests/eolian_js/test_object.eo.h
71else
72check_PROGRAMS += tests/eolian_js/eolian_js_suite
73TESTS += tests/eolian_js/eolian_js_suite
74
75tests_eolian_js_eolian_js_suite_SOURCES = \
76tests/eolian_js/eolian_js_suite.cc \
77tests/eolian_js/eolian_js_test_eolian_js_binding.cc \
78tests/eolian_js/eolian_js_test_constructor_method_impl.c \
79tests/eolian_js/eolian_js_test_test_object_impl.c
80
81tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_eolian_js_binding.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.h tests/eolian_js/test_object.eo.js.cc tests/eolian_js/test_object.eo.h
82tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_constructor_method_impl.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.c
83tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_test_object_impl.$(OBJEXT): tests/eolian_js/test_object.eo.c
84
85CLEANFILES += \
86tests/eolian_js/constructor_method_class.eo.js.cc \
87tests/eolian_js/constructor_method_class.eo.c \
88tests/eolian_js/constructor_method_class.eo.h \
89tests/eolian_js/test_object.eo.js.cc \
90tests/eolian_js/test_object.eo.c \
91tests/eolian_js/test_object.eo.h
92
93tests_eolian_js_eolian_js_suite_CXXFLAGS = \
94-I$(top_builddir)/src/lib/efl \
95-I$(top_srcdir)/src/bin/eolian_js \
96-I$(top_builddir)/src/tests/eolian_js \
97-I$(top_srcdir)/src/tests/efl_js \
98-DTESTS_WD=\"`pwd`\" \
99-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_js\" \
100-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_js\" \
101-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \
102-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_js\" \
103@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ @EFL_JS_CFLAGS@ \
104@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \
105@EO_JS_CFLAGS@ @EO_CXX_CFLAGS@ @EFL_JS_CFLAGS@
106
107tests_eolian_js_eolian_js_suite_CFLAGS = ${tests_eolian_js_eolian_js_suite_CXXFLAGS}
108tests_eolian_js_eolian_js_suite_CPPFLAGS = ${tests_eolian_js_eolian_js_suite_CXXFLAGS}
109tests_eolian_js_eolian_js_suite_LDADD = \
110@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EFL_JS_LIBS@ @USE_EVAS_LIBS@ @USE_EFL_JS_LIBS@
111tests_eolian_js_eolian_js_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@ @USE_EVAS_INTERNAL_LIBS@ @USE_EFL_JS_INTERNAL_LIBS@
112endif
113endif
114
115endif
116
117
118
diff --git a/src/Makefile_Eolian_Js_Helper.am b/src/Makefile_Eolian_Js_Helper.am
new file mode 100644
index 0000000..fcc5231
--- /dev/null
+++ b/src/Makefile_Eolian_Js_Helper.am
@@ -0,0 +1,18 @@
1#if HAVE_EOLIAN_JS
2#EOLIAN_JS = @eolian_js@
3#_EOLIAN_JS_DEP = @eolian_js@
4#else
5EOLIAN_JS = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_js/eolian_js${EXEEXT}
6_EOLIAN_JS_DEP = bin/eolian_js/eolian_js${EXEEXT}
7#endif
8
9AM_V_EOLJS = $(am__v_EOLJS_@AM_V@)
10am__v_EOLJS_ = $(am__v_EOLJS_@AM_DEFAULT_V@)
11am__v_EOLJS_0 = @echo " EOLJS " $@;
12
13SUFFIXES += .eo.js.cc
14
15%.eo.js.cc: %.eo $(_EOLIAN_JS_DEP)
16 $(AM_V_EOLJS)$(EOLIAN_JS) $(EOLIAN_FLAGS) -o $@ $<
17
18CLEANFILES += $(BUILT_SOURCES)
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 3f7dd39..ebc5480 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -2221,3 +2221,13 @@ $(NULL)
2221 2221
2222installed_evasfiltersdir = $(datadir)/evas/filters/lua 2222installed_evasfiltersdir = $(datadir)/evas/filters/lua
2223dist_installed_evasfilters_DATA = $(evas_filters_lua) 2223dist_installed_evasfilters_DATA = $(evas_filters_lua)
2224
2225if HAVE_JS
2226
2227generated_evas_js_bindings = $(evas_eolian_files:%.eo=%.eo.js.cc)
2228
2229CLEANFILES += $(generated_evas_js_bindings)
2230
2231GENERATED_JS_BINDINGS += $(generated_evas_js_bindings)
2232
2233endif
diff --git a/src/bin/efl_js/efljslaunch b/src/bin/efl_js/efljslaunch
new file mode 100755
index 0000000..785c30e
--- /dev/null
+++ b/src/bin/efl_js/efljslaunch
@@ -0,0 +1,139 @@
1#!/bin/sh
2':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
3
4// Core node modules
5var path = require('path');
6var os = require('os');
7var zlib = require('zlib');
8var child_process = require('child_process');
9
10// 3rd party modules
11var fs = require('fs-extra');
12var getopt = require('node-getopt');
13var tar = require('tar');
14
15function make_error_cb(message)
16{
17 return function(e) {
18 console.error("Error %s: %s", message, e);
19 process.exit(1);
20 };
21}
22
23function remove_files(options)
24{
25 if (options.verbose)
26 console.log("Removing temporary files");
27
28 fs.remove(options.project_folder);
29}
30
31function run_project(options)
32{
33 if (options.verbose)
34 console.log("Running the project");
35
36 var current_dir = process.cwd();
37 process.chdir(options.project_root);
38
39 var proc = child_process.fork(options.metadata.Entry);
40 proc.on('exit', function(code){
41 if (options.verbose)
42 console.log('Child exited with code %s', code);
43 process.chdir(current_dir);
44 if (!options.keep)
45 remove_files(options);
46 });
47
48}
49
50function unpack_project_data(options)
51{
52 if (options.verbose)
53 console.log("Unpacking project sources and assets");
54
55 var datafile = path.join(options.project_folder, "data.tar.gz");
56 var project_root = path.join(options.project_folder, "root");
57
58 options.project_root = project_root;
59
60 var input = fs.createReadStream(datafile);
61 var unzipper = zlib.createGunzip();
62 var extractor = tar.Extract({path: project_root, strip: 0});
63
64 input.on('error', make_error_cb("reading package data file."));
65 extractor.on('error', make_error_cb("unpacking package data file."));
66 if (!("only-extract" in options))
67 extractor.on('end', function(){ run_project(options); });
68
69 input.pipe(unzipper)
70 unzipper.pipe(extractor);
71}
72
73function read_metadata(options)
74{
75 if (options.verbose)
76 console.log("Reading project metadata");
77
78 var project_folder = options.project_folder;
79 var metadata = JSON.parse(fs.readFileSync(path.join(project_folder, "meta.json")));
80
81 if (options.verbose)
82 console.log("Project: %s\nVersion: %s\nEntry point: %s", metadata.Name, metadata.Version, metadata.Entry);
83 if ("only-dump" in options)
84 process.exit(0);
85
86 options.metadata = metadata;
87
88 unpack_project_data(options);
89}
90
91function extract(filename, options)
92{
93 if (options.verbose)
94 console.log("Extracting ", filename, "with options ", options);
95
96 var project_id = path.basename(filename, ".epk");
97 var project_folder = path.join(options['temp-dir'], project_id);
98
99 options.project_folder = project_folder;
100 options.project_id = project_id;
101
102 var input = fs.createReadStream(filename);
103 var extractor = tar.Extract({path: options['temp-dir'], strip: 0});
104
105 input.on('error', make_error_cb("reading package file."));
106 extractor.on('error', make_error_cb("unpacking package file."));
107 extractor.on('end', function(){ read_metadata(options); });
108
109 input.pipe(extractor);
110}
111
112function main() {
113 var options = getopt.create([
114 ['d', 'only-dump', 'Only dump information about the package'],
115 ['e', 'only-extract', 'Only extract the package, do not run'],
116 ['h', 'help', 'Display this help'],
117 ['k', 'keep', 'Do not remove the files after exiting'],
118 ['t', 'temp-dir=ARG', 'Temporary dir to extract files'],
119 ['v', 'verbose', 'Print information messages'],
120 ]).bindHelp().parseSystem();
121
122 var filename = options.argv[0];
123 if (filename === undefined)
124 {
125 console.error("Must provide a package file.");
126 process.exit(1);
127 }
128
129 if (!('temp-dir' in options.options))
130 {
131 options.options["temp-dir"] = path.join(os.tmpdir(), "efljs_apps");
132 if (options.verbose)
133 console.log("Defaulting temp dir to ", options.options["temp-dir"]);
134 }
135
136 extract(filename, options.options);
137}
138
139main();
diff --git a/src/bin/efl_js/efljslaunch.desktop b/src/bin/efl_js/efljslaunch.desktop
new file mode 100644
index 0000000..53371cb
--- /dev/null
+++ b/src/bin/efl_js/efljslaunch.desktop
@@ -0,0 +1,7 @@
1[Desktop Entry]
2Name=EFL JS package launcher
3Exec=efljslaunch %f
4Type=Application
5Categories=EFL
6Terminal=true
7MimeType=application/x-efljspackage;
diff --git a/src/bin/efl_js/efljslaunch.xml b/src/bin/efl_js/efljslaunch.xml
new file mode 100644
index 0000000..b1db684
--- /dev/null
+++ b/src/bin/efl_js/efljslaunch.xml
@@ -0,0 +1,7 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
3 <mime-type type="application/x-efljspackage">
4 <comment xml:lang="en">EFL JS package</comment>
5 <glob pattern="*.epk"/>
6 </mime-type>
7</mime-info> \ No newline at end of file
diff --git a/src/bin/efl_js/efljspack b/src/bin/efl_js/efljspack
new file mode 100755
index 0000000..50e27b6
--- /dev/null
+++ b/src/bin/efl_js/efljspack
@@ -0,0 +1,251 @@
1#!/bin/sh
2':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
3
4var zlib = require('zlib');
5var path = require('path');
6
7// external dependencies
8var fs = require('fs-extra');
9var tar = require('tar');
10var fstream = require('fstream');
11var getopt = require('node-getopt');
12
13/*
14 * Packing a project.
15 * The efljs package has a similar format to debian packages. It is a
16 * tar package containing two files:
17 *
18 * meta.txt: Metadata information about this package.
19 * data.tar.gz: Gzipped data, with the project tree ready to be decompressed
20 * and run by the package launcher.
21 *
22 * During the build, a out/ directory is created in the project root to
23 * store the package and temporary files.
24 */
25
26// Creates a stub .project file and packs it.
27function pack_single(sourcepath, options)
28{
29 if (options.verbose)
30 console.log("Creating project file for single file app", sourcepath);
31
32 var dir_name = path.dirname(fs.realpathSync(sourcepath));
33 var filename = path.basename(sourcepath);
34 var projectRegex = /^(.*).js$/g;
35 var project_name = projectRegex.exec(filename)[1];
36
37 if (!validade_project_name(project_name))
38 {
39 console.error("Invalid project name. Must start with a letter.");
40 process.exit(0);
41 }
42
43 var project_filename = path.join(dir_name, project_name + ".project");
44
45 var fd = fs.openSync(project_filename, 'w');
46
47 var jsonData = {};
48
49 jsonData["Name"] = project_name;
50 jsonData["Entry"] = filename;
51 jsonData["Sources"] = [[filename, '.']];
52 jsonData["Version"] = "0.1";
53
54 fs.writeSync(fd, JSON.stringify(jsonData, null, 2));
55
56 fs.closeSync(fd);
57
58 pack_project(project_filename, options);
59
60}
61
62function generate_build_info(configuration, project_file, options)
63{
64 build_info = {};
65
66 // project == project_dir
67 // /out == build_dir
68 // /data == data_dir
69 // /name-version == package_dir
70
71 build_info.package_id = configuration.Name + "-" + configuration.Version;
72 build_info.project_dir = path.dirname(project_file);
73 build_info.build_dir = path.join(build_info.project_dir, "out");
74 build_info.data_dir = path.join(build_info.build_dir, "data");
75 build_info.package_dir = path.join(build_info.build_dir, build_info.package_id);
76 build_info.data_file = path.join(build_info.package_dir, "data.tar.gz");
77 build_info.package_file = path.join(build_info.build_dir, build_info.package_id + ".epk")
78 build_info.metadata_file = path.join(build_info.package_dir, "meta.json");
79
80 if (options.verbose)
81 {
82 console.log("Project id: ", build_info.package_id);
83 console.log("Project source dir: ", build_info.project_dir);
84 console.log("Project build dir: ", build_info.build_dir);
85 console.log("Project data dir:", build_info.data_dir);
86 console.log("Project package dir:", build_info.package_dir);
87 }
88
89 return build_info;
90
91}
92
93// Project names must start with a letter and contain only
94// letters, digits and underscores.
95function validade_project_name(name)
96{
97 return (/^[a-zA-Z][\w-]*$/).test(name)
98}
99
100function pack_project(project_file, options)
101{
102 if (options.verbose)
103 console.log("Packing project from project file ", project_file);
104
105 var configuration = JSON.parse(fs.readFileSync(project_file));
106
107 if (!validade_project_name(configuration.Name))
108 {
109 console.error("Invalid project name. Must start with a letter.");
110 process.exit(0);
111 }
112
113 var build_info = generate_build_info(configuration, project_file, options);
114
115 try
116 {
117 fs.mkdirSync(build_info.build_dir);
118 fs.mkdirSync(build_info.data_dir);
119 fs.mkdirSync(build_info.package_dir);
120 }
121 catch (e)
122 {
123 console.warn("Warning: Project output directories not empty.");
124 }
125
126 create_metadata_file(configuration, build_info, options);
127
128 // If not explicitly named on configuration, add the entire directory
129 if (!('Sources' in configuration))
130 {
131 generate_source_list(configuration, build_info.project_dir, options);
132 }
133
134 create_project_tree(configuration.Sources, build_info, options);
135
136 pack_data_dir(build_info, options);
137}
138
139function create_project_tree(sources, build_info, options)
140{
141 for (var i = sources.length - 1; i >= 0; i--) {
142 if (options.verbose)
143 console.log("Adding file ", sources[i], "to package.");
144 var source_file = path.join(build_info.project_dir, sources[i][0]);
145 var destination_dir = path.join(build_info.data_dir, sources[i][1]);
146 var destination_filename = path.basename(source_file);
147 var destination_file = path.join(destination_dir, destination_filename);
148
149 fs.copySync(source_file, destination_file);
150 };
151}
152
153function generate_source_list(configuration, project_dir, options)
154{
155 console.log("Generating source list for project dir", build_info.project_dir);
156 var dir_entries = fs.readdirSync(project_dir);
157 var sources = [];
158
159 dir_entries.forEach(function(entry){
160 if (entry == "out")
161 return;
162 sources.push([entry, "."]);
163 });
164 configuration.Sources = sources;
165}
166
167function create_metadata_file(configuration, build_info, options)
168{
169 if (options.verbose)
170 console.log("Creating metadata file", build_info.metadata_file);
171
172 var metadata = {};
173
174 metadata.Name = configuration.Name;
175 metadata.Entry = configuration.Entry;
176 metadata.Version = configuration.Version;
177
178 var output = fs.createWriteStream(build_info.metadata_file);
179 output.write(JSON.stringify(metadata, null, 2));
180 output.close();
181}
182
183function pack_data_dir(build_info, options)
184{
185 if (options.verbose)
186 console.log("Packing data...");
187
188 pack_directory(build_info.data_dir, build_info.data_file, true, true, function(){
189 if (options.verbose)
190 console.log("Packed data");
191 pack_final_package(build_info, options);
192 });
193}
194
195function pack_final_package(build_info, options)
196{
197 if (options.verbose)
198 console.log("Creating package ", build_info.package_file);
199 pack_directory(build_info.package_dir, build_info.package_file, false, false, function(){
200 if (options.verbose)
201 console.log("Created project package.");
202 });
203}
204
205function pack_directory(source_dir, target_file, strip_base_dir, should_gzip, callback)
206{
207 var output = fs.createWriteStream(target_file);
208 var packer = tar.Pack({fromBase: strip_base_dir == true});
209 if (callback != undefined)
210 output.on('close', callback);
211
212 var reader = fstream.Reader({path: source_dir, type: "Directory"});
213 var destStr = reader.pipe(packer);
214 if(should_gzip)
215 destStr = destStr.pipe(zlib.createGzip());
216 destStr.pipe(output);
217}
218
219function main()
220{
221
222 var options = getopt.create([
223 ['v', 'verbose', 'Explain what is being done'],
224 ['h', 'help', 'Display this help']
225 ]).bindHelp().parseSystem();
226
227 filename = options.argv[0];
228
229 if (typeof filename === 'undefined')
230 {
231 console.error('Must provide a valid js or project file.');
232 process.exit(1);
233 }
234
235 if (endsWith(filename, ".js"))
236 {
237 pack_single(filename, options.options);
238 }
239 else if (endsWith(filename, ".project"))
240 {
241 pack_project(filename, options.options);
242 }
243}
244
245main();
246
247//// Helper functions
248function endsWith(str, suffix)
249{
250 return str.indexOf(suffix, str.length - suffix.length) !== -1;
251}
diff --git a/src/bin/efl_js/launcher_main.cc b/src/bin/efl_js/launcher_main.cc
new file mode 100644
index 0000000..680f16c
--- /dev/null
+++ b/src/bin/efl_js/launcher_main.cc
@@ -0,0 +1,156 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <iostream>
6#include <fstream>
7#include <sstream>
8#include <string>
9#include <cerrno>
10
11#include <Eo_Js.hh>
12#include <Eina.hh>
13#include <Eo.hh>
14// #include <efl_js.hh>
15
16using namespace std;
17using namespace v8;
18
19const char PATH_SEPARATOR =
20#ifdef _WIN32
21 '\\';
22#else
23 '/';
24#endif
25
26static std::string get_file_contents(const char *filename) {
27 std::ifstream in(filename, std::ios::in);
28 if (in) {
29 std::ostringstream contents;
30 contents << in.rdbuf();
31 in.close();
32 return contents.str();
33 } else {
34 throw(errno);
35 }
36}
37
38static std::string get_filename(std::string path)
39{
40 int beginIdx = path.rfind(PATH_SEPARATOR);
41 return path.substr(beginIdx + 1);
42}
43
44static void show_usage(std::string name)
45{
46 std::cerr << "Usage: " << get_filename(name) << " <option(s)> [SOURCE]\n" << std::endl
47 << "Options:" << std::endl
48 << "\t-h, --help\t\t Show this help message" << std::endl;
49}
50
51/*
52 * Basic console.log implementation with space-separated values,
53 * no substitution
54 */
55void Log(const FunctionCallbackInfo<Value>& args)
56{
57 Isolate* isolate = Isolate::GetCurrent();
58 HandleScope scope(isolate);
59
60 for (int i=0; i < args.Length(); i++)
61 {
62 if (i != 0)
63 std::cout << " ";
64 String::Utf8Value string(args[i]);
65 std::cout << *string;
66 }
67
68 std::cout << std::endl;
69
70 args.GetReturnValue().Set(v8::Null(isolate));
71}
72
73
74int main(int argc, char* argv[])
75{
76
77 std::string script_source;
78 char *filename = 0;
79
80 for (int i=1; i < argc; i++)
81 {
82 if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0))
83 {
84 show_usage(argv[0]);
85 return 0;
86 }
87 else
88 {
89 filename = argv[i];
90 }
91 }
92
93 if (!filename)
94 {
95 std::cerr << "Error: No source provided." << std::endl;
96 show_usage(argv[0]);
97 return 1;
98 }
99
100 try
101 {
102 script_source = get_file_contents(filename);
103 } catch (int errno)
104 {
105 perror("Error: ");
106 return 1;
107 }
108
109
110 efl::eina::js::compatibility_initialize();
111 v8::V8::SetFlagsFromCommandLine(&argc, const_cast<char**>(argv), true);
112
113 v8::Isolate* isolate = efl::eina::js::compatibility_isolate_new();
114 {
115 Isolate::Scope isolate_scope(isolate);
116 HandleScope handleScope(isolate);
117
118 Local<Context> context = Context::New(isolate, NULL);
119 Context::Scope context_scope(context);
120 context->Enter();
121
122 // Setup the console and log
123 Local<Object> console = Object::New(isolate);
124 Local<FunctionTemplate> log = FunctionTemplate::New(isolate, Log);
125 console->Set(String::NewFromUtf8(isolate, "log"), log->GetFunction());
126
127 Local<Object> global = context->Global();
128 global->Set(String::NewFromUtf8(isolate, "console"), console);
129
130 // Set up the efl exports; Needed to enter the context before this
131 // due to creating Objects instead of Objects Templates
132 // WIP: Commented out due to potential missing v8 platform implementation issues
133 // Local<Object> efl_exports = Object::New(isolate);
134 // global->Set(String::NewFromUtf8(isolate, "efl"), efl_exports);
135 // efl_js::init(efl_exports);
136
137 // And now the user's script
138 Local<String> source = String::NewFromUtf8(isolate, script_source.c_str());
139
140 Local<Script> script = Script::Compile(source);
141
142 TryCatch tryCatch(isolate);
143 Local<Value> result = script->Run();
144
145 if (result.IsEmpty())
146 {
147 Local<Value> exception = tryCatch.Exception();
148 String::Utf8Value exception_str(exception);
149 printf("Exception: %s\n", *exception_str);
150 }
151
152 }
153
154 V8::Dispose();
155 return 0;
156}
diff --git a/src/bin/eolian_js/.gitignore b/src/bin/eolian_js/.gitignore
new file mode 100644
index 0000000..631f68a
--- /dev/null
+++ b/src/bin/eolian_js/.gitignore
@@ -0,0 +1 @@
/eolian_js
diff --git a/src/bin/eolian_js/eolian/class.hh b/src/bin/eolian_js/eolian/class.hh
new file mode 100644
index 0000000..bd04d5f
--- /dev/null
+++ b/src/bin/eolian_js/eolian/class.hh
@@ -0,0 +1,139 @@
1#ifndef EOLIAN_KLASS_HH
2#define EOLIAN_KLASS_HH
3
4#include <Eina.hh>
5
6#include <eolian/js/domain.hh>
7
8#include <ostream>
9
10inline std::string name(Eolian_Class const* klass)
11{
12 return ::eolian_class_name_get(klass);
13}
14
15inline std::string full_name(Eolian_Class const* klass)
16{
17 return ::eolian_class_full_name_get(klass);
18}
19
20inline std::string full_name_transformed(Eolian_Class const* klass)
21{
22 auto r = full_name(klass);
23 std::replace(r.begin(), r.end(), '.', '_');
24 return r;
25}
26
27inline std::size_t namespace_size(Eolian_Class const* klass)
28{
29 std::size_t size = 0;
30 for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
31 , last; first != last; ++first)
32 ++size;
33 return size;
34}
35
36inline std::string type_class_name(Eolian_Type const* tp)
37{
38 if (tp)
39 {
40 Eolian_Type_Type tpt = ::eolian_type_type_get(tp);
41 if (tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_ALIAS || tpt == EOLIAN_TYPE_REGULAR)
42 {
43 return type_class_name(::eolian_type_base_type_get(tp));
44 }
45 else if(tpt == EOLIAN_TYPE_CLASS)
46 {
47 Eolian_Class const* klass = ::eolian_type_class_get(tp);
48 if (klass)
49 {
50 Eina_Stringshare* klass_name = ::eolian_class_full_name_get(klass);
51 if (!klass_name)
52 throw std::runtime_error("Could not get Eo class name");
53
54 return klass_name;
55 } // TODO: else should throw std::runtime_error("Could not get Eo class");
56 }
57 else if(tpt == EOLIAN_TYPE_STRUCT)
58 {
59 auto struct_type_full_name = ::eolian_type_full_name_get(tp);
60 if (!struct_type_full_name)
61 throw std::runtime_error("Could not get struct name");
62 return struct_type_full_name;
63 }
64 }
65 return "";
66}
67
68inline void print_lower_case_namespace(Eolian_Class const* klass, std::ostream& os)
69{
70 std::vector<std::string> namespace_;
71 for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
72 , last; first != last; ++first)
73 namespace_.push_back(&*first);
74 for(auto first = namespace_.begin(), last = namespace_.end()
75 ; first != last; ++first)
76 {
77 std::string lower(*first);
78 std::transform(lower.begin(), lower.end(), lower.begin(), tolower);
79 os << lower;
80 if(std::next(first) != last) os << "::";
81 }
82}
83
84inline void print_eo_class(Eolian_Class const* klass, std::ostream& os)
85{
86 assert(klass != 0);
87 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print_eo_class";
88
89 auto toupper = [] (unsigned char c) { return std::toupper(c); };
90
91 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print_eo_class";
92 std::vector<std::string> namespace_;
93 for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
94 , last; first != last; ++first)
95 namespace_.push_back(&*first);
96 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "namespace";
97 namespace_.push_back(name(klass));
98 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "class";
99 switch(eolian_class_type_get(klass))
100 {
101 case EOLIAN_CLASS_REGULAR:
102 case EOLIAN_CLASS_ABSTRACT:
103 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
104 namespace_.push_back("CLASS");
105 break;
106 case EOLIAN_CLASS_INTERFACE:
107 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
108 namespace_.push_back("INTERFACE");
109 break;
110 case EOLIAN_CLASS_MIXIN:
111 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
112 namespace_.push_back("MIXIN");
113 break;
114 default:
115 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "default ?";
116 std::abort();
117 }
118 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
119 for(auto first = namespace_.begin(), last = namespace_.end()
120 ; first != last; ++first)
121 {
122 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
123 std::string upper(*first);
124 std::transform(upper.begin(), upper.end(), upper.begin(), toupper);
125 os << upper;
126 if(std::next(first) != last) os << "_";
127 }
128 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
129}
130
131inline bool is_evas(Eolian_Class const* klass)
132{
133 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is_evas";
134 efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass));
135 return first != efl::eina::iterator<const char>()
136 && std::strcmp(&*first, "Evas") == 0;
137}
138
139#endif
diff --git a/src/bin/eolian_js/eolian/js/domain.hh b/src/bin/eolian_js/eolian/js/domain.hh
new file mode 100644
index 0000000..38cf542
--- /dev/null
+++ b/src/bin/eolian_js/eolian/js/domain.hh
@@ -0,0 +1,8 @@
1
2#include <Eina.hh>
3
4namespace eolian { namespace js {
5
6extern efl::eina::log_domain domain;
7
8} }
diff --git a/src/bin/eolian_js/eolian/js/format.hh b/src/bin/eolian_js/eolian/js/format.hh
new file mode 100644
index 0000000..a07d541
--- /dev/null
+++ b/src/bin/eolian_js/eolian/js/format.hh
@@ -0,0 +1,44 @@
1#ifndef EOLIAN_JS_FORMAT_HH
2#define EOLIAN_JS_FORMAT_HH
3
4#include <eolian/js/domain.hh>
5
6#include <algorithm>
7#include <string>
8#include <cctype>
9
10namespace eolian { namespace js {
11
12namespace format {
13
14std::string generic(std::string const& in)
15{
16 std::string s = in;
17 auto i = s.find('_');
18 while (i != std::string::npos)
19 {
20 if (i <= 0 || i+1 >= s.size() ||
21 !::isalnum(s[i-1]) || !::isalnum(s[i+1]))
22 {
23 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "Entity '" << in
24 << "' can't be conveniently converted to a JavaScript name.";
25 return in;
26 }
27 s[i+1] = static_cast<char>(::toupper(s[i+1]));
28 s.erase(i, 1);
29 i = s.find('_', i);
30 }
31 return s;
32}
33
34std::string constant(std::string in)
35{
36 std::transform(in.begin(), in.end(), in.begin(), ::toupper);
37 return in;
38}
39
40}
41
42} }
43
44#endif
diff --git a/src/bin/eolian_js/main.cc b/src/bin/eolian_js/main.cc
new file mode 100644
index 0000000..7f3cfd2
--- /dev/null
+++ b/src/bin/eolian_js/main.cc
@@ -0,0 +1,1076 @@
1
2#ifdef HAVE_CONFIG_H
3# include <config.h>
4#endif
5
6#include <Eolian.h>
7#include <Eina.hh>
8
9#include <eolian/js/domain.hh>
10#include <eolian/js/format.hh>
11#include <eolian/class.hh>
12
13#include <iostream>
14#include <fstream>
15#include <unordered_map>
16#include <sstream>
17#include <stdexcept>
18
19#include <libgen.h>
20#include <getopt.h>
21#include <cstdlib>
22#include <vector>
23#include <set>
24
25namespace eolian { namespace js {
26
27efl::eina::log_domain domain("eolian_js");
28
29struct incomplete_complex_type_error : public std::exception
30{
31 explicit incomplete_complex_type_error(std::string const& msg_arg)
32 : msg(msg_arg)
33 {}
34 virtual ~incomplete_complex_type_error() {}
35 virtual const char* what() const noexcept { return msg.c_str(); }
36
37 std::string msg;
38};
39
40} }
41
42
43std::string
44_lowercase(std::string str)
45{
46 transform(begin(str), end(str), begin(str), tolower);
47 return str;
48}
49
50std::string
51_uppercase(std::string str)
52{
53 transform(begin(str), end(str), begin(str), toupper);
54 return str;
55}
56
57std::string
58_class_name_getter(std::string const& caller_class_prefix, std::string class_name)
59{
60 std::replace(class_name.begin(), class_name.end(), '.', '_');
61 return caller_class_prefix + "_" + class_name + "_cls_name_getter";
62}
63
64void
65_final_type_and_type_type_get(Eolian_Type const* tp_in, Eolian_Type const*& tp_out, Eolian_Type_Type& tpt_out)
66{
67 tp_out = tp_in;
68 tpt_out = eolian_type_type_get(tp_in);
69 while ((tpt_out == EOLIAN_TYPE_REGULAR || tpt_out == EOLIAN_TYPE_ALIAS) && !eolian_type_is_extern(tp_out))
70 {
71 auto t = eolian_type_base_type_get(tp_out);
72 // TODO: shouldn't __undefined_type be flagged as external???
73 if (!t || !eolian_type_full_name_get(t) || strcmp(eolian_type_full_name_get(t), "__undefined_type") == 0) break;
74 tp_out = t;
75 tpt_out = eolian_type_type_get(t);
76 }
77}
78
79std::string
80_eolian_type_cpp_type_named_get(const Eolian_Type *tp, std::string const& caller_class_prefix, std::set<std::string>& need_name_getter)
81{
82 const auto is_const = eolian_type_is_const(tp);
83
84 Eolian_Type_Type tpt = EOLIAN_TYPE_UNKNOWN_TYPE;
85 _final_type_and_type_type_get(tp, tp, tpt);
86
87 if (tpt == EOLIAN_TYPE_UNKNOWN_TYPE)
88 return "error";
89
90 std::string result;
91
92 if ((tpt == EOLIAN_TYPE_VOID
93 || tpt == EOLIAN_TYPE_REGULAR
94 || tpt == EOLIAN_TYPE_COMPLEX
95 || tpt == EOLIAN_TYPE_STRUCT
96 || tpt == EOLIAN_TYPE_STRUCT_OPAQUE
97 || tpt == EOLIAN_TYPE_ENUM
98 || tpt == EOLIAN_TYPE_ALIAS
99 || tpt == EOLIAN_TYPE_CLASS)
100 && is_const)
101 {
102 result += "const ";
103 }
104
105
106 if (tpt == EOLIAN_TYPE_REGULAR
107 || tpt == EOLIAN_TYPE_COMPLEX
108 || tpt == EOLIAN_TYPE_STRUCT
109 || tpt == EOLIAN_TYPE_STRUCT_OPAQUE
110 || tpt == EOLIAN_TYPE_ENUM
111 || tpt == EOLIAN_TYPE_ALIAS
112 || tpt == EOLIAN_TYPE_CLASS)
113 {
114 for (efl::eina::iterator<const char> first(::eolian_type_namespaces_get(tp)), last; first != last; ++first)
115 {
116 std::string np(&*first);
117 result += np + "_"; // TODO: transform it to the C++ equivalent?
118 }
119
120 // this comes from ctypes at eo_lexer.c and KEYWORDS at eo_lexer.h
121 const static std::unordered_map<std::string, std::string> type_map = {
122 {"byte", "signed char"},
123 {"ubyte", "unsigned char"},
124 {"char", "char"},
125 {"short", "short"},
126 {"ushort", "unsigned short"},
127 {"int", "int"},
128 {"uint", "unsigned int"},
129 {"long", "long"},
130 {"ulong", "unsigned long"},
131 {"llong", "long long"},
132 {"ullong", "unsigned long long"},
133 {"int8", "int8_t"},
134 {"uint8", "uint8_t"},
135 {"int16", "int16_t"},
136 {"uint16", "uint16_t"},
137 {"int32", "int32_t"},
138 {"uint32", "uint32_t"},
139 {"int64", "int64_t"},
140 {"uint64", "uint64_t"},
141 {"int128", "int128_t"},
142 {"uint128", "uint128_t"},
143 {"size", "size_t"},
144 {"ssize", "ssize_t"},
145 {"intptr", "intptr_t"},
146 {"uintptr", "uintptr_t"},
147 {"ptrdiff", "ptrdiff_t"},
148 {"time", "time_t"},
149 {"float", "float"},
150 {"double", "double"},
151 {"bool", "Eina_Bool"},
152 {"void", "void"},
153 {"generic_value", "Eina_Value"},
154 {"accessor", "Eina_Accessor"},
155 {"array", "Eina_Array"},
156 {"iterator", "Eina_Iterator"},
157 {"hash", "Eina_Hash"},
158 {"list", "Eina_List"}
159 };
160
161 std::string type_name = eolian_type_name_get(tp);
162 auto it = type_map.find(type_name);
163 if (it != end(type_map))
164 type_name = it->second;
165 result += type_name;
166
167 if (tpt == EOLIAN_TYPE_STRUCT)
168 {
169 result = "efl::eina::js::make_struct_tag<" + result + ">";
170 }
171 }
172 else if (tpt == EOLIAN_TYPE_VOID)
173 result += "void";
174 else // tpt == EOLIAN_TYPE_POINTER
175 {
176 auto btp = eolian_type_base_type_get(tp);
177 result += _eolian_type_cpp_type_named_get(btp, caller_class_prefix, need_name_getter);
178
179 const auto base_is_const = eolian_type_is_const(btp);
180
181 Eolian_Type_Type btpt = EOLIAN_TYPE_UNKNOWN_TYPE;
182 _final_type_and_type_type_get(btp, btp, btpt);
183
184 if (btpt == EOLIAN_TYPE_STRUCT)
185 {
186 std::string f = "::make_struct_tag";
187 auto p = result.find(f);
188 if (p == std::string::npos)
189 throw std::runtime_error("missing struct type tag");
190 result.replace(p, f.size(), "::make_struct_ptr_tag");
191 result.pop_back();
192 result += " *";
193 if (is_const) result += " const";
194 result += ">";
195 }
196 else
197 {
198 if (btpt != EOLIAN_TYPE_POINTER || base_is_const)
199 result += ' ';
200 result += '*';
201 if (is_const) result += " const";
202 }
203
204 if (btpt == EOLIAN_TYPE_COMPLEX)
205 {
206 result = "efl::eina::js::make_complex_tag<" + result;
207
208 bool has_subtypes = false;
209 auto subtypes = eolian_type_subtypes_get(btp);
210 const Eolian_Type *subtype;
211 EINA_ITERATOR_FOREACH(subtypes, subtype)
212 {
213 auto t = _eolian_type_cpp_type_named_get(subtype, caller_class_prefix, need_name_getter);
214 auto k = type_class_name(subtype);
215 if (!k.empty())
216 {
217 result += ", " + t + ", " + _class_name_getter(caller_class_prefix, k);
218 need_name_getter.insert(k);
219 }
220 else
221 {
222 result += ", " + t + ", ::efl::eina::js::nonclass_cls_name_getter";
223 }
224 has_subtypes = true;
225 }
226
227 if (!has_subtypes)
228 throw eolian::js::incomplete_complex_type_error("Incomplete complex type");
229
230 result += ">";
231 }
232 }
233
234 /*if (!name.empty())
235 {
236 if (tpt != EOLIAN_TYPE_POINTER)
237 result += ' ';
238 result += name;
239 }*/
240
241 return result;
242}
243
244using ParametersIterator = efl::eina::iterator<const ::Eolian_Function_Parameter>;
245
246std::vector<const ::Eolian_Function_Parameter*>
247_eolian_function_keys_get(const Eolian_Function *function_id, Eolian_Function_Type ftype)
248{
249 std::vector<const ::Eolian_Function_Parameter*> keys;
250
251 for(ParametersIterator it(::eolian_property_keys_get(function_id, ftype)), last; it != last; ++it)
252 keys.push_back(&*it);
253
254 return keys;
255}
256
257std::vector<const ::Eolian_Function_Parameter*>
258_eolian_function_parameters_get(const Eolian_Function *function_id, Eolian_Function_Type function_type)
259{
260 std::vector<const ::Eolian_Function_Parameter*> parameters;
261
262 ParametersIterator it { (function_type == EOLIAN_METHOD) ?
263 ::eolian_function_parameters_get(function_id) :
264 ::eolian_property_values_get(function_id, function_type)
265 }, last;
266
267 for(; it != last; ++it)
268 parameters.push_back(&*it);
269
270 return parameters;
271}
272
273bool
274_function_return_is_missing(Eolian_Function const* func, Eolian_Function_Type func_type)
275{
276 // XXX This function shouldn't exist. Eolian should
277 // forge functions a priori. Bindings generators
278 // shouldn't be required to convert such thing.
279 Eolian_Type const* type =
280 ::eolian_function_return_type_get(func, func_type);
281 return !type;
282}
283
284int main(int argc, char** argv)
285{
286 namespace format = eolian::js::format;
287
288 std::vector<std::string> include_paths;
289 std::string out_file, in_file;
290
291 efl::eina::eina_init eina_init;
292 struct eolian_init
293 {
294 eolian_init() { ::eolian_init(); }
295 ~eolian_init() { ::eolian_shutdown(); }
296 } eolian_init;
297
298 const struct option long_options[] =
299 {
300 { "in", required_argument, 0, 'I' },
301 { "out-file", required_argument, 0, 'o' },
302 { "version", no_argument, 0, 'v' },
303 { "help", no_argument, 0, 'h' },
304 { 0, 0, 0, 0 }
305 };
306 const char* options = "I:D:o:c:arvh";
307
308 int c, idx;
309 while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1)
310 {
311 if (c == 'I')
312 {
313 include_paths.push_back(optarg);
314 }
315 else if (c == 'o')
316 {
317 if(!out_file.empty())
318 {
319 // _usage(argv[0]);
320 return 1;
321 }
322 out_file = optarg;
323 }
324 else if (c == 'h')
325 {
326 // _usage(argv[0]);
327 return 1;
328 }
329 else if (c == 'v')
330 {
331 // _print_version();
332 // if (argc == 2) exit(EXIT_SUCCESS);
333 }
334 }
335
336 if (optind == argc-1)
337 {
338 in_file = argv[optind];
339 }
340
341
342 for(auto src : include_paths)
343 if (!::eolian_directory_scan(src.c_str()))
344 {
345 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
346 << "Couldn't load eolian from '" << src << "'.";
347 }
348 if (!::eolian_all_eot_files_parse())
349 {
350 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
351 << "Eolian failed parsing eot files";
352 assert(false && "Error parsing eot files");
353 }
354 if (!::eolian_file_parse(in_file.c_str()))
355 {
356 EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
357 << "Failed parsing: " << in_file << ".";
358 assert(false && "Error parsing input file");
359 }
360
361 std::string file_basename;
362 const Eolian_Class *klass = NULL;
363 {
364 char* dup = strdup(in_file.c_str());
365 char *bn = basename(dup);
366 klass = ::eolian_class_get_by_file(bn);
367 file_basename = bn;
368 free(dup);
369 }
370 if(!klass)
371 {
372 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "could not find any class defined in this eo file";
373 return -1;
374 }
375
376 std::vector<Eolian_Function const*> constructor_functions;
377 std::vector<Eolian_Function const*> normal_functions;
378
379 std::set<Eolian_Class const*> classes;
380
381 auto separate_functions = [&] (Eolian_Class const* klass, Eolian_Function_Type t
382 , bool ignore_constructors)
383 {
384 efl::eina::iterator<Eolian_Function> first ( ::eolian_class_functions_get(klass, t) )
385 , last;
386 for(; first != last; ++first)
387 {
388 Eolian_Function const* function = &*first;
389 if(eolian_function_scope_get(function) == EOLIAN_SCOPE_PUBLIC)
390 {
391 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << ::eolian_function_full_c_name_get(function, t, EINA_FALSE);
392 if(strcmp("elm_obj_entry_input_panel_imdata_get", ::eolian_function_full_c_name_get(function, t, EINA_FALSE)) != 0 &&
393 !eolian_function_is_beta(function) &&
394 // strcmp("data_callback", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
395 strcmp("property", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
396 strcmp("part_text_anchor_geometry_get", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
397 strcmp("children_iterator_new", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
398 strcmp("inputs_get", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
399 strcmp("constructor", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
400 strcmp("render_updates", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
401 strcmp("render2_updates", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
402 strcmp("event_callback_priority_add", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
403 strcmp("event_callback_array_priority_add", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
404 strcmp("event_callback_array_del", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
405 strcmp("event_callback_call", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
406 strcmp("event_callback_forwarder_add", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
407 strcmp("event_callback_forwarder_del", ::eolian_function_name_get(function)) != 0 && // TODO: remove this
408 strcmp("event_callback_del", ::eolian_function_name_get(function)) != 0)
409 {
410 if( ::eolian_function_is_constructor(function, klass))
411 {
412 if(!ignore_constructors)
413 {
414 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is a constructor";
415 constructor_functions.push_back(function);
416 }
417 else
418 {
419 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "ignoring parent's constructors";
420 }
421 }
422 else /*if( std::strcmp( ::eolian_function_full_c_name_get(function, t, EINA_FALSE)
423 , "eo_parent") != 0)*/
424 {
425 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is a NOT constructor "
426 << ::eolian_function_full_c_name_get(function, t, EINA_FALSE);
427 normal_functions.push_back(function);
428 }
429 // else
430 // {
431 // EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "parent_set as first constructor";
432 // constructor_functions.insert(constructor_functions.begin(), function);
433 // normal_functions.push_back(function);
434 // }
435 }
436 }
437 }
438 };
439 separate_functions(klass, EOLIAN_METHOD, false);
440 separate_functions(klass, EOLIAN_PROPERTY, false);
441
442 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "functions were separated";
443
444 std::function<void(Eolian_Class const*, std::function<void(Eolian_Class const*)>)>
445 recurse_inherits
446 = [&] (Eolian_Class const* klass, std::function<void(Eolian_Class const*)> function)
447 {
448 for(efl::eina::iterator<const char> first ( ::eolian_class_inherits_get(klass))
449 , last; first != last; ++first)
450 {
451 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << &*first << std::endl;
452 Eolian_Class const* base = ::eolian_class_get_by_name(&*first);
453 function(base);
454 recurse_inherits(base, function);
455 }
456 };
457
458 auto save_functions = [&](Eolian_Class const* klass)
459 {
460 if(classes.find(klass) == classes.end())
461 {
462 classes.insert(klass);
463 separate_functions(klass, EOLIAN_METHOD, true);
464 separate_functions(klass, EOLIAN_PROPERTY, true);
465 }
466 };
467 recurse_inherits(klass, save_functions);
468
469 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "inherits were recursed";
470
471 std::ofstream os (out_file.c_str());
472 if(!os.is_open())
473 {
474 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "Couldn't open output file " << out_file;
475 return -1;
476 }
477
478 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "output was opened";
479
480 std::string class_name(name(klass)),
481 class_full_name(full_name(klass)),
482 upper_case_class_name(_uppercase(class_name)),
483 lower_case_class_name(_lowercase(class_name));
484
485 if (getenv("EFL_RUN_IN_TREE"))
486 {
487 os << "#ifdef HAVE_CONFIG_H\n";
488 os << "#include \"config.h\"\n";
489 os << "#endif\n";
490
491 os << "#include <Efl.h>\n";
492 os << "#include <Ecore.h>\n";
493 os << "#include <Eo.h>\n\n";
494 }
495 else
496 {
497 os << "#ifdef HAVE_CONFIG_H\n";
498 os << "#include \"elementary_config.h\"\n";
499 os << "#endif\n";
500
501 os << "#include <Efl.h>\n";
502 os << "#include <Ecore.h>\n";
503 os << "#include <Eo.h>\n";
504 os << "#include <Evas.h>\n";
505 os << "#include <Edje.h>\n";
506
507 os << "#include <Elementary.h>\n\n";
508 os << "extern \"C\" {\n";
509 os << "#include <elm_widget.h>\n";
510 os << "}\n\n";
511 }
512 os << "#include <Eina_Js.hh>\n\n";
513 os << "#include <Eo_Js.hh>\n\n";
514 os << "#ifdef EAPI\n";
515 os << "# undef EAPI\n";
516 os << "#endif\n";
517
518 os << "#ifdef _WIN32\n";
519 os << "# define EAPI __declspec(dllimport)\n";
520 os << "#else\n";
521 os << "# ifdef __GNUC__\n";
522 os << "# if __GNUC__ >= 4\n";
523 os << "# define EAPI __attribute__ ((visibility(\"default\")))\n";
524 os << "# else\n";
525 os << "# define EAPI\n";
526 os << "# endif\n";
527 os << "# else\n";
528 os << "# define EAPI\n";
529 os << "# endif\n";
530 os << "#endif /* ! _WIN32 */\n\n";
531 os << "extern \"C\" {\n";
532
533 if(is_evas(klass))
534 os << "#include <Evas.h>\n";
535
536 auto includes_fun = [&os] (Eolian_Class const* klass)
537 {
538 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
539 };
540 recurse_inherits(klass, includes_fun);
541 os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
542
543 os << "}\n\n";
544
545 os << "#ifdef _WIN32\n";
546 os << "# undef EAPI\n";
547 os << "# define EAPI __declspec(dllexport)\n";
548 os << "#endif /* ! _WIN32 */\n\n";
549
550 os << "#include <array>\n\n";
551
552 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "includes added";
553
554 if(namespace_size(klass))
555 {
556 std::string space = "";
557 for(efl::eina::iterator<const char> first(::eolian_class_namespaces_get(klass)), last; first != last; ++first)
558 {
559 std::string lower(_lowercase(&*first));
560 os << "namespace " << lower << " {" << space;
561 space = " ";
562 }
563
564 os << "\n";
565 }
566
567 std::string event_map = class_name;
568 event_map += "_ev_info_map";
569
570 os << "namespace {\n";
571 os << "::efl::eo::js::event_information_map " << event_map << ";\n";
572 os << "}\n";
573
574 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "namespace";
575
576 std::set<std::string> need_name_getter;
577
578 std::stringstream structs_ss;
579 for (efl::eina::iterator<Eolian_Type> first(::eolian_type_structs_get_by_file(file_basename.c_str()))
580 , last; first != last; ++first)
581 {
582 std::stringstream ss;
583 auto tp = &*first;
584 if (::eolian_type_type_get(tp) == EOLIAN_TYPE_STRUCT_OPAQUE)
585 continue;
586
587 auto struct_name = ::eolian_type_name_get(tp);
588 auto struct_type_full_name = ::eolian_type_full_name_get(tp);
589 if (!struct_name || !struct_type_full_name)
590 {
591 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Could not get struct type name";
592 continue;
593 }
594 else if(strcmp(struct_type_full_name, "Eo.Callback_Array_Item") == 0)
595 continue;
596 std::string struct_c_name = struct_type_full_name;
597 std::replace(struct_c_name.begin(), struct_c_name.end(), '.', '_');
598 ss << " {\n";
599 ss << " auto fields_func = [](v8::Isolate* isolate_, v8::Local<v8::ObjectTemplate> prototype_)\n";
600 ss << " {\n";
601 for (efl::eina::iterator<Eolian_Struct_Type_Field> sf(::eolian_type_struct_fields_get(tp))
602 , sf_end; sf != sf_end; ++sf)
603 {
604 auto field_type = ::eolian_type_struct_field_type_get(&*sf);
605 auto field_name = ::eolian_type_struct_field_name_get(&*sf);
606 if (!field_name)
607 {
608 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Could not get struct field name";
609 continue;
610 }
611 std::string field_type_tag_name;
612 try
613 {
614 field_type_tag_name = _eolian_type_cpp_type_named_get(field_type, class_name, need_name_getter);
615 }
616 catch(eolian::js::incomplete_complex_type_error const& e)
617 {
618 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Exception while generating '" << field_name << "' fielf of '" << struct_type_full_name << "' struct: " << e.what();
619 continue;
620 }
621 std::string member_ref = struct_c_name;
622 member_ref += "::";
623 member_ref += field_name;
624
625 auto k = type_class_name(field_type);
626 if (!k.empty())
627 {
628 need_name_getter.insert(k);
629 k = _class_name_getter(class_name, k);
630 }
631 else
632 {
633 k = "::efl::eina::js::nonclass_cls_name_getter";
634 }
635 ss << " prototype_->SetAccessor(::efl::eina::js::compatibility_new<v8::String>(isolate_, \"" << format::generic(field_name) << "\"),\n";
636 ss << " static_cast<v8::AccessorGetterCallback>(&::efl::eo::js::get_struct_member<" << struct_c_name << ", decltype(" << member_ref << "), &" << member_ref << ", " << k << ">),\n";
637 ss << " static_cast<v8::AccessorSetterCallback>(&::efl::eo::js::set_struct_member<" << struct_c_name << ", " << field_type_tag_name << ", decltype(" << member_ref << "), &" << member_ref << ", " << k << ">));\n";
638 }
639 ss << " };\n";
640 ss << " auto to_export = ::efl::eo::js::get_namespace({";
641 bool comma = false;
642 for (efl::eina::iterator<const char> ns_it(::eolian_type_namespaces_get(tp)), ns_end; ns_it != ns_end; ++ns_it)
643 {
644 if (comma)
645 ss << ", ";
646 comma = true;
647 ss << '"' << format::generic(&*ns_it) << '"';
648 }
649 ss << "}, isolate, global);\n";
650 ss << " ::efl::eo::js::register_struct<" << struct_c_name << ">(isolate, \""
651 << format::generic(struct_name) << "\", \"" << struct_type_full_name << "\", to_export, fields_func);\n";
652 ss << " }\n";
653
654 structs_ss << ss.str();
655 }
656
657
658 std::stringstream register_from_constructor_begin_ss;
659 register_from_constructor_begin_ss
660 << "EAPI v8::Local<v8::ObjectTemplate>\n"
661 << "register_" << lower_case_class_name << "_from_constructor\n"
662 << "(v8::Isolate* isolate, v8::Handle<v8::FunctionTemplate> constructor, ::efl::eina::js::global_ref<v8::Function>* constructor_from_eo)\n"
663 << "{\n"
664 << " v8::Local<v8::ObjectTemplate> instance = constructor->InstanceTemplate();\n"
665 << " instance->SetInternalFieldCount(1);\n"
666 << " v8::Handle<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate();\n";
667
668 std::stringstream functions_ss;
669 std::set<std::string> member_names;
670 std::set<std::string> event_member_names;
671 for(auto function : normal_functions)
672 {
673 std::vector<Eolian_Function_Type> function_types;
674 switch (eolian_function_type_get(function))
675 {
676 case EOLIAN_METHOD:
677 function_types = {EOLIAN_METHOD};
678 break;
679 case EOLIAN_PROPERTY:
680 function_types = {EOLIAN_PROP_GET, EOLIAN_PROP_SET};
681 break;
682 case EOLIAN_PROP_GET:
683 function_types = {EOLIAN_PROP_GET};
684 break;
685 case EOLIAN_PROP_SET:
686 function_types = {EOLIAN_PROP_SET};
687 break;
688 default:
689 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Unresolved function type";
690 continue;
691 }
692
693 for (const auto function_type : function_types)
694 {
695 try
696 {
697 std::string member_name;
698 switch (function_type)
699 {
700 case EOLIAN_METHOD:
701 member_name = eolian_function_name_get(function);
702 break;
703 case EOLIAN_PROP_SET:
704 member_name = std::string("set_") + eolian_function_name_get(function);
705 break;
706 case EOLIAN_PROP_GET:
707 member_name = std::string("get_") + eolian_function_name_get(function);
708 break;
709 case EOLIAN_PROPERTY:
710 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "EOLIAN_PROPERTY function type is invalid at this point";
711 return -1;
712 case EOLIAN_UNRESOLVED:
713 default:
714 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Unresolved function type";
715 return -1;
716 }
717
718 if(member_names.find(member_name) == member_names.end())
719 {
720 member_names.insert(member_name);
721 std::stringstream ss;
722 auto output_begin = [&] (std::string name)
723 {
724 if(! ::eolian_function_is_constructor(function, klass))
725 ss << " prototype->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
726 << format::generic(name) << "\")\n"
727 << " , ::efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, &efl::eo::js::call_function\n"
728 << " , efl::eo::js::call_function_data<\n"
729 << " ::efl::eina::_mpl::tuple_c<std::size_t";
730 };
731
732 output_begin(member_name);
733
734 const auto key_params = _eolian_function_keys_get(function, function_type);
735 const auto parameters = _eolian_function_parameters_get(function, function_type);
736
737 std::vector<const ::Eolian_Function_Parameter*> full_params;
738 full_params.insert(end(full_params), begin(key_params), end(key_params));
739 // only one property_get parameter is translated as the function return in C
740 const auto param_as_return = (EOLIAN_PROP_GET == function_type) && (parameters.size() == 1)
741 && _function_return_is_missing(function, function_type);
742 if (!param_as_return)
743 full_params.insert(end(full_params), begin(parameters), end(parameters));
744
745 // call_function_data Ins
746 std::size_t i = 0;
747 for (auto parameter : full_params)
748 {
749 // TODO: REVIEW THIS!!! IT IS TOO STRANGE...
750 // properties doesn't support in/out/inout
751 if (EOLIAN_PROP_SET == function_type)
752 ss << ", " << i;
753 else
754 if (EOLIAN_METHOD == function_type)
755 {
756 switch (eolian_parameter_direction_get(parameter))
757 {
758 case EOLIAN_IN_PARAM:
759 case EOLIAN_INOUT_PARAM:
760 ss << ", " << i;
761 default: break;
762 }
763 }
764 ++i;
765 }
766
767 // call_function_data Outs
768 ss << ">\n , ::efl::eina::_mpl::tuple_c<std::size_t";
769 auto key_count = key_params.size();
770 i = 0;
771 for (auto parameter : full_params)
772 {
773 // TODO: THIS TOO!!!
774 // ignore keys
775 if (key_count > 0)
776 {
777 --key_count;
778 ++i;
779 continue;
780 }
781
782 // properties doesn't support in/out/inout
783 if (EOLIAN_PROP_GET == function_type)
784 ss << ", " << i;
785 else
786 if (EOLIAN_METHOD == function_type)
787 {
788 switch (eolian_parameter_direction_get(parameter))
789 {
790 case EOLIAN_OUT_PARAM:
791 case EOLIAN_INOUT_PARAM:
792 ss << ", " << i;
793 default: break;
794 }
795 }
796 ++i;
797 }
798
799 // call_function_data Ownership
800 ss << ">\n , std::tuple<\n";
801 auto sep = "";
802 for (auto parameter : full_params)
803 {
804 auto type = eolian_parameter_type_get(parameter);
805 if(eolian_type_is_own(type))
806 ss << sep << " ::std::true_type";
807 else
808 ss << sep << " ::std::false_type";
809 sep = ",\n";
810 }
811
812
813 // call_function_data Return
814 ss << ">\n , ";
815
816 const Eolian_Type *return_type = nullptr;
817 if (param_as_return)
818 {
819 return_type = eolian_parameter_type_get(parameters[0]);
820 }
821 else
822 {
823 return_type = ::eolian_function_return_type_get(function, function_type);
824 }
825 std::string param = "void";
826 if (nullptr != return_type)
827 {
828 param = _eolian_type_cpp_type_named_get(return_type, class_name, need_name_getter);
829 }
830 ss << param;
831
832
833 // call_function_data Parameters
834 ss << "\n , std::tuple<\n";
835 sep = " ";
836 key_count = key_params.size();
837 for (auto parameter : full_params)
838 {
839 // TODO: REVIEW ALL THIS TOO!!!
840 auto type = eolian_parameter_type_get(parameter);
841 auto param = _eolian_type_cpp_type_named_get(type, class_name, need_name_getter);
842
843 if (!key_count && EOLIAN_PROP_GET == function_type)
844 param += "*";
845 else
846 {
847 switch(eolian_parameter_direction_get(parameter))
848 {
849 case EOLIAN_OUT_PARAM:
850 case EOLIAN_INOUT_PARAM:
851 param += "*";
852 default: break;
853 }
854 }
855
856 ss << sep << param;
857 sep = ",\n ";
858
859 if (key_count > 0) --key_count;
860 }
861
862
863 std::string param_class_names;
864 for (auto parameter : full_params)
865 {
866 param_class_names += '"' + type_class_name(::eolian_parameter_type_get(parameter)) + "\", ";
867 }
868 param_class_names += '"' + type_class_name(return_type) + '"';
869
870 std::string param_class_names_array = "std::array<const char*, ";
871 param_class_names_array += std::to_string(full_params.size() + 1);
872 param_class_names_array += ">{{" + param_class_names + "}}";
873
874 // // ss << __func__ << ":" << __LINE__;
875 auto output_end = [&] (std::string const& name)
876 {
877 ss << "> >(isolate, " << param_class_names_array << ", & ::" << name << ")));\n";
878 };
879 switch (function_type)
880 {
881 case EOLIAN_METHOD:
882 output_end(eolian_function_full_c_name_get(function, function_type, EINA_FALSE));
883 break;
884 case EOLIAN_PROP_SET:
885 output_end(eolian_function_full_c_name_get(function, function_type, EINA_FALSE) /*+ std::string("_set")*/);
886 break;
887 case EOLIAN_PROP_GET:
888 output_end(eolian_function_full_c_name_get(function, function_type, EINA_FALSE) /*+ std::string("_get")*/);
889 break;
890 case EOLIAN_PROPERTY:
891 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "EOLIAN_PROPERTY function type is invalid at this point";
892 return -1;
893 case EOLIAN_UNRESOLVED:
894 default:
895 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Unresolved function type";
896 return -1;
897 }
898
899 // Write function to functions stream
900 functions_ss << ss.str();
901 }
902 }
903 catch(eolian::js::incomplete_complex_type_error const& e)
904 {
905 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Exception while generating '" << eolian_function_name_get(function) << "': " << e.what();
906 }
907 }
908 }
909
910 std::stringstream events_ss;
911 auto generate_events = [&] (Eolian_Class const* klass)
912 {
913 std::stringstream ss;
914 for(efl::eina::iterator< ::Eolian_Event> first ( ::eolian_class_events_get(klass))
915 , last; first != last; ++first)
916 {
917 std::string event_name (::eolian_event_name_get(&*first));
918 std::replace(event_name.begin(), event_name.end(), ',', '_');
919
920 if (!eolian_event_is_beta(&*first) &&
921 event_member_names.find(event_name) == event_member_names.end())
922 {
923 auto tp = eolian_event_type_get(&*first);
924 ss << " {\n";
925 ss << " static efl::eo::js::event_information ev_info{&constructor_from_eo, " << eolian_event_c_name_get(&*first);
926 ss << ", &efl::eo::js::event_callback<";
927 ss << (tp ? _eolian_type_cpp_type_named_get(tp, class_name, need_name_getter) : "void");
928 ss << ">, \"" << type_class_name(tp) << "\"};\n";
929 ss << " " << event_map << "[\"" << event_name << "\"] = &ev_info;\n";
930 ss << " }\n";
931 event_member_names.insert(event_name);
932 }
933 }
934 events_ss << ss.str();
935 };
936 generate_events(klass);
937 recurse_inherits(klass, generate_events);
938
939 std::stringstream register_from_constructor_end_ss;
940 register_from_constructor_end_ss
941 << " prototype->Set(::efl::eina::js::compatibility_new<v8::String>(isolate, \"on\")\n"
942 << " , ::efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, &efl::eo::js::on_event\n"
943 << " , ::efl::eina::js::compatibility_new<v8::External>(isolate, &" << event_map << ")));\n"
944 << " static_cast<void>(prototype); /* avoid warnings */\n"
945 << " static_cast<void>(isolate); /* avoid warnings */\n"
946 << " static_cast<void>(constructor_from_eo); /* avoid warnings */\n"
947 << " return instance;\n"
948 << "}\n\n";
949
950 std::stringstream name_getters_ss;
951 for (auto const& k : need_name_getter)
952 {
953 name_getters_ss << " struct " << _class_name_getter(class_name, k) << " { static char const* class_name() { return \"" << k << "\"; } };\n";
954 }
955
956 os << "namespace {\n";
957 os << name_getters_ss.str();
958 os << "}\n\n";
959
960 os << register_from_constructor_begin_ss.str();
961 os << functions_ss.str();
962 os << register_from_constructor_end_ss.str();
963
964
965 os << "EAPI void register_" << lower_case_class_name
966 << "(v8::Handle<v8::Object> global, v8::Isolate* isolate)\n";
967 os << "{\n";
968 os << " v8::Handle<v8::FunctionTemplate> constructor = ::efl::eina::js::compatibility_new<v8::FunctionTemplate>\n";
969 os << " (isolate, efl::eo::js::constructor\n"
970 << " , efl::eo::js::constructor_data(isolate\n"
971 " , ";
972
973 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "before print eo_class";
974
975 print_eo_class(klass, os);
976
977 EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print eo_class";
978
979 for(auto function : constructor_functions)
980 {
981 auto ftype = eolian_function_type_get(function);
982 if(ftype == EOLIAN_PROPERTY)
983 ftype = EOLIAN_PROP_SET;
984 os << "\n , & ::"
985 << eolian_function_full_c_name_get(function, ftype, EINA_FALSE);
986 }
987
988 os << "));\n";
989
990 os << " static ::efl::eina::js::global_ref<v8::Function> constructor_from_eo;\n";
991 os << events_ss.str();
992 os << " register_" << lower_case_class_name << "_from_constructor(isolate, constructor, &constructor_from_eo);\n";
993
994 os << " constructor->SetClassName( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
995 << format::generic(class_name)
996 << "\"));\n";
997
998 os << " auto to_export = ::efl::eo::js::get_namespace({";
999 if (namespace_size(klass))
1000 {
1001 bool comma = false;
1002 for (efl::eina::iterator<const char> ns_it(::eolian_class_namespaces_get(klass)), ns_end; ns_it != ns_end; ++ns_it)
1003 {
1004 if (comma)
1005 os << ", ";
1006 comma = true;
1007 os << '"' << format::generic(&*ns_it) << '"';
1008 }
1009 }
1010 os << "}, isolate, global);\n";
1011
1012 os << " to_export->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
1013 << format::generic(class_name) << "\")"
1014 << ", constructor->GetFunction());\n";
1015
1016
1017 os << " {\n";
1018 os << " v8::Handle<v8::FunctionTemplate> constructor = ::efl::eina::js::compatibility_new<v8::FunctionTemplate>\n";
1019 os << " (isolate, &efl::eo::js::construct_from_eo);\n";
1020 os << " constructor->SetClassName( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
1021 << format::generic(class_name)
1022 << "\"));\n";
1023 os << " v8::Local<v8::ObjectTemplate> instance = "
1024 << "register_" << lower_case_class_name << "_from_constructor(isolate, constructor, &constructor_from_eo);\n";
1025 os << " ::efl::eina::js::make_persistent(isolate, instance);\n";
1026 os << " constructor_from_eo = {isolate, constructor->GetFunction()};\n";
1027 os << " ::efl::eina::js::register_class_constructor(\"" << class_full_name << "\", constructor_from_eo.handle());\n";
1028 os << " }\n";
1029
1030 os << structs_ss.str();
1031
1032 for (efl::eina::iterator<Eolian_Type> first(::eolian_type_enums_get_by_file(file_basename.c_str()))
1033 , last; first != last; ++first)
1034 {
1035 auto tp = &*first;
1036 if (::eolian_type_is_extern(tp))
1037 continue;
1038 std::string enum_name = ::eolian_type_name_get(tp);
1039 os << " {\n";
1040 os << " auto to_export = ::efl::eo::js::get_namespace({";
1041 bool comma = false;
1042 for (efl::eina::iterator<const char> ns_it(::eolian_type_namespaces_get(tp)), ns_end; ns_it != ns_end; ++ns_it)
1043 {
1044 if (comma)
1045 os << ", ";
1046 comma = true;
1047 os << '"' << format::generic(&*ns_it) << '"';
1048 }
1049 os << "}, isolate, global);\n";
1050 os << " v8::Handle<v8::Object> enum_obj = efl::eina::js::compatibility_new<v8::Object>(isolate);\n";
1051 os << " to_export->Set(efl::eina::js::compatibility_new<v8::String>(isolate, \""
1052 << format::generic(enum_name) << "\"), enum_obj);\n";
1053 for (efl::eina::iterator<Eolian_Enum_Type_Field> ef(::eolian_type_enum_fields_get(tp))
1054 , ef_end; ef != ef_end; ++ef)
1055 {
1056 auto field_name = ::eolian_type_enum_field_name_get(&*ef);
1057 auto field_c_name = ::eolian_type_enum_field_c_name_get(&*ef);
1058 if (!field_name || !field_c_name)
1059 {
1060 EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Could not get enum field name";
1061 continue;
1062 }
1063 os << " enum_obj->Set(efl::eina::js::compatibility_new<v8::String>(isolate, \"" << format::constant(field_name) << "\"),\n";
1064 os << " efl::eina::js::compatibility_new<v8::Int32>(isolate, static_cast<int32_t>(::" << field_c_name << ")));\n";
1065 }
1066 os << " }\n";
1067 }
1068
1069 os << "}\n\n";
1070
1071 for(std::size_t i = 0, j = namespace_size(klass); i != j; ++i)
1072 os << "}";
1073 os << "\n";
1074
1075
1076}
diff --git a/src/bindings/ecore_js/Ecore_Js.hh b/src/bindings/ecore_js/Ecore_Js.hh
new file mode 100644
index 0000000..3f877f3
--- /dev/null
+++ b/src/bindings/ecore_js/Ecore_Js.hh
@@ -0,0 +1,58 @@
1
2#ifndef EFL_ECORE_JS_HH
3#define EFL_ECORE_JS_HH
4
5#include <Ecore.hh>
6#include <Ecore_File.h>
7#include <Eina_Js.hh>
8
9#ifdef EAPI
10# undef EAPI
11#endif
12
13#ifdef _WIN32
14# ifdef EFL_ECORE_JS_BUILD
15# ifdef DLL_EXPORT
16# define EAPI __declspec(dllexport)
17# else
18# define EAPI
19# endif /* ! DLL_EXPORT */
20# else
21# define EAPI __declspec(dllimport)
22# endif /* ! EFL_ECORE_BUILD */
23#else
24# ifdef __GNUC__
25# if __GNUC__ >= 4
26# define EAPI __attribute__ ((visibility("default")))
27# else
28# define EAPI
29# endif
30# else
31# define EAPI
32# endif
33#endif /* ! _WIN32 */
34
35namespace efl { namespace ecore { namespace js {
36
37using ::efl::eina::js::compatibility_new;
38using ::efl::eina::js::compatibility_return_type;
39using ::efl::eina::js::compatibility_callback_info_type;
40using ::efl::eina::js::compatibility_return;
41using ::efl::eina::js::compatibility_get_pointer_internal_field;
42using ::efl::eina::js::compatibility_set_pointer_internal_field;
43
44EAPI void register_ecore_animator(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
45EAPI void register_ecore_event(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
46EAPI void register_ecore_file(v8::Isolate* isolate, v8::Handle<v8::Object> exports);
47EAPI void register_ecore_idle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
48EAPI void register_ecore_job(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
49EAPI void register_ecore_mainloop(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
50EAPI void register_ecore_poller(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
51EAPI void register_ecore_throttle(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
52EAPI void register_ecore_timer(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
53
54EAPI void register_ecore(v8::Isolate *isolate,v8::Handle<v8::Object> exports);
55
56} } }
57
58#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 0000000..52f8576
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_animator.cc
@@ -0,0 +1,728 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Animator* extract_animator(v8::Local<v8::Object> object)
10{
11 auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
12 return reinterpret_cast<Ecore_Animator*>(ptr);
13}
14
15static v8::Local<v8::Object> wrap_animator(Ecore_Animator *animator,
16 v8::Isolate *isolate)
17{
18 using v8::Boolean;
19 using v8::String;
20 using v8::ObjectTemplate;
21 using v8::FunctionTemplate;
22
23 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
24 obj_tpl->SetInternalFieldCount(1);
25 auto ret = obj_tpl->NewInstance();
26
27 auto del = [](compatibility_callback_info_type info)
28 -> compatibility_return_type {
29 if (info.Length() != 0)
30 return compatibility_return();
31
32 ecore_animator_del(extract_animator(info.This()));
33 return compatibility_return();
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 return compatibility_return();
43 };
44
45 auto thaw = [](compatibility_callback_info_type info)
46 -> compatibility_return_type {
47 if (info.Length() != 0)
48 return compatibility_return();
49
50 ecore_animator_thaw(extract_animator(info.This()));
51 return compatibility_return();
52 };
53
54 ret->Set(compatibility_new<String>(isolate, "del"),
55 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
56 ret->Set(compatibility_new<String>(isolate, "freeze"),
57 compatibility_new<FunctionTemplate>(isolate, freeze)
58 ->GetFunction());
59 ret->Set(compatibility_new<String>(isolate, "thaw"),
60 compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
61
62 ret->SetInternalField(0, compatibility_new<v8::External>(isolate,
63 animator));
64
65 return ret;
66}
67
68void register_pos_map_linear(v8::Isolate *isolate,
69 v8::Handle<v8::Object> global,
70 v8::Handle<v8::String> name)
71{
72 using v8::Integer;
73
74 global->Set(name,
75 compatibility_new<Integer>(isolate, ECORE_POS_MAP_LINEAR));
76}
77
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
88void register_pos_map_decelerate(v8::Isolate *isolate,
89 v8::Handle<v8::Object> global,
90 v8::Handle<v8::String> name)
91{
92 using v8::Integer;
93
94 global->Set(name,
95 compatibility_new<Integer>(isolate, ECORE_POS_MAP_DECELERATE));
96}
97
98void register_pos_map_sinusoidal(v8::Isolate *isolate,
99 v8::Handle<v8::Object> global,
100 v8::Handle<v8::String> name)
101{
102 using v8::Integer;
103
104 global->Set(name,
105 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SINUSOIDAL));
106}
107
108void register_pos_map_accelerate_factor(v8::Isolate *isolate,
109 v8::Handle<v8::Object> global,
110 v8::Handle<v8::String> name)
111{
112 using v8::Integer;
113
114 global->Set(name,
115 compatibility_new<Integer>(isolate,
116 ECORE_POS_MAP_ACCELERATE_FACTOR));
117}
118
119void register_pos_map_decelerate_factor(v8::Isolate *isolate,
120 v8::Handle<v8::Object> global,
121 v8::Handle<v8::String> name)
122{
123 using v8::Integer;
124
125 global->Set(name,
126 compatibility_new<Integer>(isolate,
127 ECORE_POS_MAP_DECELERATE_FACTOR));
128}
129
130void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
131 v8::Handle<v8::Object> global,
132 v8::Handle<v8::String> name)
133{
134 using v8::Integer;
135
136 global->Set(name,
137 compatibility_new<Integer>(isolate,
138 ECORE_POS_MAP_SINUSOIDAL_FACTOR));
139}
140
141void register_pos_map_divisor_interp(v8::Isolate *isolate,
142 v8::Handle<v8::Object> global,
143 v8::Handle<v8::String> name)
144{
145 using v8::Integer;
146
147 global->Set(name,
148 compatibility_new<Integer>(isolate,
149 ECORE_POS_MAP_DIVISOR_INTERP));
150}
151
152void register_pos_map_bounce(v8::Isolate *isolate,
153 v8::Handle<v8::Object> global,
154 v8::Handle<v8::String> name)
155{
156 using v8::Integer;
157
158 global->Set(name,
159 compatibility_new<Integer>(isolate, ECORE_POS_MAP_BOUNCE));
160}
161
162void register_pos_map_spring(v8::Isolate *isolate,
163 v8::Handle<v8::Object> global,
164 v8::Handle<v8::String> name)
165{
166 using v8::Integer;
167
168 global->Set(name,
169 compatibility_new<Integer>(isolate, ECORE_POS_MAP_SPRING));
170}
171
172void register_pos_map_cubic_bezier(v8::Isolate *isolate,
173 v8::Handle<v8::Object> global,
174 v8::Handle<v8::String> name)
175{
176 using v8::Integer;
177
178 global->Set(name,
179 compatibility_new<Integer>(isolate,
180 ECORE_POS_MAP_CUBIC_BEZIER));
181}
182
183void register_animator_source_timer(v8::Isolate *isolate,
184 v8::Handle<v8::Object> global,
185 v8::Handle<v8::String> name)
186{
187 using v8::Integer;
188
189 global->Set(name,
190 compatibility_new<Integer>(isolate,
191 ECORE_ANIMATOR_SOURCE_TIMER));
192}
193
194void register_animator_source_custom(v8::Isolate *isolate,
195 v8::Handle<v8::Object> global,
196 v8::Handle<v8::String> name)
197{
198 using v8::Integer;
199
200 global->Set(name,
201 compatibility_new<Integer>(isolate,
202 ECORE_ANIMATOR_SOURCE_CUSTOM));
203}
204
205void register_animator_frametime_set(v8::Isolate *isolate,
206 v8::Handle<v8::Object> global,
207 v8::Handle<v8::String> name)
208{
209 using v8::FunctionTemplate;
210
211 auto f = [](compatibility_callback_info_type args)
212 -> compatibility_return_type {
213 if (args.Length() != 1 || !args[0]->IsNumber())
214 return compatibility_return();
215
216 ecore_animator_frametime_set(args[0]->NumberValue());
217 return compatibility_return();
218 };
219
220 global->Set(name,
221 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
222}
223
224void register_animator_frametime_get(v8::Isolate *isolate,
225 v8::Handle<v8::Object> global,
226 v8::Handle<v8::String> name)
227{
228 using v8::Number;
229 using v8::FunctionTemplate;
230
231 auto f = [](compatibility_callback_info_type args)
232 -> compatibility_return_type {
233 if (args.Length() != 0)
234 return compatibility_return();
235
236 auto isolate = args.GetIsolate();
237 auto ret = ecore_animator_frametime_get();
238 return compatibility_return(compatibility_new<Number>(isolate, ret),
239 args);
240 };
241
242 global->Set(name,
243 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
244}
245
246void register_animator_pos_map(v8::Isolate *isolate,
247 v8::Handle<v8::Object> global,
248 v8::Handle<v8::String> name)
249{
250 using v8::Number;
251 using v8::FunctionTemplate;
252
253 auto f = [](compatibility_callback_info_type args)
254 -> compatibility_return_type {
255 if (args.Length() != 4 || !args[0]->IsNumber() || !args[1]->IsNumber()
256 || !args[2]->IsNumber() || !args[3]->IsNumber())
257 return compatibility_return();
258
259 Ecore_Pos_Map map;
260
261 switch ((int)(args[1]->NumberValue())) {
262 case ECORE_POS_MAP_LINEAR:
263 map = ECORE_POS_MAP_LINEAR;
264 break;
265 case ECORE_POS_MAP_ACCELERATE:
266 map = ECORE_POS_MAP_ACCELERATE;
267 break;
268 case ECORE_POS_MAP_DECELERATE:
269 map = ECORE_POS_MAP_DECELERATE;
270 break;
271 case ECORE_POS_MAP_SINUSOIDAL:
272 map = ECORE_POS_MAP_SINUSOIDAL;
273 break;
274 case ECORE_POS_MAP_ACCELERATE_FACTOR:
275 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
276 break;
277 case ECORE_POS_MAP_DECELERATE_FACTOR:
278 map = ECORE_POS_MAP_DECELERATE_FACTOR;
279 break;
280 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
281 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
282 break;
283 case ECORE_POS_MAP_DIVISOR_INTERP:
284 map = ECORE_POS_MAP_DIVISOR_INTERP;
285 break;
286 case ECORE_POS_MAP_BOUNCE:
287 map = ECORE_POS_MAP_BOUNCE;
288 break;
289 case ECORE_POS_MAP_SPRING:
290 map = ECORE_POS_MAP_SPRING;
291 break;
292 case ECORE_POS_MAP_CUBIC_BEZIER:
293 map = ECORE_POS_MAP_CUBIC_BEZIER;
294 break;
295 default:
296 return compatibility_return();
297 }
298
299 auto isolate = args.GetIsolate();
300 auto ret = ecore_animator_pos_map(args[0]->NumberValue(), map,
301 args[2]->NumberValue(),
302 args[3]->NumberValue());
303 return compatibility_return(compatibility_new<Number>(isolate, ret),
304 args);
305 };
306
307 global->Set(name,
308 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
309}
310
311void register_animator_pos_map_n(v8::Isolate *isolate,
312 v8::Handle<v8::Object> global,
313 v8::Handle<v8::String> name)
314{
315 using v8::Number;
316 using v8::NumberObject;
317 using v8::FunctionTemplate;
318 using v8::Array;
319
320 auto f = [](compatibility_callback_info_type args)
321 -> compatibility_return_type {
322 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
323 || !args[2]->IsArray())
324 return compatibility_return();
325
326 Ecore_Pos_Map map;
327
328 switch ((int)(args[1]->NumberValue())) {
329 case ECORE_POS_MAP_LINEAR:
330 map = ECORE_POS_MAP_LINEAR;
331 break;
332 case ECORE_POS_MAP_ACCELERATE:
333 map = ECORE_POS_MAP_ACCELERATE;
334 break;
335 case ECORE_POS_MAP_DECELERATE:
336 map = ECORE_POS_MAP_DECELERATE;
337 break;
338 case ECORE_POS_MAP_SINUSOIDAL:
339 map = ECORE_POS_MAP_SINUSOIDAL;
340 break;
341 case ECORE_POS_MAP_ACCELERATE_FACTOR:
342 map = ECORE_POS_MAP_ACCELERATE_FACTOR;
343 break;
344 case ECORE_POS_MAP_DECELERATE_FACTOR:
345 map = ECORE_POS_MAP_DECELERATE_FACTOR;
346 break;
347 case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
348 map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
349 break;
350 case ECORE_POS_MAP_DIVISOR_INTERP:
351 map = ECORE_POS_MAP_DIVISOR_INTERP;
352 break;
353 case ECORE_POS_MAP_BOUNCE:
354 map = ECORE_POS_MAP_BOUNCE;
355 break;
356 case ECORE_POS_MAP_SPRING:
357 map = ECORE_POS_MAP_SPRING;
358 break;
359 case ECORE_POS_MAP_CUBIC_BEZIER:
360 map = ECORE_POS_MAP_CUBIC_BEZIER;
361 break;
362 default:
363 return compatibility_return();
364 }
365
366 std::vector<double> v;
367 {
368 auto array = Array::Cast(*args[2]);
369 auto s = array->Length();
370 v.reserve(s);
371 for (decltype(s) i = 0;i != s;++i) {
372 auto e = array->Get(i);
373 if (!e->IsNumber())
374 return compatibility_return();
375
376 v.push_back(e->NumberValue());
377 }
378 }
379
380 auto isolate = args.GetIsolate();
381 auto ret = ecore_animator_pos_map_n(args[0]->NumberValue(), map,
382 v.size(), v.data());
383 return compatibility_return(compatibility_new<Number>(isolate, ret),
384 args);
385 };
386
387 global->Set(name,
388 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
389}
390
391void register_animator_source_set(v8::Isolate *isolate,
392 v8::Handle<v8::Object> global,
393 v8::Handle<v8::String> name)
394{
395 using v8::FunctionTemplate;
396
397 auto f = [](compatibility_callback_info_type args)
398 -> compatibility_return_type {
399 if (args.Length() != 1 || !args[0]->IsNumber())
400 return compatibility_return();
401
402 Ecore_Animator_Source source;
403
404 switch ((int)(args[0]->NumberValue())) {
405 case ECORE_ANIMATOR_SOURCE_TIMER:
406 source = ECORE_ANIMATOR_SOURCE_TIMER;
407 break;
408 case ECORE_ANIMATOR_SOURCE_CUSTOM:
409 source = ECORE_ANIMATOR_SOURCE_CUSTOM;
410 break;
411 default:
412 return compatibility_return();
413 }
414
415 ecore_animator_source_set(source);
416 return compatibility_return();
417 };
418
419 global->Set(name,
420 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
421}
422
423void register_animator_source_get(v8::Isolate *isolate,
424 v8::Handle<v8::Object> global,
425 v8::Handle<v8::String> name)
426{
427 using v8::Integer;
428 using v8::FunctionTemplate;
429
430 auto f = [](compatibility_callback_info_type args)
431 -> compatibility_return_type {
432 if (args.Length() != 0)
433 return compatibility_return();
434
435 auto isolate = args.GetIsolate();
436 auto ret = ecore_animator_source_get();
437 return compatibility_return(compatibility_new<Integer>(isolate, ret),
438 args);
439 };
440
441 global->Set(name,
442 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
443}
444
445static
446efl::eina::js::global_ref<v8::Value> animator_custom_source_tick_begin_cb_data;
447static
448efl::eina::js::global_ref<v8::Value> animator_custom_source_tick_end_cb_data;
449
450void
451register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
452 v8::Handle<v8::Object>
453 global,
454 v8::Handle<v8::String>
455 name)
456{
457 using v8::FunctionCallbackInfo;
458 using v8::Value;
459 using v8::FunctionTemplate;
460
461 auto f = [](compatibility_callback_info_type args) {
462 if (args.Length() != 1 || !args[0]->IsFunction())
463 return compatibility_return();
464
465 animator_custom_source_tick_begin_cb_data
466 = efl::eina::js::global_ref<Value>(args.GetIsolate(), args[0]);
467 ecore_animator_custom_source_tick_begin_callback_set([](void*) {
468 using v8::Function;
469 using v8::Undefined;
470 using v8::Isolate;
471
472 auto o = animator_custom_source_tick_begin_cb_data.handle();
473 Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
474 }, NULL);
475 };
476
477 global->Set(name,
478 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
479}
480
481void
482register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
483 v8::Handle<v8::Object>
484 global,
485 v8::Handle<v8::String>
486 name)
487{
488 using v8::FunctionCallbackInfo;
489 using v8::Value;
490 using v8::FunctionTemplate;
491
492 auto f = [](compatibility_callback_info_type args) {
493 if (args.Length() != 1 || !args[0]->IsFunction())
494 return compatibility_return();
495
496 efl::eina::js::global_ref<v8::Value>* data
497 = new efl::eina::js::global_ref<v8::Value>(args.GetIsolate(), args[0]);
498 ecore_animator_custom_source_tick_end_callback_set([](void* data) {
499 using v8::Function;
500 using v8::Undefined;
501 using v8::Isolate;
502
503 efl::eina::js::global_ref<v8::Value>*
504 d = static_cast<efl::eina::js::global_ref<v8::Value>*>(data);
505 auto o = d->handle();
506 Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
507 d->dispose();
508 delete d;
509 }, data);
510 };
511
512 global->Set(name,
513 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
514}
515
516void
517register_animator_custom_tick(v8::Isolate *isolate,
518 v8::Handle<v8::Object> global,
519 v8::Handle<v8::String> name)
520{
521 using v8::FunctionCallbackInfo;
522 using v8::Value;
523 using v8::FunctionTemplate;
524
525 auto f = [](compatibility_callback_info_type args) {
526 if (args.Length() != 0)
527 return compatibility_return();
528
529 ecore_animator_custom_tick();
530 };
531
532 global->Set(name,
533 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
534}
535
536void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
537 v8::Handle<v8::String> name)
538{
539 using v8::Local;
540 using v8::Value;
541 using v8::Undefined;
542 using v8::Function;
543 using v8::FunctionTemplate;
544
545 auto f = [](compatibility_callback_info_type args)
546 -> compatibility_return_type {
547 if (args.Length() != 1 || !args[0]->IsFunction())
548 return compatibility_return();
549
550 auto isolate = args.GetIsolate();
551 auto f = new efl::eina::js::global_ref<Value>(isolate, args[0]);
552
553 auto cb = [](void *data) -> Eina_Bool {
554 auto persistent = static_cast<efl::eina::js::global_ref<Value>*>(data);
555 auto o = persistent->handle();
556
557 auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
558 auto bret = ret->IsBoolean() && ret->BooleanValue();
559
560 if (!bret)
561 {
562 persistent->dispose();
563 delete persistent;
564 }
565
566 return bret ? EINA_TRUE : EINA_FALSE;
567 };
568
569 auto ret = ecore_animator_add(cb, f);
570 return compatibility_return(wrap_animator(ret, isolate), args);
571 };
572
573 global->Set(name,
574 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
575}
576
577void register_animator_timeline_add(v8::Isolate *isolate,
578 v8::Handle<v8::Object> global,
579 v8::Handle<v8::String> name)
580{
581 using v8::Handle;
582 using v8::Local;
583 using v8::Value;
584 using v8::Undefined;
585 using v8::Function;
586 using v8::FunctionTemplate;
587 using v8::Number;
588
589 auto f = [](compatibility_callback_info_type args)
590 -> compatibility_return_type {
591 if (args.Length() != 2 || !args[0]->IsNumber()
592 || !args[1]->IsFunction()) {
593 return compatibility_return();
594 }
595
596 auto f = new efl::eina::js::global_ref<Value>(args.GetIsolate(), args[1]);
597
598 auto cb = [](void *data, double pos) -> Eina_Bool {
599 auto persistent
600 = reinterpret_cast<efl::eina::js::global_ref<Value>*>(data);
601 auto o = persistent->handle();
602 auto isolate = v8::Isolate::GetCurrent();
603
604 Handle<Value> args = compatibility_new<Number>(isolate, pos);
605
606 auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
607 auto bret = ret->IsBoolean() && ret->BooleanValue();
608
609 if (!bret)
610 {
611 persistent->dispose();
612 delete persistent;
613 }
614
615 return bret ? EINA_TRUE : EINA_FALSE;
616 };
617
618 auto ret = ecore_animator_timeline_add(args[0]->NumberValue(), cb, f);
619 return compatibility_return(wrap_animator(ret, args.GetIsolate()),
620 args);
621 };
622
623 global->Set(name,
624 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
625}
626
627void register_ecore_animator(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
628{
629 register_pos_map_linear(isolate, exports,
630 compatibility_new<v8::String>(isolate,
631 "ECORE_POS_MAP_LINEAR"));
632 register_pos_map_accelerate(isolate, exports,
633 compatibility_new<v8::String>(isolate,
634 "ECORE_POS_MAP"
635 "_ACCELERATE"));
636 register_pos_map_decelerate(isolate, exports,
637 compatibility_new<v8::String>(isolate,
638 "ECORE_POS_MAP"
639 "_DECELERATE"));
640 register_pos_map_sinusoidal(isolate, exports,
641 compatibility_new<v8::String>(isolate,
642 "ECORE_POS_MAP"
643 "_SINUSOIDAL"));
644 register_pos_map_accelerate_factor(isolate, exports,
645 compatibility_new<v8::String>(isolate,
646 "ECORE_POS_MAP"
647 "_ACCELERATE"
648 "_FACTOR"));
649 register_pos_map_decelerate_factor(isolate, exports,
650 compatibility_new<v8::String>(isolate,
651 "ECORE_POS_MAP"
652 "_DECELERATE"
653 "_FACTOR"));
654 register_pos_map_sinusoidal_factor(isolate, exports,
655 compatibility_new<v8::String>(isolate,
656 "ECORE_POS_MAP"
657 "_SINUSOIDAL"
658 "_FACTOR"));
659 register_pos_map_divisor_interp(isolate, exports,
660 compatibility_new<v8::String>(isolate,
661 "ECORE_POS_MAP"
662 "_DIVISOR_INTERP"));
663 register_pos_map_bounce(isolate, exports,
664 compatibility_new<v8::String>(isolate,
665 "ECORE_POS_MAP_BOUNCE"));
666 register_pos_map_spring(isolate, exports,
667 compatibility_new<v8::String>(isolate,
668 "ECORE_POS_MAP_SPRING"));
669 register_pos_map_cubic_bezier(isolate, exports,
670 compatibility_new<v8::String>(isolate,
671 "ECORE_POS_MAP_CUBIC"
672 "_BEZIER"));
673 register_animator_source_timer(isolate, exports,
674 compatibility_new<v8::String>(isolate,
675 "ECORE_ANIMATOR"
676 "_SOURCE_TIMER"));
677 register_animator_source_custom(isolate, exports,
678 compatibility_new<v8::String>(isolate,
679 "ECORE_ANIMATOR"
680 "_SOURCE_CUSTOM"));
681 register_animator_frametime_set(isolate, exports,
682 compatibility_new<v8::String>(isolate,
683 "ecore_animator"
684 "_frametime_set"));
685 register_animator_frametime_get(isolate, exports,
686 compatibility_new<v8::String>(isolate,
687 "ecore_animator"
688 "_frametime_get"));
689 register_animator_pos_map(isolate, exports,
690 compatibility_new<v8::String>(isolate,
691 "ecore_animator_pos"
692 "_map"));
693 register_animator_pos_map_n(isolate, exports,
694 compatibility_new<v8::String>(isolate,
695 "ecore_animator_pos_map"
696 "_n"));
697 register_animator_source_set(isolate, exports,
698 compatibility_new<v8::String>(isolate,
699 "ecore_animator_source"
700 "_set"));
701 register_animator_source_get(isolate, exports,
702 compatibility_new<v8::String>(isolate,
703 "ecore_animator_source"
704 "_get"));
705 register_animator_custom_source_tick_begin_callback_set
706 (isolate, exports,
707 compatibility_new<v8::String>(isolate,
708 "ecore_animator_custom_source_tick_begin"
709 "_callback_set"));
710 register_animator_custom_source_tick_end_callback_set
711 (isolate, exports,
712 compatibility_new<v8::String>(isolate,
713 "ecore_animator_custom_source_tick_end"
714 "_callback_set"));
715 register_animator_custom_tick(isolate, exports,
716 compatibility_new<v8::String>(isolate,
717 "ecore_animator"
718 "_custom_tick"));
719 register_animator_add(isolate, exports,
720 compatibility_new<v8::String>(isolate,
721 "ecore_animator_add"));
722 register_animator_timeline_add(isolate, exports,
723 compatibility_new<v8::String>(isolate,
724 "ecore_animator"
725 "_timeline_add"));
726}
727
728} } } // 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 0000000..a086d98
--- /dev/null
+++ b/src/bindings/ecore_js/ecore_js_event.cc
@@ -0,0 +1,772 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <Ecore_Js.hh>
6
7namespace efl { namespace ecore { namespace js {
8
9static Ecore_Event *extract_event(v8::Local<v8::Object> object)
10{
11 return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0);
12}
13
14static v8::Local<v8::Object> wrap_event(Ecore_Event *event,
15 v8::Isolate *isolate)
16{
17 using v8::String;
18 using v8::ObjectTemplate;
19 using v8::FunctionTemplate;
20
21 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
22 obj_tpl->SetInternalFieldCount(1);
23 auto ret = obj_tpl->NewInstance();
24
25 auto del = [](compatibility_callback_info_type info)
26 -> compatibility_return_type {
27 if (info.Length() != 0)
28 return compatibility_return();
29
30 ecore_event_del(extract_event(info.This()));
31 return compatibility_return();
32 };
33
34 ret->Set(compatibility_new<String>(isolate, "del"),
35 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
36
37 compatibility_set_pointer_internal_field(ret, 0, event);
38
39 return ret;
40}
41
42static Ecore_Event_Handler *extract_event_handler(v8::Local<v8::Object> object)
43{
44 return compatibility_get_pointer_internal_field<Ecore_Event_Handler*>
45 (object, 0);
46}
47
48static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
49 v8::Isolate *isolate)
50{
51 using v8::String;
52 using v8::ObjectTemplate;
53 using v8::FunctionTemplate;
54 using v8::Value;
55
56 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
57 obj_tpl->SetInternalFieldCount(1);
58 auto ret = obj_tpl->NewInstance();
59
60 auto del = [](compatibility_callback_info_type info)
61 -> compatibility_return_type {
62 if (info.Length() != 0)
63 return compatibility_return();
64
65 auto p = ecore_event_handler_del(extract_event_handler(info.This()));
66
67 delete static_cast<efl::eina::js::global_ref<Value>*>(p);
68 return compatibility_return();
69 };
70
71 ret->Set(compatibility_new<String>(isolate, "del"),
72 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
73
74 compatibility_set_pointer_internal_field(ret, 0, handler);
75
76 return ret;
77}
78
79static Ecore_Event_Filter *extract_event_filter(v8::Local<v8::Object> object)
80{
81 return compatibility_get_pointer_internal_field<Ecore_Event_Filter*>
82 (object, 0);
83}
84
85static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
86 v8::Isolate *isolate)
87{
88 using v8::String;
89 using v8::ObjectTemplate;
90 using v8::FunctionTemplate;
91 using v8::Value;
92
93 auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
94 obj_tpl->SetInternalFieldCount(1);
95 auto ret = obj_tpl->NewInstance();
96
97 auto del = [](compatibility_callback_info_type info)
98 -> compatibility_return_type {
99 if (info.Length() != 0)
100 return compatibility_return();
101
102 auto p = ecore_event_filter_del(extract_event_filter(info.This()));
103 delete[] static_cast<efl::eina::js::global_ref<Value>*>(p);
104 return compatibility_return();
105 };
106
107 ret->Set(compatibility_new<String>(isolate, "del"),
108 compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
109
110 compatibility_set_pointer_internal_field(ret, 0, filter);
111
112 return ret;
113}
114
115EAPI
116void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
117 v8::Handle<v8::String> name)
118{
119 using v8::Integer;
120 global->Set(name,
121 compatibility_new<Integer>(isolate, ECORE_EVENT_NONE));
122}
123
124EAPI
125void register_event_signal_user(v8::Isolate *isolate,
126 v8::Handle<v8::Object> global,
127 v8::Handle<v8::String> name)
128{
129 using v8::Integer;
130 global->Set(name,
131 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_USER));
132}
133
134EAPI
135void register_event_signal_hup(v8::Isolate *isolate,
136 v8::Handle<v8::Object> global,
137 v8::Handle<v8::String> name)
138{
139 using v8::Integer;
140 global->Set(name,
141 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_HUP));
142}
143
144EAPI
145void register_event_signal_exit(v8::Isolate *isolate,
146 v8::Handle<v8::Object> global,
147 v8::Handle<v8::String> name)
148{
149 using v8::Integer;
150 global->Set(name,
151 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_EXIT));
152}
153
154EAPI
155void register_event_signal_power(v8::Isolate *isolate,
156 v8::Handle<v8::Object> global,
157 v8::Handle<v8::String> name)
158{
159 using v8::Integer;
160 global->Set(name,
161 compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_POWER));
162}
163
164EAPI
165void register_event_signal_realtime(v8::Isolate *isolate,
166 v8::Handle<v8::Object> global,
167 v8::Handle<v8::String> name)
168{
169 using v8::Integer;
170 global->Set(name,
171 compatibility_new<Integer>(isolate,
172 ECORE_EVENT_SIGNAL_REALTIME));
173}
174
175EAPI
176void register_event_memory_state(v8::Isolate *isolate,
177 v8::Handle<v8::Object> global,
178 v8::Handle<v8::String> name)
179{
180 using v8::Integer;
181 global->Set(name,
182 compatibility_new<Integer>(isolate, ECORE_EVENT_MEMORY_STATE));
183}
184
185EAPI
186void register_event_power_state(v8::Isolate *isolate,
187 v8::Handle<v8::Object> global,
188 v8::Handle<v8::String> name)
189{
190 using v8::Integer;
191 global->Set(name,
192 compatibility_new<Integer>(isolate, ECORE_EVENT_POWER_STATE));
193}
194
195EAPI
196void register_event_locale_changed(v8::Isolate *isolate,
197 v8::Handle<v8::Object> global,
198 v8::Handle<v8::String> name)
199{
200 using v8::Integer;
201 global->Set(name,
202 compatibility_new<Integer>(isolate,
203 ECORE_EVENT_LOCALE_CHANGED));
204}
205
206EAPI
207void register_event_hostname_changed(v8::Isolate *isolate,
208 v8::Handle<v8::Object> global,
209 v8::Handle<v8::String> name)
210{
211 using v8::Integer;