forked from enlightenment/efl
Compare commits
103 Commits
master
...
devs/felip
Author | SHA1 | Date |
---|---|---|
|
85d01fba6d | |
|
f6a72df9d0 | |
|
dc48039197 | |
|
1f5fadd9d5 | |
|
ebe77260c5 | |
|
b299a3489e | |
|
af229750c5 | |
|
ab5a140691 | |
|
5de5e8f9f8 | |
|
77ffb055a1 | |
|
3d28180ead | |
|
cf2db774b3 | |
|
5b40e6a637 | |
|
052d691232 | |
|
09265accc2 | |
|
8d2fc96d1e | |
|
fe5508a40d | |
|
6f53186765 | |
|
d44cf0f62f | |
|
fca3e3aac0 | |
|
2200d9b5ba | |
|
9857af34dd | |
|
53fb6585c2 | |
|
b9a4f79d76 | |
|
36c21bfb76 | |
|
70a523e297 | |
|
5f77d8639a | |
|
d59ec44336 | |
|
5ce444d4ce | |
|
48f7ed1115 | |
|
94a8a95710 | |
|
e3d4c7fb1e | |
|
0167274e44 | |
|
7a262ec083 | |
|
b2da868a83 | |
|
ecd24069cc | |
|
1d4145c273 | |
|
9f8624603d | |
|
5b3f2e5bb2 | |
|
60062b90bd | |
|
2e2417259a | |
|
ead4804b3b | |
|
4ca7763f60 | |
|
83cc60e9c2 | |
|
a090a65bb3 | |
|
c892457bc1 | |
|
9c21c73672 | |
|
c1d3adfc6e | |
|
583b069c5b | |
|
ebd3514937 | |
|
d9c64b3697 | |
|
5c59f25b21 | |
|
c9f40600f0 | |
|
e7003affa2 | |
|
f250ae0c47 | |
|
8412ec8918 | |
|
5c9ffed096 | |
|
9065b4bed8 | |
|
fcfe91bcb2 | |
|
391ebe306f | |
|
df7028f3f5 | |
|
173db82492 | |
|
ae3da5f067 | |
|
fd8c21d21a | |
|
b2263d470d | |
|
a13a35b9ce | |
|
3cd6638e0b | |
|
8b3f57f9ea | |
|
4e44165491 | |
|
ce3ff90020 | |
|
2852bdb497 | |
|
b2457defec | |
|
eeb0215e23 | |
|
71b8b69063 | |
|
7e8d225b66 | |
|
0be5f1aa49 | |
|
182bb33b42 | |
|
bf6f9bc140 | |
|
6f3c04593a | |
|
b09976f264 | |
|
5ab6abe46d | |
|
8210197b3a | |
|
a79d923579 | |
|
e43e1a94bf | |
|
a5d3406a11 | |
|
92681d602f | |
|
70388ed73a | |
|
aa82a2ebe8 | |
|
67b9a61caf | |
|
4c0dcfc48a | |
|
d0f80c915a | |
|
47599c43f3 | |
|
8ed4544bbc | |
|
a702e88b53 | |
|
e6c88332a1 | |
|
80baff5952 | |
|
ab4c0df702 | |
|
60163a557f | |
|
ded3a76084 | |
|
9af366b1df | |
|
1ac7705e55 | |
|
183547b0ff | |
|
b151da61ae |
|
@ -32,6 +32,7 @@ tags
|
||||||
*.eo.h
|
*.eo.h
|
||||||
*.eo.legacy.h
|
*.eo.legacy.h
|
||||||
*.eo.hh
|
*.eo.hh
|
||||||
|
*.eo.js.cc
|
||||||
*.eo.lua
|
*.eo.lua
|
||||||
.dir-locals.el
|
.dir-locals.el
|
||||||
/efl-*-doc.tar.bz2
|
/efl-*-doc.tar.bz2
|
||||||
|
|
|
@ -163,6 +163,13 @@ pc/eet-cxx.pc \
|
||||||
pc/eo-cxx.pc
|
pc/eo-cxx.pc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if HAVE_JS
|
||||||
|
pkgconfig_DATA += \
|
||||||
|
pc/eolian-js.pc \
|
||||||
|
pc/eo-js.pc \
|
||||||
|
pc/eina-js.pc
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_ENGINE_SOFTWARE_X11
|
if BUILD_ENGINE_SOFTWARE_X11
|
||||||
pkgconfig_DATA += pc/evas-software-x11.pc
|
pkgconfig_DATA += pc/evas-software-x11.pc
|
||||||
endif
|
endif
|
||||||
|
|
228
configure.ac
228
configure.ac
|
@ -999,6 +999,185 @@ EFL_EVAL_PKGS([EINA_CXX])
|
||||||
EFL_LIB_END([Eina_Cxx])
|
EFL_LIB_END([Eina_Cxx])
|
||||||
#### End of Eina CXX
|
#### End of Eina CXX
|
||||||
|
|
||||||
|
AC_ARG_WITH([js],
|
||||||
|
[AS_HELP_STRING([--with-js=@<:@nodejs/libv8/libuv/none@:>@],[enable JavaScript bindings using nodejs or libv8/libuv as build dependencies. The libuv option implies libv8. @<:@default=none@:>@])],
|
||||||
|
[want_js="${withval}"], [want_js="none"])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_NODEJS], [test "x${want_js}" = "xnodejs"])
|
||||||
|
AC_DEFINE_IF([HAVE_NODEJS], [test "x${want_js}" = "xnodejs"],
|
||||||
|
[1], [Using NodeJS])
|
||||||
|
AC_SUBST([want_js])
|
||||||
|
AC_SUBST([HAVE_NODEJS])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_JS], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibv8" -o "x${want_js}" = "xlibuv"])
|
||||||
|
AC_DEFINE_IF([HAVE_JS], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibv8" -o "x${want_js}" = "xlibuv"],
|
||||||
|
[1], [Compiling bindings for JavaScript])
|
||||||
|
AC_SUBST([HAVE_JS])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_LIBUV], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibuv"])
|
||||||
|
AC_DEFINE_IF([HAVE_LIBUV], [test "x${want_js}" = "xnodejs" -o "x${want_js}" = "xlibuv"],
|
||||||
|
[1], [Compiling libuv event loop integration])
|
||||||
|
AC_SUBST([HAVE_LIBUV])
|
||||||
|
|
||||||
|
#### Eina JS
|
||||||
|
EFL_LIB_START([Eina_Js])
|
||||||
|
|
||||||
|
AC_LANG_PUSH([C++])
|
||||||
|
case "$want_js" in
|
||||||
|
nodejs)
|
||||||
|
AC_CHECK_HEADER([node/v8.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], [node/v8.h], [Include header for libv8])
|
||||||
|
AC_DEFINE_UNQUOTED([NODE_INCLUDE_HEADER], [node/node.h], [Include header for nodejs])
|
||||||
|
V8_INCLUDE_HEADER=node/v8.h
|
||||||
|
NODE_INCLUDE_HEADER=node/node.h
|
||||||
|
AC_SUBST([V8_INCLUDE_HEADER])
|
||||||
|
AC_SUBST([NODE_INCLUDE_HEADER])
|
||||||
|
|
||||||
|
AC_CHECK_HEADER([node/uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [node/uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=node/uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_CHECK_HEADER([uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([Could not find include headers from nodejs.])]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_CHECK_HEADER([nodejs/deps/v8/v8.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], [nodejs/deps/v8/v8.h], [Include header for libv8])
|
||||||
|
AC_DEFINE_UNQUOTED([NODE_INCLUDE_HEADER], [nodejs/src/node.h], [Include header for nodejs])
|
||||||
|
V8_INCLUDE_HEADER=node/deps/v8/v8.h
|
||||||
|
NODE_INCLUDE_HEADER=nodejs/src/node.h
|
||||||
|
AC_SUBST([V8_INCLUDE_HEADER])
|
||||||
|
AC_SUBST([NODE_INCLUDE_HEADER])
|
||||||
|
|
||||||
|
AC_CHECK_HEADER([nodejs/deps/uv/uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [nodejs/deps/uv/uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=node/deps/uv/uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_CHECK_HEADER([uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([Could not find include headers from nodejs.])]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_CHECK_HEADER([nodejs/deps/v8/include/v8.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], [nodejs/deps/v8/include/v8.h], [Include header for libv8])
|
||||||
|
AC_DEFINE_UNQUOTED([NODE_INCLUDE_HEADER], [nodejs/src/node.h], [Include header for nodejs])
|
||||||
|
V8_INCLUDE_HEADER=nodejs/deps/v8/include/v8.h
|
||||||
|
NODE_INCLUDE_HEADER=nodejs/src/node.h
|
||||||
|
AC_SUBST([V8_INCLUDE_HEADER])
|
||||||
|
AC_SUBST([NODE_INCLUDE_HEADER])
|
||||||
|
|
||||||
|
AC_CHECK_HEADER([nodejs/deps/uv/include/uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [nodejs/deps/uv/include/uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=node/deps/uv/include/uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
AC_CHECK_HEADER([uv.h],
|
||||||
|
[
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [uv.h], [Include header for libuv])
|
||||||
|
UV_INCLUDE_HEADER=uv.h
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([Could not find include headers from nodejs.])]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([Could not find include headers from nodejs.])]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
])
|
||||||
|
;;
|
||||||
|
libv8)
|
||||||
|
EFL_DEPEND_PKG([EINA_JS], [V8], [v8 >= 3.25.28])
|
||||||
|
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], [v8.h], [Include header for libv8])
|
||||||
|
V8_INCLUDE_HEADER=v8.h
|
||||||
|
UV_INCLUDE_HEADER=
|
||||||
|
AC_SUBST([V8_INCLUDE_HEADER])
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
;;
|
||||||
|
libuv)
|
||||||
|
EFL_DEPEND_PKG([EINA_JS], [V8], [v8 >= 3.25.28])
|
||||||
|
EFL_DEPEND_PKG([EINA_JS], [UV], [v8 >= 1.1.0])
|
||||||
|
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], [v8.h], [Include header for libv8])
|
||||||
|
AC_DEFINE_UNQUOTED([UV_INCLUDE_HEADER], [uv.h], [Include header for libuv])
|
||||||
|
V8_INCLUDE_HEADER=v8.h
|
||||||
|
UV_INCLUDE_HEADER=uv.h
|
||||||
|
AC_SUBST([V8_INCLUDE_HEADER])
|
||||||
|
AC_SUBST([UV_INCLUDE_HEADER])
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
;;
|
||||||
|
*) AC_MSG_ERROR([Invalid javascript dependency (${want_js}): must be none, nodejs, libv8 or libuv]) ;;
|
||||||
|
esac
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EINA_JS], [eina])
|
||||||
|
EFL_ADD_CFLAGS([EINA_JS], [${EFL_PTHREAD_CFLAGS}])
|
||||||
|
EFL_EVAL_PKGS([EINA_JS])
|
||||||
|
|
||||||
|
EFL_LIB_END([Eina_Js])
|
||||||
|
#### End of Eina JS
|
||||||
|
|
||||||
|
#### Ecore JS
|
||||||
|
EFL_LIB_START([Ecore_Js])
|
||||||
|
|
||||||
|
AC_LANG_PUSH([C++])
|
||||||
|
case "$want_js" in
|
||||||
|
nodejs)
|
||||||
|
;;
|
||||||
|
libv8)
|
||||||
|
EFL_DEPEND_PKG([ECORE_JS], [V8], [v8 >= 3.25.28])
|
||||||
|
;;
|
||||||
|
libuv)
|
||||||
|
EFL_DEPEND_PKG([ECORE_JS], [V8], [v8 >= 3.25.28])
|
||||||
|
EFL_DEPEND_PKG([ECORE_JS], [UV], [v8 >= 1.1.0])
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
;;
|
||||||
|
*) AC_MSG_ERROR([Invalid javascript dependency (${want_js}): must be none, nodejs, libv8 or libuv]) ;;
|
||||||
|
esac
|
||||||
|
AC_LANG_POP([C++])
|
||||||
|
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ECORE_JS], [ecore])
|
||||||
|
EFL_ADD_CFLAGS([ECORE_JS], [${EFL_PTHREAD_CFLAGS}])
|
||||||
|
EFL_EVAL_PKGS([ECORE_JS])
|
||||||
|
|
||||||
|
EFL_LIB_END([Ecore_Js])
|
||||||
|
#### End of Ecore JS
|
||||||
|
|
||||||
|
#### Eina JS
|
||||||
|
EFL_LIB_START([Eo_Js])
|
||||||
|
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EO_JS], [eina])
|
||||||
|
EFL_ADD_CFLAGS([EO_JS], [${EFL_PTHREAD_CFLAGS}])
|
||||||
|
EFL_EVAL_PKGS([EO_JS])
|
||||||
|
|
||||||
|
EFL_LIB_END([Eo_Js])
|
||||||
|
#### End of Eina JS
|
||||||
|
|
||||||
#### Eet
|
#### Eet
|
||||||
|
|
||||||
EFL_LIB_START([Eet])
|
EFL_LIB_START([Eet])
|
||||||
|
@ -1139,6 +1318,38 @@ EFL_INTERNAL_DEPEND_PKG([EOLIAN], [eina])
|
||||||
EFL_LIB_END([Eolian])
|
EFL_LIB_END([Eolian])
|
||||||
#### End of Eolian
|
#### End of Eolian
|
||||||
|
|
||||||
|
EFL_LIB_START([Eolian_Js])
|
||||||
|
|
||||||
|
### Default values
|
||||||
|
|
||||||
|
### Additional options to configure
|
||||||
|
#EFL_ADD_FEATURE([EOLIAN_JS], [cxx], [${have_cxx11}])
|
||||||
|
#EFL_DEPEND_PKG([EOLIAN_JS], [V8], [v8 >= 3.25.28])
|
||||||
|
|
||||||
|
### Checks for programs
|
||||||
|
|
||||||
|
### Checks for libraries
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EOLIAN_JS], [eina])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([EOLIAN_JS], [EINA_JS])
|
||||||
|
|
||||||
|
### Checks for header files
|
||||||
|
|
||||||
|
### Checks for types
|
||||||
|
|
||||||
|
### Checks for structures
|
||||||
|
|
||||||
|
### Checks for compiler characteristics
|
||||||
|
|
||||||
|
### Checks for linker characteristics
|
||||||
|
|
||||||
|
### Checks for library functions
|
||||||
|
|
||||||
|
### Check availability
|
||||||
|
|
||||||
|
EFL_LIB_END([Eolian_Js])
|
||||||
|
#### End of Eolian
|
||||||
|
|
||||||
|
|
||||||
EFL_LIB_START([Eolian_Cxx])
|
EFL_LIB_START([Eolian_Cxx])
|
||||||
### Default values
|
### Default values
|
||||||
|
|
||||||
|
@ -2181,6 +2392,17 @@ AC_ARG_ENABLE([g-main-loop],
|
||||||
fi
|
fi
|
||||||
],
|
],
|
||||||
[want_g_main_loop="no"])
|
[want_g_main_loop="no"])
|
||||||
|
AC_ARG_ENABLE([libuv],
|
||||||
|
[AS_HELP_STRING([--enable-libuv],[enable ecore_main_loop based on libuv. @<:@default=disabled@:>@])],
|
||||||
|
[
|
||||||
|
if test "x${enableval}" = "xyes" ; then
|
||||||
|
want_libuv="yes"
|
||||||
|
CFOPT_WARNING="xyes"
|
||||||
|
else
|
||||||
|
want_libuv="no"
|
||||||
|
fi
|
||||||
|
],
|
||||||
|
[want_libuv="no"])
|
||||||
|
|
||||||
AC_ARG_ENABLE([gstreamer],
|
AC_ARG_ENABLE([gstreamer],
|
||||||
[AS_HELP_STRING([--enable-gstreamer],[enable gstreamer 0.10 support. @<:@default=disabled@:>@])],
|
[AS_HELP_STRING([--enable-gstreamer],[enable gstreamer 0.10 support. @<:@default=disabled@:>@])],
|
||||||
|
@ -2272,6 +2494,7 @@ EFL_OPTIONAL_DEPEND_PKG([ECORE], [${want_systemd}], [SYSTEMD], [libsystemd-daemo
|
||||||
EFL_ADD_FEATURE([ECORE], [systemd-daemon], [${want_systemd}])
|
EFL_ADD_FEATURE([ECORE], [systemd-daemon], [${want_systemd}])
|
||||||
EFL_ADD_FEATURE([ECORE], [glib])
|
EFL_ADD_FEATURE([ECORE], [glib])
|
||||||
EFL_ADD_FEATURE([ECORE], [g-main-loop])
|
EFL_ADD_FEATURE([ECORE], [g-main-loop])
|
||||||
|
EFL_ADD_FEATURE([ECORE], [libuv])
|
||||||
|
|
||||||
want_glib_integration_always=no
|
want_glib_integration_always=no
|
||||||
if test "x${with_glib}" = "xalways" ; then
|
if test "x${with_glib}" = "xalways" ; then
|
||||||
|
@ -4505,6 +4728,9 @@ pc/eo.pc
|
||||||
pc/eo-cxx.pc
|
pc/eo-cxx.pc
|
||||||
pc/eolian.pc
|
pc/eolian.pc
|
||||||
pc/eolian-cxx.pc
|
pc/eolian-cxx.pc
|
||||||
|
pc/eina-js.pc
|
||||||
|
pc/eolian-js.pc
|
||||||
|
pc/eo-js.pc
|
||||||
pc/efl.pc
|
pc/efl.pc
|
||||||
pc/efl-cxx.pc
|
pc/efl-cxx.pc
|
||||||
pc/evas-fb.pc
|
pc/evas-fb.pc
|
||||||
|
@ -4672,6 +4898,8 @@ echo " Cryptography..: ${build_crypto}"
|
||||||
echo " X11...........: ${with_x11}"
|
echo " X11...........: ${with_x11}"
|
||||||
echo " OpenGL........: ${with_opengl}"
|
echo " OpenGL........: ${with_opengl}"
|
||||||
echo " C++11.........: ${have_cxx11}"
|
echo " C++11.........: ${have_cxx11}"
|
||||||
|
echo " JavaScript....: ${want_js}"
|
||||||
|
echo " JavaScript flg: $EINA_JS_LIBS"
|
||||||
echo " GUI libs......: ${build_gui}"
|
echo " GUI libs......: ${build_gui}"
|
||||||
echo "Evas............: ${efl_lib_optional_evas} (${features_evas})"
|
echo "Evas............: ${efl_lib_optional_evas} (${features_evas})"
|
||||||
echo " Engines.......: ${features_evas_engine}"
|
echo " Engines.......: ${features_evas_engine}"
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
/efreet.pc
|
/efreet.pc
|
||||||
/eina.pc
|
/eina.pc
|
||||||
/eina-cxx.pc
|
/eina-cxx.pc
|
||||||
|
/eina-js.pc
|
||||||
/eet-cxx.pc
|
/eet-cxx.pc
|
||||||
/eio.pc
|
/eio.pc
|
||||||
/eldbus.pc
|
/eldbus.pc
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
/embryo.pc
|
/embryo.pc
|
||||||
/emotion.pc
|
/emotion.pc
|
||||||
/eo.pc
|
/eo.pc
|
||||||
|
/eo-js.pc
|
||||||
/ephysics.pc
|
/ephysics.pc
|
||||||
/escape.pc
|
/escape.pc
|
||||||
/ethumb.pc
|
/ethumb.pc
|
||||||
|
@ -53,6 +55,7 @@
|
||||||
/evil.pc
|
/evil.pc
|
||||||
/eolian.pc
|
/eolian.pc
|
||||||
/eolian-cxx.pc
|
/eolian-cxx.pc
|
||||||
|
/eolian-js.pc
|
||||||
/eo-cxx.pc
|
/eo-cxx.pc
|
||||||
/evas-cxx.pc
|
/evas-cxx.pc
|
||||||
/ecore-cxx.pc
|
/ecore-cxx.pc
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
datarootdir=@datarootdir@
|
||||||
|
datadir=@datadir@
|
||||||
|
want_js=@want_js@
|
||||||
|
|
||||||
|
Name: Eina JavaScript
|
||||||
|
Description: JavaScript C++ helpers for data structures
|
||||||
|
Version: @PACKAGE_VERSION@
|
||||||
|
Requires.private: @requirements_pc_eina@
|
||||||
|
Libs.private: @requirements_libs_eina@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-js-@VMAJ@ -DV8_INCLUDE_HEADER='@V8_INCLUDE_HEADER@' -DUV_INCLUDE_HEADER='@UV_INCLUDE_HEADER@' -DNODE_INCLUDE_HEADER='@NODE_INCLUDE_HEADER@'
|
|
@ -0,0 +1,15 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
datarootdir=@datarootdir@
|
||||||
|
datadir=@datadir@
|
||||||
|
eoincludedir=@datadir@/eolian/include
|
||||||
|
eolian_flags=-I${eoincludedir}/eo-@VMAJ@
|
||||||
|
|
||||||
|
Name: Eo JavaScript
|
||||||
|
Description: JavaScript C++ helpers for bindings for EFL's generic object system.
|
||||||
|
Version: @PACKAGE_VERSION@
|
||||||
|
Requires.private: @requirements_pc_eo@
|
||||||
|
Libs.private: @requirements_libs_eo@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/eo-js-@VMAJ@
|
|
@ -0,0 +1,14 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
datarootdir=@datarootdir@
|
||||||
|
datadir=@datadir@
|
||||||
|
|
||||||
|
Name: Eolian-JS
|
||||||
|
Description: EFL's JavaScript bindings generator.
|
||||||
|
Version: @VERSION@
|
||||||
|
Require.private: @requirements_pc_eolian@
|
||||||
|
Libs: -L${libdir}
|
||||||
|
Libs.private: @requirements_libs_eolian@
|
||||||
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eolian-js-@VMAJ@
|
|
@ -13,4 +13,4 @@ Requires.private: @requirements_pc_evas@
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Libs: -L${libdir} -levas
|
Libs: -L${libdir} -levas
|
||||||
Libs.private: @requirements_libs_evas@
|
Libs.private: @requirements_libs_evas@
|
||||||
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/evas-@VMAJ@
|
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/evas-@VMAJ@ -I${includedir}/evas-@VMAJ@/canvas
|
||||||
|
|
|
@ -78,6 +78,13 @@ include Makefile_Eolian_Cxx.am
|
||||||
include Makefile_Eet_Cxx.am
|
include Makefile_Eet_Cxx.am
|
||||||
include Makefile_Eo_Cxx.am
|
include Makefile_Eo_Cxx.am
|
||||||
include Makefile_Efl_Cxx.am
|
include Makefile_Efl_Cxx.am
|
||||||
|
|
||||||
|
include Makefile_Eina_Js.am
|
||||||
|
include Makefile_Ecore_Js.am
|
||||||
|
include Makefile_Eo_Js.am
|
||||||
|
include Makefile_Evas_Js.am
|
||||||
|
include Makefile_Eolian_Js.am
|
||||||
|
|
||||||
include Makefile_Elua.am
|
include Makefile_Elua.am
|
||||||
include Makefile_Elocation.am
|
include Makefile_Elocation.am
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
|
||||||
|
### Library
|
||||||
|
|
||||||
|
if HAVE_JS
|
||||||
|
lib_LTLIBRARIES += lib/ecore_js/libecore_js.la
|
||||||
|
|
||||||
|
lib_ecore_js_libecore_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
@EINA_JS_CFLAGS@ \
|
||||||
|
@EINA_CXX_CFLAGS@ \
|
||||||
|
@ECORE_CXX_CFLAGS@ \
|
||||||
|
@EO_CXX_CFLAGS@ \
|
||||||
|
@EO_CFLAGS@ \
|
||||||
|
@ECORE_JS_CFLAGS@ \
|
||||||
|
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||||
|
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||||
|
-DPACKAGE_DATA_DIR=\"$(datadir)/ecore_js\" \
|
||||||
|
@VALGRIND_CFLAGS@
|
||||||
|
|
||||||
|
lib_ecore_js_libecore_js_la_LIBADD = @ECORE_LIBS@ @DL_LIBS@ @ECORE_JS_LIBS@
|
||||||
|
lib_ecore_js_libecore_js_la_DEPENDENCIES = @ECORE_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@ @ECORE_JS_INTERNAL_LIBS@
|
||||||
|
lib_ecore_js_libecore_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
lib_ecore_js_libecore_js_la_SOURCES = \
|
||||||
|
bindings/ecore_js/ecore_js_init.cc \
|
||||||
|
bindings/ecore_js/ecore_js_mainloop.cc \
|
||||||
|
bindings/ecore_js/ecore_js_timer.cc \
|
||||||
|
bindings/ecore_js/ecore_js_event.cc \
|
||||||
|
bindings/ecore_js/ecore_js_job.cc \
|
||||||
|
bindings/ecore_js/ecore_js_idle.cc \
|
||||||
|
bindings/ecore_js/ecore_js_animator.cc \
|
||||||
|
bindings/ecore_js/ecore_js_poller.cc \
|
||||||
|
bindings/ecore_js/ecore_js_throttle.cc
|
||||||
|
|
||||||
|
ECORE_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_WD=\"`pwd`\" \
|
||||||
|
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ecore_js\" \
|
||||||
|
-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/ecore_js\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/ecore_js\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@EINA_JS_CFLAGS@ \
|
||||||
|
@EINA_CXX_CFLAGS@ \
|
||||||
|
@ECORE_CXX_CFLAGS@ \
|
||||||
|
@EO_CXX_CFLAGS@ \
|
||||||
|
@EO_CFLAGS@ \
|
||||||
|
@ECORE_JS_CFLAGS@
|
||||||
|
|
||||||
|
installed_ecorejsheadersdir = $(includedir)/ecore-js-@VMAJ@
|
||||||
|
dist_installed_ecorejsheaders_DATA = \
|
||||||
|
bindings/ecore_js/ecore_js_init.hh \
|
||||||
|
bindings/ecore_js/ecore_js_mainloop.hh \
|
||||||
|
bindings/ecore_js/ecore_js_timer.hh \
|
||||||
|
bindings/ecore_js/ecore_js_event.hh \
|
||||||
|
bindings/ecore_js/ecore_js_job.hh \
|
||||||
|
bindings/ecore_js/ecore_js_idle.hh \
|
||||||
|
bindings/ecore_js/ecore_js_animator.hh \
|
||||||
|
bindings/ecore_js/ecore_js_poller.hh \
|
||||||
|
bindings/ecore_js/ecore_js_throttle.hh
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
if HAVE_NODEJS
|
||||||
|
AM_TESTS_ENVIRONMENT = NODE_PATH='$(abs_builddir)/tests/ecore_js'; export NODE_PATH;
|
||||||
|
|
||||||
|
TESTS += tests/ecore_js/ecore_js_suite.js
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += tests/ecore_js/libecore_js_suite.la
|
||||||
|
|
||||||
|
tests/ecore_js/ecore_js_suite.js: tests/ecore_js/ecore_js_suite_mod.node
|
||||||
|
|
||||||
|
AM_V_CP = $(am__v_CP_@AM_V@)
|
||||||
|
am__v_CP_ = $(am__v_CP_@AM_DEFAULT_V@)
|
||||||
|
am__v_CP_0 = @echo " CP " $@;
|
||||||
|
|
||||||
|
CP = cp
|
||||||
|
|
||||||
|
tests/ecore_js/ecore_js_suite_mod.node: $(top_builddir)/src/tests/ecore_js/libecore_js_suite.la
|
||||||
|
$(AM_V_CP)$(CP) $(top_builddir)/src/tests/ecore_js/.libs/libecore_js_suite.so $(top_builddir)/src/tests/ecore_js/ecore_js_suite_mod.node
|
||||||
|
|
||||||
|
tests_ecore_js_libecore_js_suite_la_SOURCES = \
|
||||||
|
tests/ecore_js/ecore_js_suite.cc
|
||||||
|
|
||||||
|
tests_ecore_js_libecore_js_suite_la_CXXFLAGS = $(ECORE_JS_TEST_CXXFLAGS)
|
||||||
|
tests_ecore_js_libecore_js_suite_la_LIBADD = \
|
||||||
|
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_ECORE_LIBS@ @USE_EOLIAN_LIBS@ @USE_ECORE_JS_LIBS@
|
||||||
|
tests_ecore_js_libecore_js_suite_la_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@ @USE_ECORE_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
else
|
||||||
|
check_PROGRAMS += tests/ecore_js/ecore_js_suite
|
||||||
|
TESTS += tests/ecore_js/ecore_js_suite
|
||||||
|
|
||||||
|
tests_ecore_js_ecore_js_suite_SOURCES = \
|
||||||
|
tests/ecore_js/ecore_js_suite.cc
|
||||||
|
|
||||||
|
tests_ecore_js_ecore_js_suite_CXXFLAGS = $(ECORE_JS_TEST_CXXFLAGS)
|
||||||
|
tests_ecore_js_ecore_js_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_ECORE_LIBS@ @USE_EOLIAN_LIBS@ @USE_ECORE_JS_LIBS@ @ECORE_JS_LIBS@
|
||||||
|
tests_ecore_js_ecore_js_suite_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@ @USE_ECORE_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ tests/ecore_js/ecore_js_suite.js
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
|
@ -14,6 +14,7 @@ bindings/eina_cxx/eina_clone_allocators.hh \
|
||||||
bindings/eina_cxx/eina_error.hh \
|
bindings/eina_cxx/eina_error.hh \
|
||||||
bindings/eina_cxx/eina_eo_base_fwd.hh \
|
bindings/eina_cxx/eina_eo_base_fwd.hh \
|
||||||
bindings/eina_cxx/eina_fold.hh \
|
bindings/eina_cxx/eina_fold.hh \
|
||||||
|
bindings/eina_cxx/eina_function.hh \
|
||||||
bindings/eina_cxx/eina_inarray.hh \
|
bindings/eina_cxx/eina_inarray.hh \
|
||||||
bindings/eina_cxx/eina_inlist.hh \
|
bindings/eina_cxx/eina_inlist.hh \
|
||||||
bindings/eina_cxx/eina_integer_sequence.hh \
|
bindings/eina_cxx/eina_integer_sequence.hh \
|
||||||
|
@ -21,7 +22,9 @@ bindings/eina_cxx/eina_iterator.hh \
|
||||||
bindings/eina_cxx/eina_lists_auxiliary.hh \
|
bindings/eina_cxx/eina_lists_auxiliary.hh \
|
||||||
bindings/eina_cxx/eina_list.hh \
|
bindings/eina_cxx/eina_list.hh \
|
||||||
bindings/eina_cxx/eina_log.hh \
|
bindings/eina_cxx/eina_log.hh \
|
||||||
|
bindings/eina_cxx/eina_logical.hh \
|
||||||
bindings/eina_cxx/eina_optional.hh \
|
bindings/eina_cxx/eina_optional.hh \
|
||||||
|
bindings/eina_cxx/eina_pp.hh \
|
||||||
bindings/eina_cxx/eina_ptrarray.hh \
|
bindings/eina_cxx/eina_ptrarray.hh \
|
||||||
bindings/eina_cxx/eina_ptrlist.hh \
|
bindings/eina_cxx/eina_ptrlist.hh \
|
||||||
bindings/eina_cxx/eina_range_types.hh \
|
bindings/eina_cxx/eina_range_types.hh \
|
||||||
|
@ -30,6 +33,7 @@ bindings/eina_cxx/eina_stringshare.hh \
|
||||||
bindings/eina_cxx/eina_thread.hh \
|
bindings/eina_cxx/eina_thread.hh \
|
||||||
bindings/eina_cxx/eina_throw.hh \
|
bindings/eina_cxx/eina_throw.hh \
|
||||||
bindings/eina_cxx/eina_tuple.hh \
|
bindings/eina_cxx/eina_tuple.hh \
|
||||||
|
bindings/eina_cxx/eina_tuple_c.hh \
|
||||||
bindings/eina_cxx/eina_tuple_unwrap.hh \
|
bindings/eina_cxx/eina_tuple_unwrap.hh \
|
||||||
bindings/eina_cxx/eina_type_traits.hh \
|
bindings/eina_cxx/eina_type_traits.hh \
|
||||||
bindings/eina_cxx/eina_value.hh
|
bindings/eina_cxx/eina_value.hh
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
### Library
|
||||||
|
|
||||||
|
if HAVE_JS
|
||||||
|
lib_LTLIBRARIES += lib/eina_js/libeina_js.la
|
||||||
|
|
||||||
|
lib_eina_js_libeina_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
@EINA_CXX_CFLAGS@ \
|
||||||
|
@EO_CXX_CFLAGS@ \
|
||||||
|
@EO_CFLAGS@ \
|
||||||
|
@EINA_JS_CFLAGS@ \
|
||||||
|
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||||
|
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||||
|
-DPACKAGE_DATA_DIR=\"$(datadir)/eina_js\" \
|
||||||
|
@VALGRIND_CFLAGS@
|
||||||
|
|
||||||
|
lib_eina_js_libeina_js_la_LIBADD = @EINA_LIBS@ @DL_LIBS@ @EINA_JS_LIBS@
|
||||||
|
lib_eina_js_libeina_js_la_DEPENDENCIES = @EINA_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@ @EINA_JS_INTERNAL_LIBS@
|
||||||
|
lib_eina_js_libeina_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
lib_eina_js_libeina_js_la_SOURCES = \
|
||||||
|
bindings/eina_js/eina_js_container.cc \
|
||||||
|
bindings/eina_js/eina_js_value.cc \
|
||||||
|
bindings/eina_js/eina_js_error.cc \
|
||||||
|
bindings/eina_js/eina_js_accessor.cc \
|
||||||
|
bindings/eina_js/eina_js_log.cc \
|
||||||
|
bindings/eina_js/eina_js_iterator.cc
|
||||||
|
|
||||||
|
EINA_JS_TEST_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DTESTS_WD=\"`pwd`\" \
|
||||||
|
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eina_js\" \
|
||||||
|
-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eina_js\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eina_js\" \
|
||||||
|
@CHECK_CFLAGS@ \
|
||||||
|
@EINA_CXX_CFLAGS@ \
|
||||||
|
@EO_CXX_CFLAGS@ \
|
||||||
|
@EO_CFLAGS@ \
|
||||||
|
@EINA_JS_CFLAGS@
|
||||||
|
|
||||||
|
installed_einajsheadersdir = $(includedir)/eina-js-@VMAJ@
|
||||||
|
dist_installed_einajsheaders_DATA = \
|
||||||
|
bindings/eina_js/eina_js_accessor.hh \
|
||||||
|
bindings/eina_js/eina_js_array.hh \
|
||||||
|
bindings/eina_js/eina_js_compatibility.hh \
|
||||||
|
bindings/eina_js/eina_js_container.hh \
|
||||||
|
bindings/eina_js/eina_js_error.hh \
|
||||||
|
bindings/eina_js/eina_js_get_value_from_c.hh \
|
||||||
|
bindings/eina_js/eina_js_get_value.hh \
|
||||||
|
bindings/eina_js/eina_js_iterator.hh \
|
||||||
|
bindings/eina_js/eina_js_list.hh \
|
||||||
|
bindings/eina_js/eina_js_log.hh \
|
||||||
|
bindings/eina_js/eina_js_value.hh
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
if HAVE_NODEJS
|
||||||
|
AM_TESTS_ENVIRONMENT = NODE_PATH='$(abs_builddir)/tests/eina_js'; export NODE_PATH;
|
||||||
|
|
||||||
|
TESTS += tests/eina_js/eina_js_suite.js
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += tests/eina_js/libeina_js_suite.la
|
||||||
|
|
||||||
|
tests/eina_js/eina_js_suite.js: tests/eina_js/eina_js_suite_mod.node
|
||||||
|
|
||||||
|
AM_V_CP = $(am__v_CP_@AM_V@)
|
||||||
|
am__v_CP_ = $(am__v_CP_@AM_DEFAULT_V@)
|
||||||
|
am__v_CP_0 = @echo " CP " $@;
|
||||||
|
|
||||||
|
CP = cp
|
||||||
|
|
||||||
|
tests/eina_js/eina_js_suite_mod.node: $(top_builddir)/src/tests/eina_js/libeina_js_suite.la
|
||||||
|
$(AM_V_CP)$(CP) $(top_builddir)/src/tests/eina_js/.libs/libeina_js_suite.so $(top_builddir)/src/tests/eina_js/eina_js_suite_mod.node
|
||||||
|
|
||||||
|
tests_eina_js_libeina_js_suite_la_SOURCES = \
|
||||||
|
tests/eina_js/eina_js_suite.cc
|
||||||
|
|
||||||
|
tests_eina_js_libeina_js_suite_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
|
||||||
|
tests_eina_js_libeina_js_suite_la_LIBADD = \
|
||||||
|
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EINA_JS_LIBS@
|
||||||
|
tests_eina_js_libeina_js_suite_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
else
|
||||||
|
check_PROGRAMS += tests/eina_js/eina_js_suite
|
||||||
|
TESTS += tests/eina_js/eina_js_suite
|
||||||
|
|
||||||
|
tests_eina_js_eina_js_suite_SOURCES = \
|
||||||
|
tests/eina_js/eina_js_suite.cc
|
||||||
|
|
||||||
|
tests_eina_js_eina_js_suite_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
|
||||||
|
tests_eina_js_eina_js_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EINA_JS_LIBS@ @EINA_JS_LIBS@
|
||||||
|
tests_eina_js_eina_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@ tests/eina_js/eina_js_suite.js
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
### Library
|
||||||
|
|
||||||
|
if HAVE_JS
|
||||||
|
installed_eojsmainheadersdir = $(includedir)/eo-js-@VMAJ@
|
||||||
|
dist_installed_eojsmainheaders_DATA = \
|
||||||
|
bindings/eo_js/eo_js_call_function.hh \
|
||||||
|
bindings/eo_js/eo_js_constructor.hh \
|
||||||
|
bindings/eo_js/eo_js_direction.hh \
|
||||||
|
bindings/eo_js/eo_js_event.hh \
|
||||||
|
bindings/eo_js/eo_js_construct_from_eo.hh \
|
||||||
|
bindings/eo_js/Eo_Js.hh
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
### Binary
|
||||||
|
if HAVE_JS
|
||||||
|
|
||||||
|
bin_PROGRAMS += bin/eolian_js/eolian_js
|
||||||
|
|
||||||
|
bin_eolian_js_eolian_js_SOURCES = \
|
||||||
|
bin/eolian_js/main.cc
|
||||||
|
|
||||||
|
bin_eolian_js_eolian_js_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-I$(top_srcdir)/src/bin/eolian_js \
|
||||||
|
@CHECK_CFLAGS@ @EINA_CFLAGS@ @EINA_CXX_CFLAGS@ @EO_CFLAGS@ \
|
||||||
|
@EOLIAN_CXX_CFLAGS@ @EOLIAN_CFLAGS@
|
||||||
|
|
||||||
|
bin_eolian_js_eolian_js_LDADD = @CHECK_LIBS@ @USE_EOLIAN_LIBS@
|
||||||
|
|
||||||
|
bin_eolian_js_eolian_js_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
include Makefile_Eolian_Js_Helper.am
|
||||||
|
|
||||||
|
### Library
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += lib/eolian_js/libeolian_js.la
|
||||||
|
|
||||||
|
lib_eolian_js_libeolian_js_la_SOURCES = \
|
||||||
|
bindings/eolian_js/main.cc \
|
||||||
|
$(generated_evas_canvas_js_bindings)
|
||||||
|
|
||||||
|
lib_eolian_js_libeolian_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_builddir)/src/lib/efl/interfaces \
|
||||||
|
@EINA_CFLAGS@ @EINA_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ @EO_CFLAGS@ @EVAS_CFLAGS@ @ECORE_CFLAGS@ @ECORE_EVAS_CFLAGS@ @EINA_CFLAGS@ \
|
||||||
|
-I$(top_builddir)/src/lib/evas/canvas \
|
||||||
|
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||||
|
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||||
|
-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \
|
||||||
|
@VALGRIND_CFLAGS@
|
||||||
|
|
||||||
|
lib_eolian_js_libeolian_js_la_LIBADD = @EINA_LIBS@ @DL_LIBS@ @EVAS_LIBS@ @ECORE_LIBS@ @ECORE_EVAS_LIBS@ lib/ecore/libecore.la lib/evas/libevas.la lib/ecore_evas/libecore_evas.la
|
||||||
|
lib_eolian_js_libeolian_js_la_DEPENDENCIES = @EINA_INTERNAL_LIBS@ @EVAS_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@ @ECORE_INTERNAL_LIBS@ @ECORE_EVAS_INTERNAL_LIBS@ lib/ecore/libecore.la lib/evas/libevas.la lib/ecore_evas/libecore_evas.la
|
||||||
|
lib_eolian_js_libeolian_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
# check_PROGRAMS += tests/eolian_js/eolian_js_suite
|
||||||
|
# TESTS += tests/eolian_js/eolian_js_suite
|
||||||
|
|
||||||
|
# tests_eolian_js_eolian_js_suite_SOURCES = \
|
||||||
|
# tests/eolian_js/eolian_js_suite.cc \
|
||||||
|
# tests/eolian_js/eolian_js_test_evas_box.cc \
|
||||||
|
# tests/eolian_js/eolian_js_test_constructor_method.cc \
|
||||||
|
# tests/eolian_js/eolian_js_test_constructor_method_impl.c
|
||||||
|
|
||||||
|
# tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_constructor_method.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.h
|
||||||
|
|
||||||
|
# tests/eolian_js/tests_eolian_js_eolian_js_suite-eolian_js_test_constructor_method_impl.$(OBJEXT): tests/eolian_js/constructor_method_class.eo.c
|
||||||
|
|
||||||
|
# CLEANFILES += tests/eolian_js/constructor_method_class.eo.js.cc tests/eolian_js/constructor_method_class.eo.c tests/eolian_js/constructor_method_class.eo.h
|
||||||
|
|
||||||
|
# tests_eolian_js_eolian_js_suite_CXXFLAGS = \
|
||||||
|
# -I$(top_builddir)/src/lib/efl \
|
||||||
|
# -I$(top_srcdir)/src/bin/eolian_js \
|
||||||
|
# -I$(top_builddir)/src/tests/eolian_js \
|
||||||
|
# -DTESTS_WD=\"`pwd`\" \
|
||||||
|
# -DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_js\" \
|
||||||
|
# -DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_js\" \
|
||||||
|
# -DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \
|
||||||
|
# -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_js\" \
|
||||||
|
# @CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_JS_CFLAGS@ @EO_JS_CFLAGS@ @EINA_JS_CFLAGS@ \
|
||||||
|
# @EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ @EINA_CXX_CFLAGS@ \
|
||||||
|
# @EO_JS_CFLAGS@ @EO_CXX_CFLAGS@
|
||||||
|
|
||||||
|
# tests_eolian_js_eolian_js_suite_CFLAGS = ${tests_eolian_js_eolian_js_suite_CXXFLAGS}
|
||||||
|
# tests_eolian_js_eolian_js_suite_CPPFLAGS = ${tests_eolian_js_eolian_js_suite_CXXFLAGS}
|
||||||
|
# tests_eolian_js_eolian_js_suite_LDADD = \
|
||||||
|
# @CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EOLIAN_JS_LIBS@ @USE_EINA_JS_LIBS@ @USE_EVAS_LIBS@
|
||||||
|
# tests_eolian_js_eolian_js_suite_DEPENDENCIES = @USE_EOLIAN_JS_INTERNAL_LIBS@ @USE_EOLIAN_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EVAS_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
#EXTRA_DIST += tests/eolian_cxx/callback.eo
|
||||||
|
|
||||||
|
endif
|
|
@ -0,0 +1,18 @@
|
||||||
|
#if HAVE_EOLIAN_JS
|
||||||
|
#EOLIAN_JS = @eolian_js@
|
||||||
|
#_EOLIAN_JS_DEP = @eolian_js@
|
||||||
|
#else
|
||||||
|
EOLIAN_JS = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_js/eolian_js${EXEEXT}
|
||||||
|
_EOLIAN_JS_DEP = bin/eolian_js/eolian_js${EXEEXT}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AM_V_EOLJS = $(am__v_EOLJS_@AM_V@)
|
||||||
|
am__v_EOLJS_ = $(am__v_EOLJS_@AM_DEFAULT_V@)
|
||||||
|
am__v_EOLJS_0 = @echo " EOLJS " $@;
|
||||||
|
|
||||||
|
SUFFIXES += .eo.js.cc
|
||||||
|
|
||||||
|
%.eo.js.cc: %.eo $(_EOLIAN_JS_DEP)
|
||||||
|
$(AM_V_EOLJS)$(EOLIAN_JS) $(EOLIAN_FLAGS) -o $@ $<
|
||||||
|
|
||||||
|
CLEANFILES += $(BUILT_SOURCES)
|
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
if HAVE_JS
|
||||||
|
|
||||||
|
### Generated headers
|
||||||
|
|
||||||
|
generated_evas_canvas_js_bindings = \
|
||||||
|
lib/evas/canvas/evas_line.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_polygon.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_rectangle.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_text.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_textblock.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_textgrid.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_signal_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_object_smart.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_smart_clipped.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_table.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_common_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_object.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_canvas.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_grid.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_image.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_out.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_draggable_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_clickable_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_scrollable_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_selectable_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_zoomable_interface.eo.js.cc \
|
||||||
|
lib/evas/canvas/evas_box.eo.js.cc
|
||||||
|
|
||||||
|
CLEANFILES += $(generated_evas_canvas_js_bindings)
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
# if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
# check_PROGRAMS += tests/evas_cxx/cxx_compile_test
|
||||||
|
# TESTS += tests/evas_cxx/cxx_compile_test
|
||||||
|
|
||||||
|
# tests_evas_cxx_cxx_compile_test_SOURCES = tests/evas_cxx/cxx_compile_test.cc
|
||||||
|
# tests_evas_cxx_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
# -DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/evas_cxx\" \
|
||||||
|
# -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/evas_cxx\" \
|
||||||
|
# @CHECK_CFLAGS@ @ECORE_CXX_CFLAGS@ @EINA_CXX_CFLAGS@ @EVAS_CXX_CFLAGS@ @EO_CXX_CFLAGS@ \
|
||||||
|
# @ECORE_CFLAGS@ @EINA_CFLAGS@ @EVAS_CFLAGS@ @EO_CFLAGS@
|
||||||
|
# tests_evas_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_EVAS_LIBS@
|
||||||
|
# tests_evas_cxx_cxx_compile_test_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
# endif
|
||||||
|
endif
|
|
@ -0,0 +1 @@
|
||||||
|
/eolian_js
|
|
@ -0,0 +1,95 @@
|
||||||
|
#ifndef EOLIAN_KLASS_HH
|
||||||
|
#define EOLIAN_KLASS_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
|
||||||
|
#include <eolian/js/domain.hh>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
inline std::string name(Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
return ::eolian_class_name_get(klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::size_t namespace_size(Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
std::size_t size = 0;
|
||||||
|
for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
|
||||||
|
, last; first != last; ++first)
|
||||||
|
++size;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void print_lower_case_namespace(Eolian_Class const* klass, std::ostream& os)
|
||||||
|
{
|
||||||
|
std::vector<std::string> namespace_;
|
||||||
|
for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
|
||||||
|
, last; first != last; ++first)
|
||||||
|
namespace_.push_back(&*first);
|
||||||
|
for(auto first = namespace_.begin(), last = namespace_.end()
|
||||||
|
; first != last; ++first)
|
||||||
|
{
|
||||||
|
std::string lower(*first);
|
||||||
|
std::transform(lower.begin(), lower.end(), lower.begin(), tolower);
|
||||||
|
os << lower;
|
||||||
|
if(std::next(first) != last) os << "::";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void print_eo_class(Eolian_Class const* klass, std::ostream& os)
|
||||||
|
{
|
||||||
|
assert(klass != 0);
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print_eo_class";
|
||||||
|
|
||||||
|
auto toupper = [] (unsigned char c) { return std::toupper(c); };
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print_eo_class";
|
||||||
|
std::vector<std::string> namespace_;
|
||||||
|
for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
|
||||||
|
, last; first != last; ++first)
|
||||||
|
namespace_.push_back(&*first);
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "namespace";
|
||||||
|
namespace_.push_back(name(klass));
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "class";
|
||||||
|
switch(eolian_class_type_get(klass))
|
||||||
|
{
|
||||||
|
case EOLIAN_CLASS_REGULAR:
|
||||||
|
case EOLIAN_CLASS_ABSTRACT:
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
namespace_.push_back("CLASS");
|
||||||
|
break;
|
||||||
|
case EOLIAN_CLASS_INTERFACE:
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
namespace_.push_back("INTERFACE");
|
||||||
|
break;
|
||||||
|
case EOLIAN_CLASS_MIXIN:
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
namespace_.push_back("MIXIN");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "default ?";
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
for(auto first = namespace_.begin(), last = namespace_.end()
|
||||||
|
; first != last; ++first)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
std::string upper(*first);
|
||||||
|
std::transform(upper.begin(), upper.end(), upper.begin(), toupper);
|
||||||
|
os << upper;
|
||||||
|
if(std::next(first) != last) os << "_";
|
||||||
|
}
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_evas(Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is_evas";
|
||||||
|
efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass));
|
||||||
|
return first != efl::eina::iterator<const char>()
|
||||||
|
&& std::strcmp(&*first, "Evas") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
|
||||||
|
namespace eolian { namespace js {
|
||||||
|
|
||||||
|
extern efl::eina::log_domain domain;
|
||||||
|
|
||||||
|
} }
|
|
@ -0,0 +1,470 @@
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eolian.h>
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
|
||||||
|
#include <eolian/js/domain.hh>
|
||||||
|
#include <eolian/class.hh>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace eolian { namespace js {
|
||||||
|
|
||||||
|
efl::eina::log_domain domain("eina_cxx");
|
||||||
|
|
||||||
|
} }
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
std::vector<std::string> include_paths;
|
||||||
|
std::string out_file, in_file;
|
||||||
|
|
||||||
|
efl::eina::eina_init eina_init;
|
||||||
|
struct eolian_init
|
||||||
|
{
|
||||||
|
eolian_init() { ::eolian_init(); }
|
||||||
|
~eolian_init() { ::eolian_shutdown(); }
|
||||||
|
} eolian_init;
|
||||||
|
|
||||||
|
const struct option long_options[] =
|
||||||
|
{
|
||||||
|
{ "in", required_argument, 0, 'I' },
|
||||||
|
{ "out-file", required_argument, 0, 'o' },
|
||||||
|
{ "version", no_argument, 0, 'v' },
|
||||||
|
{ "help", no_argument, 0, 'h' },
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
const char* options = "I:D:o:c:arvh";
|
||||||
|
|
||||||
|
int c, idx;
|
||||||
|
while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1)
|
||||||
|
{
|
||||||
|
if (c == 'I')
|
||||||
|
{
|
||||||
|
include_paths.push_back(optarg);
|
||||||
|
}
|
||||||
|
else if (c == 'o')
|
||||||
|
{
|
||||||
|
if(!out_file.empty())
|
||||||
|
{
|
||||||
|
// _usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
out_file = optarg;
|
||||||
|
}
|
||||||
|
else if (c == 'h')
|
||||||
|
{
|
||||||
|
// _usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (c == 'v')
|
||||||
|
{
|
||||||
|
// _print_version();
|
||||||
|
// if (argc == 2) exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind == argc-1)
|
||||||
|
{
|
||||||
|
in_file = argv[optind];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(auto src : include_paths)
|
||||||
|
if (!::eolian_directory_scan(src.c_str()))
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
|
||||||
|
<< "Couldn't load eolian from '" << src << "'.";
|
||||||
|
}
|
||||||
|
if (!::eolian_all_eot_files_parse())
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
|
||||||
|
<< "Eolian failed parsing eot files";
|
||||||
|
assert(false && "Error parsing eot files");
|
||||||
|
}
|
||||||
|
if (!::eolian_eo_file_parse(in_file.c_str()))
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
|
||||||
|
<< "Failed parsing: " << in_file << ".";
|
||||||
|
assert(false && "Error parsing input file");
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eolian_Class *klass = NULL;
|
||||||
|
{
|
||||||
|
char* dup = strdup(in_file.c_str());
|
||||||
|
char *bn = basename(dup);
|
||||||
|
klass = ::eolian_class_get_by_file(bn);
|
||||||
|
free(dup);
|
||||||
|
}
|
||||||
|
if(!klass)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "could not find any class defined in this eo file";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Eolian_Function const*> constructor_functions;
|
||||||
|
std::vector<Eolian_Function const*> normal_functions;
|
||||||
|
|
||||||
|
std::set<Eolian_Class const*> classes;
|
||||||
|
|
||||||
|
auto separate_functions = [&] (Eolian_Class const* klass, Eolian_Function_Type t
|
||||||
|
, bool ignore_constructors)
|
||||||
|
{
|
||||||
|
efl::eina::iterator<Eolian_Function> first ( ::eolian_class_functions_get(klass, t) )
|
||||||
|
, last;
|
||||||
|
for(; first != last; ++first)
|
||||||
|
{
|
||||||
|
Eolian_Function const* function = &*first;
|
||||||
|
if(eolian_function_scope_get(function) == EOLIAN_SCOPE_PUBLIC)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << ::eolian_function_full_c_name_get(function);
|
||||||
|
if(strcmp("elm_obj_entry_input_panel_imdata_get", ::eolian_function_full_c_name_get(function))
|
||||||
|
!= 0)
|
||||||
|
{
|
||||||
|
if( ::eolian_function_is_constructor(function, klass))
|
||||||
|
{
|
||||||
|
if(!ignore_constructors)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is a constructor";
|
||||||
|
constructor_functions.push_back(function);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "ignoring parent's constructors";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /*if( std::strcmp( ::eolian_function_full_c_name_get(function)
|
||||||
|
, "eo_parent") != 0)*/
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "is a NOT constructor "
|
||||||
|
<< ::eolian_function_full_c_name_get(function);
|
||||||
|
normal_functions.push_back(function);
|
||||||
|
}
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "parent_set as first constructor";
|
||||||
|
// constructor_functions.insert(constructor_functions.begin(), function);
|
||||||
|
// normal_functions.push_back(function);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
separate_functions(klass, EOLIAN_METHOD, false);
|
||||||
|
separate_functions(klass, EOLIAN_PROPERTY, false);
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "functions were separated";
|
||||||
|
|
||||||
|
std::function<void(Eolian_Class const*, std::function<void(Eolian_Class const*)>)>
|
||||||
|
recurse_inherits
|
||||||
|
= [&] (Eolian_Class const* klass, std::function<void(Eolian_Class const*)> function)
|
||||||
|
{
|
||||||
|
for(efl::eina::iterator<const char> first ( ::eolian_class_inherits_get(klass))
|
||||||
|
, last; first != last; ++first)
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << &*first << std::endl;
|
||||||
|
Eolian_Class const* base = ::eolian_class_get_by_name(&*first);
|
||||||
|
function(base);
|
||||||
|
recurse_inherits(base, function);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::function<void(Eolian_Class const*)> save_functions
|
||||||
|
= [&] (Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
if(classes.find(klass) == classes.end())
|
||||||
|
{
|
||||||
|
classes.insert(klass);
|
||||||
|
separate_functions(klass, EOLIAN_METHOD, true);
|
||||||
|
separate_functions(klass, EOLIAN_PROPERTY, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
recurse_inherits(klass, save_functions);
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "inherits were recursed";
|
||||||
|
|
||||||
|
std::ofstream os (out_file.c_str());
|
||||||
|
if(!os.is_open())
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "Couldn't open output file " << out_file;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "output was opened";
|
||||||
|
|
||||||
|
std::string class_name (name(klass)), upper_case_class_name(class_name)
|
||||||
|
, lower_case_class_name(class_name);
|
||||||
|
std::transform(upper_case_class_name.begin(), upper_case_class_name.end(), upper_case_class_name.begin()
|
||||||
|
, [] (unsigned char c) { return std::toupper(c); });
|
||||||
|
std::transform(lower_case_class_name.begin(), lower_case_class_name.end(), lower_case_class_name.begin()
|
||||||
|
, [] (unsigned char c) { return std::tolower(c); });
|
||||||
|
|
||||||
|
if (getenv("EFL_RUN_IN_TREE"))
|
||||||
|
{
|
||||||
|
os << "#ifdef HAVE_CONFIG_H\n";
|
||||||
|
os << "#include \"config.h\"\n";
|
||||||
|
os << "#endif\n";
|
||||||
|
|
||||||
|
os << "extern \"C\"\n";
|
||||||
|
os << "{\n";
|
||||||
|
os << "#include <Efl.h>\n";
|
||||||
|
os << "}\n";
|
||||||
|
os << "#include <Eo.h>\n\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << "#ifdef HAVE_CONFIG_H\n";
|
||||||
|
os << "#include \"elementary_config.h\"\n";
|
||||||
|
os << "#endif\n";
|
||||||
|
|
||||||
|
os << "extern \"C\"\n";
|
||||||
|
os << "{\n";
|
||||||
|
os << "#include <Efl.h>\n";
|
||||||
|
os << "}\n";
|
||||||
|
|
||||||
|
os << "#include <Eo.h>\n\n";
|
||||||
|
os << "#include <Evas.h>\n\n";
|
||||||
|
os << "#include <Edje.h>\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
os << "#include <Elementary.h>\n\n";
|
||||||
|
os << "extern \"C\" {\n";
|
||||||
|
os << "#include <elm_widget.h>\n";
|
||||||
|
os << "}\n\n";
|
||||||
|
}
|
||||||
|
os << "#include <Eo_Js.hh>\n\n";
|
||||||
|
os << "#include EINA_STRINGIZE(V8_INCLUDE_HEADER)\n\n";
|
||||||
|
os << "extern \"C\" {\n";
|
||||||
|
|
||||||
|
if(is_evas(klass))
|
||||||
|
os << "#include <Evas.h>\n";
|
||||||
|
|
||||||
|
auto includes_fun = [&os] (Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
|
||||||
|
};
|
||||||
|
recurse_inherits(klass, includes_fun);
|
||||||
|
os << "#include <" << eolian_class_file_get(klass) << ".h>\n\n";
|
||||||
|
|
||||||
|
os << "}\n";
|
||||||
|
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "includes added";
|
||||||
|
|
||||||
|
if(namespace_size(klass))
|
||||||
|
{
|
||||||
|
os << "namespace ";
|
||||||
|
print_lower_case_namespace(klass, os);
|
||||||
|
os << " {\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "namespace";
|
||||||
|
|
||||||
|
os << "static ::efl::eina::js::compatibility_persistent<v8::ObjectTemplate> persistent_instance;\n";
|
||||||
|
os << "static ::efl::eina::js::compatibility_persistent<v8::Function> constructor_from_eo;\n";
|
||||||
|
|
||||||
|
os << "EAPI v8::Local<v8::ObjectTemplate>\nregister_" << lower_case_class_name << "_from_constructor\n"
|
||||||
|
<< "(v8::Isolate* isolate, v8::Handle<v8::FunctionTemplate> constructor)\n";
|
||||||
|
os << "{\n";
|
||||||
|
|
||||||
|
os << " v8::Local<v8::ObjectTemplate> instance = constructor->InstanceTemplate();\n";
|
||||||
|
os << " instance->SetInternalFieldCount(1);\n";
|
||||||
|
|
||||||
|
os << " v8::Handle<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate();\n";
|
||||||
|
|
||||||
|
for(auto function : normal_functions)
|
||||||
|
{
|
||||||
|
auto output_begin = [&] (std::string name)
|
||||||
|
{
|
||||||
|
if(! ::eolian_function_is_constructor(function, klass))
|
||||||
|
os << " prototype->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
|
||||||
|
<< name << "\")\n"
|
||||||
|
<< " , ::efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, &efl::eo::js::call_function\n"
|
||||||
|
<< " , efl::eo::js::call_function_data<\n"
|
||||||
|
<< " ::efl::eina::_mpl::tuple_c<std::size_t";
|
||||||
|
};
|
||||||
|
switch(eolian_function_type_get(function))
|
||||||
|
{
|
||||||
|
case EOLIAN_METHOD:
|
||||||
|
output_begin(eolian_function_name_get(function));
|
||||||
|
break;
|
||||||
|
case EOLIAN_PROPERTY:
|
||||||
|
output_begin(eolian_function_name_get(function) + std::string("_set"));
|
||||||
|
break;
|
||||||
|
// case EOLIAN_PROP_GET:
|
||||||
|
// output_begin(eolian_function_name_get(function) + std::string("_get"));
|
||||||
|
// break;
|
||||||
|
// case EOLIAN_PROP_SET:
|
||||||
|
// output_begin(eolian_function_name_get(function) + std::string("_set"));
|
||||||
|
case EOLIAN_PROP_GET:
|
||||||
|
case EOLIAN_PROP_SET:
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// os << __func__ << ":" << __LINE__;
|
||||||
|
std::size_t i = 0;
|
||||||
|
for(efl::eina::iterator< ::Eolian_Function_Parameter> parameter
|
||||||
|
( ::eolian_function_parameters_get(function) )
|
||||||
|
, last; parameter != last; ++parameter, ++i)
|
||||||
|
{
|
||||||
|
// os << __func__ << ":" << __LINE__;
|
||||||
|
switch(eolian_parameter_direction_get(&*parameter))
|
||||||
|
{
|
||||||
|
case EOLIAN_IN_PARAM:
|
||||||
|
case EOLIAN_INOUT_PARAM:
|
||||||
|
os << ", " << i;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// os << __func__ << ":" << __LINE__;
|
||||||
|
os << ">\n , ::efl::eina::_mpl::tuple_c<std::size_t";
|
||||||
|
i = 0;
|
||||||
|
for(efl::eina::iterator< ::Eolian_Function_Parameter> parameter
|
||||||
|
( ::eolian_function_parameters_get(function) )
|
||||||
|
, last; parameter != last; ++parameter, ++i)
|
||||||
|
{
|
||||||
|
switch(eolian_parameter_direction_get(&*parameter))
|
||||||
|
{
|
||||||
|
case EOLIAN_OUT_PARAM:
|
||||||
|
case EOLIAN_INOUT_PARAM:
|
||||||
|
os << ", " << i;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os << ">\n , std::tuple<\n";
|
||||||
|
efl::eina::iterator< ::Eolian_Function_Parameter> parameter
|
||||||
|
( ::eolian_function_parameters_get(function) )
|
||||||
|
, last;
|
||||||
|
// os << __func__ << ":" << __LINE__;
|
||||||
|
while(parameter != last)
|
||||||
|
{
|
||||||
|
// os << __func__ << ":" << __LINE__;
|
||||||
|
Eolian_Type const* type = eolian_parameter_type_get(&*parameter);
|
||||||
|
if(eolian_type_is_own(type))
|
||||||
|
os << " ::std::true_type";
|
||||||
|
else
|
||||||
|
os << " ::std::false_type";
|
||||||
|
if(++parameter != last)
|
||||||
|
os << ",\n";
|
||||||
|
}
|
||||||
|
// // os << __func__ << ":" << __LINE__;
|
||||||
|
auto output_end = [&] (std::string const& name)
|
||||||
|
{
|
||||||
|
os << "> >(isolate, & ::" << name << ")));\n";
|
||||||
|
};
|
||||||
|
switch(eolian_function_type_get(function))
|
||||||
|
{
|
||||||
|
case EOLIAN_METHOD:
|
||||||
|
output_end(eolian_function_full_c_name_get(function));
|
||||||
|
break;
|
||||||
|
case EOLIAN_PROPERTY:
|
||||||
|
output_end(eolian_function_full_c_name_get(function) + std::string("_set"));
|
||||||
|
break;
|
||||||
|
case EOLIAN_PROP_SET:
|
||||||
|
output_end(eolian_function_full_c_name_get(function) + std::string("_set"));
|
||||||
|
break;
|
||||||
|
case EOLIAN_PROP_GET:
|
||||||
|
output_end(eolian_function_full_c_name_get(function) + std::string("_get"));
|
||||||
|
break;
|
||||||
|
case EOLIAN_UNRESOLVED:
|
||||||
|
EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Unresolved function";
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto generate_events = [&] (Eolian_Class const* klass)
|
||||||
|
{
|
||||||
|
for(efl::eina::iterator< ::Eolian_Event> first ( ::eolian_class_events_get(klass))
|
||||||
|
, last; first != last; ++first)
|
||||||
|
{
|
||||||
|
|
||||||
|
os << " {\n";
|
||||||
|
os << " static efl::eo::js::event_information const event_information\n";
|
||||||
|
os << " = {&constructor_from_eo, ";
|
||||||
|
os << eolian_event_c_name_get(&*first);
|
||||||
|
os << "};\n\n";
|
||||||
|
os << " /* should include event " << ::eolian_event_name_get(&*first) << "*/" << std::endl;
|
||||||
|
os << " prototype->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \"event_";
|
||||||
|
std::string event_name (::eolian_event_name_get(&*first));
|
||||||
|
std::replace(event_name.begin(), event_name.end(), ',', '_');
|
||||||
|
os << event_name << "\")\n , ::efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, &efl::eo::js::event_call\n"
|
||||||
|
<< " , ::efl::eina::js::compatibility_new<v8::External>(isolate, const_cast<efl::eo::js::event_information*>"
|
||||||
|
<< "(&event_information)) ));\n";
|
||||||
|
os << " }\n\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
generate_events(klass);
|
||||||
|
recurse_inherits(klass, generate_events);
|
||||||
|
|
||||||
|
os << " static_cast<void>(prototype); /* avoid warnings */\n";
|
||||||
|
os << " static_cast<void>(isolate); /* avoid warnings */\n";
|
||||||
|
os << " return instance;\n";
|
||||||
|
os << "}\n\n";
|
||||||
|
|
||||||
|
os << "EAPI void register_" << lower_case_class_name
|
||||||
|
<< "(v8::Handle<v8::Object> global, v8::Isolate* isolate)\n";
|
||||||
|
os << "{\n";
|
||||||
|
os << " v8::Handle<v8::FunctionTemplate> constructor = ::efl::eina::js::compatibility_new<v8::FunctionTemplate>\n";
|
||||||
|
os << " (isolate, efl::eo::js::constructor\n"
|
||||||
|
<< " , efl::eo::js::constructor_data(isolate\n"
|
||||||
|
" , ";
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "before print eo_class";
|
||||||
|
|
||||||
|
print_eo_class(klass, os);
|
||||||
|
|
||||||
|
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "print eo_class";
|
||||||
|
|
||||||
|
for(auto function : constructor_functions)
|
||||||
|
{
|
||||||
|
os << "\n , & ::"
|
||||||
|
<< eolian_function_full_c_name_get(function);
|
||||||
|
if(eolian_function_type_get(function) == EOLIAN_PROPERTY)
|
||||||
|
os << "_set";
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "));\n";
|
||||||
|
|
||||||
|
os << " register_" << lower_case_class_name << "_from_constructor(isolate, constructor);\n";
|
||||||
|
|
||||||
|
os << " constructor->SetClassName( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
|
||||||
|
<< class_name
|
||||||
|
<< "\"));\n";
|
||||||
|
|
||||||
|
os << " global->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
|
||||||
|
<< class_name << "\")"
|
||||||
|
<< ", constructor->GetFunction());\n";
|
||||||
|
|
||||||
|
|
||||||
|
os << " {\n";
|
||||||
|
os << " v8::Handle<v8::FunctionTemplate> constructor = ::efl::eina::js::compatibility_new<v8::FunctionTemplate>\n";
|
||||||
|
os << " (isolate, &efl::eo::js::construct_from_eo);\n";
|
||||||
|
os << " constructor->SetClassName( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
|
||||||
|
<< class_name
|
||||||
|
<< "\"));\n";
|
||||||
|
os << " v8::Local<v8::ObjectTemplate> instance = "
|
||||||
|
<< "register_" << lower_case_class_name << "_from_constructor(isolate, constructor);\n";
|
||||||
|
os << " persistent_instance = {isolate, instance};\n";
|
||||||
|
os << " constructor_from_eo = {isolate, constructor->GetFunction()};\n";
|
||||||
|
os << " }\n";
|
||||||
|
|
||||||
|
os << "}\n\n";
|
||||||
|
|
||||||
|
for(std::size_t i = 0, j = namespace_size(klass); i != j; ++i)
|
||||||
|
os << "}";
|
||||||
|
os << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,641 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_animator.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Animator* extract_animator(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Animator*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_animator(Ecore_Animator *animator,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_animator_del(extract_animator(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto freeze = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_animator_freeze(extract_animator(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto thaw = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_animator_thaw(extract_animator(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "freeze"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, freeze)
|
||||||
|
->GetFunction());
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "thaw"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<v8::External>(isolate,
|
||||||
|
animator));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_linear(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_LINEAR));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_accelerate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_ACCELERATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_decelerate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_DECELERATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_sinusoidal(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_SINUSOIDAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_accelerate_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_POS_MAP_ACCELERATE_FACTOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_decelerate_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_POS_MAP_DECELERATE_FACTOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_POS_MAP_SINUSOIDAL_FACTOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_divisor_interp(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_POS_MAP_DIVISOR_INTERP));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_bounce(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_BOUNCE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_spring(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POS_MAP_SPRING));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_pos_map_cubic_bezier(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_POS_MAP_CUBIC_BEZIER));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_source_timer(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_ANIMATOR_SOURCE_TIMER));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_source_custom(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_ANIMATOR_SOURCE_CUSTOM));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_frametime_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_animator_frametime_set(args[0]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_frametime_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Number;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_animator_frametime_get();
|
||||||
|
return compatibility_return(compatibility_new<Number>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_pos_map(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Number;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 4 || !args[0]->IsNumber() || !args[1]->IsNumber()
|
||||||
|
|| !args[2]->IsNumber() || !args[3]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Ecore_Pos_Map map;
|
||||||
|
|
||||||
|
switch ((int)(args[1]->NumberValue())) {
|
||||||
|
case ECORE_POS_MAP_LINEAR:
|
||||||
|
map = ECORE_POS_MAP_LINEAR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_ACCELERATE:
|
||||||
|
map = ECORE_POS_MAP_ACCELERATE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DECELERATE:
|
||||||
|
map = ECORE_POS_MAP_DECELERATE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SINUSOIDAL:
|
||||||
|
map = ECORE_POS_MAP_SINUSOIDAL;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_ACCELERATE_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_ACCELERATE_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DECELERATE_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_DECELERATE_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DIVISOR_INTERP:
|
||||||
|
map = ECORE_POS_MAP_DIVISOR_INTERP;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_BOUNCE:
|
||||||
|
map = ECORE_POS_MAP_BOUNCE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SPRING:
|
||||||
|
map = ECORE_POS_MAP_SPRING;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_CUBIC_BEZIER:
|
||||||
|
map = ECORE_POS_MAP_CUBIC_BEZIER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_animator_pos_map(args[0]->NumberValue(), map,
|
||||||
|
args[2]->NumberValue(),
|
||||||
|
args[3]->NumberValue());
|
||||||
|
return compatibility_return(compatibility_new<Number>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_pos_map_n(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Number;
|
||||||
|
using v8::NumberObject;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Array;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
|
||||||
|
|| !args[2]->IsArray())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Ecore_Pos_Map map;
|
||||||
|
|
||||||
|
switch ((int)(args[1]->NumberValue())) {
|
||||||
|
case ECORE_POS_MAP_LINEAR:
|
||||||
|
map = ECORE_POS_MAP_LINEAR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_ACCELERATE:
|
||||||
|
map = ECORE_POS_MAP_ACCELERATE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DECELERATE:
|
||||||
|
map = ECORE_POS_MAP_DECELERATE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SINUSOIDAL:
|
||||||
|
map = ECORE_POS_MAP_SINUSOIDAL;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_ACCELERATE_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_ACCELERATE_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DECELERATE_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_DECELERATE_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
|
||||||
|
map = ECORE_POS_MAP_SINUSOIDAL_FACTOR;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_DIVISOR_INTERP:
|
||||||
|
map = ECORE_POS_MAP_DIVISOR_INTERP;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_BOUNCE:
|
||||||
|
map = ECORE_POS_MAP_BOUNCE;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_SPRING:
|
||||||
|
map = ECORE_POS_MAP_SPRING;
|
||||||
|
break;
|
||||||
|
case ECORE_POS_MAP_CUBIC_BEZIER:
|
||||||
|
map = ECORE_POS_MAP_CUBIC_BEZIER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<double> v;
|
||||||
|
{
|
||||||
|
auto array = Array::Cast(*args[2]);
|
||||||
|
auto s = array->Length();
|
||||||
|
v.reserve(s);
|
||||||
|
for (decltype(s) i = 0;i != s;++i) {
|
||||||
|
auto e = array->Get(i);
|
||||||
|
if (!e->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
v.push_back(e->NumberValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_animator_pos_map_n(args[0]->NumberValue(), map,
|
||||||
|
v.size(), v.data());
|
||||||
|
return compatibility_return(compatibility_new<Number>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_source_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Ecore_Animator_Source source;
|
||||||
|
|
||||||
|
switch ((int)(args[0]->NumberValue())) {
|
||||||
|
case ECORE_ANIMATOR_SOURCE_TIMER:
|
||||||
|
source = ECORE_ANIMATOR_SOURCE_TIMER;
|
||||||
|
break;
|
||||||
|
case ECORE_ANIMATOR_SOURCE_CUSTOM:
|
||||||
|
source = ECORE_ANIMATOR_SOURCE_CUSTOM;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
ecore_animator_source_set(source);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_source_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_animator_source_get();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
compatibility_persistent<v8::Value> animator_custom_source_tick_begin_cb_data;
|
||||||
|
static
|
||||||
|
compatibility_persistent<v8::Value> animator_custom_source_tick_end_cb_data;
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object>
|
||||||
|
global,
|
||||||
|
v8::Handle<v8::String>
|
||||||
|
name)
|
||||||
|
{
|
||||||
|
using v8::FunctionCallbackInfo;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args) {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
animator_custom_source_tick_begin_cb_data
|
||||||
|
= compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
ecore_animator_custom_source_tick_begin_callback_set([](void*) {
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Isolate;
|
||||||
|
|
||||||
|
auto o = animator_custom_source_tick_begin_cb_data.handle();
|
||||||
|
Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
}, NULL);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object>
|
||||||
|
global,
|
||||||
|
v8::Handle<v8::String>
|
||||||
|
name)
|
||||||
|
{
|
||||||
|
using v8::FunctionCallbackInfo;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args) {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
animator_custom_source_tick_end_cb_data
|
||||||
|
= compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
ecore_animator_custom_source_tick_end_callback_set([](void*) {
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Isolate;
|
||||||
|
|
||||||
|
auto o = animator_custom_source_tick_end_cb_data.handle();
|
||||||
|
Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
}, NULL);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
register_animator_custom_tick(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionCallbackInfo;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args) {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_animator_custom_tick();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto f = new compatibility_persistent<Value>(isolate, args[0]);
|
||||||
|
|
||||||
|
auto cb = [](void *data) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_animator_add(cb, f);
|
||||||
|
return compatibility_return(wrap_animator(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_animator_timeline_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Number;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber()
|
||||||
|
|| !args[1]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
|
||||||
|
|
||||||
|
auto cb = [](void *data, double pos) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
|
||||||
|
Handle<Value> args = compatibility_new<Number>(isolate, pos);
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_animator_timeline_add(args[0]->NumberValue(), cb, f);
|
||||||
|
return compatibility_return(wrap_animator(ret, args.GetIsolate()),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,122 @@
|
||||||
|
#ifndef ECORE_JS_ANIMATOR_HH
|
||||||
|
#define ECORE_JS_ANIMATOR_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_pos_map_linear(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_accelerate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_decelerate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_sinusoidal(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_accelerate_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_decelerate_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_sinusoidal_factor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_divisor_interp(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_bounce(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_spring(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_pos_map_cubic_bezier(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_source_timer(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_source_custom(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_frametime_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_frametime_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_pos_map(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_pos_map_n(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_source_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_source_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void
|
||||||
|
register_animator_custom_source_tick_begin_callback_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object>
|
||||||
|
global,
|
||||||
|
v8::Handle<v8::String>
|
||||||
|
name);
|
||||||
|
|
||||||
|
void
|
||||||
|
register_animator_custom_source_tick_end_callback_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object>
|
||||||
|
global,
|
||||||
|
v8::Handle<v8::String>
|
||||||
|
name);
|
||||||
|
|
||||||
|
void register_animator_custom_tick(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_animator_timeline_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_ANIMATOR_HH */
|
|
@ -0,0 +1,690 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_event.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Event *extract_event(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
return compatibility_get_pointer_internal_field<Ecore_Event*>(object, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_event(Ecore_Event *event,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_event_del(extract_event(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
compatibility_set_pointer_internal_field(ret, 0, event);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ecore_Event_Handler *extract_event_handler(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
return compatibility_get_pointer_internal_field<Ecore_Event_Handler*>
|
||||||
|
(object, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_event_handler(Ecore_Event_Handler *handler,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Value;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto p = ecore_event_handler_del(extract_event_handler(info.This()));
|
||||||
|
|
||||||
|
delete reinterpret_cast<compatibility_persistent<Value>*>(p);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
compatibility_set_pointer_internal_field(ret, 0, handler);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ecore_Event_Filter *extract_event_filter(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
return compatibility_get_pointer_internal_field<Ecore_Event_Filter*>
|
||||||
|
(object, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_event_filter(Ecore_Event_Filter *filter,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Value;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto p = ecore_event_filter_del(extract_event_filter(info.This()));
|
||||||
|
delete[] reinterpret_cast<compatibility_persistent<Value>*>(p);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
compatibility_set_pointer_internal_field(ret, 0, filter);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_NONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_user(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_USER));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_hup(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_HUP));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_exit(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_EXIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_power(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_SIGNAL_POWER));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_realtime(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_EVENT_SIGNAL_REALTIME));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_memory_state(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_MEMORY_STATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_power_state(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_EVENT_POWER_STATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_locale_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_EVENT_LOCALE_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_hostname_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_EVENT_HOSTNAME_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_system_timedate_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate,
|
||||||
|
ECORE_EVENT_SYSTEM_TIMEDATE_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_type_new(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_event_type_new();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_event_add(args[0]->NumberValue(), NULL, NULL, NULL);
|
||||||
|
return compatibility_return(wrap_event(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber()
|
||||||
|
|| !args[1]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto p = new compatibility_persistent<Value>(isolate, args[1]);
|
||||||
|
|
||||||
|
auto cb = [](void *d, int type, void */*event*/) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(d);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
Handle<Value> args = compatibility_new<Integer>(isolate, type);
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 1, &args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_event_handler_add(args[0]->Int32Value(), cb, p);
|
||||||
|
return compatibility_return(wrap_event_handler(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_filter_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 3 || !args[0]->IsFunction()
|
||||||
|
|| !args[1]->IsFunction() || !args[2]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto p = new compatibility_persistent<Value>[3]{{isolate, args[0]},
|
||||||
|
{isolate, args[1]},
|
||||||
|
{isolate, args[2]}};
|
||||||
|
|
||||||
|
auto start_cb = [](void *data) -> void* {
|
||||||
|
auto p = reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
return new compatibility_persistent<Value>{isolate, ret};
|
||||||
|
};
|
||||||
|
|
||||||
|
auto filter_cb = [](void *data, void *loop_data, int type,
|
||||||
|
void */*event*/) -> Eina_Bool {
|
||||||
|
typedef compatibility_persistent<Value> p_t;
|
||||||
|
|
||||||
|
auto p = reinterpret_cast<p_t*>(data) + 1;
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
Handle<Value> args[2]{
|
||||||
|
reinterpret_cast<p_t*>(loop_data)->handle(),
|
||||||
|
compatibility_new<Integer>(isolate, type)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto end_cb = [](void *user_data, void *func_data) -> void {
|
||||||
|
typedef compatibility_persistent<Value> p_t;
|
||||||
|
|
||||||
|
auto loop_data = std::unique_ptr<p_t>(reinterpret_cast<p_t*>
|
||||||
|
(func_data));
|
||||||
|
auto p = reinterpret_cast<p_t*>(user_data) + 2;
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
Handle<Value> args = p->handle();
|
||||||
|
|
||||||
|
Function::Cast(*o)->Call(o->ToObject(), 1, &args);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_event_filter_add(start_cb, filter_cb, end_cb, p);
|
||||||
|
return compatibility_return(wrap_event_filter(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_current_type_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_event_current_type_get();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_memory_state_normal(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_NORMAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_memory_state_low(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_MEMORY_STATE_LOW));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_power_state_mains(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POWER_STATE_MAINS));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_power_state_battery(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POWER_STATE_BATTERY));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_power_state_low(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<Integer>(isolate, ECORE_POWER_STATE_LOW));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_memory_state_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_memory_state_get();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_power_state_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_power_state_get();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_user_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::String;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Object;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto p = new compatibility_persistent<Value>(isolate, args[0]);
|
||||||
|
|
||||||
|
auto cb = [](void *d, int type, void *event) -> Eina_Bool {
|
||||||
|
auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
auto wrapped_event = compatibility_new<Object>(isolate);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto n
|
||||||
|
= reinterpret_cast<Ecore_Event_Signal_User*>(event)->number;
|
||||||
|
wrapped_event->Set(compatibility_new<String>(isolate, "number"),
|
||||||
|
compatibility_new<Integer>(isolate, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle<Value> args[2]{
|
||||||
|
compatibility_new<Integer>(isolate, type),
|
||||||
|
wrapped_event
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, cb, p);
|
||||||
|
return compatibility_return(wrap_event_handler(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_exit_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Object;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto p = new compatibility_persistent<Value>(isolate, args[0]);
|
||||||
|
|
||||||
|
auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
|
||||||
|
auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
auto wrapped_event = compatibility_new<Object>(isolate);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto event = reinterpret_cast<Ecore_Event_Signal_Exit*>(ev);
|
||||||
|
auto interrupt = event->interrupt;
|
||||||
|
auto quit = event->quit;
|
||||||
|
auto terminate = event->terminate;
|
||||||
|
|
||||||
|
wrapped_event->Set(compatibility_new<String>(isolate,
|
||||||
|
"interrupt"),
|
||||||
|
compatibility_new<Boolean>(isolate,
|
||||||
|
interrupt));
|
||||||
|
wrapped_event->Set(compatibility_new<String>(isolate, "quit"),
|
||||||
|
compatibility_new<Boolean>(isolate, quit));
|
||||||
|
wrapped_event->Set(compatibility_new<String>(isolate,
|
||||||
|
"terminate"),
|
||||||
|
compatibility_new<Boolean>(isolate,
|
||||||
|
terminate));
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle<Value> args[2]{
|
||||||
|
compatibility_new<Integer>(isolate, type),
|
||||||
|
wrapped_event
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, cb, p);
|
||||||
|
return compatibility_return(wrap_event_handler(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_event_signal_realtime_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::String;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Object;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::Handle;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
auto p = new compatibility_persistent<Value>(isolate, args[0]);
|
||||||
|
|
||||||
|
auto cb = [](void *d, int type, void *ev) -> Eina_Bool {
|
||||||
|
auto p = reinterpret_cast<compatibility_persistent<Value>*>(d);
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = p->handle();
|
||||||
|
|
||||||
|
auto wrapped_event = compatibility_new<Object>(isolate);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto n
|
||||||
|
= reinterpret_cast<Ecore_Event_Signal_Realtime*>(ev)->num;
|
||||||
|
wrapped_event->Set(compatibility_new<String>(isolate, "num"),
|
||||||
|
compatibility_new<Integer>(isolate, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle<Value> args[2]{
|
||||||
|
compatibility_new<Integer>(isolate, type),
|
||||||
|
wrapped_event
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 2, args);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_event_handler_add(ECORE_EVENT_SIGNAL_REALTIME, cb, p);
|
||||||
|
return compatibility_return(wrap_event_handler(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,123 @@
|
||||||
|
#ifndef ECORE_JS_EVENT_HH
|
||||||
|
#define ECORE_JS_EVENT_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_event_none(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_user(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_hup(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_exit(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_power(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_realtime(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_memory_state(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_power_state(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_locale_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_hostname_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_system_timedate_changed(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_type_new(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_filter_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_current_type_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_memory_state_normal(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_memory_state_low(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_power_state_mains(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_power_state_battery(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_power_state_low(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_memory_state_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_power_state_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_user_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_exit_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_event_signal_realtime_handler_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_EVENT_HH */
|
|
@ -0,0 +1,276 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_idle.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Idler* extract_idler(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Idler*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
v8::Local<v8::Object> wrap_idler(Ecore_Idler *idler, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_idler_del(extract_idler(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<v8::External>(isolate, idler));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ecore_Idle_Enterer* extract_idle_enterer(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Idle_Enterer*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_idle_enterer(Ecore_Idle_Enterer *idle_enterer,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::External;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_idle_enterer_del(extract_idle_enterer(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0,
|
||||||
|
compatibility_new<External>(isolate, idle_enterer));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ecore_Idle_Exiter* extract_idle_exiter(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Idle_Exiter*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_idle_exiter(Ecore_Idle_Exiter *idle_exiter,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::External;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_idle_exiter_del(extract_idle_exiter(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<External>(isolate, idle_exiter));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
auto ret = ecore_idler_add([](void *data) -> Eina_Bool {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_idler(ret, args.GetIsolate()), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_idle_enterer_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
auto ret = ecore_idle_enterer_add([](void *data) -> Eina_Bool {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_idle_enterer_before_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
auto ret = ecore_idle_enterer_before_add([](void *data) -> Eina_Bool {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_idle_enterer(ret, args.GetIsolate()),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_idle_exiter_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
auto ret = ecore_idle_exiter_add([](void *data) -> Eina_Bool {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_idle_exiter(ret, args.GetIsolate()),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef ECORE_JS_IDLE_HH
|
||||||
|
#define ECORE_JS_IDLE_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_idler_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_idle_enterer_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_idle_enterer_before_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_idle_exiter_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_IDLE_HH */
|
|
@ -0,0 +1,56 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_init.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_init(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto init = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_init();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, init)
|
||||||
|
->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto shutdown = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_shutdown();
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, shutdown)
|
||||||
|
->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef ECORE_JS_INIT_HH
|
||||||
|
#define ECORE_JS_INIT_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
|
||||||
|
void register_init(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_INIT_HH */
|
|
@ -0,0 +1,78 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_job.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Job* extract_job(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Job*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_job(Ecore_Job *job, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_job_del(extract_job(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<v8::External>(isolate, job));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
auto ret = ecore_job_add([](void *data) {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
|
||||||
|
delete persistent;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_job(ret, args.GetIsolate()), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef ECORE_JS_JOB_HH
|
||||||
|
#define ECORE_JS_JOB_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_job_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_JOB_HH */
|
|
@ -0,0 +1,253 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_mainloop.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_callback_cancel(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
global->Set(name, compatibility_new<Boolean>(isolate,
|
||||||
|
bool{ECORE_CALLBACK_CANCEL}));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_callback_renew(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
global->Set(name, compatibility_new<Boolean>(isolate,
|
||||||
|
bool{ECORE_CALLBACK_RENEW}));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_callback_pass_on(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
global->Set(name, compatibility_new<Boolean>(isolate,
|
||||||
|
bool{ECORE_CALLBACK_PASS_ON}));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_callback_done(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
global->Set(name, compatibility_new<Boolean>(isolate,
|
||||||
|
bool{ECORE_CALLBACK_DONE}));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_iterate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_main_loop_iterate();
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_iterate_may_block(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto ret = ecore_main_loop_iterate_may_block(args[0]->NumberValue());
|
||||||
|
return compatibility_return(compatibility_new<Integer>
|
||||||
|
(args.GetIsolate(), ret), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_begin(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_main_loop_begin();
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_quit(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_main_loop_quit();
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_animator_ticked_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto ret = ecore_main_loop_animator_ticked_get();
|
||||||
|
return compatibility_return(compatibility_new<Boolean>
|
||||||
|
(args.GetIsolate(), ret), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_nested_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto ret = ecore_main_loop_nested_get();
|
||||||
|
return compatibility_return(compatibility_new<Boolean>
|
||||||
|
(args.GetIsolate(), ret), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_thread_safe_call_async(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
ecore_main_loop_thread_safe_call_async([](void *data) {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
|
||||||
|
delete persistent;
|
||||||
|
}, f);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_mainloop_thread_safe_call_sync(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto f = new compatibility_persistent<Value>(args.GetIsolate(),
|
||||||
|
args[0]);
|
||||||
|
void *data = ecore_main_loop_thread_safe_call_sync([](void *data) {
|
||||||
|
compatibility_persistent<Value> *persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto isolate = v8::Isolate::GetCurrent();
|
||||||
|
auto o = persistent->handle();
|
||||||
|
auto res = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
void *ret = new compatibility_persistent<Value>(isolate, res);
|
||||||
|
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}, f);
|
||||||
|
|
||||||
|
auto ret = reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto value = ret->handle();
|
||||||
|
|
||||||
|
delete ret;
|
||||||
|
|
||||||
|
return compatibility_return(value, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef ECORE_JS_MAINLOOP_HH
|
||||||
|
#define ECORE_JS_MAINLOOP_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_callback_cancel(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_callback_renew(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_callback_pass_on(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_callback_done(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_iterate(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_iterate_may_block(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_begin(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_quit(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_animator_ticked_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_nested_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_thread_safe_call_async(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_mainloop_thread_safe_call_sync(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_MAINLOOP_HH */
|
|
@ -0,0 +1,170 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_poller.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Poller* extract_poller(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Poller*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_poller(Ecore_Poller *poller,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_poller_del(extract_poller(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<v8::External>(isolate, poller));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_poller_core(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
global->Set(name, compatibility_new<Integer>(isolate, ECORE_POLLER_CORE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_poller_poll_interval_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Ecore_Poller_Type type;
|
||||||
|
|
||||||
|
switch ((int)(args[0]->NumberValue())) {
|
||||||
|
case ECORE_POLLER_CORE:
|
||||||
|
type = ECORE_POLLER_CORE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
ecore_poller_poll_interval_set(type, args[1]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_poller_poll_interval_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Ecore_Poller_Type type;
|
||||||
|
|
||||||
|
switch ((int)(args[0]->NumberValue())) {
|
||||||
|
case ECORE_POLLER_CORE:
|
||||||
|
type = ECORE_POLLER_CORE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_poller_poll_interval_get(type);
|
||||||
|
return compatibility_return(compatibility_new<Integer>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_poller_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Isolate;
|
||||||
|
using v8::Function;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
|
||||||
|
|| !args[2]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ecore_Poller_Type type;
|
||||||
|
|
||||||
|
switch ((int)(args[0]->NumberValue())) {
|
||||||
|
case ECORE_POLLER_CORE:
|
||||||
|
type = ECORE_POLLER_CORE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto f = new compatibility_persistent<Value>(isolate, args[2]);
|
||||||
|
|
||||||
|
auto cb = [](void *data) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_poller_add(type, args[1]->NumberValue(), cb, f);
|
||||||
|
return compatibility_return(wrap_poller(ret, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef ECORE_JS_POLLER_HH
|
||||||
|
#define ECORE_JS_POLLER_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_poller_core(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_poller_poll_interval_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_poller_poll_interval_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_poller_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_POLLER_HH */
|
|
@ -0,0 +1,51 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_throttle.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_throttle_adjust(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_throttle_adjust(args[0]->NumberValue());
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Number;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
auto ret = ecore_throttle_get();
|
||||||
|
return compatibility_return(compatibility_new<Number>(isolate, ret),
|
||||||
|
args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef ECORE_JS_THROTTLE_HH
|
||||||
|
#define ECORE_JS_THROTTLE_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
|
||||||
|
void register_throttle_adjust(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_throttle_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_THROTTLE_HH */
|
|
@ -0,0 +1,242 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ecore_js_timer.hh>
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
static Ecore_Timer* extract_timer(v8::Local<v8::Object> object)
|
||||||
|
{
|
||||||
|
auto ptr = v8::External::Cast(*object->GetInternalField(0))->Value();
|
||||||
|
return reinterpret_cast<Ecore_Timer*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static v8::Local<v8::Object> wrap_timer(Ecore_Timer *timer,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::String;
|
||||||
|
using v8::ObjectTemplate;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(1);
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto del = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_timer_del(extract_timer(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto freeze = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_timer_freeze(extract_timer(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto freeze_get = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto ret = ecore_timer_freeze_get(extract_timer(info.This()));
|
||||||
|
return compatibility_return(compatibility_new<Boolean>
|
||||||
|
(info.GetIsolate(), bool(ret)),
|
||||||
|
info);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto thaw = [](compatibility_callback_info_type info)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_timer_thaw(extract_timer(info.This()));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "del"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, del)->GetFunction());
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "freeze"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, freeze)
|
||||||
|
->GetFunction());
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "freeze_get"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, freeze_get)
|
||||||
|
->GetFunction());
|
||||||
|
ret->Set(compatibility_new<String>(isolate, "thaw"),
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, thaw)->GetFunction());
|
||||||
|
|
||||||
|
ret->SetInternalField(0, compatibility_new<v8::External>(isolate, timer));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_timer_precision_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Number;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto ret = ecore_timer_precision_get();
|
||||||
|
return compatibility_return(compatibility_new<Number>
|
||||||
|
(args.GetIsolate(), ret), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_timer_precision_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
ecore_timer_precision_set(args[0]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_timer_dump(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using std::unique_ptr;
|
||||||
|
using std::free;
|
||||||
|
using std::unique_ptr;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto dump = unique_ptr<char, void(*)(char*)>(ecore_timer_dump(),
|
||||||
|
[](char *str) {
|
||||||
|
free(str);
|
||||||
|
});
|
||||||
|
auto ret = (dump
|
||||||
|
? compatibility_new<String>(args.GetIsolate(), dump.get())
|
||||||
|
: compatibility_new<String>(args.GetIsolate(), ""));
|
||||||
|
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_timer_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber()
|
||||||
|
|| !args[1]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
|
||||||
|
|
||||||
|
auto cb = [](void *data) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(data);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_timer_add(args[0]->NumberValue(), cb, f);
|
||||||
|
return compatibility_return(wrap_timer(ret, args.GetIsolate()), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_timer_loop_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Undefined;
|
||||||
|
using v8::Function;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber()
|
||||||
|
|| !args[1]->IsFunction()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_persistent<Value> *f
|
||||||
|
= new compatibility_persistent<Value>(args.GetIsolate(), args[1]);
|
||||||
|
|
||||||
|
auto cb = [](void *d) -> Eina_Bool {
|
||||||
|
auto persistent
|
||||||
|
= reinterpret_cast<compatibility_persistent<Value>*>(d);
|
||||||
|
auto o = persistent->handle();
|
||||||
|
|
||||||
|
auto ret = Function::Cast(*o)->Call(o->ToObject(), 0, NULL);
|
||||||
|
auto bret = ret->IsBoolean() && ret->BooleanValue();
|
||||||
|
|
||||||
|
if (!bret)
|
||||||
|
delete persistent;
|
||||||
|
|
||||||
|
return bret ? EINA_TRUE : EINA_FALSE;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto ret = ecore_timer_loop_add(args[0]->NumberValue(), cb, f);
|
||||||
|
|
||||||
|
return compatibility_return(wrap_timer(ret, args.GetIsolate()), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace ecore { namespace js {
|
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef ECORE_JS_TIMER_HH
|
||||||
|
#define ECORE_JS_TIMER_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace ecore { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_timer_precision_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_timer_precision_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_timer_dump(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_timer_add(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_timer_loop_add(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* ECORE_JS_TIMER_HH */
|
|
@ -21,6 +21,7 @@
|
||||||
#include <eina_log.hh>
|
#include <eina_log.hh>
|
||||||
#include <eina_optional.hh>
|
#include <eina_optional.hh>
|
||||||
#include <eina_integer_sequence.hh>
|
#include <eina_integer_sequence.hh>
|
||||||
|
#include <eina_pp.hh>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @page eina_cxx_main Eina C++ (BETA)
|
* @page eina_cxx_main Eina C++ (BETA)
|
||||||
|
|
|
@ -135,7 +135,10 @@ struct accessor
|
||||||
* @warning It is important to take care when using it, since the
|
* @warning It is important to take care when using it, since the
|
||||||
* handle will be automatically release upon object destruction.
|
* handle will be automatically release upon object destruction.
|
||||||
*/
|
*/
|
||||||
Eina_Accessor* native_handle() const;
|
Eina_Accessor* native_handle() const
|
||||||
|
{
|
||||||
|
return _impl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Swap content between both objects.
|
* @brief Swap content between both objects.
|
||||||
|
|
|
@ -32,6 +32,8 @@ public:
|
||||||
typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator for this container. */
|
typedef typename _base_type::reverse_iterator reverse_iterator; /**< Type for reverse iterator for this container. */
|
||||||
typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for reverse iterator for this container. */
|
typedef typename _base_type::const_reverse_iterator const_reverse_iterator; /**< Type for reverse iterator for this container. */
|
||||||
|
|
||||||
|
typedef typename _base_type::native_handle_type native_handle_type;
|
||||||
|
|
||||||
using _base_type::_base_type;
|
using _base_type::_base_type;
|
||||||
using _base_type::clear;
|
using _base_type::clear;
|
||||||
using _base_type::size;
|
using _base_type::size;
|
||||||
|
@ -59,6 +61,7 @@ public:
|
||||||
using _base_type::ciend;
|
using _base_type::ciend;
|
||||||
using _base_type::swap;
|
using _base_type::swap;
|
||||||
using _base_type::max_size;
|
using _base_type::max_size;
|
||||||
|
using _base_type::release_native_handle;
|
||||||
using _base_type::native_handle;
|
using _base_type::native_handle;
|
||||||
|
|
||||||
friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs)
|
friend bool operator==(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> const& rhs)
|
||||||
|
@ -131,6 +134,101 @@ struct _ptr_eo_array_iterator : _ptr_array_iterator<Eo>
|
||||||
using _base_type::native_handle;
|
using _base_type::native_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
struct _eo_array_access_traits : _ptr_array_access_traits
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct iterator
|
||||||
|
{
|
||||||
|
typedef _ptr_eo_array_iterator<T> type;
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
struct const_iterator : iterator<T const> {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static T& back(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return *static_cast<T*>(static_cast<void*>(array->data[size<T>(array)-1]));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static T const& back(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::back<T>(const_cast<Eina_Array*>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static T& front(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return *static_cast<T*>(static_cast<void*>(array->data[0]));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static T const& front(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::front<T>(const_cast<Eina_Array*>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename iterator<T>::type begin(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return _ptr_eo_array_iterator<T>(array->data);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename iterator<T>::type end(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return _ptr_eo_array_iterator<T>(array->data + size<T>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename const_iterator<T>::type begin(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::begin<T>(const_cast<Eina_Array*>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename const_iterator<T>::type end(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::end<T>(const_cast<Eina_Array*>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename iterator<T>::type> rbegin(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::end<T>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename iterator<T>::type> rend(Eina_Array* array)
|
||||||
|
{
|
||||||
|
return std::reverse_iterator<_ptr_eo_array_iterator<T> >(_eo_array_access_traits::begin<T>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename const_iterator<T>::type> rbegin(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::end<T>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename const_iterator<T>::type> rend(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return std::reverse_iterator<_ptr_eo_array_iterator<T>const>(_eo_array_access_traits::begin<T>(array));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename const_iterator<T>::type cbegin(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::begin<T>(array);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static typename const_iterator<T>::type cend(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::end<T>(array);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename const_iterator<T>::type> crbegin(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::rbegin<T>(array);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static std::reverse_iterator<typename const_iterator<T>::type> crend(Eina_Array const* array)
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::rend<T>(array);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename CloneAllocator>
|
template <typename T, typename CloneAllocator>
|
||||||
class array<T, CloneAllocator, typename std::enable_if<std::is_base_of<efl::eo::base, T>::value>::type>
|
class array<T, CloneAllocator, typename std::enable_if<std::is_base_of<efl::eo::base, T>::value>::type>
|
||||||
: ptr_array<Eo, typename std::conditional
|
: ptr_array<Eo, typename std::conditional
|
||||||
|
@ -331,7 +429,150 @@ bool operator!=(array<T, CloneAllocator> const& lhs, array<T, CloneAllocator> co
|
||||||
{
|
{
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename Enable = void>
|
||||||
|
class range_array : range_ptr_array<T>
|
||||||
|
{
|
||||||
|
typedef range_ptr_array<T> _base_type;
|
||||||
|
public:
|
||||||
|
typedef typename _base_type::value_type value_type;
|
||||||
|
typedef typename _base_type::reference reference;
|
||||||
|
typedef typename _base_type::const_reference const_reference;
|
||||||
|
typedef typename _base_type::const_iterator const_iterator;
|
||||||
|
typedef typename _base_type::iterator iterator;
|
||||||
|
typedef typename _base_type::pointer pointer;
|
||||||
|
typedef typename _base_type::const_pointer const_pointer;
|
||||||
|
typedef typename _base_type::size_type size_type;
|
||||||
|
typedef typename _base_type::difference_type difference_type;
|
||||||
|
|
||||||
|
typedef typename _base_type::reverse_iterator reverse_iterator;
|
||||||
|
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
typedef typename _base_type::native_handle_type native_handle_type;
|
||||||
|
|
||||||
|
range_array& operator=(range_array&& other) = default;
|
||||||
|
|
||||||
|
using _base_type::_base_type;
|
||||||
|
using _base_type::size;
|
||||||
|
using _base_type::empty;
|
||||||
|
using _base_type::back;
|
||||||
|
using _base_type::front;
|
||||||
|
using _base_type::begin;
|
||||||
|
using _base_type::end;
|
||||||
|
using _base_type::rbegin;
|
||||||
|
using _base_type::rend;
|
||||||
|
using _base_type::cbegin;
|
||||||
|
using _base_type::cend;
|
||||||
|
using _base_type::crbegin;
|
||||||
|
using _base_type::crend;
|
||||||
|
using _base_type::native_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class range_array<T, typename std::enable_if<std::is_base_of<efl::eo::base, T>::value>::type>
|
||||||
|
: range_ptr_array<Eo>
|
||||||
|
{
|
||||||
|
typedef range_ptr_array<Eo> _base_type;
|
||||||
|
typedef range_array<T> _self_type;
|
||||||
|
public:
|
||||||
|
typedef T value_type;
|
||||||
|
typedef value_type& reference;
|
||||||
|
typedef value_type const& const_reference;
|
||||||
|
typedef _ptr_eo_array_iterator<value_type const> const_iterator;
|
||||||
|
typedef _ptr_eo_array_iterator<value_type> iterator;
|
||||||
|
typedef value_type* pointer;
|
||||||
|
typedef value_type const* const_pointer;
|
||||||
|
typedef std::size_t size_type;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
|
||||||
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
|
explicit range_array(Eina_Array* handle)
|
||||||
|
: _base_type(handle) {}
|
||||||
|
range_array() {}
|
||||||
|
range_array(range_array<T> const& other)
|
||||||
|
: _base_type(other.native_handle())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
range_array<T>& operator=(range_array<T>const& other)
|
||||||
|
{
|
||||||
|
_base_type::_handle = other._handle;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
range_array& operator=(range_array&& other) = default;
|
||||||
|
range_array(range_array&& other) = default;
|
||||||
|
|
||||||
|
using _base_type::size;
|
||||||
|
using _base_type::empty;
|
||||||
|
|
||||||
|
reference front()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::front<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
reference back()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::back<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
const_reference front() const { return const_cast<_self_type*>(this)->front(); }
|
||||||
|
const_reference back() const { return const_cast<_self_type*>(this)->back(); }
|
||||||
|
iterator begin()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::begin<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
iterator end()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::end<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
const_iterator begin() const
|
||||||
|
{
|
||||||
|
return const_cast<_self_type*>(this)->begin();
|
||||||
|
}
|
||||||
|
const_iterator end() const
|
||||||
|
{
|
||||||
|
return const_cast<_self_type*>(this)->end();
|
||||||
|
}
|
||||||
|
const_iterator cbegin() const
|
||||||
|
{
|
||||||
|
return begin();
|
||||||
|
}
|
||||||
|
const_iterator cend() const
|
||||||
|
{
|
||||||
|
return end();
|
||||||
|
}
|
||||||
|
reverse_iterator rbegin()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::rbegin<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
reverse_iterator rend()
|
||||||
|
{
|
||||||
|
return _eo_array_access_traits::rend<value_type>(native_handle());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rbegin() const
|
||||||
|
{
|
||||||
|
return const_cast<_self_type*>(this)->rbegin();
|
||||||
|
}
|
||||||
|
const_reverse_iterator rend() const
|
||||||
|
{
|
||||||
|
return const_cast<_self_type*>(this)->rend();
|
||||||
|
}
|
||||||
|
const_reverse_iterator crbegin() const
|
||||||
|
{
|
||||||
|
return rbegin();
|
||||||
|
}
|
||||||
|
const_reverse_iterator crend() const
|
||||||
|
{
|
||||||
|
return rend();
|
||||||
|
}
|
||||||
|
using _base_type::swap;
|
||||||
|
using _base_type::native_handle;
|
||||||
|
|
||||||
|
friend bool operator==(range_array<T> const& rhs, range_array<T> const& lhs)
|
||||||
|
{
|
||||||
|
return rhs.size() == lhs.size() && std::equal(rhs.begin(), rhs.end(), lhs.begin());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -154,7 +154,8 @@ struct malloc_clone_allocator
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void deallocate_clone(T const* p)
|
static void deallocate_clone(T const* p)
|
||||||
{
|
{
|
||||||
static_assert(std::is_pod<T>::value, "malloc_clone_allocator can only be used with POD types");
|
static_assert(std::is_pod<T>::value || std::is_void<T>::value
|
||||||
|
, "malloc_clone_allocator can only be used with POD types");
|
||||||
std::free(const_cast<T*>(p));
|
std::free(const_cast<T*>(p));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef EFL_EINA_FUNCTION_HH
|
||||||
|
#define EFL_EINA_FUNCTION_HH
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace _mpl {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct function_params;
|
||||||
|
|
||||||
|
template <typename R, typename... P>
|
||||||
|
struct function_params<R(*)(P...)>
|
||||||
|
{
|
||||||
|
typedef std::tuple<P...> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct function_return;
|
||||||
|
|
||||||
|
template <typename R, typename... P>
|
||||||
|
struct function_return<R(*)(P...)>
|
||||||
|
{
|
||||||
|
typedef R type;
|
||||||
|
};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH
|
#ifndef EINA_CXX_EINA_INTEGER_SEQUENCE_HH
|
||||||
#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH
|
#define EINA_CXX_EINA_INTEGER_SEQUENCE_HH
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Eina_Cxx_Data_Types_Group
|
* @addtogroup Eina_Cxx_Data_Types_Group
|
||||||
*
|
*
|
||||||
|
|
|
@ -190,6 +190,8 @@ public:
|
||||||
typedef typename _base_type::reverse_iterator reverse_iterator;
|
typedef typename _base_type::reverse_iterator reverse_iterator;
|
||||||
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
|
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
typedef typename _base_type::native_handle_type native_handle_type;
|
||||||
|
|
||||||
list& operator=(list&& other) = default;
|
list& operator=(list&& other) = default;
|
||||||
list(list&& other) = default;
|
list(list&& other) = default;
|
||||||
list() = default;
|
list() = default;
|
||||||
|
@ -224,6 +226,7 @@ public:
|
||||||
using _base_type::max_size;
|
using _base_type::max_size;
|
||||||
using _base_type::native_handle;
|
using _base_type::native_handle;
|
||||||
using _base_type::accessor;
|
using _base_type::accessor;
|
||||||
|
using _base_type::release_native_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename CloneAllocator>
|
template <typename T, typename CloneAllocator>
|
||||||
|
@ -295,6 +298,7 @@ public:
|
||||||
using _base_type::get_clone_allocator;
|
using _base_type::get_clone_allocator;
|
||||||
using _base_type::pop_back;
|
using _base_type::pop_back;
|
||||||
using _base_type::pop_front;
|
using _base_type::pop_front;
|
||||||
|
using _base_type::release_native_handle;
|
||||||
|
|
||||||
void push_back(const_reference w)
|
void push_back(const_reference w)
|
||||||
{
|
{
|
||||||
|
@ -443,6 +447,8 @@ public:
|
||||||
typedef typename _base_type::reverse_iterator reverse_iterator;
|
typedef typename _base_type::reverse_iterator reverse_iterator;
|
||||||
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
|
typedef typename _base_type::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
typedef typename _base_type::native_handle_type native_handle_type;
|
||||||
|
|
||||||
using _base_type::_base_type;
|
using _base_type::_base_type;
|
||||||
using _base_type::size;
|
using _base_type::size;
|
||||||
using _base_type::empty;
|
using _base_type::empty;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef EFL_EINA_LOGICAL_HH
|
||||||
|
#define EFL_EINA_LOGICAL_HH
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace _mpl {
|
||||||
|
|
||||||
|
template <bool... N>
|
||||||
|
struct or_impl
|
||||||
|
{
|
||||||
|
static constexpr bool value()
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool... N>
|
||||||
|
struct or_;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct or_<> : std::integral_constant<bool, false> {};
|
||||||
|
|
||||||
|
template <bool B>
|
||||||
|
struct or_<B> : std::integral_constant<bool, B> {};
|
||||||
|
|
||||||
|
template <bool B1, bool B2, bool... Bs>
|
||||||
|
struct or_<B1, B2, Bs...> : std::integral_constant<bool, B1 || B2 || or_<Bs...>::value> {};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
#ifndef EINA_PP_HH
|
||||||
|
#define EINA_PP_HH
|
||||||
|
|
||||||
|
#define EINA_STRINGIZE_IMPL(x) #x
|
||||||
|
#define EINA_STRINGIZE(x) EINA_STRINGIZE_IMPL(x)
|
||||||
|
|
||||||
|
#endif
|
|
@ -401,6 +401,7 @@ struct _ptr_array_common_base
|
||||||
struct _ptr_array_impl : CloneAllocator
|
struct _ptr_array_impl : CloneAllocator
|
||||||
{
|
{
|
||||||
_ptr_array_impl() : _array( ::eina_array_new(32u) ) {}
|
_ptr_array_impl() : _array( ::eina_array_new(32u) ) {}
|
||||||
|
_ptr_array_impl(Eina_Array* array) : _array(array) {}
|
||||||
_ptr_array_impl(CloneAllocator allocator)
|
_ptr_array_impl(CloneAllocator allocator)
|
||||||
: clone_allocator_type(allocator), _array( ::eina_array_new(32u)) {}
|
: clone_allocator_type(allocator), _array( ::eina_array_new(32u)) {}
|
||||||
|
|
||||||
|
@ -448,6 +449,8 @@ public:
|
||||||
|
|
||||||
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
|
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
|
||||||
|
|
||||||
|
typedef Eina_Array* native_handle_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor. Create an empty array.
|
* @brief Default constructor. Create an empty array.
|
||||||
*
|
*
|
||||||
|
@ -1209,6 +1212,13 @@ public:
|
||||||
*/
|
*/
|
||||||
size_type max_size() const { return -1; }
|
size_type max_size() const { return -1; }
|
||||||
|
|
||||||
|
Eina_Array* release_native_handle()
|
||||||
|
{
|
||||||
|
Eina_Array* tmp = this->_impl._array;
|
||||||
|
this->_impl._array = ::eina_array_new(32u);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a handle for the wrapped Eina_Array.
|
* @brief Get a handle for the wrapped Eina_Array.
|
||||||
* @return Handle for the native Eina array.
|
* @return Handle for the native Eina array.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <eina_eo_base_fwd.hh>
|
#include <eina_eo_base_fwd.hh>
|
||||||
#include <eina_iterator.hh>
|
#include <eina_iterator.hh>
|
||||||
#include <eina_throw.hh>
|
#include <eina_throw.hh>
|
||||||
|
#include <eina_range_types.hh>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
@ -364,7 +365,7 @@ struct _ptr_list_common_base
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
T* _new_clone(T const& a)
|
T* _new_clone(typename std::conditional<std::is_void<T>::value, T const*, T>::type const& a)
|
||||||
{
|
{
|
||||||
return _get_clone_allocator().allocate_clone(a);
|
return _get_clone_allocator().allocate_clone(a);
|
||||||
}
|
}
|
||||||
|
@ -407,11 +408,12 @@ class ptr_list : protected _ptr_list_common_base<T, CloneAllocator>
|
||||||
{
|
{
|
||||||
typedef _ptr_list_common_base<T, CloneAllocator> _base_type; /**< Type for the base class. */
|
typedef _ptr_list_common_base<T, CloneAllocator> _base_type; /**< Type for the base class. */
|
||||||
public:
|
public:
|
||||||
typedef T value_type; /**< The type of each element. */
|
typedef typename std::conditional<std::is_void<T>::value, T*, T>::type
|
||||||
typedef T& reference; /**< Type for a reference to an element. */
|
value_type; /**< The type of each element. */
|
||||||
typedef T const& const_reference; /**< Type for a constant reference to an element. */
|
typedef value_type& reference; /**< Type for a reference to an element. */
|
||||||
typedef _ptr_list_iterator<T const> const_iterator; /**< Type for a iterator for this container. */
|
typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
|
||||||
typedef _ptr_list_iterator<T> iterator; /**< Type for a constant iterator for this container. */
|
typedef _ptr_list_iterator<value_type const> const_iterator; /**< Type for a iterator for this container. */
|
||||||
|
typedef _ptr_list_iterator<value_type> iterator; /**< Type for a constant iterator for this container. */
|
||||||
typedef T* pointer; /**< Type for a pointer to an element. */
|
typedef T* pointer; /**< Type for a pointer to an element. */
|
||||||
typedef T const* const_pointer; /**< Type for a constant pointer for an element. */
|
typedef T const* const_pointer; /**< Type for a constant pointer for an element. */
|
||||||
typedef std::size_t size_type; /**< Type for size information. */
|
typedef std::size_t size_type; /**< Type for size information. */
|
||||||
|
@ -421,6 +423,8 @@ public:
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
|
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator for this container. */
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; /**< Type for reverse iterator for this container. */
|
||||||
|
|
||||||
|
typedef Eina_List* native_handle_type;
|
||||||
|
|
||||||
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
|
typedef std::unique_ptr<value_type, clone_allocator_deleter<clone_allocator_type> > _unique_ptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -548,7 +552,7 @@ public:
|
||||||
*/
|
*/
|
||||||
std::size_t size() const
|
std::size_t size() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::size<T>(this->_impl._list);
|
return _ptr_list_access_traits::size<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -560,7 +564,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::empty<T>(this->_impl._list);
|
return _ptr_list_access_traits::empty<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -934,7 +938,7 @@ public:
|
||||||
*/
|
*/
|
||||||
value_type& back()
|
value_type& back()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::back<T>(this->_impl._list);
|
return _ptr_list_access_traits::back<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -946,7 +950,7 @@ public:
|
||||||
*/
|
*/
|
||||||
value_type const& back() const
|
value_type const& back() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::back<T>(this->_impl._list);
|
return _ptr_list_access_traits::back<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -955,7 +959,7 @@ public:
|
||||||
*/
|
*/
|
||||||
value_type& front()
|
value_type& front()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::front<T>(this->_impl._list);
|
return _ptr_list_access_traits::front<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -967,7 +971,7 @@ public:
|
||||||
*/
|
*/
|
||||||
value_type const& front() const
|
value_type const& front() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::front<T>(this->_impl._list);
|
return _ptr_list_access_traits::front<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -979,7 +983,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::cbegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -991,7 +995,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::cend<T>(this->_impl._list);
|
return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1004,7 +1008,7 @@ public:
|
||||||
*/
|
*/
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::begin<T>(this->_impl._list);
|
return _ptr_list_access_traits::begin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1020,7 +1024,7 @@ public:
|
||||||
*/
|
*/
|
||||||
iterator end()
|
iterator end()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::end<T>(this->_impl._list);
|
return _ptr_list_access_traits::end<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1032,7 +1036,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_reverse_iterator rbegin() const
|
const_reverse_iterator rbegin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::rbegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1044,7 +1048,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_reverse_iterator rend() const
|
const_reverse_iterator rend() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::rend<T>(this->_impl._list);
|
return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1057,7 +1061,7 @@ public:
|
||||||
*/
|
*/
|
||||||
reverse_iterator rbegin()
|
reverse_iterator rbegin()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::rbegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::rbegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1074,7 +1078,7 @@ public:
|
||||||
*/
|
*/
|
||||||
reverse_iterator rend()
|
reverse_iterator rend()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::rend<T>(this->_impl._list);
|
return _ptr_list_access_traits::rend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1087,7 +1091,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_iterator cbegin() const
|
const_iterator cbegin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::cbegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::cbegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1100,7 +1104,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_iterator cend() const
|
const_iterator cend() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::cend<T>(this->_impl._list);
|
return _ptr_list_access_traits::cend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1113,7 +1117,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_reverse_iterator crbegin() const
|
const_reverse_iterator crbegin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::crbegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::crbegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1126,7 +1130,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const_reverse_iterator crend() const
|
const_reverse_iterator crend() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::crend<T>(this->_impl._list);
|
return _ptr_list_access_traits::crend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1137,9 +1141,9 @@ public:
|
||||||
* the first element of the list. If the list is empty the returned
|
* the first element of the list. If the list is empty the returned
|
||||||
* iterator is the same as the one returned by @ref iend().
|
* iterator is the same as the one returned by @ref iend().
|
||||||
*/
|
*/
|
||||||
eina::iterator<T> ibegin()
|
eina::iterator<value_type> ibegin()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::ibegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1154,9 +1158,9 @@ public:
|
||||||
* @note Note that attempting to access this position causes undefined
|
* @note Note that attempting to access this position causes undefined
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
eina::iterator<T> iend()
|
eina::iterator<value_type> iend()
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::iend<T>(this->_impl._list);
|
return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1168,7 +1172,7 @@ public:
|
||||||
*/
|
*/
|
||||||
eina::iterator<T const> ibegin() const
|
eina::iterator<T const> ibegin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::ibegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::ibegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1180,7 +1184,7 @@ public:
|
||||||
*/
|
*/
|
||||||
eina::iterator<T const> iend() const
|
eina::iterator<T const> iend() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::iend<T>(this->_impl._list);
|
return _ptr_list_access_traits::iend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1193,7 +1197,7 @@ public:
|
||||||
*/
|
*/
|
||||||
eina::iterator<T const> cibegin() const
|
eina::iterator<T const> cibegin() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::cibegin<T>(this->_impl._list);
|
return _ptr_list_access_traits::cibegin<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1206,7 +1210,7 @@ public:
|
||||||
*/
|
*/
|
||||||
eina::iterator<T const> ciend() const
|
eina::iterator<T const> ciend() const
|
||||||
{
|
{
|
||||||
return _ptr_list_access_traits::ciend<T>(this->_impl._list);
|
return _ptr_list_access_traits::ciend<value_type>(this->_impl._list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1224,6 +1228,13 @@ public:
|
||||||
*/
|
*/
|
||||||
size_type max_size() const { return -1; }
|
size_type max_size() const { return -1; }
|
||||||
|
|
||||||
|
Eina_List* release_native_handle()
|
||||||
|
{
|
||||||
|
Eina_List* tmp = this->_impl._list;
|
||||||
|
this->_impl._list = 0;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a handle for the wrapped @c Eina_List.
|
* @brief Get a handle for the wrapped @c Eina_List.
|
||||||
* @return Handle for the native Eina list.
|
* @return Handle for the native Eina list.
|
||||||
|
@ -1269,9 +1280,9 @@ public:
|
||||||
* @brief Get a @ref eina::accessor for the list.
|
* @brief Get a @ref eina::accessor for the list.
|
||||||
* @return <tt>eina::accessor</tt> to the list.
|
* @return <tt>eina::accessor</tt> to the list.
|
||||||
*/
|
*/
|
||||||
eina::accessor<T> accessor()
|
eina::accessor<value_type> accessor()
|
||||||
{
|
{
|
||||||
return eina::accessor<T>(eina_list_accessor_new(this->_impl._list));
|
return eina::accessor<value_type>(eina_list_accessor_new(this->_impl._list));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,12 @@ namespace efl { namespace eina {
|
||||||
template <typename T, typename Traits>
|
template <typename T, typename Traits>
|
||||||
struct _const_range_template
|
struct _const_range_template
|
||||||
{
|
{
|
||||||
typedef typename Traits::template const_iterator<T>::type const_iterator; /**< Type for constant iterator to the range. */
|
typedef typename std::conditional<std::is_void<T>::value, T*, T>::type
|
||||||
typedef typename Traits::template iterator<T>::type iterator; /**< Type for iterator to the range. */
|
value_type; /**< The type of each element. */
|
||||||
typedef T value_type; /**< The type of each element. */
|
typedef typename Traits::template const_iterator<value_type>::type const_iterator; /**< Type for constant iterator to the range. */
|
||||||
typedef T& reference; /**< Type for a reference to an element. */
|
typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for iterator to the range. */
|
||||||
typedef T const& const_reference; /**< Type for a constant reference to an element. */
|
typedef value_type& reference; /**< Type for a reference to an element. */
|
||||||
|
typedef value_type const& const_reference; /**< Type for a constant reference to an element. */
|
||||||
typedef T* pointer; /**< Type for a pointer to an element. */
|
typedef T* pointer; /**< Type for a pointer to an element. */
|
||||||
typedef T const* const_pointer; /**< Type for a constant pointer to an element. */
|
typedef T const* const_pointer; /**< Type for a constant pointer to an element. */
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator to the range. */
|
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for reverse iterator to the range. */
|
||||||
|
@ -235,10 +236,13 @@ void swap(_const_range_template<T, Traits>& lhs, _const_range_template<T, Traits
|
||||||
template <typename T, typename Traits>
|
template <typename T, typename Traits>
|
||||||
struct _mutable_range_template : _const_range_template<T, Traits>
|
struct _mutable_range_template : _const_range_template<T, Traits>
|
||||||
{
|
{
|
||||||
typedef T value_type; /**< The type of each element. */
|
typedef typename std::conditional<std::is_void<T>::value, T*, T>::type
|
||||||
typedef typename Traits::template iterator<T>::type iterator; /**< Type for a iterator to the range. */
|
value_type; /**< The type of each element. */
|
||||||
|
typedef value_type& reference_type;
|
||||||
|
typedef value_type const& const_reference_type;
|
||||||
|
typedef typename Traits::template iterator<value_type>::type iterator; /**< Type for a iterator to the range. */
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for constant reverse iterator to the range. */
|
typedef std::reverse_iterator<iterator> reverse_iterator; /**< Type for constant reverse iterator to the range. */
|
||||||
typedef typename Traits::template native_handle<T>::type native_handle_type; /**< Type for the native handle of the container. */
|
typedef typename Traits::template native_handle<value_type>::type native_handle_type; /**< Type for the native handle of the container. */
|
||||||
typedef _const_range_template<T, Traits> _base_type; /**< Type for the base class. */
|
typedef _const_range_template<T, Traits> _base_type; /**< Type for the base class. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +264,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
|
||||||
* @brief Get a reference to the last element.
|
* @brief Get a reference to the last element.
|
||||||
* @return Reference to the last element of the range.
|
* @return Reference to the last element of the range.
|
||||||
*/
|
*/
|
||||||
value_type& back() const
|
reference_type back() const
|
||||||
{
|
{
|
||||||
return Traits::template back<value_type>(native_handle());
|
return Traits::template back<value_type>(native_handle());
|
||||||
}
|
}
|
||||||
|
@ -269,7 +273,7 @@ struct _mutable_range_template : _const_range_template<T, Traits>
|
||||||
* @brief Get a reference to the first element.
|
* @brief Get a reference to the first element.
|
||||||
* @return Reference to the first element of the range.
|
* @return Reference to the first element of the range.
|
||||||
*/
|
*/
|
||||||
value_type& front() const
|
reference_type front() const
|
||||||
{
|
{
|
||||||
return Traits::template front<value_type>(native_handle());
|
return Traits::template front<value_type>(native_handle());
|
||||||
}
|
}
|
||||||
|
@ -349,11 +353,17 @@ protected:
|
||||||
template <typename T, typename Traits>
|
template <typename T, typename Traits>
|
||||||
struct _range_template : private std::conditional
|
struct _range_template : private std::conditional
|
||||||
<std::is_const<T>::value
|
<std::is_const<T>::value
|
||||||
, _const_range_template<typename std::remove_const<T>::type, Traits>
|
, _const_range_template
|
||||||
, _mutable_range_template<T, Traits> >::type
|
<typename std::conditional<std::is_void<T>::value, T*, typename std::remove_const<T>::type>::type
|
||||||
|
, Traits>
|
||||||
|
, _mutable_range_template<typename std::conditional<std::is_void<T>::value, T*, T>::type, Traits> >::type
|
||||||
{
|
{
|
||||||
typedef std::integral_constant<bool, !std::is_const<T>::value> is_mutable; /**< Type that specifies if the elements can be modified. */
|
typedef std::integral_constant<bool, !std::is_const<T>::value> is_mutable; /**< Type that specifies if the elements can be modified. */
|
||||||
typedef typename std::remove_const<T>::type value_type; /**< The type of each element. */
|
typedef typename std::conditional
|
||||||
|
<std::is_void<T>::value
|
||||||
|
, T*
|
||||||
|
, typename std::remove_const<T>::type
|
||||||
|
>::type value_type; /**< The type of each element. */
|
||||||
typedef typename std::conditional<is_mutable::value, _mutable_range_template<value_type, Traits>
|
typedef typename std::conditional<is_mutable::value, _mutable_range_template<value_type, Traits>
|
||||||
, _const_range_template<value_type, Traits> >::type _base_type; /**< Type for the base class. */
|
, _const_range_template<value_type, Traits> >::type _base_type; /**< Type for the base class. */
|
||||||
typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */
|
typedef typename _base_type::native_handle_type native_handle_type; /**< Type for the native handle of the container. */
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#ifndef EFL_EINA_EINA_TUPLE_HH_
|
#ifndef EFL_EINA_EINA_TUPLE_HH_
|
||||||
#define EFL_EINA_EINA_TUPLE_HH_
|
#define EFL_EINA_EINA_TUPLE_HH_
|
||||||
|
|
||||||
|
#include <eina_integer_sequence.hh>
|
||||||
|
#include <eina_logical.hh>
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace efl { namespace eina { namespace _mpl {
|
namespace efl { namespace eina { namespace _mpl {
|
||||||
|
|
||||||
template <typename A, typename... Args>
|
template <typename A, typename... Args>
|
||||||
|
@ -21,15 +26,64 @@ struct push_front<C<Args...>, AArgs...>
|
||||||
typedef C<Args..., AArgs...> type;
|
typedef C<Args..., AArgs...> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename A>
|
template <typename A, std::size_t N = 1>
|
||||||
struct pop_front;
|
struct pop_front;
|
||||||
|
|
||||||
template <template <typename...> class C, typename T, typename... Args>
|
template <template <typename...> class C, typename T, typename... Args>
|
||||||
struct pop_front<C<T, Args...> >
|
struct pop_front<C<T, Args...>, 1>
|
||||||
{
|
{
|
||||||
typedef C<Args...> type;
|
typedef C<Args...> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename A, std::size_t N>
|
||||||
|
struct pop_front : pop_front<typename pop_front<A, 1>::type, N-1>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename F, std::size_t... I>
|
||||||
|
void for_each_impl(T&& t, F&& f, eina::index_sequence<I...>)
|
||||||
|
{
|
||||||
|
std::initializer_list<int> l = { (f(std::get<I>(t)), 0)...};
|
||||||
|
static_cast<void>(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename F>
|
||||||
|
void for_each(T&& t, F&& f)
|
||||||
|
{
|
||||||
|
_mpl::for_each_impl(t, f, eina::make_index_sequence
|
||||||
|
<std::tuple_size<typename std::remove_reference<T>::type>::value>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename Transform>
|
||||||
|
struct tuple_transform;
|
||||||
|
|
||||||
|
template <typename...T, typename Transform>
|
||||||
|
struct tuple_transform<std::tuple<T...>, Transform>
|
||||||
|
{
|
||||||
|
typedef std::tuple<typename Transform::template apply<T>::type...> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename Tuple>
|
||||||
|
struct tuple_contains;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename...Ts>
|
||||||
|
struct tuple_contains<T, std::tuple<Ts...> >
|
||||||
|
: _mpl::or_<std::is_same<T, Ts>::value...>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename Tuple>
|
||||||
|
struct tuple_find : std::integral_constant<int, -1> {};
|
||||||
|
|
||||||
|
template <typename T, typename... Ts>
|
||||||
|
struct tuple_find<T, std::tuple<T, Ts...> > : std::integral_constant<std::size_t, 0> {};
|
||||||
|
|
||||||
|
template <typename T, typename T1, typename... Ts>
|
||||||
|
struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant
|
||||||
|
<std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {};
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef EFL_EINA_EINA_TUPLE_C_HH_
|
||||||
|
#define EFL_EINA_EINA_TUPLE_C_HH_
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace _mpl {
|
||||||
|
|
||||||
|
template <typename T, T... Ts>
|
||||||
|
using tuple_c = std::tuple<std::integral_constant<T, Ts>...>;
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
#include <eina_js_accessor.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
EAPI void register_destroy_accessor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
std::cerr << "register_destroy_accessor" << std::endl;
|
||||||
|
typedef void (*deleter_t)(void*);
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type info) -> compatibility_return_type
|
||||||
|
{
|
||||||
|
if (info.Length() != 1 || !info[0]->IsObject())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
v8::Handle<v8::Object> o = info[0]->ToObject();
|
||||||
|
|
||||||
|
deleter_t deleter = compatibility_get_pointer_internal_field<deleter_t>(o, 1);
|
||||||
|
deleter(compatibility_get_pointer_internal_field<>(o, 0));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,77 @@
|
||||||
|
#ifndef EINA_JS_ACCESSOR_HH
|
||||||
|
#define EINA_JS_ACCESSOR_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <eina_js_value.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
#include <eina_js_get_value.hh>
|
||||||
|
#include <eina_js_get_value_from_c.hh>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
js::compatibility_return_type accessor_get(js::compatibility_callback_info_type info)
|
||||||
|
{
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
v8::Isolate* isolate = info.GetIsolate();
|
||||||
|
if (info.Length() != 1 || !info[0]->IsNumber())
|
||||||
|
return js::compatibility_return();
|
||||||
|
|
||||||
|
auto idx = js::get_value_from_javascript
|
||||||
|
(info[0], isolate, js::value_tag<std::size_t>());
|
||||||
|
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
void *ptr = compatibility_get_pointer_internal_field(info.Holder(), 0);
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
return compatibility_return
|
||||||
|
(js::get_value_from_c((*static_cast<T*>(ptr))[idx], isolate), info);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Creates a copy from \p a accessor and exports it to be manipulated by the JS
|
||||||
|
code */
|
||||||
|
template<class T>
|
||||||
|
v8::Local<v8::Object> export_accessor( ::efl::eina::accessor<T> &a, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
typedef ::efl::eina::accessor<T> accessor_type;
|
||||||
|
|
||||||
|
auto obj_tpl = [&]() -> compatibility_persistent<v8::ObjectTemplate>*
|
||||||
|
{
|
||||||
|
auto obj_tpl = compatibility_new<v8::ObjectTemplate>(isolate);
|
||||||
|
(*obj_tpl)->SetInternalFieldCount(1);
|
||||||
|
|
||||||
|
(*obj_tpl)->Set(js::compatibility_new<v8::String>(isolate, "get")
|
||||||
|
, js::compatibility_new<v8::FunctionTemplate>(isolate, &accessor_get<accessor_type>));
|
||||||
|
|
||||||
|
return new compatibility_persistent<v8::ObjectTemplate> {isolate, obj_tpl};
|
||||||
|
}();
|
||||||
|
|
||||||
|
auto instance = obj_tpl->handle()->NewInstance();
|
||||||
|
compatibility_set_pointer_internal_field(instance, 0, &a);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extracts and returns a copy from the internal accessor object from the JS
|
||||||
|
object */
|
||||||
|
template<class T>
|
||||||
|
::efl::eina::accessor<T> import_accessor(v8::Handle<v8::Object> o)
|
||||||
|
{
|
||||||
|
typedef ::efl::eina::accessor<T> accessor_type;
|
||||||
|
|
||||||
|
void* ptr = compatibility_get_pointer_internal_field(o, 0);
|
||||||
|
|
||||||
|
return *static_cast<accessor_type*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Registers the function to destroy the accessor objects to the JS code */
|
||||||
|
void register_destroy_accessor(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* EINA_JS_ACCESSOR_HH */
|
|
@ -0,0 +1,75 @@
|
||||||
|
#ifndef EINA_JS_ARRAY_HH
|
||||||
|
#define EINA_JS_ARRAY_HH
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <eina_js_container.hh>
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include <eina_array.hh>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct eina_array : eina_container_common<efl::eina::array
|
||||||
|
<T
|
||||||
|
, typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type> >
|
||||||
|
{
|
||||||
|
typedef eina_container_common<efl::eina::array<T
|
||||||
|
, typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type> > base_type;
|
||||||
|
using base_type::base_type;
|
||||||
|
typedef typename base_type::container_type container_type;
|
||||||
|
|
||||||
|
eina_container_base* concat(eina_container_base const& other) const
|
||||||
|
{
|
||||||
|
return detail::concat(*this, other);
|
||||||
|
}
|
||||||
|
eina_container_base* slice(std::int64_t i, std::int64_t j) const
|
||||||
|
{
|
||||||
|
return detail::slice(*this, i, j);
|
||||||
|
}
|
||||||
|
js::container_type get_container_type() const { return array_container_type; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct range_eina_array : eina_container_common<efl::eina::range_array<T> >
|
||||||
|
{
|
||||||
|
typedef eina_container_common<efl::eina::range_array<T> > base_type;
|
||||||
|
using base_type::base_type;
|
||||||
|
typedef typename base_type::container_type container_type;
|
||||||
|
typedef typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type clone_allocator_type;
|
||||||
|
|
||||||
|
eina_container_base* concat(eina_container_base const& other) const
|
||||||
|
{
|
||||||
|
std::cout << __func__ << std::endl;
|
||||||
|
range_eina_array<T>const& rhs = static_cast<range_eina_array<T>const&>(other);
|
||||||
|
efl::eina::array<T, clone_allocator_type>
|
||||||
|
array(this->_container.begin(), this->_container.end());
|
||||||
|
array.insert(array.end(), rhs._container.begin(), rhs._container.end());
|
||||||
|
return new eina_array<T>(array.release_native_handle());
|
||||||
|
}
|
||||||
|
eina_container_base* slice(std::int64_t i, std::int64_t j) const
|
||||||
|
{
|
||||||
|
efl::eina::array<T, clone_allocator_type>
|
||||||
|
array(std::next(this->_container.begin(), i), std::next(this->_container.begin(), j));
|
||||||
|
return new eina_array<T>(array.release_native_handle());
|
||||||
|
}
|
||||||
|
js::container_type get_container_type() const { return array_container_type; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,499 @@
|
||||||
|
#ifndef EFL_EINA_JS_COMPATIBILITY_HH
|
||||||
|
#define EFL_EINA_JS_COMPATIBILITY_HH
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
namespace v8 {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct FunctionCallbackInfo;
|
||||||
|
template <typename T>
|
||||||
|
struct PropertyCallbackInfo;
|
||||||
|
template <typename T>
|
||||||
|
struct UniquePersistent;
|
||||||
|
|
||||||
|
class AccessorInfo;
|
||||||
|
|
||||||
|
class Arguments;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T = v8::External, typename Enable = void>
|
||||||
|
struct _libv8_isolate_test;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _libv8_isolate_test
|
||||||
|
<T, typename std::enable_if
|
||||||
|
<std::is_same<decltype( & T::New)
|
||||||
|
, v8::Local<T> (*)(v8::Isolate*, void*)>::value>::type>
|
||||||
|
: std::true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _libv8_isolate_test
|
||||||
|
<T, typename std::enable_if
|
||||||
|
<std::is_same<decltype( & T::New)
|
||||||
|
, v8::Local<T> (*)(void*)>::value>::type>
|
||||||
|
: std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T = v8::FunctionTemplate, typename Enable = void>
|
||||||
|
struct _libv8_callback_info_test;
|
||||||
|
|
||||||
|
typedef v8::Handle<v8::Value>(*_libv8_invocation_callback)(v8::Arguments const&);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _libv8_callback_info_test
|
||||||
|
<T, typename std::enable_if
|
||||||
|
<!std::is_same<decltype( & T::SetCallHandler)
|
||||||
|
, void (T::*)(_libv8_invocation_callback, v8::Handle<v8::Value>)>::value>::type>
|
||||||
|
: std::true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _libv8_callback_info_test
|
||||||
|
<T, typename std::enable_if
|
||||||
|
<std::is_same<decltype( & T::SetCallHandler)
|
||||||
|
, void (T::*)(_libv8_invocation_callback, v8::Handle<v8::Value>)>::value>::type>
|
||||||
|
: std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T = v8::ObjectTemplate, typename Enable = void>
|
||||||
|
struct _libv8_property_callback_info_test
|
||||||
|
: std::true_type {};
|
||||||
|
|
||||||
|
typedef v8::Handle<v8::Value>(*_libv8_getter_callback)(v8::Local<v8::String>, v8::AccessorInfo const&);
|
||||||
|
typedef void(*_libv8_setter_callback)(v8::Local<v8::String>, v8::Local<v8::Value>, v8::AccessorInfo const&);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _libv8_property_callback_info_test
|
||||||
|
<T, typename std::enable_if
|
||||||
|
<std::is_same<decltype( & T::SetAccessor)
|
||||||
|
, void (T::*)
|
||||||
|
(v8::Handle<v8::String>
|
||||||
|
, _libv8_getter_callback
|
||||||
|
, _libv8_setter_callback
|
||||||
|
, v8::Handle<v8::Value>
|
||||||
|
, v8::AccessControl
|
||||||
|
, v8::PropertyAttribute
|
||||||
|
, v8::Handle<v8::AccessorSignature>
|
||||||
|
)>::value>::type>
|
||||||
|
: std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr bool const v8_uses_isolate = _libv8_isolate_test<>::value;
|
||||||
|
static constexpr bool const v8_uses_callback_info = _libv8_callback_info_test<>::value;
|
||||||
|
static constexpr bool const v8_uses_property_callback_info = _libv8_property_callback_info_test<>::value;
|
||||||
|
|
||||||
|
using compatibility_return_type = std::conditional<v8_uses_callback_info, void, v8::Handle<v8::Value> >::type;
|
||||||
|
using compatibility_callback_info_type
|
||||||
|
= std::conditional<v8_uses_callback_info, v8::FunctionCallbackInfo<v8::Value> const&, v8::Arguments const&>
|
||||||
|
::type;
|
||||||
|
using compatibility_callback_info_pointer
|
||||||
|
= std::conditional<v8_uses_callback_info, v8::FunctionCallbackInfo<v8::Value> const*, v8::Arguments const*>
|
||||||
|
::type;
|
||||||
|
|
||||||
|
typedef compatibility_return_type(*compatibility_function_callback)(compatibility_callback_info_type);
|
||||||
|
|
||||||
|
using compatibility_accessor_getter_return_type
|
||||||
|
= std::conditional<v8_uses_property_callback_info, void, v8::Handle<v8::Value> >::type;
|
||||||
|
using compatibility_accessor_callback_info_type
|
||||||
|
= std::conditional<v8_uses_property_callback_info
|
||||||
|
, v8::PropertyCallbackInfo<v8::Value> const&, v8::AccessorInfo const&>
|
||||||
|
::type;
|
||||||
|
|
||||||
|
static_assert(v8_uses_property_callback_info == v8_uses_callback_info
|
||||||
|
&& v8_uses_callback_info == v8_uses_isolate, "");
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct compatibility_type_tag {};
|
||||||
|
|
||||||
|
template <bool = v8_uses_isolate>
|
||||||
|
struct compatibility_string;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct compatibility_string<true> : v8::String
|
||||||
|
{
|
||||||
|
template <typename... Args>
|
||||||
|
static v8::Local<v8::String> New(Args...args)
|
||||||
|
{
|
||||||
|
return NewFromUtf8(v8::Isolate::GetCurrent(), args...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct compatibility_string<false> : v8::String
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename...Args>
|
||||||
|
auto compatibility_new_impl(v8::Isolate*, std::true_type, compatibility_type_tag<v8::String>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(compatibility_string<>::New(args...))
|
||||||
|
{
|
||||||
|
return compatibility_string<>::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename...Args>
|
||||||
|
auto compatibility_new_impl(v8::Isolate*, std::false_type, compatibility_type_tag<v8::String>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(compatibility_string<>::New(args...))
|
||||||
|
{
|
||||||
|
return compatibility_string<>::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename...Args>
|
||||||
|
auto compatibility_new_impl(std::nullptr_t, std::true_type, compatibility_type_tag<v8::String>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(compatibility_string<>::New(args...))
|
||||||
|
{
|
||||||
|
return compatibility_string<>::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename...Args>
|
||||||
|
auto compatibility_new_impl(std::nullptr_t, std::false_type, compatibility_type_tag<v8::String>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(compatibility_string<>::New(args...))
|
||||||
|
{
|
||||||
|
return compatibility_string<>::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new_impl(v8::Isolate* isolate, std::true_type, compatibility_type_tag<T>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(T::New(isolate, args...))
|
||||||
|
{
|
||||||
|
return T::New(isolate, args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new_impl(v8::Isolate*, std::false_type, compatibility_type_tag<T>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(T::New(args...))
|
||||||
|
{
|
||||||
|
return T::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new_impl(std::nullptr_t, std::true_type, compatibility_type_tag<T>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(T::New(v8::Isolate::GetCurrent(), args...))
|
||||||
|
{
|
||||||
|
return T::New(v8::Isolate::GetCurrent(), args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new_impl(std::nullptr_t, std::false_type, compatibility_type_tag<T>
|
||||||
|
, Args...args) ->
|
||||||
|
decltype(T::New(args...))
|
||||||
|
{
|
||||||
|
return T::New(args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new(v8::Isolate* isolate, Args...args) ->
|
||||||
|
decltype(js::compatibility_new_impl<>
|
||||||
|
(isolate, std::integral_constant<bool, v8_uses_isolate>()
|
||||||
|
, compatibility_type_tag<T>()
|
||||||
|
, args...))
|
||||||
|
{
|
||||||
|
return js::compatibility_new_impl(isolate, std::integral_constant<bool, v8_uses_isolate>()
|
||||||
|
, compatibility_type_tag<T>()
|
||||||
|
, args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Args>
|
||||||
|
auto compatibility_new(nullptr_t, Args...args) ->
|
||||||
|
decltype(js::compatibility_new_impl<>(nullptr, std::integral_constant<bool, v8_uses_isolate>()
|
||||||
|
, compatibility_type_tag<T>()
|
||||||
|
, args...))
|
||||||
|
{
|
||||||
|
return js::compatibility_new_impl<>(nullptr, std::integral_constant<bool, v8_uses_isolate>()
|
||||||
|
, compatibility_type_tag<T>()
|
||||||
|
, args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
inline void compatibility_return_impl(T object, U const& info, std::true_type)
|
||||||
|
{
|
||||||
|
info.GetReturnValue().Set(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Handle<v8::Value>
|
||||||
|
compatibility_return_impl(T object, compatibility_callback_info_type, std::false_type)
|
||||||
|
{
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Handle<v8::Value>
|
||||||
|
compatibility_return_impl(T object, compatibility_accessor_callback_info_type, std::false_type)
|
||||||
|
{
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
compatibility_return_type
|
||||||
|
compatibility_return(T object, compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
return compatibility_return_impl(object, args, std::integral_constant<bool, v8_uses_callback_info>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
compatibility_return_type
|
||||||
|
compatibility_return(T object, compatibility_accessor_callback_info_type args)
|
||||||
|
{
|
||||||
|
return compatibility_return_impl(object, args, std::integral_constant<bool, v8_uses_property_callback_info>());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void compatibility_return_nil_impl(std::true_type) {}
|
||||||
|
|
||||||
|
inline v8::Handle<v8::Value>
|
||||||
|
compatibility_return_nil_impl(std::false_type)
|
||||||
|
{
|
||||||
|
return v8::Handle<v8::Value>();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
compatibility_return_type
|
||||||
|
compatibility_return()
|
||||||
|
{
|
||||||
|
return compatibility_return_nil_impl(std::integral_constant<bool, v8_uses_callback_info>());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _v8_isolate_throw_exception : v8::Isolate
|
||||||
|
{
|
||||||
|
v8::Handle<v8::Value> ThrowException_impl(v8::Handle<v8::Value> v)
|
||||||
|
{
|
||||||
|
using namespace v8;
|
||||||
|
return ThrowException(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void
|
||||||
|
compatibility_throw_impl(v8::Isolate* isolate, v8::Local<v8::Value> exception, std::true_type)
|
||||||
|
{
|
||||||
|
static_cast<_v8_isolate_throw_exception*>(isolate)->ThrowException_impl(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Handle<v8::Value>
|
||||||
|
compatibility_throw_impl(v8::Isolate* isolate, v8::Local<v8::Value> exception, std::false_type)
|
||||||
|
{
|
||||||
|
return static_cast<_v8_isolate_throw_exception*>(isolate)->ThrowException_impl(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::conditional<v8_uses_isolate, void, v8::Handle<v8::Value> >::type
|
||||||
|
compatibility_throw(v8::Isolate* isolate, v8::Local<v8::Value> exception)
|
||||||
|
{
|
||||||
|
return compatibility_throw_impl(isolate, exception, std::integral_constant<bool, v8_uses_isolate>());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
compatibility_throw_impl(v8::Local<v8::Value> exception, std::true_type)
|
||||||
|
{
|
||||||
|
static_cast<_v8_isolate_throw_exception*>(v8::Isolate::GetCurrent())->ThrowException_impl(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Handle<v8::Value>
|
||||||
|
compatibility_throw_impl(v8::Local<v8::Value> exception, std::false_type)
|
||||||
|
{
|
||||||
|
return static_cast<_v8_isolate_throw_exception*>(v8::Isolate::GetCurrent())->ThrowException_impl(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::conditional<v8_uses_isolate, void, v8::Handle<v8::Value> >::type
|
||||||
|
compatibility_throw(v8::Local<v8::Value> exception)
|
||||||
|
{
|
||||||
|
return compatibility_throw_impl(exception, std::integral_constant<bool, v8_uses_isolate>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, bool = v8_uses_isolate>
|
||||||
|
struct compatibility_persistent;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct compatibility_persistent<T, true> : v8::UniquePersistent<T>
|
||||||
|
{
|
||||||
|
typedef v8::UniquePersistent<T> _base;
|
||||||
|
|
||||||
|
compatibility_persistent(compatibility_persistent&& other)
|
||||||
|
: _base(other.Pass())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
compatibility_persistent& operator=(compatibility_persistent&& other)
|
||||||
|
{
|
||||||
|
this->_base::operator=(other.Pass());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_persistent() {}
|
||||||
|
compatibility_persistent(v8::Isolate* isolate, v8::Handle<T> v)
|
||||||
|
: _base(isolate, v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator->() const
|
||||||
|
{
|
||||||
|
return *handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Handle<T> handle() const { return v8::Local<T>::New(v8::Isolate::GetCurrent(), *this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct compatibility_persistent<T, false> : v8::Persistent<T>
|
||||||
|
{
|
||||||
|
typedef v8::Persistent<T> _base;
|
||||||
|
|
||||||
|
compatibility_persistent() {}
|
||||||
|
compatibility_persistent(v8::Isolate*, v8::Handle<T> v)
|
||||||
|
: _base(v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Handle<T>& handle() { return *this; }
|
||||||
|
v8::Handle<T> const& handle() const { return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T = std::integral_constant<bool, v8_uses_isolate> >
|
||||||
|
struct _v8_object_internal_field;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct _v8_object_internal_field<std::true_type> : v8::Object
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void* GetPointerFromInternalField(int) { return nullptr; }
|
||||||
|
inline void SetPointerInInternalField(int, void*) {}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct _v8_object_internal_field<std::false_type> : v8::Object
|
||||||
|
{
|
||||||
|
void* GetAlignedPointerFromInternalField(int index)
|
||||||
|
{
|
||||||
|
return GetPointerFromInternalField(index);
|
||||||
|
}
|
||||||
|
void SetAlignedPointerInInternalField(int index, void* p)
|
||||||
|
{
|
||||||
|
SetPointerInInternalField(index, p);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T = void*>
|
||||||
|
inline T compatibility_get_pointer_internal_field(v8::Handle<v8::Object> object, std::size_t index)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<T>
|
||||||
|
(static_cast<_v8_object_internal_field<>*>(*object)->GetAlignedPointerFromInternalField(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void compatibility_set_pointer_internal_field(v8::Handle<v8::Object> object, std::size_t index
|
||||||
|
, T* pointer)
|
||||||
|
{
|
||||||
|
static_cast<_v8_object_internal_field<>*>(*object)->SetAlignedPointerInInternalField(index, pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T = void, bool = v8_uses_isolate>
|
||||||
|
struct compatibility_handle_scope_impl;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct compatibility_handle_scope_impl<T, true> : v8::HandleScope
|
||||||
|
{
|
||||||
|
compatibility_handle_scope_impl(v8::Isolate* isolate)
|
||||||
|
: HandleScope(isolate)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct compatibility_handle_scope_impl<T, false> : v8::HandleScope
|
||||||
|
{
|
||||||
|
compatibility_handle_scope_impl(v8::Isolate*)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
using compatibility_handle_scope = compatibility_handle_scope_impl<>;
|
||||||
|
|
||||||
|
template <bool = v8_uses_isolate>
|
||||||
|
struct _v8_initialize_icu;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct _v8_initialize_icu<true> : v8::V8
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct _v8_initialize_icu<false> : v8::V8
|
||||||
|
{
|
||||||
|
static bool InitializeICU(const char* = NULL)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void compatibility_initialize()
|
||||||
|
{
|
||||||
|
v8::V8::Initialize();
|
||||||
|
static_cast<_v8_initialize_icu<>*>(nullptr)->InitializeICU();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
v8::Local<T> compatibility_cast(v8::Local<U> v)
|
||||||
|
{
|
||||||
|
return *static_cast<v8::Local<T>*>(static_cast<void*>(&v));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
v8::Local<T> compatibility_cast(U* v)
|
||||||
|
{
|
||||||
|
return *static_cast<v8::Local<T>*>(static_cast<void*>(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T = v8::Isolate, bool = v8_uses_isolate>
|
||||||
|
struct _v8_get_current_context;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _v8_get_current_context<T, false> : v8::Context
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct _v8_get_current_context<T, true> : T
|
||||||
|
{
|
||||||
|
static v8::Local<v8::Context> GetCurrent()
|
||||||
|
{
|
||||||
|
return T::GetCurrent()->GetCurrentContext();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline v8::Local<v8::Object> compatibility_global()
|
||||||
|
{
|
||||||
|
return _v8_get_current_context<>::GetCurrent()->Global();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T = v8::StackTrace>
|
||||||
|
typename std::enable_if<!v8_uses_isolate, v8::Local<T>>::type
|
||||||
|
compatibility_current_stack_trace(v8::Isolate*, int frame_limit,
|
||||||
|
v8::StackTrace::StackTraceOptions options)
|
||||||
|
{
|
||||||
|
return T::CurrentStackTrace(frame_limit, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T = v8::StackTrace>
|
||||||
|
typename std::enable_if<v8_uses_isolate, v8::Local<T>>::type
|
||||||
|
compatibility_current_stack_trace(v8::Isolate *isolate, int frame_limit,
|
||||||
|
v8::StackTrace::StackTraceOptions options)
|
||||||
|
{
|
||||||
|
return T::CurrentStackTrace(isolate, frame_limit, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,387 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#include <eina_integer_sequence.hh>
|
||||||
|
#include <eina_tuple.hh>
|
||||||
|
#include <eina_ptrlist.hh>
|
||||||
|
#include <eina_js_list.hh>
|
||||||
|
#include <eina_js_array.hh>
|
||||||
|
#include <eina_js_get_value_from_c.hh>
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct tag { typedef T type; };
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
compatibility_persistent<v8::ObjectTemplate>* instance_persistents[container_type_size];
|
||||||
|
compatibility_persistent<v8::Function>* instance_templates[container_type_size];
|
||||||
|
|
||||||
|
v8::Local<v8::Object> concat(eina_container_base& lhs, v8::Isolate* isolate, v8::Local<v8::Value> other)
|
||||||
|
{
|
||||||
|
if(other->IsObject())
|
||||||
|
{
|
||||||
|
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(other);
|
||||||
|
v8::String::Utf8Value constructor_name (obj->GetConstructorName());
|
||||||
|
std::cout << "constructor " << *constructor_name << std::endl;
|
||||||
|
if(obj->GetConstructorName()->Equals(efl::eina::js::compatibility_new<v8::String>(isolate, "eina_list")))
|
||||||
|
{
|
||||||
|
eina_container_base& rhs = *static_cast<eina_container_base*>
|
||||||
|
(efl::eina::js::compatibility_get_pointer_internal_field(obj, 0));
|
||||||
|
std::cout << "me " << &lhs << " other " << &rhs << std::endl;
|
||||||
|
std::type_info const& typeinfo_lhs = typeid(lhs)
|
||||||
|
, &typeinfo_rhs = typeid(rhs);
|
||||||
|
if(!typeinfo_lhs.before(typeinfo_rhs) && !typeinfo_rhs.before(typeinfo_lhs))
|
||||||
|
{
|
||||||
|
v8::Handle<v8::Value> a[] =
|
||||||
|
{efl::eina::js::compatibility_new<v8::External>(isolate, rhs.concat(lhs))};
|
||||||
|
std::cerr << __func__ << ":" << __LINE__<< " " << lhs.get_container_type() << std::endl;
|
||||||
|
assert(!!*instance_templates[lhs.get_container_type()]->handle());
|
||||||
|
v8::Local<v8::Object> result =
|
||||||
|
instance_templates[lhs.get_container_type()]->handle()->NewInstance(1, a);
|
||||||
|
std::cerr << __func__ << ":" << __LINE__<< std::endl;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << "not same implementation type" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << "Not a list" << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << "Not an object" << std::endl;
|
||||||
|
std::cout << "Some test failed" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Local<v8::Object> slice(eina_container_base& self, v8::Isolate* isolate, v8::Local<v8::Value> iv
|
||||||
|
, v8::Local<v8::Value> jv)
|
||||||
|
{
|
||||||
|
if((iv->IsUint32() || iv->IsInt32()) && (jv->IsUint32() || jv->IsInt32()))
|
||||||
|
{
|
||||||
|
std::int64_t i = iv->IntegerValue(), j = jv->IntegerValue();
|
||||||
|
v8::Handle<v8::Value> a[] = {efl::eina::js::compatibility_new<v8::External>(isolate, self.slice(i, j))};
|
||||||
|
v8::Local<v8::Object> result = instance_templates[self.get_container_type()]->handle()
|
||||||
|
->NewInstance(1, a);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << "parameters are not integral" << std::endl;
|
||||||
|
std::cout << "Some test failed" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_accessor_getter_return_type length
|
||||||
|
(v8::Local<v8::String>, compatibility_accessor_callback_info_type info)
|
||||||
|
{
|
||||||
|
v8::Local<v8::Object> self_obj = compatibility_cast<v8::Object>(info.This());
|
||||||
|
eina_container_base* self = static_cast<eina_container_base*>
|
||||||
|
(compatibility_get_pointer_internal_field(self_obj, 0));
|
||||||
|
std::cout << "size " << self->size() << std::endl;
|
||||||
|
return compatibility_return(js::get_value_from_c(self->size(), info.GetIsolate()), info);
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_accessor_getter_return_type index_get
|
||||||
|
(uint32_t index, compatibility_accessor_callback_info_type info)
|
||||||
|
{
|
||||||
|
std::cout << "index_get " << index << std::endl;
|
||||||
|
v8::Local<v8::Object> self_obj = v8::Local<v8::Object>::Cast(info.This());
|
||||||
|
eina_container_base* self = static_cast<eina_container_base*>
|
||||||
|
(compatibility_get_pointer_internal_field(self_obj, 0));
|
||||||
|
return compatibility_return(self->get(info.GetIsolate(), index), info);
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_return_type new_eina_list(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cerr << "new_eina_list" << std::endl;
|
||||||
|
if(args.IsConstructCall())
|
||||||
|
{
|
||||||
|
if(args.Length() == 0)
|
||||||
|
{
|
||||||
|
eina_container_base* p = new range_eina_list<int>;
|
||||||
|
std::cerr << "called eina list constructor p = " << p << std::endl;
|
||||||
|
compatibility_set_pointer_internal_field
|
||||||
|
(args.This(), 0, dynamic_cast<void*>(p));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "more than one parameter" << std::endl;
|
||||||
|
if(args[0]->IsExternal())
|
||||||
|
{
|
||||||
|
std::cout << "Is external" << std::endl;
|
||||||
|
eina_container_base* base = reinterpret_cast<eina_container_base*>
|
||||||
|
(v8::External::Cast(*args[0])->Value());
|
||||||
|
std::cout << "base " << base << std::endl;
|
||||||
|
compatibility_set_pointer_internal_field
|
||||||
|
(args.This(), 0, dynamic_cast<void*>(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::abort();
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_return_type new_eina_array(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cerr << "new_eina_array" << std::endl;
|
||||||
|
if(args.IsConstructCall())
|
||||||
|
{
|
||||||
|
if(args.Length() == 0)
|
||||||
|
{
|
||||||
|
eina_container_base* p = new eina_array<int>;
|
||||||
|
std::cerr << "called eina array constructor p = " << p << std::endl;
|
||||||
|
compatibility_set_pointer_internal_field
|
||||||
|
(args.This(), 0, dynamic_cast<void*>(p));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "more than one parameter" << std::endl;
|
||||||
|
if(args[0]->IsExternal())
|
||||||
|
{
|
||||||
|
std::cout << "Is external" << std::endl;
|
||||||
|
eina_container_base* base = reinterpret_cast<eina_container_base*>
|
||||||
|
(v8::External::Cast(*args[0])->Value());
|
||||||
|
std::cout << "base " << base << std::endl;
|
||||||
|
compatibility_set_pointer_internal_field
|
||||||
|
(args.This(), 0, dynamic_cast<void*>(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::abort();
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
struct function_params;
|
||||||
|
|
||||||
|
template <typename R, typename... Sig>
|
||||||
|
struct function_params<R(*)(Sig...)>
|
||||||
|
{
|
||||||
|
typedef std::tuple<Sig...> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
struct function_result;
|
||||||
|
|
||||||
|
template <typename R, typename... Sig>
|
||||||
|
struct function_result<R(*)(Sig...)>
|
||||||
|
{
|
||||||
|
typedef R type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_persistent : std::false_type {};
|
||||||
|
|
||||||
|
template <typename...A>
|
||||||
|
struct is_persistent<v8::Persistent<A...> > : std::true_type {};
|
||||||
|
|
||||||
|
template <std::size_t I, typename Sig>
|
||||||
|
typename std::tuple_element<I, Sig>::type
|
||||||
|
get_element(v8::Isolate* isolate
|
||||||
|
, compatibility_callback_info_type args
|
||||||
|
, typename std::enable_if
|
||||||
|
<is_persistent<typename std::tuple_element<I, Sig>::type>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cout << "get args " << I << std::endl;
|
||||||
|
return typename std::tuple_element<I, Sig>::type(isolate, args[I]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t I, typename Sig>
|
||||||
|
typename std::tuple_element<I, Sig>::type
|
||||||
|
get_element(v8::Isolate* /*isolate*/
|
||||||
|
, compatibility_callback_info_type args
|
||||||
|
, typename std::enable_if
|
||||||
|
<!is_persistent<typename std::tuple_element<I, Sig>::type>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cout << "get args " << I << std::endl;
|
||||||
|
return args[I];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename R, typename T, typename F, std::size_t... N>
|
||||||
|
R call_impl(v8::Isolate* isolate
|
||||||
|
, compatibility_callback_info_type args
|
||||||
|
, T* self, F* f
|
||||||
|
, eina::index_sequence<N...>)
|
||||||
|
{
|
||||||
|
struct print
|
||||||
|
{
|
||||||
|
~print()
|
||||||
|
{
|
||||||
|
std::cout << "was called" << std::endl;
|
||||||
|
}
|
||||||
|
} print_;
|
||||||
|
std::cout << "self " << self << " pointer " << (void*)f
|
||||||
|
<< " F " << typeid(F).name() << std::endl;
|
||||||
|
assert(self != 0);
|
||||||
|
return (*f)(*self, isolate, js::get_element<N, Sig>(isolate, args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename T, typename F, typename R>
|
||||||
|
compatibility_return_type call_generic_impl(compatibility_callback_info_type args, tag<R>)
|
||||||
|
{
|
||||||
|
T* self = static_cast<T*>
|
||||||
|
(compatibility_get_pointer_internal_field<>(args.This(), 0));
|
||||||
|
F* f = reinterpret_cast<F*>(v8::External::Cast(*args.Data())->Value());
|
||||||
|
return compatibility_return
|
||||||
|
(js::get_value_from_c
|
||||||
|
(js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
|
||||||
|
, eina::make_index_sequence<std::tuple_size<Sig>::value>())
|
||||||
|
, args.GetIsolate())
|
||||||
|
, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename T, typename F>
|
||||||
|
compatibility_return_type call_generic_impl(compatibility_callback_info_type args, tag<void>)
|
||||||
|
{
|
||||||
|
T* self = static_cast<T*>
|
||||||
|
(compatibility_get_pointer_internal_field(args.This(), 0));
|
||||||
|
F* f = reinterpret_cast<F*>(v8::External::Cast(*args.Data())->Value());
|
||||||
|
js::call_impl<Sig, void>(args.GetIsolate(), args, self, f
|
||||||
|
, eina::make_index_sequence<std::tuple_size<Sig>::value>());
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename R, typename T, typename F>
|
||||||
|
compatibility_return_type call_generic(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
return efl::eina::js::call_generic_impl<Sig, T, F>(args, tag<R>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename T, typename F, typename R>
|
||||||
|
compatibility_return_type call_function_impl(compatibility_callback_info_type args, tag<R>)
|
||||||
|
{
|
||||||
|
std::cout << "return type " << typeid(R).name() << std::endl;
|
||||||
|
T* self = static_cast<T*>
|
||||||
|
(compatibility_get_pointer_internal_field(args.This(), 0));
|
||||||
|
F f = reinterpret_cast<F>(v8::External::Cast(*args.Data())->Value());
|
||||||
|
return compatibility_return
|
||||||
|
(/*js::get_value_from_c*/
|
||||||
|
(js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
|
||||||
|
, eina::make_index_sequence<std::tuple_size<Sig>::value>())
|
||||||
|
/*, args.GetIsolate()*/)
|
||||||
|
, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename T, typename F>
|
||||||
|
compatibility_return_type call_function_impl(compatibility_callback_info_type args, tag<void>)
|
||||||
|
{
|
||||||
|
T* self = static_cast<T*>
|
||||||
|
(compatibility_get_pointer_internal_field(args.This(), 0));
|
||||||
|
F f = reinterpret_cast<F>(v8::External::Cast(*args.Data())->Value());
|
||||||
|
js::call_impl<Sig, void>(args.GetIsolate(), args, self, f
|
||||||
|
, eina::make_index_sequence<std::tuple_size<Sig>::value>());
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Sig, typename R, typename T, typename F>
|
||||||
|
compatibility_return_type call_function(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cout << "R: " << typeid(R).name() << std::endl;
|
||||||
|
return efl::eina::js::call_function_impl<Sig, T, F>(args, tag<R>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename F>
|
||||||
|
void register_(v8::Isolate* isolate, const char* name, F f, v8::Handle<v8::ObjectTemplate> template_
|
||||||
|
, typename std::enable_if<std::is_function<typename std::remove_pointer<F>::type>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cout << "registering " << name << " with pointer " << reinterpret_cast<void*>(f) << std::endl;
|
||||||
|
template_->Set(compatibility_new<v8::String>(isolate, name)
|
||||||
|
, compatibility_new<v8::FunctionTemplate>
|
||||||
|
(isolate, &efl::eina::js::call_function
|
||||||
|
<typename eina::_mpl::pop_front<typename function_params<F>::type, 2u>::type
|
||||||
|
, typename function_result<F>::type, T, F>
|
||||||
|
, compatibility_new<v8::External>
|
||||||
|
(isolate, reinterpret_cast<void*>(f))));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename...Sig, typename F>
|
||||||
|
void register_(v8::Isolate* isolate, const char* name, F&& f, v8::Handle<v8::ObjectTemplate> template_
|
||||||
|
, typename std::enable_if<!std::is_function<typename std::remove_pointer<F>::type>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
using result_type = decltype
|
||||||
|
(std::declval<F>()
|
||||||
|
(std::declval<T&>(), std::declval<v8::Isolate*>()
|
||||||
|
, std::declval<Sig>()...)
|
||||||
|
);
|
||||||
|
template_->Set(compatibility_new<v8::String>(isolate, name)
|
||||||
|
, compatibility_new<v8::FunctionTemplate>
|
||||||
|
(isolate
|
||||||
|
, &efl::eina::js::call_generic<std::tuple<Sig...>, result_type, T, F>
|
||||||
|
, compatibility_new<v8::External>
|
||||||
|
(isolate, new F(std::forward<F>(f)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Local<v8::ObjectTemplate> register_template(v8::Isolate* isolate, v8::Handle<v8::FunctionTemplate> constructor)
|
||||||
|
{
|
||||||
|
v8::Local<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate();
|
||||||
|
instance_t->SetInternalFieldCount(1);
|
||||||
|
|
||||||
|
instance_t->SetIndexedPropertyHandler(& efl::eina::js::index_get);
|
||||||
|
|
||||||
|
v8::Local<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate();
|
||||||
|
prototype->SetAccessor(compatibility_new<v8::String>(isolate, "length"), &efl::eina::js::length);
|
||||||
|
|
||||||
|
using namespace std::placeholders;
|
||||||
|
js::register_<js::eina_container_base>
|
||||||
|
(isolate, "concat", &js::concat, prototype);
|
||||||
|
js::register_<js::eina_container_base>
|
||||||
|
(isolate, "slice", &js::slice, prototype);
|
||||||
|
js::register_<js::eina_container_base>
|
||||||
|
(isolate, "toString", std::bind(&js::eina_container_base::to_string, _1, _2), prototype);
|
||||||
|
js::register_<js::eina_container_base>
|
||||||
|
(isolate, "join", std::bind(&js::eina_container_base::to_string, _1, _2), prototype);
|
||||||
|
js::register_<js::eina_container_base, v8::Local<v8::Value> >
|
||||||
|
(isolate, "indexOf", std::bind(&js::eina_container_base::index_of, _1, _2, _3), prototype);
|
||||||
|
js::register_<js::eina_container_base, v8::Local<v8::Value> >
|
||||||
|
(isolate, "lastIndexOf", std::bind(&js::eina_container_base::last_index_of, _1, _2, _3), prototype);
|
||||||
|
|
||||||
|
return instance_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void register_class(v8::Isolate* isolate, container_type type, const char* class_name
|
||||||
|
, compatibility_function_callback callback)
|
||||||
|
{
|
||||||
|
v8::Handle<v8::FunctionTemplate> constructor
|
||||||
|
= compatibility_new<v8::FunctionTemplate>(isolate, callback);
|
||||||
|
constructor->SetClassName(compatibility_new<v8::String>(isolate, class_name));
|
||||||
|
|
||||||
|
v8::Local<v8::ObjectTemplate> instance_t = efl::eina::js::register_template(isolate, constructor);
|
||||||
|
|
||||||
|
efl::eina::js::instance_persistents[type] = new compatibility_persistent<v8::ObjectTemplate>{isolate, instance_t};
|
||||||
|
efl::eina::js::instance_templates[type] = new compatibility_persistent<v8::Function>{isolate, constructor->GetFunction()};
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } }
|
||||||
|
|
||||||
|
EAPI void eina_container_register(v8::Handle<v8::Object>, v8::Isolate* isolate)
|
||||||
|
{
|
||||||
|
efl::eina::js::register_class(isolate, efl::eina::js::list_container_type
|
||||||
|
, "eina_list", &efl::eina::js::new_eina_list);
|
||||||
|
efl::eina::js::register_class(isolate, efl::eina::js::array_container_type
|
||||||
|
, "eina_array", &efl::eina::js::new_eina_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI v8::Handle<v8::Function> get_list_instance_template()
|
||||||
|
{
|
||||||
|
return efl::eina::js::instance_templates[efl::eina::js::list_container_type]->handle();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
#ifndef EINA_JS_CONTAINER_HH
|
||||||
|
#define EINA_JS_CONTAINER_HH
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
enum container_type
|
||||||
|
{
|
||||||
|
list_container_type
|
||||||
|
, array_container_type
|
||||||
|
, container_type_size
|
||||||
|
};
|
||||||
|
|
||||||
|
struct eina_container_base
|
||||||
|
{
|
||||||
|
virtual ~eina_container_base() {}
|
||||||
|
|
||||||
|
virtual std::size_t size() const = 0;
|
||||||
|
virtual eina_container_base* concat(eina_container_base const& rhs) const = 0;
|
||||||
|
virtual eina_container_base* slice(std::int64_t i, std::int64_t j) const = 0;
|
||||||
|
virtual int index_of(v8::Isolate* isolate, v8::Local<v8::Value> v) const = 0;
|
||||||
|
virtual int last_index_of(v8::Isolate* isolate, v8::Local<v8::Value> v) const = 0;
|
||||||
|
virtual v8::Local<v8::Value> get(v8::Isolate*, std::size_t) const = 0;
|
||||||
|
virtual v8::Local<v8::String> to_string(v8::Isolate*) const = 0;
|
||||||
|
virtual container_type get_container_type() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename C>
|
||||||
|
struct eina_container_common;
|
||||||
|
|
||||||
|
template <typename C, typename T, typename Enable = void>
|
||||||
|
struct eina_container_type_specific;
|
||||||
|
|
||||||
|
template <typename C, typename T>
|
||||||
|
struct eina_container_type_specific
|
||||||
|
<C, T, typename std::enable_if<std::is_integral<T>::value
|
||||||
|
&& !std::is_same<T, bool>::value
|
||||||
|
&& !std::is_same<T, char>::value
|
||||||
|
&& !std::is_same<T, char16_t>::value
|
||||||
|
&& !std::is_same<T, char32_t>::value
|
||||||
|
&& !std::is_same<T, wchar_t>::value>::type>
|
||||||
|
: eina_container_base
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> get(v8::Isolate* isolate, std::size_t index) const
|
||||||
|
{
|
||||||
|
return efl::eina::js::compatibility_new<v8::Number>(isolate, *std::next(container_get().begin(), index));
|
||||||
|
}
|
||||||
|
int index_of(v8::Isolate*, v8::Local<v8::Value> v) const
|
||||||
|
{
|
||||||
|
std::cout << "index_of" << std::endl;
|
||||||
|
if(v->IsInt32() || v->IsUint32())
|
||||||
|
{
|
||||||
|
int64_t value = v->IntegerValue();
|
||||||
|
typedef typename C::const_iterator iterator;
|
||||||
|
iterator first = container_get().begin()
|
||||||
|
, last = container_get().end()
|
||||||
|
, found = std::find(first, last, value);
|
||||||
|
if(found == last)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return std::distance(first, found);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int last_index_of(v8::Isolate*, v8::Local<v8::Value> v) const
|
||||||
|
{
|
||||||
|
std::cout << "last_index_of" << std::endl;
|
||||||
|
if(v->IsInt32() || v->IsUint32())
|
||||||
|
{
|
||||||
|
int64_t value = v->IntegerValue();
|
||||||
|
auto last = container_get().rend()
|
||||||
|
, found = std::find(container_get().rbegin(), last, value);
|
||||||
|
if(found == last)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return std::distance(container_get().begin(), found.base()) -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
C& container_get() { return static_cast<eina_container_common<C>&>(*this)._container; }
|
||||||
|
C const& container_get() const { return static_cast<eina_container_common<C>const&>(*this)._container; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <eina_js_error.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina {namespace js {
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
js::compatibility_return_type convert_error_to_javascript_exception(v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
std::cerr << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
Eina_Error err = eina_error_get();
|
||||||
|
if (!err)
|
||||||
|
return compatibility_return();
|
||||||
|
std::cerr << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
v8::Local<v8::Object> je = eina::js::compatibility_new<v8::Object>(isolate);
|
||||||
|
std::cerr << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "code"),
|
||||||
|
compatibility_new<v8::String>(isolate, "Eina_Error"));
|
||||||
|
std::cerr << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "value"),
|
||||||
|
compatibility_new<v8::String>(isolate, eina_error_msg_get(err)));
|
||||||
|
std::cerr << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
return compatibility_throw(isolate, je);
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef EINA_JS_ERROR_HH
|
||||||
|
#define EINA_JS_ERROR_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the error value set through Eina's error tool to a JavaScript
|
||||||
|
* exception.
|
||||||
|
*
|
||||||
|
* The exception object will have a `code` string field with the `"Eina_Error"`
|
||||||
|
* string value and a `value` string field with the value extracted from
|
||||||
|
* `eina_error_msg_get`.
|
||||||
|
*
|
||||||
|
* It won't reset the error to NULL, so you can still access the error object,
|
||||||
|
* but if you keep calling this function without clearing the error, a new
|
||||||
|
* exception will be generated for each call after some error is reached. We,
|
||||||
|
* therefore, suggest you to call `eina_error_set(0)` afterwards.
|
||||||
|
*/
|
||||||
|
js::compatibility_return_type convert_error_to_javascript_exception(v8::Isolate *isolate);
|
||||||
|
|
||||||
|
} } } // namespace efl::eina::js
|
||||||
|
|
||||||
|
#endif /* EINA_JS_ERROR_HH */
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef EFL_EINA_JS_GET_VALUE_HH
|
||||||
|
#define EFL_EINA_JS_GET_VALUE_HH
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct value_tag
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline int get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<T>
|
||||||
|
, typename std::enable_if<(std::is_integral<T>::value && !std::is_same<T, Eina_Bool>::value)>::type* = 0)
|
||||||
|
{
|
||||||
|
if(v->IsInt32())
|
||||||
|
return v->Int32Value();
|
||||||
|
else if(v->IsUint32())
|
||||||
|
return v->Uint32Value();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
|
||||||
|
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char* get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<char*>)
|
||||||
|
{
|
||||||
|
if(v->IsNull())
|
||||||
|
return nullptr;
|
||||||
|
else if(v->IsString())
|
||||||
|
{
|
||||||
|
v8::String::Utf8Value str(v->ToString());
|
||||||
|
char* string = strdup(*str); // TODO: leaks
|
||||||
|
std::cerr << "String " << string << std::endl;
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
|
||||||
|
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<const char*>)
|
||||||
|
{
|
||||||
|
return get_value_from_javascript(v, isolate, value_tag<char*>());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Eo* get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<Eo*>)
|
||||||
|
{
|
||||||
|
if(v->IsNull())
|
||||||
|
return nullptr;
|
||||||
|
else if(v->IsObject())
|
||||||
|
{
|
||||||
|
v8::Local<v8::Object> object = v->ToObject();
|
||||||
|
if(object->InternalFieldCount() == 1)
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> r = object->GetInternalField(0);
|
||||||
|
if(v8::External* external = v8::External::Cast(*r))
|
||||||
|
{
|
||||||
|
return static_cast<Eo*>(external->Value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
|
||||||
|
throw std::logic_error("");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<T>
|
||||||
|
, typename std::enable_if<std::is_enum<T>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
if(v->IsInt32())
|
||||||
|
return static_cast<T>(v->Int32Value());
|
||||||
|
else if(v->IsUint32())
|
||||||
|
return static_cast<T>(v->Uint32Value());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
|
||||||
|
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<Eina_Bool>)
|
||||||
|
{
|
||||||
|
if(v->IsBoolean() || v->IsBooleanObject())
|
||||||
|
{
|
||||||
|
return v->BooleanValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Boolean type")));
|
||||||
|
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline double get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value> v
|
||||||
|
, v8::Isolate* isolate
|
||||||
|
, value_tag<T>
|
||||||
|
, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
if(v->IsNumber())
|
||||||
|
{
|
||||||
|
return v->NumberValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T get_value_from_javascript
|
||||||
|
(v8::Local<v8::Value>, v8::Isolate* isolate, value_tag<T>
|
||||||
|
, typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value
|
||||||
|
&& !std::is_enum<T>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Trying to convert to " << typeid(T).name() << " to call a C function" << std::endl;
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(isolate, v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(isolate, "Not implemented yet")));
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,106 @@
|
||||||
|
#ifndef EFL_EINA_JS_GET_VALUE_FROM_C_HH
|
||||||
|
#define EFL_EINA_JS_GET_VALUE_FROM_C_HH
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename T> struct print_tag {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(T v, v8::Isolate* isolate
|
||||||
|
, typename std::enable_if<std::is_integral<T>::value && !std::is_same<T,bool>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_new<v8::Integer>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(T v, v8::Isolate* isolate
|
||||||
|
, typename std::enable_if<std::is_same<T,bool>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_new<v8::Boolean>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<T>
|
||||||
|
get_value_from_c(v8::Local<T> v, v8::Isolate*)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// inline v8::Local<v8::Value>
|
||||||
|
// get_value_from_c(T v, v8::Isolate* isolate
|
||||||
|
// , typename std::enable_if<std::is_integral<T>::value>::type* = 0)
|
||||||
|
// {
|
||||||
|
// return v8::Integer::New(isolate, v);
|
||||||
|
// }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(T v, v8::Isolate* isolate
|
||||||
|
, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_new<v8::Number>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(const char* v, v8::Isolate* isolate)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_new<v8::String>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(char* v, v8::Isolate* isolate)
|
||||||
|
{
|
||||||
|
return js::get_value_from_c(const_cast<const char*>(v), isolate);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(void*, v8::Isolate*)
|
||||||
|
{
|
||||||
|
std::cout << "aborting because we don't know type void*" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(const void*, v8::Isolate*)
|
||||||
|
{
|
||||||
|
std::cout << "aborting because we don't know type void*" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(T&, v8::Isolate*
|
||||||
|
, typename std::enable_if
|
||||||
|
<!std::is_pointer<T>::value
|
||||||
|
&& !std::is_integral<T>::value
|
||||||
|
&& !std::is_floating_point<T>::value
|
||||||
|
>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cout << "aborting because we don't know type " << typeid(print_tag<T>).name() << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline v8::Local<v8::Value>
|
||||||
|
get_value_from_c(T& object, v8::Isolate* isolate
|
||||||
|
, typename std::enable_if<std::is_pointer<T>::value
|
||||||
|
&& !(std::is_same<T, char*>::value || std::is_same<T, const char*>::value)>::type* = 0)
|
||||||
|
{
|
||||||
|
std::cout << "derefering " << typeid(print_tag<T>).name() << std::endl;
|
||||||
|
return get_value_from_c(*object, isolate);
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include <eina_js_iterator.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_destroy_iterator(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
typedef void (*deleter_t)(void*);
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type info) -> compatibility_return_type
|
||||||
|
{
|
||||||
|
if (info.Length() != 1 || !info[0]->IsObject())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
v8::Handle<v8::Object> o = info[0]->ToObject();
|
||||||
|
|
||||||
|
deleter_t deleter = compatibility_get_pointer_internal_field<deleter_t>(o, 1);
|
||||||
|
deleter(compatibility_get_pointer_internal_field<>(o, 0));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,83 @@
|
||||||
|
#ifndef EINA_JS_ITERATOR_HH
|
||||||
|
#define EINA_JS_ITERATOR_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include <eina_js_value.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
/* Exports the \p iterator to be manipulated by the JS code. The iterator should
|
||||||
|
remain alive as long as there is JS code referencing it. The JS code is able
|
||||||
|
to destroy the iterator by itself if you register the appropriate function
|
||||||
|
through `register_destroy_iterator`.
|
||||||
|
|
||||||
|
The exported JS object models part the [iterator concept from ECMAScript
|
||||||
|
6](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol).
|
||||||
|
|
||||||
|
The iterator will have the `next` function, but the returned object won't
|
||||||
|
have a `done` attribute, because the eina_iterator itself doesn't expose this
|
||||||
|
information.*/
|
||||||
|
template<class T>
|
||||||
|
v8::Local<v8::Object> export_iterator(::efl::eina::iterator<T> *i,
|
||||||
|
v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
typedef ::efl::eina::iterator<T> value_type;
|
||||||
|
typedef value_type *ptr_type;
|
||||||
|
typedef void (*deleter_t)(void*);
|
||||||
|
|
||||||
|
auto obj_tpl = compatibility_new<v8::ObjectTemplate>(isolate);
|
||||||
|
obj_tpl->SetInternalFieldCount(2);
|
||||||
|
|
||||||
|
auto ret = obj_tpl->NewInstance();
|
||||||
|
|
||||||
|
auto next = [](js::compatibility_callback_info_type info) -> compatibility_return_type
|
||||||
|
{
|
||||||
|
if (info.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
void *ptr = compatibility_get_pointer_internal_field(info.This(), 0);
|
||||||
|
auto &value = *static_cast<ptr_type>(ptr);
|
||||||
|
v8::Local<v8::Object> o = compatibility_new<v8::Object>(info.GetIsolate());
|
||||||
|
o->Set(compatibility_new<v8::String>(info.GetIsolate(), "value"),
|
||||||
|
value_cast<v8::Local<v8::Value>>(*value, info.GetIsolate()));
|
||||||
|
++value;
|
||||||
|
return compatibility_return(o, info);
|
||||||
|
};
|
||||||
|
|
||||||
|
ret->Set(compatibility_new<v8::String>(isolate, "next"),
|
||||||
|
compatibility_new<v8::FunctionTemplate>(isolate, next)->GetFunction());
|
||||||
|
|
||||||
|
{
|
||||||
|
deleter_t deleter = [](void *i) {
|
||||||
|
delete static_cast<ptr_type>(i);
|
||||||
|
};
|
||||||
|
compatibility_set_pointer_internal_field(ret, 0, i);
|
||||||
|
compatibility_set_pointer_internal_field
|
||||||
|
(ret, 1, reinterpret_cast<void*>(deleter));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extracts and returns a copy from the internal iterator object from the JS
|
||||||
|
object. */
|
||||||
|
template<class T>
|
||||||
|
::efl::eina::iterator<T> *import_iterator(v8::Handle<v8::Object> o)
|
||||||
|
;
|
||||||
|
// {
|
||||||
|
// typedef ::efl::eina::iterator<T> value_type;
|
||||||
|
// typedef value_type *ptr_type;
|
||||||
|
|
||||||
|
// return reinterpret_cast<ptr_type>(o->GetAlignedPointerFromInternalField(0));
|
||||||
|
// }
|
||||||
|
|
||||||
|
void register_destroy_iterator(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* EINA_JS_ITERATOR_HH */
|
|
@ -0,0 +1,130 @@
|
||||||
|
#ifndef EINA_JS_LIST_HH
|
||||||
|
#define EINA_JS_LIST_HH
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <eina_js_container.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
#include <Eina.hh>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
template <typename C>
|
||||||
|
struct eina_container_common : eina_container_type_specific<C, typename C::value_type>
|
||||||
|
{
|
||||||
|
eina_container_common() : _container(0) {}
|
||||||
|
eina_container_common(typename C::native_handle_type raw) : _container(raw) {}
|
||||||
|
|
||||||
|
std::size_t size() const { return _container.size(); }
|
||||||
|
v8::Local<v8::String> to_string(v8::Isolate* isolate) const
|
||||||
|
{
|
||||||
|
std::cout << "to_string" << std::endl;
|
||||||
|
typedef typename container_type::const_iterator iterator;
|
||||||
|
std::stringstream s;
|
||||||
|
for(iterator first = _container.begin()
|
||||||
|
, last = _container.end()
|
||||||
|
, last_elem = std::next(last, -1); first != last; ++first)
|
||||||
|
{
|
||||||
|
s << *first;
|
||||||
|
if(first != last_elem)
|
||||||
|
s << ",";
|
||||||
|
}
|
||||||
|
std::cout << "string " << s.str() << std::endl;
|
||||||
|
return compatibility_new<v8::String>(isolate, s.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
C _container;
|
||||||
|
typedef C container_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
eina_container_base* concat(T const& self, eina_container_base const& other)
|
||||||
|
{
|
||||||
|
std::cout << __func__ << " " << typeid(container_type).name() << std::endl;
|
||||||
|
T const& rhs = static_cast<T const&>(other);
|
||||||
|
typedef typename T::container_type container_type;
|
||||||
|
container_type container(self._container.begin(), self._container.end());
|
||||||
|
container.insert(container.end(), rhs._container.begin(), rhs._container.end());
|
||||||
|
return new T(container.release_native_handle());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
eina_container_base* slice(T const& self, std::int64_t i, std::int64_t j)
|
||||||
|
{
|
||||||
|
std::cout << __func__ << std::endl;
|
||||||
|
typedef typename T::container_type container_type;
|
||||||
|
container_type container(std::next(self._container.begin(), i), std::next(self._container.begin(), j));
|
||||||
|
return new T(container.release_native_handle());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct eina_list : eina_container_common<efl::eina::list
|
||||||
|
<T
|
||||||
|
, typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type> >
|
||||||
|
{
|
||||||
|
typedef eina_container_common<efl::eina::list<T
|
||||||
|
, typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type> > base_type;
|
||||||
|
using base_type::base_type;
|
||||||
|
typedef typename base_type::container_type container_type;
|
||||||
|
|
||||||
|
eina_container_base* concat(eina_container_base const& other) const
|
||||||
|
{
|
||||||
|
return detail::concat(*this, other);
|
||||||
|
}
|
||||||
|
eina_container_base* slice(std::int64_t i, std::int64_t j) const
|
||||||
|
{
|
||||||
|
return detail::slice(*this, i, j);
|
||||||
|
}
|
||||||
|
js::container_type get_container_type() const { return list_container_type; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct range_eina_list : eina_container_common<efl::eina::range_list<T> >
|
||||||
|
{
|
||||||
|
typedef eina_container_common<efl::eina::range_list<T> > base_type;
|
||||||
|
using base_type::base_type;
|
||||||
|
typedef typename base_type::container_type container_type;
|
||||||
|
typedef typename std::conditional
|
||||||
|
<std::is_base_of<efl::eo::base, T>::value
|
||||||
|
, efl::eina::eo_clone_allocator
|
||||||
|
, efl::eina::malloc_clone_allocator
|
||||||
|
>::type clone_allocator_type;
|
||||||
|
|
||||||
|
eina_container_base* concat(eina_container_base const& other) const
|
||||||
|
{
|
||||||
|
std::cout << __func__ << " " << typeid(container_type).name() << std::endl;
|
||||||
|
range_eina_list<T>const& rhs = static_cast<range_eina_list<T>const&>(other);
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
efl::eina::list<T, clone_allocator_type>
|
||||||
|
list(this->_container.begin(), this->_container.end());
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
list.insert(list.end(), rhs._container.begin(), rhs._container.end());
|
||||||
|
std::cout << __func__ << ":" << __LINE__ << std::endl;
|
||||||
|
return new eina_list<T>(list.release_native_handle());
|
||||||
|
}
|
||||||
|
eina_container_base* slice(std::int64_t i, std::int64_t j) const
|
||||||
|
{
|
||||||
|
efl::eina::list<T, clone_allocator_type>
|
||||||
|
list(std::next(this->_container.begin(), i), std::next(this->_container.begin(), j));
|
||||||
|
return new eina_list<T>(list.release_native_handle());
|
||||||
|
}
|
||||||
|
js::container_type get_container_type() const { return list_container_type; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,645 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <eina_js_log.hh>
|
||||||
|
#include <eina_js_value.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
|
||||||
|
va_list args)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
#if 0
|
||||||
|
/* TODO: unfortunately, the elegant and exception-safe version isn't
|
||||||
|
compiling (yet!) */
|
||||||
|
efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args),
|
||||||
|
efl::eina::steal_stringshare_ref);
|
||||||
|
return compatibility_new<String>(isolate, s.data(), String::kNormalString,
|
||||||
|
s.size());
|
||||||
|
#else
|
||||||
|
auto s = eina_stringshare_vprintf(fmt, args);
|
||||||
|
auto ret = compatibility_new<String>(isolate, s);
|
||||||
|
eina_stringshare_del(s);
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static compatibility_persistent<v8::Value> js_eina_log_print_cb_data;
|
||||||
|
|
||||||
|
static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
|
||||||
|
const char *file, const char *fnc, int line,
|
||||||
|
const char *fmt, void */*data*/, va_list args)
|
||||||
|
{
|
||||||
|
using v8::String;
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::Isolate;
|
||||||
|
|
||||||
|
Isolate *const isolate = Isolate::GetCurrent();
|
||||||
|
constexpr unsigned argc = 7;
|
||||||
|
|
||||||
|
v8::Handle<v8::Value> argv[argc] = {
|
||||||
|
compatibility_new<String>(isolate, d->name),
|
||||||
|
compatibility_new<String>(isolate, d->color),
|
||||||
|
compatibility_new<Integer>(isolate, static_cast<int>(level)),
|
||||||
|
compatibility_new<String>(isolate, file),
|
||||||
|
compatibility_new<String>(isolate, fnc),
|
||||||
|
compatibility_new<Integer>(isolate, line),
|
||||||
|
to_v8_string(isolate, fmt, args)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto o = js_eina_log_print_cb_data.handle();
|
||||||
|
v8::Function::Cast(*o)->Call(o->ToObject(), argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool valid_level_conversion(int src, Eina_Log_Level &dst)
|
||||||
|
{
|
||||||
|
if (src != EINA_LOG_LEVEL_CRITICAL && src != EINA_LOG_LEVEL_ERR
|
||||||
|
&& src != EINA_LOG_LEVEL_WARN && src != EINA_LOG_LEVEL_INFO
|
||||||
|
&& src != EINA_LOG_LEVEL_DBG)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dst = static_cast<Eina_Log_Level>(src);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_critical(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_LEVEL_CRITICAL;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_LEVEL_ERR;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_warn(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_LEVEL_WARN;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_info(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_LEVEL_INFO;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_LEVEL_DBG;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_global(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_DOMAIN_GLOBAL;
|
||||||
|
global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::String;
|
||||||
|
using v8::StackTrace;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto print = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
|
||||||
|
|| !args[2]->IsString())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
Eina_Log_Level level;
|
||||||
|
if (!valid_level_conversion(args[1]->NumberValue(), level))
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto frame = compatibility_current_stack_trace<>(args.GetIsolate(), 1,
|
||||||
|
StackTrace::kDetailed)->GetFrame(0);
|
||||||
|
|
||||||
|
eina_log_print(args[0]->NumberValue(), level,
|
||||||
|
*String::Utf8Value(frame->GetScriptNameOrSourceURL()),
|
||||||
|
*String::Utf8Value(frame->GetFunctionName()),
|
||||||
|
frame->GetLineNumber(), "%s",
|
||||||
|
*String::Utf8Value(args[2]));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, print)
|
||||||
|
->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_register(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::String;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
int d = eina_log_domain_register(*String::Utf8Value(args[0]),
|
||||||
|
*String::Utf8Value(args[1]));
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
return compatibility_return(value_cast<Local<Value>>(d, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_unregister(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_domain_unregister(args[0]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_registered_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
int l = eina_log_domain_registered_level_get(args[0]->NumberValue());
|
||||||
|
auto isolate = args.GetIsolate();
|
||||||
|
return compatibility_return(value_cast<Local<Value>>(l, isolate), args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_registered_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_domain_registered_level_set(args[0]->NumberValue(),
|
||||||
|
args[1]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_print_cb_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsFunction())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
js_eina_log_print_cb_data
|
||||||
|
= compatibility_persistent<Value>(args.GetIsolate(), args[0]);
|
||||||
|
eina_log_print_cb_set(js_eina_log_print_cb, NULL);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_level_set(args[0]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
int l = eina_log_level_get();
|
||||||
|
auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_level_check(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Boolean;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
bool b = eina_log_level_check(args[0]->NumberValue());
|
||||||
|
auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_color_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsBoolean())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_color_disable_set(args[0]->BooleanValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_color_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
bool b = eina_log_color_disable_get();
|
||||||
|
auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_file_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsBoolean())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_file_disable_set(args[0]->BooleanValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_file_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
bool b = eina_log_file_disable_get();
|
||||||
|
auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_function_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsBoolean())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_function_disable_set(args[0]->BooleanValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_function_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
bool b = eina_log_function_disable_get();
|
||||||
|
auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_abort_on_critical_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsBoolean())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_abort_on_critical_set(args[0]->BooleanValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_abort_on_critical_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Boolean;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
bool b = eina_log_abort_on_critical_get();
|
||||||
|
auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_abort_on_critical_level_set(args[0]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 0)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
int l = eina_log_abort_on_critical_level_get();
|
||||||
|
auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::String;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsNumber())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
eina_log_domain_level_set(*String::Utf8Value(args[0]),
|
||||||
|
args[1]->NumberValue());
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_domain_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::String;
|
||||||
|
using v8::Integer;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 1 || !args[0]->IsString())
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
int l = eina_log_domain_level_get(*String::Utf8Value(args[0]));
|
||||||
|
auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
|
||||||
|
return compatibility_return(ret, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_state_start(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_STATE_START;
|
||||||
|
global->Set(name, compatibility_new<v8::Integer>(isolate, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_state_stop(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
int value = EINA_LOG_STATE_STOP;
|
||||||
|
global->Set(name, compatibility_new<v8::Integer>(isolate, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Value;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::String;
|
||||||
|
|
||||||
|
auto f = [](compatibility_callback_info_type args)
|
||||||
|
-> compatibility_return_type {
|
||||||
|
if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
|
||||||
|
|| !args[2]->IsString()) {
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
eina_log_timing(args[0]->NumberValue(),
|
||||||
|
static_cast<Eina_Log_State>(args[1]->NumberValue()),
|
||||||
|
*String::Utf8Value(args[2]));
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name,
|
||||||
|
compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,135 @@
|
||||||
|
#ifndef EINA_JS_LOG_HH
|
||||||
|
#define EINA_JS_LOG_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
using ::efl::eina::js::compatibility_new;
|
||||||
|
using ::efl::eina::js::compatibility_return_type;
|
||||||
|
using ::efl::eina::js::compatibility_callback_info_type;
|
||||||
|
using ::efl::eina::js::compatibility_return;
|
||||||
|
using ::efl::eina::js::compatibility_get_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_set_pointer_internal_field;
|
||||||
|
using ::efl::eina::js::compatibility_persistent;
|
||||||
|
|
||||||
|
void register_log_level_critical(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_warn(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_info(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_global(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_register(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_unregister(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_registered_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_registered_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_print_cb_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_level_check(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_color_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_color_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_file_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_file_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_function_disable_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_function_disable_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_abort_on_critical_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_abort_on_critical_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_level_set(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_domain_level_get(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_state_start(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_state_stop(v8::Isolate *isolate,
|
||||||
|
v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* EINA_JS_LOG_HH */
|
|
@ -0,0 +1,148 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <eina_js_value.hh>
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
compatibility_return_type eina_value_set(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
if (args.Length() != 1)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
void *ptr = js::compatibility_get_pointer_internal_field(args.Holder(), 0);
|
||||||
|
v8::Isolate *isolate = args.GetIsolate();
|
||||||
|
try {
|
||||||
|
*static_cast<value*>(ptr) = value_cast<value>(args[0]);
|
||||||
|
} catch(const std::bad_cast &e) {
|
||||||
|
v8::Local<v8::Object> je = compatibility_new<v8::Object>(isolate);
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "code"),
|
||||||
|
compatibility_new<v8::String>(isolate, "std::bad_cast"));
|
||||||
|
return compatibility_throw(isolate, je);
|
||||||
|
} catch(const ::efl::eina::system_error &e) {
|
||||||
|
v8::Local<v8::Object> je = compatibility_new<v8::Object>(isolate);
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "code"),
|
||||||
|
compatibility_new<v8::String>(isolate, "std::error_code"));
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "category"),
|
||||||
|
compatibility_new<v8::String>(isolate, e.code().category().name()));
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "value"),
|
||||||
|
compatibility_new<v8::Integer>(isolate, e.code().value()));
|
||||||
|
return compatibility_throw(isolate, je);
|
||||||
|
}
|
||||||
|
return compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_return_type eina_value_get(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
void *ptr = compatibility_get_pointer_internal_field(args.Holder(), 0);
|
||||||
|
auto &value = *static_cast<eina::value*>(ptr);
|
||||||
|
return compatibility_return
|
||||||
|
(value_cast<v8::Local<v8::Value>>(value, args.GetIsolate()), args);
|
||||||
|
}
|
||||||
|
|
||||||
|
compatibility_return_type eina_value_constructor(compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
if (args.Length() != 1)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
v8::Isolate* isolate = args.GetIsolate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
std::unique_ptr<value>
|
||||||
|
ptr(new value(value_cast<value>(args[0])));
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
compatibility_set_pointer_internal_field(args.This(), 0, ptr.get());
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
ptr.release();
|
||||||
|
} catch(const std::bad_cast &e) {
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
v8::Local<v8::Object> je = compatibility_new<v8::Object>(isolate);
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "code"),
|
||||||
|
compatibility_new<v8::String>(isolate, "std::bad_cast"));
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
return compatibility_throw(isolate,je);
|
||||||
|
} catch(const ::efl::eina::system_error &e) {
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
v8::Local<v8::Object> je = compatibility_new<v8::Object>(isolate);
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "code"),
|
||||||
|
compatibility_new<v8::String>(isolate, "std::error_code"));
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "category"),
|
||||||
|
compatibility_new<v8::String>(isolate, e.code().category().name()));
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
je->Set(compatibility_new<v8::String>(isolate, "value"),
|
||||||
|
compatibility_new<v8::Integer>(isolate, e.code().value()));
|
||||||
|
std::cout << __func__ << ':' << __LINE__ << std::endl;
|
||||||
|
return compatibility_throw(isolate, je);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
using v8::Isolate;
|
||||||
|
using v8::Local;
|
||||||
|
using v8::Value;
|
||||||
|
using v8::Integer;
|
||||||
|
using v8::String;
|
||||||
|
using v8::Object;
|
||||||
|
using v8::FunctionTemplate;
|
||||||
|
using v8::FunctionCallbackInfo;
|
||||||
|
|
||||||
|
typedef ::efl::eina::value value_type;
|
||||||
|
typedef value_type *ptr_type;
|
||||||
|
|
||||||
|
static compatibility_persistent<v8::FunctionTemplate>* constructor
|
||||||
|
= new compatibility_persistent<v8::FunctionTemplate>
|
||||||
|
{isolate, compatibility_new<v8::FunctionTemplate>(isolate, &eina_value_constructor)};
|
||||||
|
|
||||||
|
static compatibility_persistent<v8::ObjectTemplate>* instance
|
||||||
|
= new compatibility_persistent<v8::ObjectTemplate>
|
||||||
|
{isolate, constructor->handle()->InstanceTemplate()};
|
||||||
|
instance->handle()->SetInternalFieldCount(1);
|
||||||
|
|
||||||
|
auto prototype = constructor->handle()->PrototypeTemplate();
|
||||||
|
|
||||||
|
prototype->Set(compatibility_new<v8::String>(isolate, "set")
|
||||||
|
, compatibility_new<FunctionTemplate>(isolate, &eina_value_set));
|
||||||
|
prototype->Set(compatibility_new<v8::String>(isolate, "get")
|
||||||
|
, compatibility_new<FunctionTemplate>(isolate, &eina_value_get));
|
||||||
|
|
||||||
|
global->Set(name, constructor->handle()->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI
|
||||||
|
void register_destroy_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name)
|
||||||
|
{
|
||||||
|
typedef ::efl::eina::value value_type;
|
||||||
|
typedef value_type *ptr_type;
|
||||||
|
|
||||||
|
auto dtor = [](compatibility_callback_info_type info) -> js::compatibility_return_type
|
||||||
|
{
|
||||||
|
if (info.Length() != 1)
|
||||||
|
return compatibility_return();
|
||||||
|
|
||||||
|
auto o = info[0]->ToObject();
|
||||||
|
delete static_cast<ptr_type>(compatibility_get_pointer_internal_field(o, 0));
|
||||||
|
compatibility_set_pointer_internal_field<void*>(o, 0, nullptr);
|
||||||
|
assert(compatibility_get_pointer_internal_field(o, 0) == nullptr);
|
||||||
|
return compatibility_return();
|
||||||
|
};
|
||||||
|
|
||||||
|
global->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, dtor)->GetFunction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} } } // namespace efl { namespace js {
|
|
@ -0,0 +1,145 @@
|
||||||
|
#ifndef EINA_JS_VALUE_HH
|
||||||
|
#define EINA_JS_VALUE_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
|
||||||
|
namespace efl { namespace eina { namespace js {
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<class T, class = void>
|
||||||
|
struct is_representable_as_v8_integer: std::false_type {};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_representable_as_v8_integer
|
||||||
|
<T,
|
||||||
|
typename std::enable_if<std::is_integral<T>::value
|
||||||
|
/* v8::Integer only stores 32-bit signed and unsigned
|
||||||
|
numbers. */
|
||||||
|
&& (sizeof(T) <= sizeof(int32_t))>::type>
|
||||||
|
: std::true_type {};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<is_representable_as_v8_integer<T>::value
|
||||||
|
&& std::is_signed<T>::value,
|
||||||
|
v8::Local<v8::Value>>::type
|
||||||
|
to_v8_number(const T &v, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
return compatibility_new<v8::Integer>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<is_representable_as_v8_integer<T>::value
|
||||||
|
&& std::is_unsigned<T>::value,
|
||||||
|
v8::Local<v8::Value>>::type
|
||||||
|
to_v8_number(const T &v, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
return compatibility_new<v8::Integer>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<(std::is_integral<T>::value
|
||||||
|
&& !is_representable_as_v8_integer<T>::value)
|
||||||
|
|| std::is_floating_point<T>::value,
|
||||||
|
v8::Local<v8::Value>>::type
|
||||||
|
to_v8_number(const T &v, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
return compatibility_new<v8::Number>(isolate, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<std::is_same<T, ::efl::eina::stringshare>::value
|
||||||
|
|| std::is_same<T, std::string>::value,
|
||||||
|
v8::Local<v8::Value>>::type
|
||||||
|
to_v8_string(const T &v, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
return compatibility_new<v8::String>(isolate, v.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<std::is_same<T, v8::Local<v8::Value>>::value, T>::type
|
||||||
|
value_cast(const ::efl::eina::value &v, v8::Isolate *isolate)
|
||||||
|
{
|
||||||
|
using detail::to_v8_number;
|
||||||
|
using detail::to_v8_string;
|
||||||
|
using ::efl::eina::get;
|
||||||
|
|
||||||
|
const auto &t = v.type_info();
|
||||||
|
if (t == EINA_VALUE_TYPE_UINT64) {
|
||||||
|
return to_v8_number(get<uint64_t>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_UCHAR) {
|
||||||
|
return to_v8_number(get<unsigned char>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_USHORT) {
|
||||||
|
return to_v8_number(get<unsigned short>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_UINT) {
|
||||||
|
return to_v8_number(get<unsigned int>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_ULONG) {
|
||||||
|
return to_v8_number(get<unsigned long>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_CHAR) {
|
||||||
|
return to_v8_number(get<char>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_SHORT) {
|
||||||
|
return to_v8_number(get<short>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_INT) {
|
||||||
|
return to_v8_number(get<int>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_LONG) {
|
||||||
|
return to_v8_number(get<long>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_FLOAT) {
|
||||||
|
return to_v8_number(get<float>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_DOUBLE) {
|
||||||
|
return to_v8_number(get<double>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_STRINGSHARE) {
|
||||||
|
return to_v8_string(get<::efl::eina::stringshare>(v), isolate);
|
||||||
|
} else if (t == EINA_VALUE_TYPE_STRING) {
|
||||||
|
return to_v8_string(get<std::string>(v), isolate);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast{};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<std::is_same<T, ::efl::eina::value>::value, T>::type
|
||||||
|
value_cast(const v8::Handle<v8::Value> &v)
|
||||||
|
{
|
||||||
|
using ::efl::eina::value;
|
||||||
|
|
||||||
|
if (v->IsBoolean()) {
|
||||||
|
return value(int{v->BooleanValue()});
|
||||||
|
} else if (v->IsInt32()) {
|
||||||
|
return value(v->Int32Value());
|
||||||
|
} else if (v->IsUint32()) {
|
||||||
|
return value(v->Uint32Value());
|
||||||
|
} else if (v->IsNumber()) {
|
||||||
|
return value(v->NumberValue());
|
||||||
|
} else if (v->IsString()) {
|
||||||
|
v8::String::Utf8Value data(v);
|
||||||
|
return value(std::string(*data, data.length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast{};
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
# JS binding
|
||||||
|
|
||||||
|
- There is the `value()` constructor, which accepts a primitive value as input
|
||||||
|
argument and might throw.
|
||||||
|
- The returned object has a `get()` method, which can be used to get the
|
||||||
|
wrapped value as a JavaScript value.
|
||||||
|
- The returned object has a `set()` method, which can be used to change the
|
||||||
|
wrapped value.
|
||||||
|
*/
|
||||||
|
void register_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
void register_destroy_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
|
||||||
|
v8::Handle<v8::String> name);
|
||||||
|
|
||||||
|
} } } // namespace efl::js
|
||||||
|
|
||||||
|
#endif /* EINA_JS_VALUE_HH */
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef EFL_EO_JS_HH
|
||||||
|
#define EFL_EO_JS_HH
|
||||||
|
|
||||||
|
#include <eo_js_direction.hh>
|
||||||
|
#include <eo_js_constructor.hh>
|
||||||
|
#include <eo_js_call_function.hh>
|
||||||
|
#include <eo_js_event.hh>
|
||||||
|
#include <eo_js_construct_from_eo.hh>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
#ifndef EFL_EO_JS_CALL_FUNCTION_HH
|
||||||
|
#define EFL_EO_JS_CALL_FUNCTION_HH
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_tuple.hh>
|
||||||
|
#include <eina_tuple_c.hh>
|
||||||
|
#include <eina_function.hh>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#include <eina_js_get_value.hh>
|
||||||
|
#include <eina_js_get_value_from_c.hh>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace efl { namespace eo { namespace js {
|
||||||
|
|
||||||
|
inline eina::js::compatibility_return_type call_function(eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cerr << "call_function" << std::endl;
|
||||||
|
void* data = v8::External::Cast(*args.Data())->Value();
|
||||||
|
std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type)>*
|
||||||
|
f = static_cast<std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type)>*>(data);
|
||||||
|
return (*f)(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename In, typename Out, typename Ownership, typename F>
|
||||||
|
struct method_caller
|
||||||
|
{
|
||||||
|
typedef typename eina::_mpl::function_params<F>::type parameters_t;
|
||||||
|
|
||||||
|
template <std::size_t I>
|
||||||
|
struct is_out : eina::_mpl::tuple_contains<std::integral_constant<std::size_t, I>, Out>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <typename U, std::size_t I, typename Outs>
|
||||||
|
static
|
||||||
|
typename std::tuple_element<I, parameters_t>::type
|
||||||
|
get_value(eina::js::compatibility_callback_info_type args, Outs& /*outs*/, v8::Isolate* isolate
|
||||||
|
, std::false_type)
|
||||||
|
{
|
||||||
|
std::cout << "is NOT out" << std::endl;
|
||||||
|
return eina::js::get_value_from_javascript
|
||||||
|
(args[I], isolate
|
||||||
|
, eina::js::value_tag<typename std::tuple_element
|
||||||
|
<I, typename eina::_mpl::function_params<U>::type>::type>());
|
||||||
|
}
|
||||||
|
template <typename U, std::size_t I, typename Outs>
|
||||||
|
static
|
||||||
|
typename std::add_pointer<
|
||||||
|
typename std::tuple_element
|
||||||
|
<eina::_mpl::tuple_find<std::integral_constant<std::size_t, I>, Out>::value
|
||||||
|
, Outs>::type>::type
|
||||||
|
get_value(eina::js::compatibility_callback_info_type, Outs& outs, v8::Isolate*
|
||||||
|
, std::true_type)
|
||||||
|
{
|
||||||
|
std::cout << "is out" << std::endl;
|
||||||
|
return &std::get<eina::_mpl::tuple_find<std::integral_constant<std::size_t, I>, Out>::value>
|
||||||
|
(outs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_unique_value(eina::js::compatibility_callback_info_type args
|
||||||
|
, R const& r) const
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_return(eina::js::get_value_from_c(r, args.GetIsolate()), args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Outs>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_value(eina::js::compatibility_callback_info_type args
|
||||||
|
, Outs const& outs
|
||||||
|
, typename std::enable_if<std::tuple_size<Outs>::value == 1>::type* = 0) const
|
||||||
|
{
|
||||||
|
return create_return_unique_value(args, std::get<0u>(outs));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Outs>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_value(eina::js::compatibility_callback_info_type
|
||||||
|
, Outs const&
|
||||||
|
, typename std::enable_if<std::tuple_size<Outs>::value == 0>::type* = 0) const
|
||||||
|
{
|
||||||
|
// nothing
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Outs>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_value(eina::js::compatibility_callback_info_type args
|
||||||
|
, Outs const& outs
|
||||||
|
, typename std::enable_if<(std::tuple_size<Outs>::value > 1)>::type* = 0) const
|
||||||
|
{
|
||||||
|
v8::Isolate* isolate = args.GetIsolate();
|
||||||
|
int const length = std::tuple_size<Outs>::value;
|
||||||
|
v8::Local<v8::Array> ret = eina::js::compatibility_new<v8::Array>(isolate, length);
|
||||||
|
set_return<0u>(isolate, ret, outs, eina::make_index_sequence<std::tuple_size<Outs>::value>());
|
||||||
|
return eina::js::compatibility_return(ret, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename R, typename Outs>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_value(eina::js::compatibility_callback_info_type args
|
||||||
|
, R const& r
|
||||||
|
, Outs const&
|
||||||
|
, typename std::enable_if<std::tuple_size<Outs>::value == 0>::type* = 0) const
|
||||||
|
{
|
||||||
|
return create_return_unique_value(args, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t Offset, typename Outs, std::size_t...S>
|
||||||
|
void set_return(v8::Isolate* isolate, v8::Local<v8::Array> r
|
||||||
|
, Outs const& outs, eina::index_sequence<S...>) const
|
||||||
|
{
|
||||||
|
std::initializer_list<int> l
|
||||||
|
= {(r->Set(S+Offset, eina::js::get_value_from_c(std::get<S>(outs), isolate)),0)...};
|
||||||
|
static_cast<void>(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename R, typename Outs>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
create_return_value(eina::js::compatibility_callback_info_type args
|
||||||
|
, R const& r
|
||||||
|
, Outs const& outs
|
||||||
|
, typename std::enable_if<std::tuple_size<Outs>::value != 0>::type* = 0) const
|
||||||
|
{
|
||||||
|
v8::Isolate* isolate = args.GetIsolate();
|
||||||
|
int const length = std::tuple_size<Outs>::value + 1;
|
||||||
|
v8::Local<v8::Array> ret = eina::js::compatibility_new<v8::Array>(isolate, length);
|
||||||
|
ret->Set(0, eina::js::get_value_from_c(r, isolate));
|
||||||
|
set_return<1u>(isolate, ret, outs, eina::make_index_sequence<std::tuple_size<Outs>::value>());
|
||||||
|
return eina::js::compatibility_return(ret, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t... I>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
aux(eina::js::compatibility_callback_info_type args, eina::index_sequence<I...>
|
||||||
|
, std::true_type) const
|
||||||
|
{
|
||||||
|
typename eina::_mpl::tuple_transform<Out, out_transform<parameters_t> >::type outs {};
|
||||||
|
static_cast<void>(outs);
|
||||||
|
|
||||||
|
function(get_value<F, I>(args, outs, args.GetIsolate(), typename is_out<I>::type())...);
|
||||||
|
return create_return_value(args, outs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t... I>
|
||||||
|
eina::js::compatibility_return_type
|
||||||
|
aux(eina::js::compatibility_callback_info_type args, eina::index_sequence<I...>
|
||||||
|
, std::false_type) const
|
||||||
|
{
|
||||||
|
typename eina::_mpl::tuple_transform<Out, out_transform<parameters_t> >::type outs {};
|
||||||
|
static_cast<void>(outs);
|
||||||
|
|
||||||
|
typename eina::_mpl::function_return<F>::type r =
|
||||||
|
function(get_value<F, I>(args, outs, args.GetIsolate(), typename is_out<I>::type())...);
|
||||||
|
return create_return_value(args, r, outs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
struct out_transform
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct apply
|
||||||
|
{
|
||||||
|
typedef typename std::remove_pointer<typename std::tuple_element<T::value, P>::type>::type type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
eina::js::compatibility_return_type operator()(eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
std::cerr << "call function operator()(args)" << std::endl;
|
||||||
|
int input_parameters = std::tuple_size<In>::value;
|
||||||
|
if(input_parameters <= args.Length())
|
||||||
|
{
|
||||||
|
v8::Local<v8::Object> self = args.This();
|
||||||
|
v8::Local<v8::Value> external = self->GetInternalField(0);
|
||||||
|
Eo* eo = static_cast<Eo*>(v8::External::Cast(*external)->Value());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
eo_do
|
||||||
|
(eo,
|
||||||
|
return aux(args, eina::make_index_sequence<std::tuple_size<parameters_t>::value>()
|
||||||
|
, std::is_same<void, typename eina::_mpl::function_return<F>::type>())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch(std::logic_error const&)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_throw
|
||||||
|
(v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(nullptr, "Expected more arguments for this call")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
F function;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename In, typename Out, typename Ownership, typename F>
|
||||||
|
v8::Handle<v8::Value> call_function_data(v8::Isolate* isolate, F f)
|
||||||
|
{
|
||||||
|
return eina::js::compatibility_new<v8::External>
|
||||||
|
(isolate, new std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type const&)>
|
||||||
|
(method_caller<In, Out, Ownership, F>{f}));
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef EFL_EO_JS_CONSTRUCT_FROM_EO_HH
|
||||||
|
#define EFL_EO_JS_CONSTRUCT_FROM_EO_HH
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_tuple.hh>
|
||||||
|
#include <eina_tuple_c.hh>
|
||||||
|
#include <eina_function.hh>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#include <eina_js_get_value.hh>
|
||||||
|
#include <eina_js_get_value_from_c.hh>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace efl { namespace eo { namespace js {
|
||||||
|
|
||||||
|
inline eina::js::compatibility_return_type construct_from_eo(eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
if(args.IsConstructCall())
|
||||||
|
{
|
||||||
|
args.This()->SetInternalField(0, args[0]);
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::size_t argc = args.Length();
|
||||||
|
std::vector<v8::Local<v8::Value> > argv (argc ? argc : 1 );
|
||||||
|
for(int i = 0; i != args.Length(); ++i)
|
||||||
|
argv[i] = args[i];
|
||||||
|
args.Callee()->NewInstance(argc, &argv[0]);
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,156 @@
|
||||||
|
#ifndef EFL_EO_JS_CONSTRUCTOR_HH
|
||||||
|
#define EFL_EO_JS_CONSTRUCTOR_HH
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_tuple.hh>
|
||||||
|
#include <eina_function.hh>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#include <eina_js_get_value.hh>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace efl { namespace eo { namespace js {
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
inline void constructor(v8::FunctionCallbackInfo<v8::Value> const& args)
|
||||||
|
{
|
||||||
|
if(args.IsConstructCall())
|
||||||
|
{
|
||||||
|
void* data = v8::External::Cast(*args.Data())->Value();
|
||||||
|
std::function<void(v8::FunctionCallbackInfo<v8::Value>const&)>*
|
||||||
|
f = static_cast<std::function<void(v8::FunctionCallbackInfo<v8::Value>const&)>*>(data);
|
||||||
|
(*f)(args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::size_t argc = args.Length();
|
||||||
|
std::vector<v8::Local<v8::Value> > argv (argc ? argc : 1 );
|
||||||
|
for(int i = 0; i != args.Length(); ++i)
|
||||||
|
argv[i] = args[i];
|
||||||
|
args.Callee()->NewInstance(argc, &argv[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
inline eina::js::compatibility_return_type constructor(eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
if(args.IsConstructCall())
|
||||||
|
{
|
||||||
|
void* data = v8::External::Cast(*args.Data())->Value();
|
||||||
|
std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type)>*
|
||||||
|
f = static_cast<std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type)>*>
|
||||||
|
(data);
|
||||||
|
return (*f)(args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::size_t argc = args.Length();
|
||||||
|
std::vector<v8::Local<v8::Value> > argv (argc ? argc : 1 );
|
||||||
|
for(int i = 0; i != args.Length(); ++i)
|
||||||
|
argv[i] = args[i];
|
||||||
|
args.Callee()->NewInstance(argc, &argv[0]);
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename...F>
|
||||||
|
struct constructor_caller
|
||||||
|
{
|
||||||
|
struct call
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
void operator()(T function) const
|
||||||
|
{
|
||||||
|
int const parameters
|
||||||
|
= std::tuple_size<typename eina::_mpl::function_params<T>::type>::value;
|
||||||
|
if(*current + parameters <= args->Length())
|
||||||
|
{
|
||||||
|
aux(function, eina::make_index_sequence<parameters>());
|
||||||
|
*current += parameters;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(args->GetIsolate(), "Expected more arguments for this call")));
|
||||||
|
throw std::logic_error("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U, std::size_t I>
|
||||||
|
static
|
||||||
|
typename std::tuple_element<I, typename eina::_mpl::function_params<U>::type>::type
|
||||||
|
get_value(v8::Local<v8::Value> v, v8::Isolate* isolate)
|
||||||
|
{
|
||||||
|
typename std::tuple_element<I, typename eina::_mpl::function_params<U>::type>::type
|
||||||
|
tmp =
|
||||||
|
eina::js::get_value_from_javascript
|
||||||
|
(v, isolate
|
||||||
|
, eina::js::value_tag<typename std::tuple_element
|
||||||
|
<I, typename eina::_mpl::function_params<U>::type>::type>());
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, std::size_t... I>
|
||||||
|
void aux(T function, eina::index_sequence<I...>) const
|
||||||
|
{
|
||||||
|
function(get_value<T, I>((*args)[I + *current], args->GetIsolate())...);
|
||||||
|
}
|
||||||
|
|
||||||
|
int* current;
|
||||||
|
eina::js::compatibility_callback_info_pointer args;
|
||||||
|
};
|
||||||
|
|
||||||
|
eina::js::compatibility_return_type operator()(eina::js::compatibility_callback_info_type args) const
|
||||||
|
{
|
||||||
|
int current_index = 1;
|
||||||
|
if(args.Length() != 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Eo* parent = eina::js::get_value_from_javascript
|
||||||
|
(args[0], args.GetIsolate(), eina::js::value_tag<Eo*>());
|
||||||
|
Eo* eo = eo_add
|
||||||
|
(klass
|
||||||
|
, parent
|
||||||
|
, eina::_mpl::for_each(constructors, call{¤t_index, &args})
|
||||||
|
);
|
||||||
|
assert(eo != 0);
|
||||||
|
v8::Local<v8::Object> self = args.This();
|
||||||
|
self->SetInternalField(0, eina::js::compatibility_new<v8::External>(args.GetIsolate(), eo));
|
||||||
|
}
|
||||||
|
catch(std::logic_error const&) {}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eina::js::compatibility_throw
|
||||||
|
(v8::Exception::TypeError
|
||||||
|
(eina::js::compatibility_new<v8::String>(args.GetIsolate(), "Expected at least one argument for this call")));
|
||||||
|
}
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
Eo_Class const* klass;
|
||||||
|
std::tuple<F...> constructors;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... F>
|
||||||
|
v8::Handle<v8::Value> constructor_data(v8::Isolate* isolate, Eo_Class const* klass, F... f)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "function called %s\n", __func__); fflush(stderr);
|
||||||
|
return eina::js::compatibility_new<v8::External>
|
||||||
|
(isolate
|
||||||
|
, new std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type)>
|
||||||
|
(constructor_caller<F...>{klass, std::tuple<F...>{f...}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef EFL_EO_JS_EO_JS_DIRECTION_HH
|
||||||
|
#define EFL_EO_JS_EO_JS_DIRECTION_HH
|
||||||
|
|
||||||
|
namespace efl { namespace eo { namespace js {
|
||||||
|
|
||||||
|
struct input {};
|
||||||
|
struct output {};
|
||||||
|
struct input_output {};
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,80 @@
|
||||||
|
#ifndef EFL_EO_JS_EVENT_HH
|
||||||
|
#define EFL_EO_JS_EVENT_HH
|
||||||
|
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <eina_tuple.hh>
|
||||||
|
#include <eina_tuple_c.hh>
|
||||||
|
#include <eina_function.hh>
|
||||||
|
#include <Eo.h>
|
||||||
|
|
||||||
|
#include <eina_js_get_value.hh>
|
||||||
|
#include <eina_js_get_value_from_c.hh>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace efl { namespace eo { namespace js {
|
||||||
|
|
||||||
|
struct event_information
|
||||||
|
{
|
||||||
|
eina::js::compatibility_persistent<v8::Function>* constructor;
|
||||||
|
Eo_Event_Description const* event;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct event_callback_information
|
||||||
|
{
|
||||||
|
event_information* event_info;
|
||||||
|
eina::js::compatibility_persistent<v8::Function> function;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline Eina_Bool event_callback(void* data, Eo* obj, Eo_Event_Description const*
|
||||||
|
, void* /*event_info*/)
|
||||||
|
{
|
||||||
|
event_callback_information* event = static_cast<event_callback_information*>(data);
|
||||||
|
v8::Handle<v8::Value> a[] = {eina::js::compatibility_new<v8::External>(nullptr, obj)};
|
||||||
|
v8::Local<v8::Object> self = (event->event_info->constructor->handle())->NewInstance(1, a);
|
||||||
|
|
||||||
|
v8::Handle<v8::Value> call_args[] = {self};
|
||||||
|
event->function->Call(eina::js::compatibility_global(), 1, call_args);
|
||||||
|
|
||||||
|
return EO_CALLBACK_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eina::js::compatibility_return_type event_call(eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
if(args.Length() >= 1)
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> arg1 = args[0];
|
||||||
|
if(arg1->IsFunction())
|
||||||
|
{
|
||||||
|
v8::Local<v8::Value> data = args.Data();
|
||||||
|
event_information* event =
|
||||||
|
static_cast<event_information*>
|
||||||
|
(v8::External::Cast(*data)->Value());
|
||||||
|
|
||||||
|
v8::Local<v8::Object> self = args.This();
|
||||||
|
v8::Local<v8::Value> external = self->GetInternalField(0);
|
||||||
|
Eo* eo = static_cast<Eo*>(v8::External::Cast(*external)->Value());
|
||||||
|
|
||||||
|
event_callback_information* i = new event_callback_information
|
||||||
|
{event, eina::js::compatibility_persistent<v8::Function>
|
||||||
|
(args.GetIsolate()
|
||||||
|
, eina::js::compatibility_cast<v8::Function>(*arg1->ToObject()))};
|
||||||
|
|
||||||
|
eo_do(eo, eo_event_callback_priority_add
|
||||||
|
(event->event, EO_CALLBACK_PRIORITY_DEFAULT, &event_callback, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
} } }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NODEJS
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(NODE_INCLUDE_HEADER)
|
||||||
|
#include EINA_STRINGIZE(UV_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <Efl.h>
|
||||||
|
#include <Eo.h>
|
||||||
|
#include <Ecore.h>
|
||||||
|
#include <Ecore_Evas.h>
|
||||||
|
|
||||||
|
namespace evas {
|
||||||
|
EAPI void register_box(v8::Handle<v8::Object> global, v8::Isolate* isolate);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Ecore_Evas* ee;
|
||||||
|
|
||||||
|
void init(v8::Handle<v8::Object> exports)
|
||||||
|
{
|
||||||
|
std::cout << "init hey " << std::endl;
|
||||||
|
::eina_init();
|
||||||
|
::ecore_init();
|
||||||
|
::ecore_evas_init();
|
||||||
|
::eo_init();
|
||||||
|
|
||||||
|
// ee = ecore_evas_new(NULL, 100, 100, 200, 200, NULL);
|
||||||
|
// ecore_evas_show(ee);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
evas::register_box(exports, v8::Isolate::GetCurrent());
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
std::cout << "Exception" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "inited " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_MODULE(efl, init)
|
||||||
|
|
||||||
|
#endif
|
|
@ -200,10 +200,14 @@ ecore_app_no_system_modules(void)
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_init(void)
|
ecore_init(void)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
if (++_ecore_init_count != 1)
|
if (++_ecore_init_count != 1)
|
||||||
return _ecore_init_count;
|
return _ecore_init_count;
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
/*
|
/*
|
||||||
if (strcmp(nl_langinfo(CODESET), "UTF-8"))
|
if (strcmp(nl_langinfo(CODESET), "UTF-8"))
|
||||||
{
|
{
|
||||||
|
@ -214,39 +218,54 @@ ecore_init(void)
|
||||||
if (!evil_init())
|
if (!evil_init())
|
||||||
return --_ecore_init_count;
|
return --_ecore_init_count;
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
if (!eina_init())
|
if (!eina_init())
|
||||||
goto shutdown_evil;
|
goto shutdown_evil;
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR);
|
_ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
if (_ecore_log_dom < 0)
|
if (_ecore_log_dom < 0)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
EINA_LOG_ERR("Ecore was unable to create a log domain.");
|
EINA_LOG_ERR("Ecore was unable to create a log domain.");
|
||||||
goto shutdown_log_dom;
|
goto shutdown_log_dom;
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
_ecore_pfx = eina_prefix_new(NULL, ecore_init,
|
_ecore_pfx = eina_prefix_new(NULL, ecore_init,
|
||||||
"ECORE", "ecore", "checkme",
|
"ECORE", "ecore", "checkme",
|
||||||
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
|
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
|
||||||
PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
if (!_ecore_pfx)
|
if (!_ecore_pfx)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
ERR("Could not get ecore installation prefix");
|
ERR("Could not get ecore installation prefix");
|
||||||
goto shutdown_log_dom;
|
goto shutdown_log_dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
eo_init();
|
eo_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
|
if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
|
||||||
if (_ecore_fps_debug) _ecore_fps_debug_init();
|
if (_ecore_fps_debug) _ecore_fps_debug_init();
|
||||||
if (!ecore_mempool_init()) goto shutdown_mempool;
|
if (!ecore_mempool_init()) goto shutdown_mempool;
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_main_loop_init();
|
_ecore_main_loop_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_signal_init();
|
_ecore_signal_init();
|
||||||
#ifndef HAVE_EXOTIC
|
#ifndef HAVE_EXOTIC
|
||||||
_ecore_exe_init();
|
_ecore_exe_init();
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_thread_init();
|
_ecore_thread_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_glib_init();
|
_ecore_glib_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_job_init();
|
_ecore_job_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
_ecore_time_init();
|
_ecore_time_init();
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
eina_lock_new(&_thread_mutex);
|
eina_lock_new(&_thread_mutex);
|
||||||
eina_condition_new(&_thread_cond, &_thread_mutex);
|
eina_condition_new(&_thread_cond, &_thread_mutex);
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
#include "Ecore.h"
|
#include "Ecore.h"
|
||||||
#include "ecore_private.h"
|
#include "ecore_private.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_EPOLL_H
|
#if defined(HAVE_SYS_EPOLL_H) && !defined(HAVE_LIBUV)
|
||||||
# define HAVE_EPOLL 1
|
# define HAVE_EPOLL 1
|
||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
#else
|
#else
|
||||||
|
@ -157,6 +157,49 @@ timerfd_settime(int fd EINA_UNUSED,
|
||||||
# include <glib.h>
|
# include <glib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
#define ECORE_STRINGIZE_IMPL(x) #x
|
||||||
|
#define ECORE_STRINGIZE(x) ECORE_STRINGIZE_IMPL(x)
|
||||||
|
#include ECORE_STRINGIZE(UV_INCLUDE_HEADER)
|
||||||
|
#include <dlfcn.h>
|
||||||
|
static uv_prepare_t _ecore_main_uv_prepare;
|
||||||
|
static uv_check_t _ecore_main_uv_check;
|
||||||
|
static uv_timer_t _ecore_main_uv_handle_timers;
|
||||||
|
static uv_idle_t _ecore_main_uv_idler_caller;
|
||||||
|
static Eina_Bool _ecore_main_uv_idling;
|
||||||
|
static Eina_Bool _ecore_main_uv_idler_calling;
|
||||||
|
|
||||||
|
static int (*_dl_uv_run)(uv_loop_t*, uv_run_mode mode) = 0;
|
||||||
|
static int (*_dl_uv_stop)(uv_loop_t*) = 0;
|
||||||
|
static uv_loop_t* (*_dl_uv_default_loop)() = 0;
|
||||||
|
static int (*_dl_uv_poll_init_socket)(uv_loop_t* loop, uv_poll_t* handle, uv_os_sock_t fd) = 0;
|
||||||
|
static int (*_dl_uv_poll_init)(uv_loop_t* loop, uv_poll_t* handle, int fd) = 0;
|
||||||
|
static int (*_dl_uv_poll_start)(uv_poll_t* handle, int events, uv_poll_cb cb) = 0;
|
||||||
|
static int (*_dl_uv_idle_init_)(uv_loop_t* loop, uv_idle_t* idle) = 0;
|
||||||
|
static int _dl_uv_idle_init(uv_loop_t* loop, uv_idle_t* idle)
|
||||||
|
{
|
||||||
|
DBG("uv_idle_init %p", idle);
|
||||||
|
return _dl_uv_idle_init_(loop, idle);
|
||||||
|
}
|
||||||
|
static int (*_dl_uv_idle_start)(uv_idle_t* handle, uv_idle_cb cb) = 0;
|
||||||
|
static int (*_dl_uv_timer_init)(uv_loop_t*, uv_timer_t* handle);
|
||||||
|
static int (*_dl_uv_timer_start)(uv_timer_t* handle,
|
||||||
|
uv_timer_cb cb,
|
||||||
|
uint64_t timeout,
|
||||||
|
uint64_t repeat);
|
||||||
|
static int (*_dl_uv_timer_stop)(uv_timer_t* handle);
|
||||||
|
static int (*_dl_uv_prepare_init)(uv_loop_t*, uv_prepare_t* prepare);
|
||||||
|
static int (*_dl_uv_prepare_start)(uv_prepare_t* prepare, uv_prepare_cb cb);
|
||||||
|
static int (*_dl_uv_check_init)(uv_loop_t*, uv_check_t* prepare);
|
||||||
|
static int (*_dl_uv_check_start)(uv_check_t* prepare, uv_check_cb cb);
|
||||||
|
static int (*_dl_uv_close_)(uv_handle_t* handle, uv_close_cb close_cb);
|
||||||
|
static int _dl_uv_close(uv_handle_t* handle, uv_close_cb close_cb)
|
||||||
|
{
|
||||||
|
DBG("closing _dl_uv_close %p", handle);
|
||||||
|
return _dl_uv_close_(handle, close_cb);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NS_PER_SEC (1000.0 * 1000.0 * 1000.0)
|
#define NS_PER_SEC (1000.0 * 1000.0 * 1000.0)
|
||||||
|
|
||||||
struct _Ecore_Fd_Handler
|
struct _Ecore_Fd_Handler
|
||||||
|
@ -181,6 +224,9 @@ struct _Ecore_Fd_Handler
|
||||||
#if defined(USE_G_MAIN_LOOP)
|
#if defined(USE_G_MAIN_LOOP)
|
||||||
GPollFD gfd;
|
GPollFD gfd;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
uv_poll_t uv_handle;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
GENERIC_ALLOC_SIZE_DECLARE(Ecore_Fd_Handler);
|
GENERIC_ALLOC_SIZE_DECLARE(Ecore_Fd_Handler);
|
||||||
|
|
||||||
|
@ -198,7 +244,7 @@ struct _Ecore_Win32_Handler
|
||||||
GENERIC_ALLOC_SIZE_DECLARE(Ecore_Win32_Handler);
|
GENERIC_ALLOC_SIZE_DECLARE(Ecore_Win32_Handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#if !defined(USE_G_MAIN_LOOP) && !defined(HAVE_LIBUV)
|
||||||
static int _ecore_main_select(double timeout);
|
static int _ecore_main_select(double timeout);
|
||||||
#endif
|
#endif
|
||||||
static void _ecore_main_prepare_handlers(void);
|
static void _ecore_main_prepare_handlers(void);
|
||||||
|
@ -310,9 +356,13 @@ _ecore_try_add_to_call_list(Ecore_Fd_Handler *fdh)
|
||||||
{
|
{
|
||||||
/* check if this fdh is already in the list */
|
/* check if this fdh is already in the list */
|
||||||
if (fdh->next_ready)
|
if (fdh->next_ready)
|
||||||
return;
|
{
|
||||||
|
DBG("next_ready");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (fdh->read_active || fdh->write_active || fdh->error_active)
|
if (fdh->read_active || fdh->write_active || fdh->error_active)
|
||||||
{
|
{
|
||||||
|
DBG("added");
|
||||||
/*
|
/*
|
||||||
* make sure next_ready is non-null by pointing to ourselves
|
* make sure next_ready is non-null by pointing to ourselves
|
||||||
* use that to indicate this fdh is in the ready list
|
* use that to indicate this fdh is in the ready list
|
||||||
|
@ -344,6 +394,7 @@ _ecore_epoll_add(int efd,
|
||||||
int events,
|
int events,
|
||||||
void *ptr)
|
void *ptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct epoll_event ev;
|
struct epoll_event ev;
|
||||||
|
|
||||||
memset(&ev, 0, sizeof (ev));
|
memset(&ev, 0, sizeof (ev));
|
||||||
|
@ -376,19 +427,78 @@ _gfd_events_from_fdh(Ecore_Fd_Handler *fdh)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
static void
|
||||||
|
_ecore_main_uv_poll_cb(uv_poll_t* handle, int status, int events)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_uv_poll_cb %p status %d events %d", (void*)handle->data, status, events);
|
||||||
|
Ecore_Fd_Handler* fdh = handle->data;
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
fdh->error_active = EINA_TRUE;
|
||||||
|
if (events & UV_READABLE)
|
||||||
|
fdh->read_active = EINA_TRUE;
|
||||||
|
if (events & UV_WRITABLE)
|
||||||
|
fdh->write_active = EINA_TRUE;
|
||||||
|
|
||||||
|
_ecore_try_add_to_call_list(fdh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ecore_main_uv_events_from_fdh(Ecore_Fd_Handler *fdh)
|
||||||
|
{
|
||||||
|
int events = 0;
|
||||||
|
if (fdh->flags & ECORE_FD_READ) events |= UV_READABLE;
|
||||||
|
if (fdh->flags & ECORE_FD_WRITE) events |= UV_WRITABLE;
|
||||||
|
DBG("events is %d", (int)events);
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
_ecore_main_fdh_poll_add(Ecore_Fd_Handler *fdh)
|
_ecore_main_fdh_poll_add(Ecore_Fd_Handler *fdh)
|
||||||
{
|
{
|
||||||
|
DBG("_ecore_main_fdh_poll_add");
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
r = _ecore_epoll_add(_ecore_get_epoll_fd(), fdh->fd,
|
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
||||||
_ecore_poll_events_from_fdh(fdh), fdh);
|
{
|
||||||
|
r = _ecore_epoll_add(_ecore_get_epoll_fd(), fdh->fd,
|
||||||
|
_ecore_poll_events_from_fdh(fdh), fdh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef USE_G_MAIN_LOOP
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!fdh->file)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_fdh_poll_add libuv socket %p", fdh);
|
||||||
|
fdh->uv_handle.data = fdh;
|
||||||
|
DBG("_ecore_main_fdh_poll_add2 %p", fdh);
|
||||||
|
_dl_uv_poll_init_socket(_dl_uv_default_loop(), &fdh->uv_handle, fdh->fd);
|
||||||
|
DBG("_ecore_main_fdh_poll_add3 %p", fdh->uv_handle.data);
|
||||||
|
_dl_uv_poll_start(&fdh->uv_handle, _ecore_main_uv_events_from_fdh(fdh)
|
||||||
|
, _ecore_main_uv_poll_cb);
|
||||||
|
DBG("_ecore_main_fdh_poll_add libuv DONE");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_fdh_poll_add libuv file");
|
||||||
|
fdh->uv_handle.data = fdh;
|
||||||
|
DBG("_ecore_main_fdh_poll_add2 %p", fdh);
|
||||||
|
_dl_uv_poll_init(_dl_uv_default_loop(), &fdh->uv_handle, fdh->fd);
|
||||||
|
DBG("_ecore_main_fdh_poll_add3 %p", fdh->uv_handle.data);
|
||||||
|
_dl_uv_poll_start(&fdh->uv_handle, _ecore_main_uv_events_from_fdh(fdh)
|
||||||
|
, _ecore_main_uv_poll_cb);
|
||||||
|
DBG("_ecore_main_fdh_poll_add libuv DONE");
|
||||||
|
}
|
||||||
|
#elif defined(USE_G_MAIN_LOOP)
|
||||||
fdh->gfd.fd = fdh->fd;
|
fdh->gfd.fd = fdh->fd;
|
||||||
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
||||||
fdh->gfd.revents = 0;
|
fdh->gfd.revents = 0;
|
||||||
|
@ -402,32 +512,43 @@ _ecore_main_fdh_poll_add(Ecore_Fd_Handler *fdh)
|
||||||
static inline void
|
static inline void
|
||||||
_ecore_main_fdh_poll_del(Ecore_Fd_Handler *fdh)
|
_ecore_main_fdh_poll_del(Ecore_Fd_Handler *fdh)
|
||||||
{
|
{
|
||||||
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct epoll_event ev;
|
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
||||||
int efd = _ecore_get_epoll_fd();
|
{
|
||||||
|
struct epoll_event ev;
|
||||||
|
int efd = _ecore_get_epoll_fd();
|
||||||
|
|
||||||
memset(&ev, 0, sizeof (ev));
|
memset(&ev, 0, sizeof (ev));
|
||||||
DBG("removing poll on %d", fdh->fd);
|
DBG("removing poll on %d", fdh->fd);
|
||||||
/* could get an EBADF if somebody closed the FD before removing it */
|
/* could get an EBADF if somebody closed the FD before removing it */
|
||||||
if ((epoll_ctl(efd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0))
|
if ((epoll_ctl(efd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0))
|
||||||
{
|
{
|
||||||
if (errno == EBADF)
|
if (errno == EBADF)
|
||||||
{
|
{
|
||||||
WRN("fd %d was closed, can't remove from epoll - reinit!",
|
WRN("fd %d was closed, can't remove from epoll - reinit!",
|
||||||
fdh->fd);
|
fdh->fd);
|
||||||
_ecore_main_loop_shutdown();
|
_ecore_main_loop_shutdown();
|
||||||
_ecore_main_loop_init();
|
_ecore_main_loop_init();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno);
|
ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef USE_G_MAIN_LOOP
|
#ifdef HAVE_LIBUV
|
||||||
|
DBG("_ecore_main_fdh_poll_del libuv %p", fdh);
|
||||||
|
_dl_uv_close(&fdh->uv_handle, 0);
|
||||||
|
DBG("_ecore_main_fdh_poll_del libuv DONE");
|
||||||
|
#elif USE_G_MAIN_LOOP
|
||||||
fdh->gfd.fd = fdh->fd;
|
fdh->gfd.fd = fdh->fd;
|
||||||
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
||||||
fdh->gfd.revents = 0;
|
fdh->gfd.revents = 0;
|
||||||
|
@ -440,21 +561,31 @@ _ecore_main_fdh_poll_del(Ecore_Fd_Handler *fdh)
|
||||||
static inline int
|
static inline int
|
||||||
_ecore_main_fdh_poll_modify(Ecore_Fd_Handler *fdh)
|
_ecore_main_fdh_poll_modify(Ecore_Fd_Handler *fdh)
|
||||||
{
|
{
|
||||||
|
DBG("_ecore_main_fdh_poll_modify %p", fdh);
|
||||||
int r = 0;
|
int r = 0;
|
||||||
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct epoll_event ev;
|
if ((!fdh->file) && HAVE_EPOLL && epoll_fd >= 0)
|
||||||
int efd = _ecore_get_epoll_fd();
|
{
|
||||||
|
struct epoll_event ev;
|
||||||
|
int efd = _ecore_get_epoll_fd();
|
||||||
|
|
||||||
memset(&ev, 0, sizeof (ev));
|
memset(&ev, 0, sizeof (ev));
|
||||||
ev.events = _ecore_poll_events_from_fdh(fdh);
|
ev.events = _ecore_poll_events_from_fdh(fdh);
|
||||||
ev.data.ptr = fdh;
|
ev.data.ptr = fdh;
|
||||||
DBG("modifing epoll on %d to %08x", fdh->fd, ev.events);
|
DBG("modifing epoll on %d to %08x", fdh->fd, ev.events);
|
||||||
r = epoll_ctl(efd, EPOLL_CTL_MOD, fdh->fd, &ev);
|
r = epoll_ctl(efd, EPOLL_CTL_MOD, fdh->fd, &ev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef USE_G_MAIN_LOOP
|
#ifdef HAVE_LIBUV
|
||||||
|
abort();
|
||||||
|
#elif defined(USE_G_MAIN_LOOP)
|
||||||
fdh->gfd.fd = fdh->fd;
|
fdh->gfd.fd = fdh->fd;
|
||||||
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
fdh->gfd.events = _gfd_events_from_fdh(fdh);
|
||||||
fdh->gfd.revents = 0;
|
fdh->gfd.revents = 0;
|
||||||
|
@ -467,6 +598,7 @@ _ecore_main_fdh_poll_modify(Ecore_Fd_Handler *fdh)
|
||||||
static inline int
|
static inline int
|
||||||
_ecore_main_fdh_epoll_mark_active(void)
|
_ecore_main_fdh_epoll_mark_active(void)
|
||||||
{
|
{
|
||||||
|
DBG("_ecore_main_fdh_epoll_mark_active");
|
||||||
struct epoll_event ev[32];
|
struct epoll_event ev[32];
|
||||||
int i, ret;
|
int i, ret;
|
||||||
int efd = _ecore_get_epoll_fd();
|
int efd = _ecore_get_epoll_fd();
|
||||||
|
@ -833,26 +965,285 @@ detect_time_changes_stop(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
static void _ecore_main_loop_idler_cb(uv_idle_t* handle EINA_UNUSED);
|
||||||
|
|
||||||
|
static
|
||||||
|
void _ecore_main_loop_timer_run(uv_timer_t* timer)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_timer_run do_quit %d", (int)do_quit);
|
||||||
|
/* _ecore_main_loop_iterate_internal(1); */
|
||||||
|
|
||||||
|
DBG("_ecore_main_loop_timer_run");
|
||||||
|
if(_ecore_main_uv_idling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_timer_run EXITING IDLE");
|
||||||
|
_ecore_main_uv_idling = EINA_FALSE;
|
||||||
|
_ecore_animator_run_reset();
|
||||||
|
_ecore_idle_exiter_call();
|
||||||
|
}
|
||||||
|
|
||||||
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
_ecore_timer_expired_timers_call(_ecore_time_loop_time);
|
||||||
|
_ecore_timer_cleanup();
|
||||||
|
|
||||||
|
_ecore_signal_received_process();
|
||||||
|
|
||||||
|
DBG("_ecore_main_loop_timer_run iterate internal");
|
||||||
|
|
||||||
|
if(_ecore_timers_exists())
|
||||||
|
{
|
||||||
|
double next_stop = _ecore_timer_next_get();
|
||||||
|
while(next_stop == 0)
|
||||||
|
{
|
||||||
|
/* _ecore_main_loop_iterate_internal(1); */
|
||||||
|
next_stop = _ecore_timer_next_get();
|
||||||
|
}
|
||||||
|
DBG("next_stop %f\n", next_stop);
|
||||||
|
if(next_stop > 0.0)
|
||||||
|
{
|
||||||
|
DBG("should sleep %f\n", next_stop);
|
||||||
|
|
||||||
|
_dl_uv_timer_stop(&_ecore_main_uv_handle_timers);
|
||||||
|
_dl_uv_timer_start(&_ecore_main_uv_handle_timers, &_ecore_main_loop_timer_run, next_stop * 1000, 0);
|
||||||
|
|
||||||
|
DBG("will awake\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DBG("no more timers?");
|
||||||
|
|
||||||
|
if(!_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare ENTERING IDLE");
|
||||||
|
_ecore_main_uv_idling = EINA_TRUE;
|
||||||
|
_ecore_idle_enterer_call();
|
||||||
|
_ecore_throttle();
|
||||||
|
|
||||||
|
if(_ecore_idler_exist() && !_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare may call idles?");
|
||||||
|
if(_ecore_main_uv_idler_calling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare CALL IDLES");
|
||||||
|
_ecore_main_uv_idler_calling = EINA_TRUE;
|
||||||
|
_dl_uv_idle_init(_dl_uv_default_loop(), &_ecore_main_uv_idler_caller);
|
||||||
|
_dl_uv_idle_start(&_ecore_main_uv_idler_caller, &_ecore_main_loop_idler_cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_ecore_main_uv_idler_calling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_timer_run STOP IDLES");
|
||||||
|
_ecore_main_uv_idler_calling = EINA_FALSE;
|
||||||
|
_dl_uv_close(&_ecore_main_uv_idler_caller, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_ecore_main_uv_idler_calling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_timer_run STOP IDLES");
|
||||||
|
_ecore_main_uv_idler_calling = EINA_FALSE;
|
||||||
|
_dl_uv_close(&_ecore_main_uv_idler_caller, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG("exit\n");
|
||||||
|
}
|
||||||
|
static void _ecore_main_loop_uv_prepare(uv_prepare_t* handle);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ecore_main_loop_idler_cb(uv_idle_t* handle EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_idler_cb");
|
||||||
|
in_main_loop++;
|
||||||
|
_ecore_lock();
|
||||||
|
|
||||||
|
assert(_ecore_main_uv_idling && _ecore_main_uv_idler_calling);
|
||||||
|
|
||||||
|
_ecore_idler_all_call();
|
||||||
|
|
||||||
|
if(_ecore_event_exist() || !_ecore_idler_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_idler_cb");
|
||||||
|
assert(_ecore_main_uv_idler_calling);
|
||||||
|
_ecore_main_uv_idler_calling = EINA_FALSE;
|
||||||
|
_dl_uv_close(&_ecore_main_uv_idler_caller, 0);
|
||||||
|
}
|
||||||
|
if(_ecore_event_exist())
|
||||||
|
{
|
||||||
|
assert(!_ecore_main_uv_idler_calling);
|
||||||
|
_ecore_main_uv_idling = EINA_FALSE;
|
||||||
|
_ecore_animator_run_reset();
|
||||||
|
_ecore_idle_exiter_call();
|
||||||
|
}
|
||||||
|
|
||||||
|
in_main_loop--;
|
||||||
|
_ecore_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
void
|
||||||
|
_ecore_main_loop_uv_check(uv_check_t* handle EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_check");
|
||||||
|
in_main_loop++;
|
||||||
|
_ecore_lock();
|
||||||
|
|
||||||
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
|
||||||
|
if(_ecore_main_uv_idling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_check");
|
||||||
|
if(_ecore_main_uv_idler_calling && (_ecore_event_exist() || !_ecore_idler_exist()))
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_check STOP IDLES");
|
||||||
|
_ecore_main_uv_idler_calling = EINA_FALSE;
|
||||||
|
_dl_uv_close(&_ecore_main_uv_idler_caller, 0);
|
||||||
|
}
|
||||||
|
if(_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_idler_cb EXIT IDLE");
|
||||||
|
assert(!_ecore_main_uv_idler_calling);
|
||||||
|
_ecore_main_uv_idling = EINA_FALSE;
|
||||||
|
_ecore_animator_run_reset();
|
||||||
|
_ecore_idle_exiter_call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
_ecore_main_fd_handlers_call();
|
||||||
|
DBG("");
|
||||||
|
if (fd_handlers_with_buffer)
|
||||||
|
_ecore_main_fd_handlers_buf_call();
|
||||||
|
DBG("");
|
||||||
|
_ecore_signal_received_process();
|
||||||
|
DBG("");
|
||||||
|
/* _ecore_event_call(); */
|
||||||
|
DBG("");
|
||||||
|
_ecore_main_fd_handlers_cleanup();
|
||||||
|
DBG("");
|
||||||
|
|
||||||
|
DBG("");
|
||||||
|
_ecore_timer_expired_timers_call(_ecore_time_loop_time);
|
||||||
|
DBG("");
|
||||||
|
_ecore_timer_cleanup();
|
||||||
|
DBG("");
|
||||||
|
|
||||||
|
_ecore_idle_enterer_call();
|
||||||
|
_ecore_throttle();
|
||||||
|
_ecore_main_uv_idling = EINA_TRUE;
|
||||||
|
|
||||||
|
if (fd_handlers_with_buffer)
|
||||||
|
_ecore_main_fd_handlers_buf_call();
|
||||||
|
}
|
||||||
|
|
||||||
|
in_main_loop--;
|
||||||
|
_ecore_unlock();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
_ecore_main_loop_init(void)
|
_ecore_main_loop_init(void)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
DBG("_ecore_main_loop_init");
|
||||||
epoll_fd = epoll_create(1);
|
epoll_fd = epoll_create(1);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
if ((epoll_fd < 0) && HAVE_EPOLL)
|
if ((epoll_fd < 0) && HAVE_EPOLL)
|
||||||
WRN("Failed to create epoll fd!");
|
WRN("Failed to create epoll fd!");
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
epoll_pid = getpid();
|
epoll_pid = getpid();
|
||||||
_ecore_fd_close_on_exec(epoll_fd);
|
_ecore_fd_close_on_exec(epoll_fd);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
/* add polls on all our file descriptors */
|
/* add polls on all our file descriptors */
|
||||||
Ecore_Fd_Handler *fdh;
|
Ecore_Fd_Handler *fdh;
|
||||||
EINA_INLIST_FOREACH(fd_handlers, fdh)
|
EINA_INLIST_FOREACH(fd_handlers, fdh)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
if (fdh->delete_me)
|
if (fdh->delete_me)
|
||||||
continue;
|
continue;
|
||||||
_ecore_epoll_add(epoll_fd, fdh->fd,
|
_ecore_epoll_add(epoll_fd, fdh->fd,
|
||||||
_ecore_poll_events_from_fdh(fdh), fdh);
|
_ecore_poll_events_from_fdh(fdh), fdh);
|
||||||
_ecore_main_fdh_poll_add(fdh);
|
_ecore_main_fdh_poll_add(fdh);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
DBG("loading lib uv");
|
||||||
|
#ifdef HAVE_NODEJS
|
||||||
|
void* lib = dlopen(NULL, RTLD_LAZY);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
#else
|
||||||
|
void* lib = dlopen("libuv.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
#endif
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
|
||||||
|
if(lib && dlsym(lib, "uv_run"))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
DBG("loaded lib uv");
|
||||||
|
_dl_uv_run = dlsym(lib, "uv_run");
|
||||||
|
assert(!!_dl_uv_run);
|
||||||
|
_dl_uv_stop = dlsym(lib, "uv_stop");
|
||||||
|
assert(!!_dl_uv_stop);
|
||||||
|
_dl_uv_default_loop = dlsym(lib, "uv_default_loop");
|
||||||
|
assert(!!_dl_uv_default_loop);
|
||||||
|
_dl_uv_poll_init_socket = dlsym(lib, "uv_poll_init_socket");
|
||||||
|
assert(!!_dl_uv_poll_init_socket);
|
||||||
|
_dl_uv_poll_init = dlsym(lib, "uv_poll_init");
|
||||||
|
assert(!!_dl_uv_poll_init);
|
||||||
|
_dl_uv_poll_start = dlsym(lib, "uv_poll_start");
|
||||||
|
assert(!!_dl_uv_poll_start);
|
||||||
|
_dl_uv_idle_init_ = dlsym(lib, "uv_idle_init");
|
||||||
|
assert(!!_dl_uv_idle_init);
|
||||||
|
_dl_uv_idle_start = dlsym(lib, "uv_idle_start");
|
||||||
|
assert(!!_dl_uv_idle_start);
|
||||||
|
_dl_uv_timer_init = dlsym(lib, "uv_timer_init");
|
||||||
|
assert(!!_dl_uv_timer_init);
|
||||||
|
_dl_uv_timer_start = dlsym(lib, "uv_timer_start");
|
||||||
|
assert(!!_dl_uv_timer_start);
|
||||||
|
_dl_uv_timer_stop = dlsym(lib, "uv_timer_stop");
|
||||||
|
assert(!!_dl_uv_timer_stop);
|
||||||
|
_dl_uv_prepare_init = dlsym(lib, "uv_prepare_init");
|
||||||
|
assert(!!_dl_uv_prepare_init);
|
||||||
|
_dl_uv_prepare_start = dlsym(lib, "uv_prepare_start");
|
||||||
|
assert(!!_dl_uv_prepare_start);
|
||||||
|
_dl_uv_check_init = dlsym(lib, "uv_check_init");
|
||||||
|
assert(!!_dl_uv_check_init);
|
||||||
|
_dl_uv_check_start = dlsym(lib, "uv_check_start");
|
||||||
|
assert(!!_dl_uv_check_start);
|
||||||
|
_dl_uv_close_ = dlsym(lib, "uv_close");
|
||||||
|
assert(!!_dl_uv_close);
|
||||||
|
//dlclose(lib);
|
||||||
|
|
||||||
|
DBG("_dl_uv_prepare_init");
|
||||||
|
_dl_uv_prepare_init(_dl_uv_default_loop(), &_ecore_main_uv_prepare);
|
||||||
|
DBG("_dl_uv_prepare_start");
|
||||||
|
_dl_uv_prepare_start(&_ecore_main_uv_prepare, &_ecore_main_loop_uv_prepare);
|
||||||
|
DBG("_dl_uv_prepare_started");
|
||||||
|
|
||||||
|
DBG("_dl_uv_check_init");
|
||||||
|
_dl_uv_check_init(_dl_uv_default_loop(), &_ecore_main_uv_check);
|
||||||
|
DBG("_dl_uv_check_start");
|
||||||
|
_dl_uv_check_start(&_ecore_main_uv_check, &_ecore_main_loop_uv_check);
|
||||||
|
DBG("_dl_uv_check_started");
|
||||||
|
|
||||||
|
_dl_uv_timer_init(_dl_uv_default_loop(), &_ecore_main_uv_handle_timers);
|
||||||
|
}
|
||||||
|
/* else */
|
||||||
|
/* DBG("did not load uv"); */
|
||||||
|
fprintf(stderr, "ecore_init %s() %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
|
||||||
|
DBG("loaded dlsyms uv");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* setup for the g_main_loop only integration */
|
/* setup for the g_main_loop only integration */
|
||||||
#ifdef USE_G_MAIN_LOOP
|
#ifdef USE_G_MAIN_LOOP
|
||||||
ecore_glib_source = g_source_new(&ecore_gsource_funcs, sizeof (GSource));
|
ecore_glib_source = g_source_new(&ecore_gsource_funcs, sizeof (GSource));
|
||||||
|
@ -917,11 +1308,21 @@ _ecore_main_loop_shutdown(void)
|
||||||
close(timer_fd);
|
close(timer_fd);
|
||||||
timer_fd = -1;
|
timer_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
if(_dl_uv_run)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_shutdown");
|
||||||
|
_dl_uv_timer_stop(&_ecore_main_uv_handle_timers);
|
||||||
|
_dl_uv_close(&_ecore_main_uv_handle_timers, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
|
_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
|
||||||
{
|
{
|
||||||
|
DBG("_ecore_main_fd_handler_del %p", fd_handler);
|
||||||
if (fd_handler->delete_me)
|
if (fd_handler->delete_me)
|
||||||
{
|
{
|
||||||
ERR("fdh %p deleted twice", fd_handler);
|
ERR("fdh %p deleted twice", fd_handler);
|
||||||
|
@ -942,6 +1343,9 @@ EAPI void
|
||||||
ecore_main_loop_iterate(void)
|
ecore_main_loop_iterate(void)
|
||||||
{
|
{
|
||||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run) {
|
||||||
|
#endif
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#ifndef USE_G_MAIN_LOOP
|
||||||
_ecore_lock();
|
_ecore_lock();
|
||||||
_ecore_time_loop_time = ecore_time_get();
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
@ -950,12 +1354,20 @@ ecore_main_loop_iterate(void)
|
||||||
#else
|
#else
|
||||||
g_main_context_iteration(NULL, 0);
|
g_main_context_iteration(NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_dl_uv_run(_dl_uv_default_loop(), UV_RUN_ONCE | UV_RUN_NOWAIT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_main_loop_iterate_may_block(int may_block)
|
ecore_main_loop_iterate_may_block(int may_block)
|
||||||
{
|
{
|
||||||
EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
|
EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run) {
|
||||||
|
#endif
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#ifndef USE_G_MAIN_LOOP
|
||||||
_ecore_lock();
|
_ecore_lock();
|
||||||
_ecore_time_loop_time = ecore_time_get();
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
@ -967,15 +1379,25 @@ in_main_loop--;
|
||||||
#else
|
#else
|
||||||
return g_main_context_iteration(NULL, may_block);
|
return g_main_context_iteration(NULL, may_block);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_dl_uv_run(_dl_uv_default_loop(), may_block ? UV_RUN_ONCE | UV_RUN_NOWAIT : UV_RUN_ONCE);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_main_loop_begin(void)
|
ecore_main_loop_begin(void)
|
||||||
{
|
{
|
||||||
|
DBG("ecore_main_loop_begin");
|
||||||
EINA_MAIN_LOOP_CHECK_RETURN;
|
EINA_MAIN_LOOP_CHECK_RETURN;
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
sd_notify(0, "READY=1");
|
sd_notify(0, "READY=1");
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
if(!_dl_uv_run) {
|
||||||
|
#endif
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#ifndef USE_G_MAIN_LOOP
|
||||||
_ecore_lock();
|
_ecore_lock();
|
||||||
in_main_loop++;
|
in_main_loop++;
|
||||||
|
@ -993,6 +1415,17 @@ ecore_main_loop_begin(void)
|
||||||
}
|
}
|
||||||
do_quit = 0;
|
do_quit = 0;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBUV
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG("uv_run");
|
||||||
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
if(!do_quit)
|
||||||
|
_dl_uv_run(_dl_uv_default_loop(), UV_RUN_DEFAULT);
|
||||||
|
do_quit = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -1003,6 +1436,9 @@ ecore_main_loop_quit(void)
|
||||||
#ifdef USE_G_MAIN_LOOP
|
#ifdef USE_G_MAIN_LOOP
|
||||||
if (ecore_main_loop)
|
if (ecore_main_loop)
|
||||||
g_main_loop_quit(ecore_main_loop);
|
g_main_loop_quit(ecore_main_loop);
|
||||||
|
#elif defined(HAVE_LIBUV)
|
||||||
|
if(_dl_uv_run)
|
||||||
|
_dl_uv_stop(_dl_uv_default_loop());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,6 +1451,7 @@ ecore_main_loop_nested_get(void)
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
ecore_main_loop_animator_ticked_get(void)
|
ecore_main_loop_animator_ticked_get(void)
|
||||||
{
|
{
|
||||||
|
DBG("ecore_main_loop_animator_ticked_get");
|
||||||
return _ecore_animator_run_get();
|
return _ecore_animator_run_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,6 +1477,7 @@ _ecore_main_fd_handler_add(int fd,
|
||||||
Ecore_Fd_Cb buf_func,
|
Ecore_Fd_Cb buf_func,
|
||||||
const void *buf_data)
|
const void *buf_data)
|
||||||
{
|
{
|
||||||
|
DBG("_ecore_main_fd_handler_add");
|
||||||
Ecore_Fd_Handler *fdh = NULL;
|
Ecore_Fd_Handler *fdh = NULL;
|
||||||
|
|
||||||
if ((fd < 0) || (flags == 0) || (!func)) return NULL;
|
if ((fd < 0) || (flags == 0) || (!func)) return NULL;
|
||||||
|
@ -1389,7 +1827,7 @@ _ecore_main_prepare_handlers(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#if !defined(USE_G_MAIN_LOOP)
|
||||||
static int
|
static int
|
||||||
_ecore_main_select(double timeout)
|
_ecore_main_select(double timeout)
|
||||||
{
|
{
|
||||||
|
@ -1671,19 +2109,24 @@ _ecore_main_win32_handlers_cleanup(void)
|
||||||
static void
|
static void
|
||||||
_ecore_main_fd_handlers_call(void)
|
_ecore_main_fd_handlers_call(void)
|
||||||
{
|
{
|
||||||
|
DBG("%s", "");
|
||||||
/* grab a new list */
|
/* grab a new list */
|
||||||
if (!fd_handlers_to_call_current)
|
if (!fd_handlers_to_call_current)
|
||||||
{
|
{
|
||||||
|
DBG("fd_handlers_to_call %p", fd_handlers_to_call);
|
||||||
fd_handlers_to_call_current = fd_handlers_to_call;
|
fd_handlers_to_call_current = fd_handlers_to_call;
|
||||||
fd_handlers_to_call = NULL;
|
fd_handlers_to_call = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBG("%s", "");
|
||||||
while (fd_handlers_to_call_current)
|
while (fd_handlers_to_call_current)
|
||||||
{
|
{
|
||||||
Ecore_Fd_Handler *fdh = fd_handlers_to_call_current;
|
Ecore_Fd_Handler *fdh = fd_handlers_to_call_current;
|
||||||
|
|
||||||
|
DBG("%p", fdh);
|
||||||
if (!fdh->delete_me)
|
if (!fdh->delete_me)
|
||||||
{
|
{
|
||||||
|
DBG("not delete me %p", fdh);
|
||||||
if ((fdh->read_active) ||
|
if ((fdh->read_active) ||
|
||||||
(fdh->write_active) ||
|
(fdh->write_active) ||
|
||||||
(fdh->error_active))
|
(fdh->error_active))
|
||||||
|
@ -1709,14 +2152,17 @@ _ecore_main_fd_handlers_call(void)
|
||||||
/* stop when we point to ourselves */
|
/* stop when we point to ourselves */
|
||||||
if (fdh->next_ready == fdh)
|
if (fdh->next_ready == fdh)
|
||||||
{
|
{
|
||||||
|
DBG("end %p", fdh);
|
||||||
fdh->next_ready = NULL;
|
fdh->next_ready = NULL;
|
||||||
fd_handlers_to_call_current = NULL;
|
fd_handlers_to_call_current = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBG("not end %p", fdh);
|
||||||
fd_handlers_to_call_current = fdh->next_ready;
|
fd_handlers_to_call_current = fdh->next_ready;
|
||||||
fdh->next_ready = NULL;
|
fdh->next_ready = NULL;
|
||||||
}
|
}
|
||||||
|
DBG("out");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1751,8 +2197,100 @@ _ecore_main_fd_handlers_buf_call(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_G_MAIN_LOOP
|
#ifdef HAVE_LIBUV
|
||||||
|
static void
|
||||||
|
_ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare");
|
||||||
|
_ecore_lock();
|
||||||
|
in_main_loop++;
|
||||||
|
|
||||||
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
_ecore_timer_expired_timers_call(_ecore_time_loop_time);
|
||||||
|
_ecore_timer_cleanup();
|
||||||
|
|
||||||
|
/* process signals into events .... */
|
||||||
|
_ecore_signal_received_process();
|
||||||
|
|
||||||
|
if (!_ecore_main_uv_idling)
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare");
|
||||||
|
if(!_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare ENTER IDLE");
|
||||||
|
_ecore_main_uv_idling = EINA_TRUE;
|
||||||
|
_ecore_idle_enterer_call();
|
||||||
|
_ecore_throttle();
|
||||||
|
|
||||||
|
if(_ecore_idler_exist() && !_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare CALL IDLES");
|
||||||
|
_ecore_main_uv_idler_calling = EINA_TRUE;
|
||||||
|
_dl_uv_idle_init(_dl_uv_default_loop(), &_ecore_main_uv_idler_caller);
|
||||||
|
_dl_uv_idle_start(&_ecore_main_uv_idler_caller, &_ecore_main_loop_idler_cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBG("_ecore_main_loop_uv_prepare");
|
||||||
|
|
||||||
|
if (fd_handlers_with_buffer)
|
||||||
|
_ecore_main_fd_handlers_buf_call();
|
||||||
|
}
|
||||||
|
else if(_ecore_event_exist())
|
||||||
|
{
|
||||||
|
DBG("_ecore_main_loop_uv_prepare EXIT IDLE");
|
||||||
|
_ecore_main_uv_idling = EINA_FALSE;
|
||||||
|
|
||||||
|
_ecore_idle_exiter_call();
|
||||||
|
|
||||||
|
if(_ecore_main_uv_idler_calling)
|
||||||
|
{
|
||||||
|
_ecore_main_uv_idler_calling = EINA_FALSE;
|
||||||
|
_dl_uv_close(&_ecore_main_uv_idler_caller, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double t = -1;
|
||||||
|
if (do_quit)
|
||||||
|
{
|
||||||
|
DBG("do quit outside loop");
|
||||||
|
_dl_uv_stop(_dl_uv_default_loop());
|
||||||
|
t = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG("t %f", t);
|
||||||
|
|
||||||
|
_ecore_main_fd_handlers_call();
|
||||||
|
if (fd_handlers_with_buffer) _ecore_main_fd_handlers_buf_call();
|
||||||
|
/* process signals into events .... */
|
||||||
|
_ecore_signal_received_process();
|
||||||
|
/* handle events ... */
|
||||||
|
_ecore_event_call();
|
||||||
|
_ecore_main_fd_handlers_cleanup();
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (fd_handlers_with_prep)
|
||||||
|
_ecore_main_prepare_handlers();
|
||||||
|
|
||||||
|
_ecore_time_loop_time = ecore_time_get();
|
||||||
|
_ecore_timer_enable_new();
|
||||||
|
if (_ecore_timers_exists())
|
||||||
|
{
|
||||||
|
t = _ecore_timer_next_get();
|
||||||
|
DBG("Should awake after %f", t);
|
||||||
|
|
||||||
|
if (t >= 0.0)
|
||||||
|
{
|
||||||
|
_dl_uv_timer_start(&_ecore_main_uv_handle_timers, &_ecore_main_loop_timer_run, t * 1000
|
||||||
|
, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ecore_unlock();
|
||||||
|
in_main_loop--;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USE_G_MAIN_LOOP)
|
||||||
enum {
|
enum {
|
||||||
SPIN_MORE,
|
SPIN_MORE,
|
||||||
SPIN_RESTART,
|
SPIN_RESTART,
|
||||||
|
|
|
@ -2,4 +2,5 @@ check-results.xml
|
||||||
*_suite
|
*_suite
|
||||||
*_suite.log
|
*_suite.log
|
||||||
*_suite.trs
|
*_suite.trs
|
||||||
|
*.node
|
||||||
*/cxx_compile_test
|
*/cxx_compile_test
|
||||||
|
|
|
@ -0,0 +1,500 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <eina_js_compatibility.hh>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eo.hh>
|
||||||
|
|
||||||
|
#include <ecore_js_init.hh>
|
||||||
|
#include <ecore_js_mainloop.hh>
|
||||||
|
#include <ecore_js_timer.hh>
|
||||||
|
#include <ecore_js_event.hh>
|
||||||
|
#include <ecore_js_job.hh>
|
||||||
|
#include <ecore_js_idle.hh>
|
||||||
|
#include <ecore_js_animator.hh>
|
||||||
|
#include <ecore_js_poller.hh>
|
||||||
|
#include <ecore_js_throttle.hh>
|
||||||
|
|
||||||
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Executes a string within the current v8 context.
|
||||||
|
bool ExecuteString(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::String> source,
|
||||||
|
v8::Handle<v8::Value> name)
|
||||||
|
{
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(isolate);
|
||||||
|
v8::TryCatch try_catch;
|
||||||
|
v8::ScriptOrigin origin(name);
|
||||||
|
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
|
||||||
|
if (script.IsEmpty()) {
|
||||||
|
std::cerr << "Compilation failed" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during compilation.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Compilation succesful" << std::endl;
|
||||||
|
v8::Handle<v8::Value> result = script->Run();
|
||||||
|
if (result.IsEmpty()) {
|
||||||
|
std::cout << "Failed with exception thrown" << std::endl;
|
||||||
|
//assert(try_catch.HasCaught());
|
||||||
|
//std::abort();
|
||||||
|
// Print errors that happened during execution.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
if(try_catch.HasCaught())
|
||||||
|
std::cerr << "Exception " << ToCString(v8::String::Utf8Value(try_catch.Message()->Get()))
|
||||||
|
<< std::endl;
|
||||||
|
std::abort();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
assert(!try_catch.HasCaught());
|
||||||
|
// if (print_result && !result->IsUndefined()) {
|
||||||
|
// // If all went well and the result wasn't undefined then print
|
||||||
|
// // the returned value.
|
||||||
|
// v8::String::Utf8Value str(result);
|
||||||
|
// const char* cstr = ToCString(str);
|
||||||
|
// printf("%s\n", cstr);
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_return_type Print(efl::eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
return efl::eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_setup(v8::Handle<v8::Object> exports)
|
||||||
|
{
|
||||||
|
using namespace efl::ecore::js;
|
||||||
|
using efl::eina::js::compatibility_new;
|
||||||
|
using v8::String;
|
||||||
|
|
||||||
|
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||||
|
|
||||||
|
// init
|
||||||
|
efl::ecore::js::register_init(isolate, exports,
|
||||||
|
efl::eina::js::compatibility_new<v8::String>
|
||||||
|
(isolate, "ecore_init"));
|
||||||
|
efl::ecore::js::register_shutdown(isolate, exports,
|
||||||
|
efl::eina::js::compatibility_new<v8::String>
|
||||||
|
(isolate, "ecore_shutdown"));
|
||||||
|
|
||||||
|
// mainloop
|
||||||
|
register_callback_cancel(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_CALLBACK_CANCEL"));
|
||||||
|
register_callback_renew(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_CALLBACK_RENEW"));
|
||||||
|
register_callback_pass_on(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_CALLBACK_PASS_ON"));
|
||||||
|
register_callback_done(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_CALLBACK_DONE"));
|
||||||
|
register_mainloop_iterate(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_mainloop_iterate"));
|
||||||
|
register_mainloop_iterate_may_block(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_mainloop_iterate_may_block"));
|
||||||
|
register_mainloop_begin(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_mainloop_begin"));
|
||||||
|
register_mainloop_quit(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_mainloop_quit"));
|
||||||
|
register_mainloop_animator_ticked_get(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_mainlop_animator_ticked_get"));
|
||||||
|
register_mainloop_nested_get(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_mainloop_nested_get"));
|
||||||
|
register_mainloop_thread_safe_call_async(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_mainloop_thread_safe_call"
|
||||||
|
"_async"));
|
||||||
|
register_mainloop_thread_safe_call_sync(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_mainloop_thread_safe_call"
|
||||||
|
"_sync"));
|
||||||
|
|
||||||
|
// timer
|
||||||
|
register_timer_precision_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_timer_precision"
|
||||||
|
"_get"));
|
||||||
|
register_timer_precision_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_timer_precision"
|
||||||
|
"_set"));
|
||||||
|
register_timer_dump(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_timer_dump"));
|
||||||
|
register_timer_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_timer_add"));
|
||||||
|
register_timer_loop_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_timer_loop_add"));
|
||||||
|
|
||||||
|
// event
|
||||||
|
register_event_none(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_EVENT_NONE"));
|
||||||
|
register_event_signal_user(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_SIGNAL_USER"));
|
||||||
|
register_event_signal_hup(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_SIGNAL_HUP"));
|
||||||
|
register_event_signal_exit(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_SIGNAL_EXIT"));
|
||||||
|
register_event_signal_power(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_SIGNAL_POWER"));
|
||||||
|
register_event_signal_realtime(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_SIGNAL_REALTIME"));
|
||||||
|
register_event_memory_state(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_MEMORY_STATE"));
|
||||||
|
register_event_power_state(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_POWER_STATE"));
|
||||||
|
register_event_locale_changed(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_LOCALE_CHANGED"));
|
||||||
|
register_event_hostname_changed(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_EVENT_HOSTNAME_CHANGED"));
|
||||||
|
register_event_system_timedate_changed(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ECORE_EVENT_SYSTEM_TIMEDATE"
|
||||||
|
"_CHANGED"));
|
||||||
|
register_event_type_new(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_event_type_new"));
|
||||||
|
register_event_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_event_add"));
|
||||||
|
register_event_handler_add(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_event_handler_add"));
|
||||||
|
register_event_filter_add(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_event_filter_add"));
|
||||||
|
register_event_current_type_get(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ecore_event_current_type_get"));
|
||||||
|
register_memory_state_normal(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_MEMORY_STATE_NORMAL"));
|
||||||
|
register_memory_state_low(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_MEMORY_STATE_LOW"));
|
||||||
|
register_power_state_mains(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_POWER_STATE_MAINS"));
|
||||||
|
register_power_state_battery(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate, "ECORE_POWER_STATE_BATTERY"));
|
||||||
|
register_power_state_low(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POWER_STATE_LOW"));
|
||||||
|
register_event_signal_user_handler_add(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_event_signal_user_handler"
|
||||||
|
"_add"));
|
||||||
|
register_event_signal_exit_handler_add(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_event_signal_exit_handler"
|
||||||
|
"_add"));
|
||||||
|
register_event_signal_realtime_handler_add(isolate, exports,
|
||||||
|
compatibility_new<String>
|
||||||
|
(isolate,
|
||||||
|
"ecore_event_signal_realtime"
|
||||||
|
"_handler_add"));
|
||||||
|
|
||||||
|
// job
|
||||||
|
register_job_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_job_add"));
|
||||||
|
|
||||||
|
// idle
|
||||||
|
register_idler_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_idler_add"));
|
||||||
|
register_idle_enterer_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_idle_enterer"
|
||||||
|
"_add"));
|
||||||
|
register_idle_enterer_before_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_idle"
|
||||||
|
"_enterer_before"
|
||||||
|
"_add"));
|
||||||
|
register_idle_exiter_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_idle_exiter_add"));
|
||||||
|
|
||||||
|
// animator
|
||||||
|
register_pos_map_linear(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP_LINEAR"));
|
||||||
|
register_pos_map_accelerate(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_ACCELERATE"));
|
||||||
|
register_pos_map_decelerate(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_DECELERATE"));
|
||||||
|
register_pos_map_sinusoidal(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_SINUSOIDAL"));
|
||||||
|
register_pos_map_accelerate_factor(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_ACCELERATE"
|
||||||
|
"_FACTOR"));
|
||||||
|
register_pos_map_decelerate_factor(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_DECELERATE"
|
||||||
|
"_FACTOR"));
|
||||||
|
register_pos_map_sinusoidal_factor(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_SINUSOIDAL"
|
||||||
|
"_FACTOR"));
|
||||||
|
register_pos_map_divisor_interp(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP"
|
||||||
|
"_DIVISOR_INTERP"));
|
||||||
|
register_pos_map_bounce(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP_BOUNCE"));
|
||||||
|
register_pos_map_spring(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP_SPRING"));
|
||||||
|
register_pos_map_cubic_bezier(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_POS_MAP_CUBIC"
|
||||||
|
"_BEZIER"));
|
||||||
|
register_animator_source_timer(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_ANIMATOR"
|
||||||
|
"_SOURCE_TIMER"));
|
||||||
|
register_animator_source_custom(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ECORE_ANIMATOR"
|
||||||
|
"_SOURCE_CUSTOM"));
|
||||||
|
register_animator_frametime_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator"
|
||||||
|
"_frametime_set"));
|
||||||
|
register_animator_frametime_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator"
|
||||||
|
"_frametime_get"));
|
||||||
|
register_animator_pos_map(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_pos"
|
||||||
|
"_map"));
|
||||||
|
register_animator_pos_map_n(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_pos_map"
|
||||||
|
"_n"));
|
||||||
|
register_animator_source_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_source"
|
||||||
|
"_set"));
|
||||||
|
register_animator_source_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_source"
|
||||||
|
"_get"));
|
||||||
|
register_animator_custom_source_tick_begin_callback_set
|
||||||
|
(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_custom_source_tick_begin"
|
||||||
|
"_callback_set"));
|
||||||
|
register_animator_custom_source_tick_end_callback_set
|
||||||
|
(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_custom_source_tick_end"
|
||||||
|
"_callback_set"));
|
||||||
|
register_animator_custom_tick(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator"
|
||||||
|
"_custom_tick"));
|
||||||
|
register_animator_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator_add"));
|
||||||
|
register_animator_timeline_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_animator"
|
||||||
|
"_timeline_add"));
|
||||||
|
|
||||||
|
// poller
|
||||||
|
register_poller_core(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ECORE_POLLER_CORE"));
|
||||||
|
register_poller_poll_interval_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_poller"
|
||||||
|
"_poll_interval"
|
||||||
|
"_set"));
|
||||||
|
register_poller_poll_interval_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_poller"
|
||||||
|
"_poll_interval"
|
||||||
|
"_get"));
|
||||||
|
register_poller_add(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "ecore_poller_add"));
|
||||||
|
|
||||||
|
// throttle
|
||||||
|
register_throttle_adjust(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_throttle_adjust"));
|
||||||
|
register_throttle_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"ecore_throttle_get"));
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_NODEJS
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
efl::eina::eina_init eina_init;
|
||||||
|
efl::eo::eo_init eo_init;
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_initialize();
|
||||||
|
v8::Isolate* isolate = v8::Isolate::New();
|
||||||
|
assert(isolate != 0);
|
||||||
|
|
||||||
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(isolate);
|
||||||
|
v8::Handle<v8::Context> context
|
||||||
|
= efl::eina::js::compatibility_new<v8::Context>
|
||||||
|
(isolate, nullptr
|
||||||
|
, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
|
||||||
|
if (context.IsEmpty()) {
|
||||||
|
fprintf(stderr, "Error creating context\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
context->Enter();
|
||||||
|
{
|
||||||
|
std::vector<char> script;
|
||||||
|
{
|
||||||
|
std::ifstream script_file(TESTS_SRC_DIR "/ecore_js_suite.js");
|
||||||
|
script_file.seekg(0, std::ios::end);
|
||||||
|
std::size_t script_size = script_file.tellg();
|
||||||
|
script_file.seekg(0, std::ios::beg);
|
||||||
|
script.resize(script_size+1);
|
||||||
|
script_file.rdbuf()->sgetn(&script[0], script_size);
|
||||||
|
auto line_break = std::find(script.begin(), script.end(), '\n');
|
||||||
|
assert(line_break != script.end());
|
||||||
|
++line_break;
|
||||||
|
std::fill(script.begin(), line_break, ' ');
|
||||||
|
|
||||||
|
std::cerr << "program:" << std::endl;
|
||||||
|
std::copy(script.begin(), script.end(), std::ostream_iterator<char>(std::cerr));
|
||||||
|
std::cerr << "end of program" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Enter the execution environment before evaluating any code.
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String>
|
||||||
|
(nullptr, "(shell)"));
|
||||||
|
v8::Local<v8::Object> global = context->Global();
|
||||||
|
v8::Handle<v8::Object> console = efl::eina::js::compatibility_new<v8::Object>(isolate);
|
||||||
|
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "console"), console);
|
||||||
|
console->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "log")
|
||||||
|
, efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, & ::Print)
|
||||||
|
->GetFunction());
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
v8::Handle<v8::Object> exports = efl::eina::js::compatibility_new<v8::Object>(isolate);
|
||||||
|
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "suite"), exports);
|
||||||
|
|
||||||
|
test_setup(exports);
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(v8::Isolate::GetCurrent());
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
ExecuteString(v8::Isolate::GetCurrent(),
|
||||||
|
efl::eina::js::compatibility_new<v8::String>(v8::Isolate::GetCurrent(), &script[0]),
|
||||||
|
name);
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
}
|
||||||
|
context->Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include EINA_STRINGIZE(NODE_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void eina_js_module_init(v8::Handle<v8::Object> exports)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "teste\n"); fflush(stderr);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
eina_init();
|
||||||
|
eo_init();
|
||||||
|
|
||||||
|
test_setup(exports);
|
||||||
|
|
||||||
|
std::cerr << "registered" << std::endl;
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_MODULE(ecore_js_suite_mod, ::eina_js_module_init)
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,297 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var suite;
|
||||||
|
var assert;
|
||||||
|
|
||||||
|
if(typeof process !== 'undefined') {
|
||||||
|
console.log('running from nodejs');
|
||||||
|
console.log('path', process.env.NODE_PATH);
|
||||||
|
console.log("teste1");
|
||||||
|
|
||||||
|
suite = require('ecore_js_suite_mod');
|
||||||
|
assert = require('assert');
|
||||||
|
assert(suite != null);
|
||||||
|
} else {
|
||||||
|
assert = function(test, message) { if (test !== true) throw message; };
|
||||||
|
console.log('running from libv8')
|
||||||
|
}
|
||||||
|
|
||||||
|
function abs(n) {
|
||||||
|
if (n < 0)
|
||||||
|
return n * -1;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
var TOLERANCE = 0.0001;
|
||||||
|
|
||||||
|
// Ecore initialization
|
||||||
|
|
||||||
|
suite.ecore_init();
|
||||||
|
|
||||||
|
console.log("Finished init");
|
||||||
|
|
||||||
|
var captured = false;
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
|
||||||
|
suite.ecore_mainloop_thread_safe_call_async(function() {
|
||||||
|
captured = true;
|
||||||
|
suite.ecore_mainloop_quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ecore mainloop init
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
assert(captured);
|
||||||
|
|
||||||
|
// Timers
|
||||||
|
|
||||||
|
var p = 2.5;
|
||||||
|
suite.ecore_timer_precision_set(p);
|
||||||
|
assert(abs(suite.ecore_timer_precision_get() - p) < TOLERANCE);
|
||||||
|
|
||||||
|
p = 0.5;
|
||||||
|
suite.ecore_timer_precision_set(p);
|
||||||
|
assert(abs(suite.ecore_timer_precision_get() - p) < TOLERANCE);
|
||||||
|
|
||||||
|
var dump = suite.ecore_timer_dump();
|
||||||
|
assert(typeof(dump) === 'string');
|
||||||
|
console.log("### BEGINING of Timer dump: ###");
|
||||||
|
console.log(dump);
|
||||||
|
console.log("### END of Timer dump ###");
|
||||||
|
|
||||||
|
var ncalls = 0;
|
||||||
|
|
||||||
|
captured = false;
|
||||||
|
suite.ecore_timer_add(1, function() {
|
||||||
|
++ncalls;
|
||||||
|
if (ncalls != 4)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
captured = true;
|
||||||
|
suite.ecore_job_add(suite.ecore_mainloop_quit);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured);
|
||||||
|
|
||||||
|
ncalls = 0;
|
||||||
|
captured = false;
|
||||||
|
|
||||||
|
suite.ecore_timer_loop_add(1, function() {
|
||||||
|
++ncalls;
|
||||||
|
if (ncalls != 4)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
captured = true;
|
||||||
|
suite.ecore_job_add(suite.ecore_mainloop_quit);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured);
|
||||||
|
|
||||||
|
captured = false;
|
||||||
|
|
||||||
|
var timer = suite.ecore_timer_add(1, function() {
|
||||||
|
captured = true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(timer.freeze_get() === false);
|
||||||
|
|
||||||
|
timer.freeze();
|
||||||
|
|
||||||
|
assert(timer.freeze_get() === true);
|
||||||
|
|
||||||
|
timer.thaw();
|
||||||
|
|
||||||
|
assert(timer.freeze_get() === false);
|
||||||
|
|
||||||
|
timer.del();
|
||||||
|
|
||||||
|
suite.ecore_timer_add(2, function() {
|
||||||
|
suite.ecore_job_add(suite.ecore_mainloop_quit);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured === false);
|
||||||
|
|
||||||
|
// Ecore event
|
||||||
|
|
||||||
|
var myevent = suite.ecore_event_type_new();
|
||||||
|
|
||||||
|
captured = [0, 0, 0]
|
||||||
|
|
||||||
|
var handler1 = suite.ecore_event_handler_add(myevent, function(event) {
|
||||||
|
assert(suite.ecore_event_current_type_get() === myevent);
|
||||||
|
assert(event === myevent);
|
||||||
|
captured[0] += 1;
|
||||||
|
return suite.ECORE_CALLBACK_PASS_ON;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_event_handler_add(myevent, function(event) {
|
||||||
|
assert(suite.ecore_event_current_type_get() === myevent);
|
||||||
|
assert(event === myevent);
|
||||||
|
captured[1] += 1;
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_event_handler_add(myevent, function(event) {
|
||||||
|
assert(suite.ecore_event_current_type_get() === myevent);
|
||||||
|
assert(event === myevent);
|
||||||
|
captured[2] += 1;
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_timer_add(1, function() {
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
assert(captured[0] === 0 && captured[1] === 0 && captured[2] === 0);
|
||||||
|
suite.ecore_timer_add(1, function() {
|
||||||
|
assert(captured[0] === 1 && captured[1] === 1 && captured[2] === 0);
|
||||||
|
handler1.del();
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_timer_add(1, function() {
|
||||||
|
assert(captured[0] === 1 && captured[1] === 3 && captured[2] === 0);
|
||||||
|
suite.ecore_mainloop_quit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
|
||||||
|
var filter = suite.ecore_event_filter_add(function() {
|
||||||
|
return {count: 0};
|
||||||
|
}, function(loop_data, event) {
|
||||||
|
assert(event === myevent);
|
||||||
|
var c = loop_data.count;
|
||||||
|
++loop_data.count;
|
||||||
|
return c != 0;
|
||||||
|
}, function(loop_data) {});
|
||||||
|
|
||||||
|
suite.ecore_timer_add(1, suite.ecore_mainloop_quit);
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured[1] === 5);
|
||||||
|
filter.del();
|
||||||
|
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
suite.ecore_event_add(myevent);
|
||||||
|
|
||||||
|
suite.ecore_timer_add(1, suite.ecore_mainloop_quit);
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured[1] === 8);
|
||||||
|
|
||||||
|
// Ecore job
|
||||||
|
|
||||||
|
captured = false;
|
||||||
|
|
||||||
|
suite.ecore_job_add(function() {
|
||||||
|
captured = true;
|
||||||
|
suite.ecore_mainloop_quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
assert(captured === false);
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured === true);
|
||||||
|
|
||||||
|
captured = false;
|
||||||
|
var job = suite.ecore_job_add(function() {
|
||||||
|
captured = true;
|
||||||
|
});
|
||||||
|
suite.ecore_job_add(suite.ecore_mainloop_quit);
|
||||||
|
job.del();
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured === false);
|
||||||
|
|
||||||
|
// Ecore idle
|
||||||
|
var counter = 1;
|
||||||
|
captured = [0, 0, 0, 0, 0];
|
||||||
|
|
||||||
|
suite.ecore_idler_add(function() {
|
||||||
|
captured[0] = counter;
|
||||||
|
counter += 1;
|
||||||
|
suite.ecore_job_add(function() {});
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_idle_enterer_add(function() {
|
||||||
|
captured[1] = counter;
|
||||||
|
counter += 1;
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_idle_enterer_add(function() {
|
||||||
|
captured[2] = counter;
|
||||||
|
counter += 1;
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_idle_enterer_before_add(function() {
|
||||||
|
captured[3] = counter;
|
||||||
|
counter += 1;
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_idle_exiter_add(function() {
|
||||||
|
captured[4] = counter;
|
||||||
|
counter += 1;
|
||||||
|
suite.ecore_mainloop_quit();
|
||||||
|
return suite.ECORE_CALLBACK_DONE;
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.ecore_mainloop_begin();
|
||||||
|
assert(captured[0] === 4);
|
||||||
|
assert(captured[1] === 2);
|
||||||
|
assert(captured[2] === 3);
|
||||||
|
assert(captured[3] === 1);
|
||||||
|
assert(captured[4] === 5);
|
||||||
|
|
||||||
|
// Ecore animator
|
||||||
|
|
||||||
|
suite.ecore_animator_frametime_set(1);
|
||||||
|
assert(suite.ecore_animator_frametime_get() === 1);
|
||||||
|
suite.ecore_animator_frametime_set(1 / 50);
|
||||||
|
assert(suite.ecore_animator_frametime_get() === (1 / 50));
|
||||||
|
|
||||||
|
assert(suite.ecore_animator_pos_map(0.5, suite.ECORE_POS_MAP_LINEAR, 0, 0)
|
||||||
|
=== 0.5);
|
||||||
|
|
||||||
|
suite.ecore_animator_source_set(suite.ECORE_ANIMATOR_SOURCE_CUSTOM);
|
||||||
|
assert(suite.ecore_animator_source_get()
|
||||||
|
=== suite.ECORE_ANIMATOR_SOURCE_CUSTOM);
|
||||||
|
suite.ecore_animator_source_set(suite.ECORE_ANIMATOR_SOURCE_TIMER);
|
||||||
|
assert(suite.ecore_animator_source_get() === suite.ECORE_ANIMATOR_SOURCE_TIMER);
|
||||||
|
|
||||||
|
// Ecore poller
|
||||||
|
|
||||||
|
suite.ecore_poller_poll_interval_set(suite.ECORE_POLLER_CORE, 42);
|
||||||
|
assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 42);
|
||||||
|
suite.ecore_poller_poll_interval_set(suite.ECORE_POLLER_CORE, 2);
|
||||||
|
assert(suite.ecore_poller_poll_interval_get(suite.ECORE_POLLER_CORE) === 2);
|
||||||
|
|
||||||
|
// Ecore throttle
|
||||||
|
|
||||||
|
suite.ecore_throttle_adjust(3);
|
||||||
|
assert(suite.ecore_throttle_get() === 3);
|
||||||
|
suite.ecore_throttle_adjust(-3);
|
||||||
|
assert(suite.ecore_throttle_get() === 0);
|
||||||
|
|
||||||
|
// Ecore shutdown
|
||||||
|
|
||||||
|
suite.ecore_shutdown();
|
||||||
|
|
||||||
|
console.log("Finished shutdown");
|
||||||
|
|
||||||
|
// finished tests
|
||||||
|
|
||||||
|
console.log("Test execution with success");
|
|
@ -0,0 +1,444 @@
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Eo.hh>
|
||||||
|
|
||||||
|
#include <eina_js_accessor.hh>
|
||||||
|
#include <eina_js_list.hh>
|
||||||
|
#include <eina_js_iterator.hh>
|
||||||
|
#include <eina_js_error.hh>
|
||||||
|
#include <eina_js_log.cc>
|
||||||
|
|
||||||
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Executes a string within the current v8 context.
|
||||||
|
bool ExecuteString(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::String> source,
|
||||||
|
v8::Handle<v8::Value> name)
|
||||||
|
{
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(isolate);
|
||||||
|
v8::TryCatch try_catch;
|
||||||
|
v8::ScriptOrigin origin(name);
|
||||||
|
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
|
||||||
|
if (script.IsEmpty()) {
|
||||||
|
std::cerr << "Compilation failed" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during compilation.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Compilation succesful" << std::endl;
|
||||||
|
v8::Handle<v8::Value> result = script->Run();
|
||||||
|
if (result.IsEmpty()) {
|
||||||
|
std::cout << "Failed with exception thrown" << std::endl;
|
||||||
|
//assert(try_catch.HasCaught());
|
||||||
|
//std::abort();
|
||||||
|
// Print errors that happened during execution.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
if(try_catch.HasCaught())
|
||||||
|
std::cerr << "Exception " << ToCString(v8::String::Utf8Value(try_catch.Message()->Get()))
|
||||||
|
<< std::endl;
|
||||||
|
std::abort();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
assert(!try_catch.HasCaught());
|
||||||
|
// if (print_result && !result->IsUndefined()) {
|
||||||
|
// // If all went well and the result wasn't undefined then print
|
||||||
|
// // the returned value.
|
||||||
|
// v8::String::Utf8Value str(result);
|
||||||
|
// const char* cstr = ToCString(str);
|
||||||
|
// printf("%s\n", cstr);
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_return_type Print(efl::eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
return efl::eina::js::compatibility_return();
|
||||||
|
}
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_return_type clear_eina_error(efl::eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
eina_error_set(0);
|
||||||
|
return efl::eina::js::convert_error_to_javascript_exception(args.GetIsolate());
|
||||||
|
}
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_return_type set_eina_error(efl::eina::js::compatibility_callback_info_type args)
|
||||||
|
{
|
||||||
|
eina_error_set(eina_error_msg_static_register("foobar"));
|
||||||
|
return efl::eina::js::convert_error_to_javascript_exception(args.GetIsolate());
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void eina_container_register(v8::Handle<v8::Object> global, v8::Isolate* isolate);
|
||||||
|
EAPI v8::Local<v8::Function> get_list_instance_template();
|
||||||
|
|
||||||
|
efl::eina::ptr_list<int> list;
|
||||||
|
efl::eina::js::range_eina_list<int> raw_list;
|
||||||
|
|
||||||
|
efl::eina::array<int> array;
|
||||||
|
|
||||||
|
static void eina_log_print_cb_js_test(const Eina_Log_Domain *d,
|
||||||
|
Eina_Log_Level level, const char *file,
|
||||||
|
const char *fnc, int line,
|
||||||
|
const char */*fmt*/, void */*data*/,
|
||||||
|
va_list args)
|
||||||
|
{
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
static int index = 0;
|
||||||
|
|
||||||
|
const char *msg = va_arg(args, const char*);
|
||||||
|
|
||||||
|
string domains[] = {"", "", "", "mydomain", "mydomain2"};
|
||||||
|
int levels[] = {EINA_LOG_LEVEL_DBG, EINA_LOG_LEVEL_CRITICAL,
|
||||||
|
EINA_LOG_LEVEL_WARN, EINA_LOG_LEVEL_INFO,
|
||||||
|
EINA_LOG_LEVEL_ERR};
|
||||||
|
string functions[] = {"f1", "", "f2", "f3", ""};
|
||||||
|
#ifdef HAVE_NODEJS
|
||||||
|
int lines[] = {191, 192, 193, 194, 200};
|
||||||
|
#else
|
||||||
|
int lines[] = {190, 191, 192, 193, 199};
|
||||||
|
#endif
|
||||||
|
string messages[] = {"I changed again", "Cool to Hate", "One Fine Day",
|
||||||
|
"Never Gonna Find Me", "The Kids Aren't Alright"};
|
||||||
|
|
||||||
|
assert(string(d->name, d->namelen) == domains[index]);
|
||||||
|
assert(level == levels[index]);
|
||||||
|
{
|
||||||
|
auto last_component = strrchr(file, '/');
|
||||||
|
assert(last_component);
|
||||||
|
assert(last_component == string("/eina_js_suite.js"));
|
||||||
|
}
|
||||||
|
assert(fnc == functions[index]);
|
||||||
|
assert(line == lines[index]);
|
||||||
|
assert(msg == messages[index]);
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_setup(v8::Handle<v8::Object> exports)
|
||||||
|
{
|
||||||
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
|
|
||||||
|
// container globals
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
list.push_back(new int(5));
|
||||||
|
list.push_back(new int(10));
|
||||||
|
list.push_back(new int(15));
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
raw_list = efl::eina::js::range_eina_list<int>(list.native_handle());
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
eina_container_register(exports, v8::Isolate::GetCurrent());
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
v8::Handle<v8::Value> a[] = {efl::eina::js::compatibility_new<v8::External>(nullptr, &raw_list)};
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
exports->Set(efl::eina::js::compatibility_new<v8::String>(nullptr, "raw_list")
|
||||||
|
, get_list_instance_template()->NewInstance(1, a));
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
// error globals
|
||||||
|
exports->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "clear_eina_error"),
|
||||||
|
efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, clear_eina_error)
|
||||||
|
->GetFunction());
|
||||||
|
exports->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "set_eina_error"),
|
||||||
|
efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, set_eina_error)
|
||||||
|
->GetFunction());
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
// accessor
|
||||||
|
Eina_Array* array = eina_array_new(3);
|
||||||
|
eina_array_push(array, new int(42));
|
||||||
|
eina_array_push(array, new int(24));
|
||||||
|
eina_array_push(array, new int(0));
|
||||||
|
|
||||||
|
static efl::eina::accessor<int> acc(eina_array_accessor_new(array));
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
v8::Local<v8::Object> wrapped_acc = efl::eina::js::export_accessor( acc, isolate);
|
||||||
|
exports->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "acc"), wrapped_acc);
|
||||||
|
|
||||||
|
static efl::eina::iterator<int> it(eina_array_iterator_new(array));
|
||||||
|
|
||||||
|
v8::Local<v8::Object> wrapped_it = efl::eina::js::export_iterator(&it, isolate);
|
||||||
|
|
||||||
|
exports->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "it"), wrapped_it);
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
efl::eina::js::register_value
|
||||||
|
(isolate, exports
|
||||||
|
, efl::eina::js::compatibility_new<v8::String>(isolate, "value"));
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
// log
|
||||||
|
using namespace efl::eina::js;
|
||||||
|
using v8::String;
|
||||||
|
{
|
||||||
|
int d = eina_log_domain_register("mydomain", "");
|
||||||
|
eina_log_domain_registered_level_set(d, EINA_LOG_LEVEL_DBG);
|
||||||
|
exports->Set(compatibility_new<String>(isolate, "mydomain"),
|
||||||
|
value_cast<v8::Local<v8::Value>>(d, isolate));
|
||||||
|
}
|
||||||
|
register_log_level_critical(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"LOG_LEVEL_CRITICAL"));
|
||||||
|
register_log_level_err(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "LOG_LEVEL_ERR"));
|
||||||
|
register_log_level_warn(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "LOG_LEVEL_WARN"));
|
||||||
|
register_log_level_info(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "LOG_LEVEL_INFO"));
|
||||||
|
register_log_level_dbg(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "LOG_LEVEL_DBG"));
|
||||||
|
register_log_domain_global(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"LOG_DOMAIN_GLOBAL"));
|
||||||
|
register_log_print(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "log_print"));
|
||||||
|
register_log_domain_register(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_domain"
|
||||||
|
"_register"));
|
||||||
|
register_log_domain_unregister(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_domain_unregis"
|
||||||
|
"ter"));
|
||||||
|
register_log_domain_registered_level_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log"
|
||||||
|
"_domain"
|
||||||
|
"_register"
|
||||||
|
"ed_level"
|
||||||
|
"_get"));
|
||||||
|
register_log_domain_registered_level_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log"
|
||||||
|
"_domain"
|
||||||
|
"_register"
|
||||||
|
"ed_level"
|
||||||
|
"_set"));
|
||||||
|
register_log_print_cb_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_print_cb_set"));
|
||||||
|
register_log_level_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "log_level_set"));
|
||||||
|
register_log_level_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "log_level_get"));
|
||||||
|
register_log_level_check(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_level_check"));
|
||||||
|
register_log_color_disable_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_color_disable"
|
||||||
|
"_set"));
|
||||||
|
register_log_color_disable_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_color_disable"
|
||||||
|
"_get"));
|
||||||
|
register_log_file_disable_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_file_disable"
|
||||||
|
"_set"));
|
||||||
|
register_log_file_disable_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_file_disable"
|
||||||
|
"_get"));
|
||||||
|
register_log_abort_on_critical_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort_on"
|
||||||
|
"_critical"
|
||||||
|
"_set"));
|
||||||
|
register_log_abort_on_critical_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort_on"
|
||||||
|
"_critical"
|
||||||
|
"_get"));
|
||||||
|
register_log_function_disable_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_function"
|
||||||
|
"_disable_set"));
|
||||||
|
register_log_function_disable_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_function"
|
||||||
|
"_disable_get"));
|
||||||
|
register_log_abort_on_critical_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort_on"
|
||||||
|
"_critical"
|
||||||
|
"_set"));
|
||||||
|
register_log_abort_on_critical_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort_on"
|
||||||
|
"_critical"
|
||||||
|
"_get"));
|
||||||
|
register_log_abort_on_critical_level_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort"
|
||||||
|
"_on"
|
||||||
|
"_critical"
|
||||||
|
"_level"
|
||||||
|
"_set"));
|
||||||
|
register_log_abort_on_critical_level_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_abort"
|
||||||
|
"_on"
|
||||||
|
"_critical"
|
||||||
|
"_level"
|
||||||
|
"_get"));
|
||||||
|
register_log_domain_level_set(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_domain_level"
|
||||||
|
"_set"));
|
||||||
|
register_log_domain_level_get(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"log_domain_level"
|
||||||
|
"_get"));
|
||||||
|
register_log_state_start(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate,
|
||||||
|
"LOG_STATE_START"));
|
||||||
|
register_log_state_stop(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "LOG_STATE_STOP"));
|
||||||
|
register_log_timing(isolate, exports,
|
||||||
|
compatibility_new<String>(isolate, "log_timing"));
|
||||||
|
|
||||||
|
eina_log_print_cb_set(eina_log_print_cb_js_test, NULL);
|
||||||
|
eina_log_level_set(EINA_LOG_LEVEL_DBG);
|
||||||
|
eina_log_abort_on_critical_set(EINA_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_NODEJS
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
efl::eina::eina_init eina_init;
|
||||||
|
efl::eo::eo_init eo_init;
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_initialize();
|
||||||
|
v8::Isolate* isolate = v8::Isolate::New();
|
||||||
|
assert(isolate != 0);
|
||||||
|
|
||||||
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(isolate);
|
||||||
|
v8::Handle<v8::Context> context
|
||||||
|
= efl::eina::js::compatibility_new<v8::Context>
|
||||||
|
(isolate, nullptr
|
||||||
|
, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
|
||||||
|
if (context.IsEmpty()) {
|
||||||
|
fprintf(stderr, "Error creating context\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
context->Enter();
|
||||||
|
{
|
||||||
|
std::vector<char> script;
|
||||||
|
{
|
||||||
|
std::ifstream script_file(TESTS_SRC_DIR "/eina_js_suite.js");
|
||||||
|
script_file.seekg(0, std::ios::end);
|
||||||
|
std::size_t script_size = script_file.tellg();
|
||||||
|
script_file.seekg(0, std::ios::beg);
|
||||||
|
script.resize(script_size+1);
|
||||||
|
script_file.rdbuf()->sgetn(&script[0], script_size);
|
||||||
|
auto line_break = std::find(script.begin(), script.end(), '\n');
|
||||||
|
assert(line_break != script.end());
|
||||||
|
++line_break;
|
||||||
|
std::fill(script.begin(), line_break, ' ');
|
||||||
|
|
||||||
|
std::cerr << "program:" << std::endl;
|
||||||
|
std::copy(script.begin(), script.end(), std::ostream_iterator<char>(std::cerr));
|
||||||
|
std::cerr << "end of program" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Enter the execution environment before evaluating any code.
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String>
|
||||||
|
(nullptr, TESTS_SRC_DIR "/eina_js_suite.js"));
|
||||||
|
v8::Local<v8::Object> global = context->Global();
|
||||||
|
v8::Handle<v8::Object> console = efl::eina::js::compatibility_new<v8::Object>(isolate);
|
||||||
|
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "console"), console);
|
||||||
|
console->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "log")
|
||||||
|
, efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, & ::Print)
|
||||||
|
->GetFunction());
|
||||||
|
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
v8::Handle<v8::Object> exports = efl::eina::js::compatibility_new<v8::Object>(isolate);
|
||||||
|
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "suite"), exports);
|
||||||
|
|
||||||
|
test_setup(exports);
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
efl::eina::js::compatibility_handle_scope handle_scope(v8::Isolate::GetCurrent());
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
ExecuteString(v8::Isolate::GetCurrent(),
|
||||||
|
efl::eina::js::compatibility_new<v8::String>(v8::Isolate::GetCurrent(), &script[0]),
|
||||||
|
name);
|
||||||
|
std::cerr << __LINE__ << std::endl;
|
||||||
|
}
|
||||||
|
context->Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include EINA_STRINGIZE(NODE_INCLUDE_HEADER)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void eina_js_module_init(v8::Handle<v8::Object> exports)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "teste\n"); fflush(stderr);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
eina_init();
|
||||||
|
eo_init();
|
||||||
|
|
||||||
|
test_setup(exports);
|
||||||
|
|
||||||
|
std::cerr << "registered" << std::endl;
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error" << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_MODULE(eina_js_suite_mod, ::eina_js_module_init)
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,267 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var suite;
|
||||||
|
var assert;
|
||||||
|
|
||||||
|
if(typeof process !== 'undefined')
|
||||||
|
{
|
||||||
|
console.log('running from nodejs');
|
||||||
|
console.log('path', process.env.NODE_PATH);
|
||||||
|
console.log("teste1");
|
||||||
|
|
||||||
|
suite = require('eina_js_suite_mod');
|
||||||
|
assert = require('assert');
|
||||||
|
assert(suite != null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert = function(test, message) { if (test !== true) throw message; };
|
||||||
|
console.log('running from libv8')
|
||||||
|
}
|
||||||
|
|
||||||
|
// container tests
|
||||||
|
|
||||||
|
console.log("teste");
|
||||||
|
var l1 = suite.raw_list;
|
||||||
|
console.log ("l1 ", l1.toString());
|
||||||
|
assert (l1.length == 3);
|
||||||
|
var l2 = suite.raw_list;
|
||||||
|
console.log ("l2 ", l2.toString());
|
||||||
|
assert (l2.length == 3);
|
||||||
|
var c = l1.concat(l2);
|
||||||
|
console.log ("c ", c.toString());
|
||||||
|
assert (c.length == (l1.length + l2.length));
|
||||||
|
assert (c[0] == l1[0]);
|
||||||
|
assert (c[1] == l1[1]);
|
||||||
|
assert (c[2] == l1[2]);
|
||||||
|
assert (c[3] == l2[0]);
|
||||||
|
assert (c[4] == l2[1]);
|
||||||
|
assert (c[5] == l2[2]);
|
||||||
|
assert (c.indexOf(c[0]) == 0);
|
||||||
|
assert (c.indexOf(c[1]) == 1);
|
||||||
|
assert (c.indexOf(c[2]) == 2);
|
||||||
|
assert (c.indexOf(c[3]) == 0);
|
||||||
|
assert (c.indexOf(c[4]) == 1);
|
||||||
|
assert (c.indexOf(c[5]) == 2);
|
||||||
|
assert (c.lastIndexOf(c[0]) == 3);
|
||||||
|
assert (c.lastIndexOf(c[1]) == 4);
|
||||||
|
assert (c.lastIndexOf(c[2]) == 5);
|
||||||
|
assert (c.lastIndexOf(c[3]) == 3);
|
||||||
|
assert (c.lastIndexOf(c[4]) == 4);
|
||||||
|
assert (c.lastIndexOf(c[5]) == 5);
|
||||||
|
var s1 = l1.slice(1, 3);
|
||||||
|
console.log ("s1 ", s1.toString());
|
||||||
|
assert (s1.length == 2);
|
||||||
|
assert (s1[0] == l1[1]);
|
||||||
|
assert (s1[1] == l1[2]);
|
||||||
|
var s2 = c.slice(1, 3);
|
||||||
|
console.log ("s2 ", s2.toString());
|
||||||
|
assert (s2.length == 2);
|
||||||
|
assert (s2[0] == l1[1]);
|
||||||
|
assert (s2[1] == l1[2]);
|
||||||
|
|
||||||
|
console.log("Finished containers");
|
||||||
|
|
||||||
|
// error tests
|
||||||
|
|
||||||
|
var captured = false;
|
||||||
|
console.log("#1");
|
||||||
|
try {
|
||||||
|
console.log("#2");
|
||||||
|
suite.clear_eina_error();
|
||||||
|
console.log("#3");
|
||||||
|
} catch(e) {
|
||||||
|
console.log("#4");
|
||||||
|
console.log("Exception ", e.toString());
|
||||||
|
console.log("#5");
|
||||||
|
captured = true;
|
||||||
|
}
|
||||||
|
console.log("#6");
|
||||||
|
assert(captured === false, 'error #1');
|
||||||
|
console.log("#7");
|
||||||
|
|
||||||
|
captured = false;
|
||||||
|
try {
|
||||||
|
console.log("#1");
|
||||||
|
suite.set_eina_error();
|
||||||
|
console.log("#2");
|
||||||
|
} catch(e) {
|
||||||
|
console.log("#3");
|
||||||
|
console.log("Exception ", e.toString());
|
||||||
|
console.log("#4");
|
||||||
|
assert(e.code === 'Eina_Error', 'error #2');
|
||||||
|
console.log("#5");
|
||||||
|
assert(e.value === 'foobar', 'error #3');
|
||||||
|
console.log("#6");
|
||||||
|
captured = true;
|
||||||
|
console.log("#7");
|
||||||
|
}
|
||||||
|
console.log("#8");
|
||||||
|
assert(captured === true, 'error #4');
|
||||||
|
|
||||||
|
console.log("Finished errors");
|
||||||
|
|
||||||
|
// accessor tests
|
||||||
|
|
||||||
|
assert(suite.acc.get(0) === 42, 'accessor #1');
|
||||||
|
assert(suite.acc.get(1) === 24, 'accessor #2');
|
||||||
|
|
||||||
|
console.log("Finished accessors");
|
||||||
|
|
||||||
|
// iterator tests
|
||||||
|
|
||||||
|
assert(suite.it.next().value === 42, 'iterator #1');
|
||||||
|
assert(suite.it.next().value === 24, 'iterator #2');
|
||||||
|
|
||||||
|
console.log("Finished iterators");
|
||||||
|
|
||||||
|
// value tests
|
||||||
|
|
||||||
|
console.log("x");
|
||||||
|
|
||||||
|
var my_value = new suite.value(1);
|
||||||
|
console.log("x");
|
||||||
|
var wrapped = my_value.get();
|
||||||
|
console.log("x");
|
||||||
|
assert(typeof(wrapped) === 'number', 'value #1');
|
||||||
|
console.log("x");
|
||||||
|
assert(wrapped === 1, 'value #2');
|
||||||
|
console.log("x");
|
||||||
|
|
||||||
|
my_value.set(2);
|
||||||
|
console.log("x");
|
||||||
|
assert(wrapped === 1, 'value #3');
|
||||||
|
console.log("x");
|
||||||
|
wrapped = my_value.get();
|
||||||
|
console.log("x");
|
||||||
|
assert(typeof(wrapped) === 'number', 'value #4');
|
||||||
|
console.log("x");
|
||||||
|
assert(wrapped === 2, 'value #5');
|
||||||
|
console.log("x");
|
||||||
|
|
||||||
|
my_value.set(true);
|
||||||
|
console.log("x");
|
||||||
|
assert(wrapped === 2, 'value #6');
|
||||||
|
console.log("x");
|
||||||
|
wrapped = my_value.get();
|
||||||
|
console.log("x");
|
||||||
|
// boolean is represented as integer in the efl::eina::value layer
|
||||||
|
console.log("x");
|
||||||
|
assert(typeof(wrapped) === 'number', 'value #7');
|
||||||
|
console.log("x");
|
||||||
|
assert(wrapped === 1, 'value #8');
|
||||||
|
console.log("x");
|
||||||
|
|
||||||
|
console.log("x");
|
||||||
|
var captured = false;
|
||||||
|
console.log("x");
|
||||||
|
try {
|
||||||
|
console.log("x");
|
||||||
|
my_value.set({type: 'complex object'});
|
||||||
|
console.log("x");
|
||||||
|
} catch(e) {
|
||||||
|
console.log("x");
|
||||||
|
assert(e.code === 'std::bad_cast', 'value #9');
|
||||||
|
console.log("x");
|
||||||
|
captured = true;
|
||||||
|
console.log("x");
|
||||||
|
}
|
||||||
|
console.log("x");
|
||||||
|
assert(captured === true, 'value #10');
|
||||||
|
console.log("x");
|
||||||
|
|
||||||
|
console.log("x");
|
||||||
|
captured = false;
|
||||||
|
console.log("x");
|
||||||
|
try {
|
||||||
|
console.log("x");
|
||||||
|
my_value = new suite.value({type: 'complex object'});
|
||||||
|
console.log("x");
|
||||||
|
} catch(e) {
|
||||||
|
console.log("e.code ", e.code, ' ', typeof e);
|
||||||
|
assert(e.code === 'std::bad_cast', 'value #11');
|
||||||
|
console.log("x");
|
||||||
|
captured = true;
|
||||||
|
console.log("x");
|
||||||
|
}
|
||||||
|
assert(captured === true, 'value #12');
|
||||||
|
|
||||||
|
// log
|
||||||
|
|
||||||
|
function f1(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_DBG, 'I changed again'); }; f1();
|
||||||
|
suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_CRITICAL, 'Cool to Hate');
|
||||||
|
function f2(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_WARN, 'One Fine Day'); }; f2();
|
||||||
|
function f3(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_INFO, 'Never Gonna Find Me'); }; f3();
|
||||||
|
|
||||||
|
mydomain2 = suite.log_domain_register('mydomain2', '');
|
||||||
|
suite.log_domain_registered_level_set(mydomain2, suite.LOG_LEVEL_DBG);
|
||||||
|
assert(suite.log_domain_registered_level_get(mydomain2) === suite.LOG_LEVEL_DBG, '#1');
|
||||||
|
|
||||||
|
suite.log_print(mydomain2, suite.LOG_LEVEL_ERR, "The Kids Aren't Alright");
|
||||||
|
|
||||||
|
suite.log_domain_unregister(mydomain2);
|
||||||
|
mydomain2 = undefined;
|
||||||
|
|
||||||
|
suite.log_color_disable_set(true);
|
||||||
|
assert(suite.log_color_disable_get() === true, '#2');
|
||||||
|
suite.log_color_disable_set(false);
|
||||||
|
assert(suite.log_color_disable_get() === false, '#3');
|
||||||
|
|
||||||
|
suite.log_file_disable_set(true);
|
||||||
|
assert(suite.log_file_disable_get() === true, '#4');
|
||||||
|
suite.log_file_disable_set(false);
|
||||||
|
assert(suite.log_file_disable_get() === false, '#5');
|
||||||
|
|
||||||
|
suite.log_function_disable_set(true);
|
||||||
|
assert(suite.log_function_disable_get() === true, '#6');
|
||||||
|
suite.log_function_disable_set(false);
|
||||||
|
assert(suite.log_function_disable_get() === false, '#7');
|
||||||
|
|
||||||
|
suite.log_abort_on_critical_set(true);
|
||||||
|
assert(suite.log_abort_on_critical_get() === true, '#8');
|
||||||
|
suite.log_abort_on_critical_set(false);
|
||||||
|
assert(suite.log_abort_on_critical_get() === false, '#9');
|
||||||
|
|
||||||
|
var entered = false;
|
||||||
|
suite.log_print_cb_set(function(domain, color, level, file, func, line, msg) {
|
||||||
|
assert(domain === 'mydomain', '#10');
|
||||||
|
assert(color === '', '#11');
|
||||||
|
assert(level === suite.LOG_LEVEL_WARN, '#12');
|
||||||
|
assert(function(){ var components = file.split('/'); return components[components.length - 1]; }() === 'eina_js_suite.js', '#13');
|
||||||
|
assert(func === 'f4', '#14');
|
||||||
|
assert(line === ((typeof process !== 'undefined') ? 237 : 236), '#15');
|
||||||
|
assert(msg === 'What Happened To You', '#16');
|
||||||
|
entered = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
function f4(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_WARN, 'What Happened To You'); }; f4();
|
||||||
|
assert(entered === true, '#17');
|
||||||
|
|
||||||
|
assert(suite.log_level_get() === suite.LOG_LEVEL_DBG, '#18');
|
||||||
|
assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === true, '#19');
|
||||||
|
suite.log_level_set(suite.LOG_LEVEL_CRITICAL);
|
||||||
|
assert(suite.log_level_get() === suite.LOG_LEVEL_CRITICAL, '#20');
|
||||||
|
assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === false, '#21');
|
||||||
|
|
||||||
|
assert(suite.log_abort_on_critical_get() === false, '#22');
|
||||||
|
suite.log_abort_on_critical_set(true);
|
||||||
|
assert(suite.log_abort_on_critical_get() === true, '#23');
|
||||||
|
|
||||||
|
suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_CRITICAL);
|
||||||
|
assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_CRITICAL, '#24');
|
||||||
|
suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_ERR);
|
||||||
|
assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_ERR, '#25');
|
||||||
|
|
||||||
|
suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_WARN);
|
||||||
|
assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_WARN, '#26');
|
||||||
|
suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_INFO);
|
||||||
|
assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_INFO, '#27');
|
||||||
|
|
||||||
|
assert(typeof(suite.LOG_STATE_START) === 'number', '#28');
|
||||||
|
assert(typeof(suite.LOG_STATE_STOP) === 'number', '#29');
|
||||||
|
assert(typeof(suite.log_timing) === 'function', '#30');
|
||||||
|
|
||||||
|
// finished tests
|
||||||
|
|
||||||
|
console.log ("Test execution with success");
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
class Constructor_Method_Class (Eo.Base)
|
||||||
|
{
|
||||||
|
legacy_prefix: null;
|
||||||
|
data: Constructor_Method_Class_Data;
|
||||||
|
methods {
|
||||||
|
constructor1 {
|
||||||
|
params { @in int one; }
|
||||||
|
}
|
||||||
|
constructor2 {
|
||||||
|
params { @in double two; }
|
||||||
|
}
|
||||||
|
method1 {
|
||||||
|
params { @in int one; }
|
||||||
|
}
|
||||||
|
method2 {
|
||||||
|
params { @in int one; }
|
||||||
|
return: int;
|
||||||
|
}
|
||||||
|
method3 {
|
||||||
|
params { @in int one; @in double two; }
|
||||||
|
}
|
||||||
|
rmethod1 {
|
||||||
|
params { @in int one; @in double two; }
|
||||||
|
return: int;
|
||||||
|
}
|
||||||
|
outmethod1 {
|
||||||
|
params { @out int one; }
|
||||||
|
}
|
||||||
|
outmethod2 {
|
||||||
|
params { @out int one; }
|
||||||
|
return: int;
|
||||||
|
}
|
||||||
|
outmethod3 {
|
||||||
|
params { @out int one; @out double two; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
Eo.Base.constructor;
|
||||||
|
Eo.Base.finalize;
|
||||||
|
}
|
||||||
|
constructors {
|
||||||
|
.constructor1;
|
||||||
|
.constructor2;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
void eolian_js_test_evas_box(TCase* tc);
|
||||||
|
void eolian_js_test_constructor_method(TCase* tc);
|
||||||
|
|
||||||
|
typedef struct _Eolian_Js_Test_Case Eolian_Js_Test_Case;
|
||||||
|
struct _Eolian_Js_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eolian_Js_Test_Case etc[] = {
|
||||||
|
//{ "Eolian-Js Evas Box", eolian_js_test_evas_box },
|
||||||
|
{ "Eolian-Js Constructor Method", eolian_js_test_constructor_method },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Eolian_Js_Test_Case *itr;
|
||||||
|
|
||||||
|
itr = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; itr->test_case; itr++)
|
||||||
|
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Suite *
|
||||||
|
eolian_js_build_suite(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
Suite *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
s = suite_create("Eolian Js");
|
||||||
|
|
||||||
|
for (i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tc = tcase_create(etc[i].test_case);
|
||||||
|
tcase_set_timeout(tc, 0);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
Suite *s;
|
||||||
|
SRunner *sr;
|
||||||
|
int i, failed_count;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
||||||
|
argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
|
||||||
|
|
||||||
|
s = eolian_js_build_suite(argc - 1, (const char **)argv + 1);
|
||||||
|
sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
return (failed_count == 0) ? 0 : 255;
|
||||||
|
}
|
|
@ -0,0 +1,231 @@
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eo_Js.hh>
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include <Eo.hh>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include <constructor_method_class.eo.js.cc>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
static const char script[] =
|
||||||
|
"function assert(condition, message) {\n"
|
||||||
|
" if (!condition) {\n"
|
||||||
|
" print(\"Assertion failed \", message);\n"
|
||||||
|
" throw message || \"Assertion failed\";\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"print(\"teste\");\n"
|
||||||
|
"x = new Constructor_Method_Class(5, 10.0);"
|
||||||
|
"x.method1(2);\n"
|
||||||
|
"r = x.method2(3);\n"
|
||||||
|
"x.method3(3, 11.1);\n"
|
||||||
|
"r = x.rmethod1(3, 11.1);\n"
|
||||||
|
"assert(r == 5);\n"
|
||||||
|
"try\n"
|
||||||
|
"{\n"
|
||||||
|
" x.method3(3);\n"
|
||||||
|
" assert(false, \"No exception thrown! this is wrong\");\n"
|
||||||
|
"}\n"
|
||||||
|
"catch (err)\n"
|
||||||
|
"{\n"
|
||||||
|
" print(\"Correctly exception thrown\");\n"
|
||||||
|
"}\n"
|
||||||
|
"try\n"
|
||||||
|
"{\n"
|
||||||
|
" y = new Constructor_Method_Class(5);\n"
|
||||||
|
" assert(false, \"No exception thrown! this is wrong\");\n"
|
||||||
|
"}\n"
|
||||||
|
"catch (err)\n"
|
||||||
|
"{\n"
|
||||||
|
" print(\"Correctly exception thrown\");\n"
|
||||||
|
"}\n"
|
||||||
|
"try\n"
|
||||||
|
"{\n"
|
||||||
|
" y = new Constructor_Method_Class(5.1, 10);\n"
|
||||||
|
" assert(false, \"No exception thrown! this is wrong\");\n"
|
||||||
|
"}\n"
|
||||||
|
"catch (err)\n"
|
||||||
|
"{\n"
|
||||||
|
" print(\"Correctly exception thrown\");\n"
|
||||||
|
"}\n"
|
||||||
|
"z = Constructor_Method_Class(5, 10.0);\n"
|
||||||
|
// Out parameters
|
||||||
|
"print(\"Going to run outmethod1\");\n"
|
||||||
|
"r = x.outmethod1();\n"
|
||||||
|
"print(\"Ran outmethod1\");\n"
|
||||||
|
"assert(r == 5);\n"
|
||||||
|
"print(\"Going to run outmethod2\");\n"
|
||||||
|
"r = x.outmethod2();\n"
|
||||||
|
"print(\"ran outmethod2\");\n"
|
||||||
|
"assert(Array.isArray(r));\n"
|
||||||
|
"print(\"Return is array from outmethod2\");\n"
|
||||||
|
"assert(r[0] == 11);\n"
|
||||||
|
"assert(r[1] == 10);\n"
|
||||||
|
"print(\"Going to run outmethod3\");\n"
|
||||||
|
"r = x.outmethod3();\n"
|
||||||
|
"print(\"ran outmethod3\");\n"
|
||||||
|
"assert(Array.isArray(r));\n"
|
||||||
|
"print(\"Return is array from outmethod3\");\n"
|
||||||
|
"assert(r[0] == 11);\n"
|
||||||
|
"assert(r[1] == 5.1);\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Executes a string within the current v8 context.
|
||||||
|
bool ExecuteString(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::String> source,
|
||||||
|
v8::Handle<v8::Value> name)
|
||||||
|
{
|
||||||
|
v8::HandleScope handle_scope
|
||||||
|
#if 0
|
||||||
|
(isolate)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
v8::TryCatch try_catch;
|
||||||
|
v8::ScriptOrigin origin(name);
|
||||||
|
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
|
||||||
|
if (script.IsEmpty()) {
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during compilation.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v8::Handle<v8::Value> result = script->Run();
|
||||||
|
if (result.IsEmpty()) {
|
||||||
|
std::cout << "Failed with exception thrown" << std::endl;
|
||||||
|
assert(try_catch.HasCaught());
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during execution.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
assert(!try_catch.HasCaught());
|
||||||
|
// if (print_result && !result->IsUndefined()) {
|
||||||
|
// // If all went well and the result wasn't undefined then print
|
||||||
|
// // the returned value.
|
||||||
|
// v8::String::Utf8Value str(result);
|
||||||
|
// const char* cstr = ToCString(str);
|
||||||
|
// printf("%s\n", cstr);
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
v8::HandleScope handle_scope(args.GetIsolate());
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
v8::Handle<v8::Value> Print(v8::Arguments const& args) {
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
v8::HandleScope handle_scope;
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
START_TEST(eolian_js_test_constructor_method_test)
|
||||||
|
{
|
||||||
|
int argc = 1;
|
||||||
|
const char* argv[] = {"test"};
|
||||||
|
efl::eina::eina_init eina_init;
|
||||||
|
efl::eo::eo_init eo_init;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
v8::V8::InitializeICU();
|
||||||
|
#endif
|
||||||
|
v8::V8::Initialize();
|
||||||
|
v8::V8::SetFlagsFromCommandLine(&argc, const_cast<char**>(argv), true);
|
||||||
|
|
||||||
|
v8::Isolate* isolate = v8::Isolate::New();
|
||||||
|
|
||||||
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
|
|
||||||
|
assert(isolate != 0);
|
||||||
|
|
||||||
|
v8::Handle<v8::Context> context;
|
||||||
|
v8::HandleScope handle_scope
|
||||||
|
#if 0
|
||||||
|
(isolate)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Create a template for the global object.
|
||||||
|
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(/*isolate*/);
|
||||||
|
// Bind the global 'print' function to the C++ Print callback.
|
||||||
|
global->Set(v8::String::New/*FromUtf8*/(/*isolate,*/ "print"),
|
||||||
|
v8::FunctionTemplate::New(/*isolate,*/ Print));
|
||||||
|
|
||||||
|
context = v8::Context::New(/*isolate*/NULL, global);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (context.IsEmpty()) {
|
||||||
|
fprintf(stderr, "Error creating context\n");
|
||||||
|
}
|
||||||
|
context->Enter();
|
||||||
|
{
|
||||||
|
// Enter the execution environment before evaluating any code.
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::String> name(v8::String::New/*FromUtf8*/(/*context->GetIsolate(),*/ "(shell)"));
|
||||||
|
|
||||||
|
register_constructor_method_class(context->Global(), isolate);
|
||||||
|
|
||||||
|
v8::HandleScope handle_scope/*(context->GetIsolate())*/;
|
||||||
|
ExecuteString(/*context->GetIsolate(),*/isolate,
|
||||||
|
v8::String::New/*FromUtf8*/(/*context->GetIsolate(), */script),
|
||||||
|
name);
|
||||||
|
}
|
||||||
|
context->Exit();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void eolian_js_test_constructor_method(TCase* tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eolian_js_test_constructor_method_test);
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eo.h>
|
||||||
|
#include <Ecore.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "constructor_method_class.eo.h"
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
struct _Constructor_Method_Class_Data
|
||||||
|
{
|
||||||
|
Eina_Bool one, two;
|
||||||
|
};
|
||||||
|
typedef struct _Constructor_Method_Class_Data Constructor_Method_Class_Data;
|
||||||
|
|
||||||
|
#define MY_CLASS CONSTRUCTOR_METHOD_CLASS_CLASS
|
||||||
|
|
||||||
|
static void _constructor_method_class_eo_base_constructor(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd)
|
||||||
|
{
|
||||||
|
pd->one = pd->two = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _constructor_method_class_constructor1(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd, int one)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "one == %d\n", one);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(one == 5);
|
||||||
|
pd->one = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _constructor_method_class_constructor2(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd, double two)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "two == %f\n", two);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(two == 10.0);
|
||||||
|
pd->two = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eo * _constructor_method_class_eo_base_finalize(Eo *obj, Constructor_Method_Class_Data *pd)
|
||||||
|
{
|
||||||
|
if(!pd->one || !pd->two)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _constructor_method_class_method1(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int one)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "method1 one == %d\n", one);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(one == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _constructor_method_class_method2(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int one)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "method2 one == %d\n", one);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(one == 3);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _constructor_method_class_method3(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int one, double two)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "method3 one == %d two == %f\n", one, two);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(one == 3);
|
||||||
|
ck_assert(two == 11.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _constructor_method_class_rmethod1(Eo * obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int one, double two)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "rmethod1 one == %d two == %f\n", one, two);
|
||||||
|
fflush(stderr);
|
||||||
|
ck_assert(one == 3);
|
||||||
|
ck_assert(two == 11.1);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _constructor_method_class_outmethod1(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int *one)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "outmethod1\n");
|
||||||
|
*one = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _constructor_method_class_outmethod2(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int *one)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "outmethod2\n");
|
||||||
|
*one = 10;
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _constructor_method_class_outmethod3(Eo* obj EINA_UNUSED, Constructor_Method_Class_Data *pd EINA_UNUSED, int *one, double *two)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "outmethod3\n");
|
||||||
|
*one = 11;
|
||||||
|
*two = 5.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <constructor_method_class.eo.c>
|
|
@ -0,0 +1,183 @@
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eo_Js.hh>
|
||||||
|
#include <Eina.hh>
|
||||||
|
#include <Eo.hh>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace evas {
|
||||||
|
EAPI void register_box(v8::Handle<v8::Object> global, v8::Isolate* isolate);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
static const char script[] =
|
||||||
|
"function assert(condition, message) {\n"
|
||||||
|
" if (!condition) {\n"
|
||||||
|
" print(\"Assertion failed \", message);\n"
|
||||||
|
" throw message || \"Assertion failed\";\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"print(\"teste\");\n"
|
||||||
|
"x = new Box();\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Executes a string within the current v8 context.
|
||||||
|
bool ExecuteString(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::String> source,
|
||||||
|
v8::Handle<v8::Value> name)
|
||||||
|
{
|
||||||
|
v8::HandleScope handle_scope
|
||||||
|
#if 0
|
||||||
|
(isolate)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
v8::TryCatch try_catch;
|
||||||
|
v8::ScriptOrigin origin(name);
|
||||||
|
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
|
||||||
|
if (script.IsEmpty()) {
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during compilation.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v8::Handle<v8::Value> result = script->Run();
|
||||||
|
if (result.IsEmpty()) {
|
||||||
|
std::cout << "Failed with exception thrown" << std::endl;
|
||||||
|
assert(try_catch.HasCaught());
|
||||||
|
std::abort();
|
||||||
|
// Print errors that happened during execution.
|
||||||
|
// if (report_exceptions)
|
||||||
|
// ReportException(isolate, &try_catch);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
assert(!try_catch.HasCaught());
|
||||||
|
// if (print_result && !result->IsUndefined()) {
|
||||||
|
// // If all went well and the result wasn't undefined then print
|
||||||
|
// // the returned value.
|
||||||
|
// v8::String::Utf8Value str(result);
|
||||||
|
// const char* cstr = ToCString(str);
|
||||||
|
// printf("%s\n", cstr);
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
v8::HandleScope handle_scope(args.GetIsolate());
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
v8::Handle<v8::Value> Print(v8::Arguments const& args) {
|
||||||
|
bool first = true;
|
||||||
|
for (int i = 0; i < args.Length(); i++) {
|
||||||
|
v8::HandleScope handle_scope;
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
v8::String::Utf8Value str(args[i]);
|
||||||
|
const char* cstr = ToCString(str);
|
||||||
|
printf("%s", cstr);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
START_TEST(eolian_js_test_evas_box)
|
||||||
|
{
|
||||||
|
int argc = 1;
|
||||||
|
const char* argv[] = {"test"};
|
||||||
|
efl::eina::eina_init eina_init;
|
||||||
|
efl::eo::eo_init eo_init;
|
||||||
|
|
||||||
|
//v8::V8::InitializeICU();
|
||||||
|
v8::V8::Initialize();
|
||||||
|
v8::V8::SetFlagsFromCommandLine(&argc, const_cast<char**>(argv), true);
|
||||||
|
|
||||||
|
v8::Isolate* isolate = v8::Isolate::New();
|
||||||
|
|
||||||
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
|
|
||||||
|
assert(isolate != 0);
|
||||||
|
|
||||||
|
v8::Handle<v8::Context> context;
|
||||||
|
v8::HandleScope handle_scope
|
||||||
|
#if 0
|
||||||
|
(isolate)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Create a template for the global object.
|
||||||
|
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New
|
||||||
|
(
|
||||||
|
#if 0
|
||||||
|
isolate
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
// Bind the global 'print' function to the C++ Print callback.
|
||||||
|
global->Set(v8::String::New/*FromUtf8*/(/*isolate,*/ "print"),
|
||||||
|
v8::FunctionTemplate::New(/*isolate,*/ Print));
|
||||||
|
|
||||||
|
context = v8::Context::New(/*isolate*/NULL, global);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (context.IsEmpty()) {
|
||||||
|
fprintf(stderr, "Error creating context\n");
|
||||||
|
}
|
||||||
|
context->Enter();
|
||||||
|
{
|
||||||
|
// Enter the execution environment before evaluating any code.
|
||||||
|
v8::Context::Scope context_scope(context);
|
||||||
|
v8::Local<v8::String> name(v8::String::New/*FromUtf8*/(/*context->GetIsolate(),*/ "(shell)"));
|
||||||
|
|
||||||
|
evas::register_box(context->Global(), isolate);
|
||||||
|
|
||||||
|
v8::HandleScope handle_scope/*(context->GetIsolate())*/;
|
||||||
|
ExecuteString(/*context->GetIsolate()*/isolate,
|
||||||
|
v8::String::New/*FromUtf8*/(/*context->GetIsolate(), */script),
|
||||||
|
name);
|
||||||
|
}
|
||||||
|
context->Exit();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void eolian_js_test_evas_box(TCase* tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eolian_js_test_evas_box);
|
||||||
|
}
|
Loading…
Reference in New Issue