summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-09 01:45:51 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-09 01:45:51 -0200
commita090a65bb3f1771a10b445d12d3405bea92d8980 (patch)
treede0770b218cc76baccc1b79fc4178dd571d34248
parentc892457bc1f4098260186d67a5abeaaa19ac02ce (diff)
downloadefl-a090a65bb3f1771a10b445d12d3405bea92d8980.tar.gz
Fixes with libv8 alone
-rw-r--r--configure.ac16
-rw-r--r--src/Makefile_Eina_Js.am149
-rw-r--r--src/bin/eolian_js/main.cc34
-rw-r--r--src/bindings/eina_js/eina_js_compatibility.hh136
-rw-r--r--src/bindings/eina_js/eina_js_container.cc17
-rw-r--r--src/bindings/eo_js/eo_js_call_function.hh26
-rw-r--r--src/bindings/eo_js/eo_js_construct_from_eo.hh9
-rw-r--r--src/bindings/eo_js/eo_js_constructor.hh86
-rw-r--r--src/bindings/eo_js/eo_js_event.hh8
-rw-r--r--src/bindings/eolian_js/main.cc4
-rw-r--r--src/tests/eina_js/eina_js_suite.cc4
11 files changed, 245 insertions, 244 deletions
diff --git a/configure.ac b/configure.ac
index 48f5ffc7a4..5b9b5b8f4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1003,8 +1003,14 @@ 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])
+
+#### Eina JS
+EFL_LIB_START([Eina_Js])
AC_LANG_PUSH([C++])
case "$want_js" in
@@ -1020,15 +1026,15 @@ case "$want_js" in
libv8)
AM_CONDITIONAL([HAVE_JS], [1])
EFL_DEPEND_PKG([EINA_JS], [V8], [v8 >= 3.25.28])
- EFL_DEPEND_PKG([EO_JS], [V8], [v8 >= 3.25.28])
+# EFL_DEPEND_PKG([EO_JS], [V8], [v8 >= 3.25.28])
AC_DEFINE_UNQUOTED([V8_INCLUDE_HEADER], ["v8.h"], [Include header for libv8])
;;
libuv)
AM_CONDITIONAL([HAVE_JS], [1])
EFL_DEPEND_PKG([EINA_JS], [V8], [v8 >= 3.25.28])
EFL_DEPEND_PKG([EINA_JS], [UV], [v8 >= 1.1.0])
- EFL_DEPEND_PKG([EO_JS], [V8], [v8 >= 3.25.28])
- EFL_DEPEND_PKG([EO_JS], [UV], [v8 >= 1.1.0])
+# EFL_DEPEND_PKG([EO_JS], [V8], [v8 >= 3.25.28])
+# EFL_DEPEND_PKG([EO_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])
;;
@@ -1039,9 +1045,6 @@ case "$want_js" in
esac
AC_LANG_POP([C++])
-#### Eina JS
-EFL_LIB_START([Eina_Js])
-
EFL_INTERNAL_DEPEND_PKG([EINA_JS], [eina])
EFL_ADD_CFLAGS([EINA_JS], [${EFL_PTHREAD_CFLAGS}])
EFL_EVAL_PKGS([EINA_JS])
@@ -4782,6 +4785,7 @@ echo " X11...........: ${with_x11}"
echo " OpenGL........: ${with_opengl}"
echo " C++11.........: ${have_cxx11}"
echo " JavaScript....: ${want_js}"
+echo " JavaScript flg: $EINA_JS_LIBS"
echo " GUI libs......: ${build_gui}"
echo "Evas............: ${efl_lib_optional_evas} (${features_evas})"
echo " Engines.......: ${features_evas_engine}"
diff --git a/src/Makefile_Eina_Js.am b/src/Makefile_Eina_Js.am
index b1e41a282b..55827dace1 100644
--- a/src/Makefile_Eina_Js.am
+++ b/src/Makefile_Eina_Js.am
@@ -14,8 +14,8 @@ lib_eina_js_libeina_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-DPACKAGE_DATA_DIR=\"$(datadir)/eina_js\" \
@VALGRIND_CFLAGS@
-lib_eina_js_libeina_js_la_LIBADD = @EINA_LIBS@ @DL_LIBS@
-lib_eina_js_libeina_js_la_DEPENDENCIES = @EINA_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@
+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 = \
@@ -26,6 +26,17 @@ 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_einacxxmainheadersdir = $(includedir)/eina-cxx-@VMAJ@
#dist_installed_einacxxmainheaders_DATA = \
bindings/eina_cxx/Eina.hh
@@ -62,21 +73,15 @@ bindings/eina_cxx/eina_value.hh
if EFL_ENABLE_TESTS
-TEST_LOG_DRIVER = node
+if HAVE_NODEJS
+TESTS += tests/eina_js/eina_js_suite.js
+
lib_LTLIBRARIES += tests/eina_js/libeina_js_suite.la \
tests/eina_js/libeina_js_value.la \
tests/eina_js/libeina_js_error.la \
tests/eina_js/libeina_js_accessor.la \
tests/eina_js/libeina_js_log.la \
tests/eina_js/libeina_js_iterator.la
-#check_PROGRAMS += tests/eina_js/eina_js_suite.js
-TESTS += tests/eina_js/eina_js_suite.js
-#TESTS += tests/eina_js/eina_js_suite \
-tests/eina_js/eina_js_value \
-tests/eina_js/eina_js_error \
-tests/eina_js/eina_js_accessor \
-tests/eina_js/eina_js_log \
-tests/eina_js/eina_js_iterator
tests/eina_js/eina_js_suite.js: $(top_builddir)/src/tests/eina_js/eina_js_suite.node
@@ -89,8 +94,6 @@ CP = cp
$(top_builddir)/src/tests/eina_js/eina_js_suite.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.node
-#EXTRA_DIST += tests/eina_js/eina_js_suite.node
-
tests_eina_js_libeina_js_suite_la_SOURCES = \
tests/eina_js/eina_js_suite.cc
@@ -109,85 +112,85 @@ tests/eina_js/eina_js_log.cc
tests_eina_js_libeina_js_iterator_la_SOURCES = \
tests/eina_js/eina_js_iterator.cc
-tests_eina_js_libeina_js_suite_la_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@
tests_eina_js_libeina_js_suite_la_LIBADD = \
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@ @USE_EOLIAN_JS_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@
-tests_eina_js_libeina_js_value_la_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@
+tests_eina_js_libeina_js_value_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
tests_eina_js_libeina_js_value_la_LIBADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
tests_eina_js_libeina_js_value_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
-tests_eina_js_libeina_js_error_la_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@
+tests_eina_js_libeina_js_error_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
tests_eina_js_libeina_js_error_la_LIBADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
tests_eina_js_libeina_js_error_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
-tests_eina_js_libeina_js_accessor_la_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@
+tests_eina_js_libeina_js_accessor_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
tests_eina_js_libeina_js_accessor_la_LIBADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
tests_eina_js_libeina_js_accessor_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
-tests_eina_js_libeina_js_log_la_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@
+tests_eina_js_libeina_js_log_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
tests_eina_js_libeina_js_log_la_LIBADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
tests_eina_js_libeina_js_log_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
-tests_eina_js_libeina_js_iterator_la_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@
+tests_eina_js_libeina_js_iterator_la_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
tests_eina_js_libeina_js_iterator_la_LIBADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
tests_eina_js_libeina_js_iterator_la_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+else
+
+EINA_TESTS_PREFIX =
+
+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_value_SOURCES = \
+# tests/eina_js/eina_js_value.cc
+
+# tests_eina_js_eina_js_error_SOURCES = \
+# tests/eina_js/eina_js_error.cc
+
+# tests_eina_js_eina_js_accessor_SOURCES = \
+# tests/eina_js/eina_js_accessor.cc
+
+# tests_eina_js_eina_js_log_SOURCES = \
+# tests/eina_js/eina_js_log.cc
+
+# tests_eina_js_eina_js_iterator_SOURCES = \
+# tests/eina_js/eina_js_iterator.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_EOLIAN_JS_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_value_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
+# tests_eina_js_eina_js_value_LDADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
+# tests_eina_js_eina_js_value_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+
+# tests_eina_js_eina_js_error_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
+# tests_eina_js_eina_js_error_LDADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
+# tests_eina_js_eina_js_error_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+
+# tests_eina_js_eina_js_accessor_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
+# tests_eina_js_eina_js_accessor_LDADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
+# tests_eina_js_eina_js_accessor_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+
+# tests_eina_js_eina_js_log_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
+# tests_eina_js_eina_js_log_LDADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
+# tests_eina_js_eina_js_log_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+
+# tests_eina_js_eina_js_iterator_CXXFLAGS = $(EINA_JS_TEST_CXXFLAGS)
+# tests_eina_js_eina_js_iterator_LDADD = @CHECK_LIBS@ @USE_EINA_JS_LIBS@ @USE_EINA_LIBS@ @USE_EO_LIBS@
+# tests_eina_js_eina_js_iterator_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_LIBS@
+
+endif
+
+#EXTRA_DIST += tests/eina_js/eina_js_suite.node
+
+
endif
endif
diff --git a/src/bin/eolian_js/main.cc b/src/bin/eolian_js/main.cc
index d8c98192e0..c74fd70632 100644
--- a/src/bin/eolian_js/main.cc
+++ b/src/bin/eolian_js/main.cc
@@ -270,8 +270,8 @@ int main(int argc, char** argv)
EINA_CXX_DOM_LOG_WARN(eolian::js::domain) << "namespace";
- os << "static v8::Persistent<v8::ObjectTemplate> persistent_instance;\n";
- os << "static v8::Persistent<v8::Function> constructor_from_eo;\n";
+ 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";
@@ -287,9 +287,9 @@ int main(int argc, char** argv)
auto output_begin = [&] (std::string name)
{
if(! ::eolian_function_is_constructor(function, klass))
- os << " prototype->Set( ::v8::String::New/*FromUtf8(isolate,*/( \""
+ os << " prototype->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
<< name << "\")\n"
- << " , v8::FunctionTemplate::New(/*isolate,*/ &efl::eo::js::call_function\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";
};
@@ -387,15 +387,15 @@ int main(int argc, char** argv)
os << " {\n";
os << " static efl::eo::js::event_information const event_information\n";
- os << " = {&constructor_from_eo, ";
+ os << " = {&constructor_from_eo.handle(), ";
os << eolian_event_c_name_get(&*first);
os << "};\n\n";
os << " /* should include event " << ::eolian_event_name_get(&*first) << "*/" << std::endl;
- os << " prototype->Set(v8::String::New(/*FromUtf8(isolate,*/ \"event_";
+ 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 , v8::FunctionTemplate::New(/*isolate,*/ &efl::eo::js::event_call\n"
- << " , v8::External::New(const_cast<efl::eo::js::event_information*>"
+ 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";
@@ -412,8 +412,8 @@ int main(int argc, char** argv)
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 = v8::FunctionTemplate::New\n";
- os << " (/*isolate,*/ efl::eo::js::constructor\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"
" , ";
@@ -435,25 +435,25 @@ int main(int argc, char** argv)
os << " register_" << lower_case_class_name << "_from_constructor(isolate, constructor);\n";
- os << " constructor->SetClassName(v8::String::New/*FromUtf8(isolate,*/( \""
+ os << " constructor->SetClassName( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
<< class_name
<< "\"));\n";
- os << " global->Set(v8::String::New/*FromUtf8(isolate,*/( \""
+ os << " global->Set( ::efl::eina::js::compatibility_new<v8::String>(isolate, \""
<< class_name << "\")"
<< ", constructor->GetFunction());\n";
os << " {\n";
- os << " v8::Handle<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New\n";
- os << " (/*isolate,*/ &efl::eo::js::construct_from_eo);\n";
- os << " constructor->SetClassName(v8::String::New/*FromUtf8(isolate,*/( \""
+ 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 = v8::Persistent<v8::ObjectTemplate>::New(instance);\n";
- os << " constructor_from_eo = v8::Persistent<v8::Function>::New(constructor->GetFunction());\n";
+ os << " persistent_instance = ::efl::eina::js::compatibility_persistent<v8::ObjectTemplate>(isolate, instance);\n";
+ os << " constructor_from_eo = ::efl::eina::js::compatibility_persistent<v8::Function>(isolate, constructor->GetFunction());\n";
os << " }\n";
os << "}\n\n";
diff --git a/src/bindings/eina_js/eina_js_compatibility.hh b/src/bindings/eina_js/eina_js_compatibility.hh
index e0749461d7..bfe799abb7 100644
--- a/src/bindings/eina_js/eina_js_compatibility.hh
+++ b/src/bindings/eina_js/eina_js_compatibility.hh
@@ -15,6 +15,8 @@ template <typename T>
struct UniquePersistent;
class AccessorInfo;
+
+class Arguments;
}
@@ -65,7 +67,9 @@ struct _libv8_callback_info_test
};
template <typename T = v8::ObjectTemplate, typename Enable = void>
-struct _libv8_property_callback_info_test;
+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&);
@@ -83,26 +87,26 @@ struct _libv8_property_callback_info_test
, v8::PropertyAttribute
, v8::Handle<v8::AccessorSignature>
)>::value>::type>
- : std::true_type
-{
-};
-
-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
{
};
+
+// 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;
@@ -112,6 +116,9 @@ using compatibility_return_type = std::conditional<v8_uses_callback_info, void,
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);
@@ -122,8 +129,8 @@ using compatibility_accessor_callback_info_type
, v8::PropertyCallbackInfo<v8::Value> const&, v8::AccessorInfo const&>
::type;
-static_assert(!v8_uses_callback_info, "");
-static_assert(!v8_uses_isolate, "");
+static_assert(v8_uses_callback_info, "");
+static_assert(v8_uses_isolate, "");
template <typename T>
struct compatibility_type_tag {};
@@ -137,22 +144,23 @@ struct compatibility_string<std::true_type> : v8::String {};
template <>
struct compatibility_string<std::false_type> : v8::String
{
- static v8::Local<v8::String> NewFromUtf8(v8::Isolate*, const char* data)
+ template <typename... Args>
+ static v8::Local<v8::String> NewFromUtf8(v8::Isolate*, const char* data, Args...args)
{
- return v8::String::New(data);
+ return New(data, args...);
}
};
-template <typename...Args>
-auto compatibility_new_impl(v8::Isolate* isolate, std::true_type, compatibility_type_tag<v8::String>
+template <typename T, typename...Args>
+auto compatibility_new_impl(v8::Isolate* isolate, T, compatibility_type_tag<v8::String>
, Args...args) ->
decltype(compatibility_string<>::NewFromUtf8(isolate, args...))
{
return compatibility_string<>::NewFromUtf8(isolate, args...);
}
-template <typename...Args>
-auto compatibility_new_impl(nullptr_t, std::true_type, compatibility_type_tag<v8::String>
+template <typename T, typename...Args>
+auto compatibility_new_impl(nullptr_t, T, compatibility_type_tag<v8::String>
, Args...args) ->
decltype(compatibility_string<>::NewFromUtf8(v8::Isolate::GetCurrent(), args...))
{
@@ -193,7 +201,7 @@ auto compatibility_new_impl(std::nullptr_t, std::false_type, compatibility_type_
template <typename T, typename...Args>
auto compatibility_new(v8::Isolate* isolate, Args...args) ->
- decltype(js::compatibility_new_impl<T>
+ decltype(js::compatibility_new_impl<>
(isolate, std::integral_constant<bool, v8_uses_isolate>()
, compatibility_type_tag<T>()
, args...))
@@ -205,19 +213,19 @@ auto compatibility_new(v8::Isolate* isolate, Args...args) ->
template <typename T, typename...Args>
auto compatibility_new(nullptr_t, Args...args) ->
- decltype(js::compatibility_new_impl<T>(nullptr, std::integral_constant<bool, v8_uses_isolate>()
- , compatibility_type_tag<T>()
- , args...))
+ decltype(js::compatibility_new_impl<>(nullptr, std::integral_constant<bool, v8_uses_isolate>()
+ , compatibility_type_tag<T>()
+ , args...))
{
- return js::compatibility_new_impl<T>(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.ReturnValue().Set(object);
+ info.GetReturnValue().Set(object);
}
template <typename T>
@@ -274,9 +282,10 @@ struct _v8_isolate_throw_exception<std::true_type> : v8::Isolate
template <>
struct _v8_isolate_throw_exception<std::false_type> : v8::Isolate
{
- static v8::Handle<v8::Value> ThrowException(v8::Handle<v8::Value> v)
+ template <typename...Args>
+ static v8::Handle<v8::Value> ThrowException(v8::Handle<v8::Value> v, Args...args)
{
- return v8::ThrowException(v);
+ return ThrowException(v);
}
};
@@ -287,11 +296,11 @@ compatibility_throw_impl(v8::Isolate* isolate, v8::Local<v8::Value> exception, s
}
inline v8::Handle<v8::Value>
-compatibility_throw_impl(v8::Isolate*, v8::Local<v8::Value> exception, std::false_type)
+compatibility_throw_impl(v8::Isolate* isolate, v8::Local<v8::Value> exception, std::false_type)
{
- return v8::ThrowException(exception);
+ return static_cast<_v8_isolate_throw_exception<>*>(isolate)->ThrowException(exception);
}
-
+
inline std::conditional<v8_uses_isolate, void, v8::Handle<v8::Value> >::type
compatibility_throw(v8::Isolate* isolate, v8::Local<v8::Value> exception)
{
@@ -307,7 +316,7 @@ compatibility_throw_impl(v8::Local<v8::Value> exception, std::true_type)
inline v8::Handle<v8::Value>
compatibility_throw_impl(v8::Local<v8::Value> exception, std::false_type)
{
- return v8::ThrowException(exception);
+ return static_cast<_v8_isolate_throw_exception<>*>(v8::Isolate::GetCurrent())->ThrowException(exception);
}
inline std::conditional<v8_uses_isolate, void, v8::Handle<v8::Value> >::type
@@ -323,18 +332,48 @@ template <typename T>
struct compatibility_persistent<T, true> : v8::UniquePersistent<T>
{
typedef v8::UniquePersistent<T> _base;
- using _base::_base;
+
+ compatibility_persistent(compatibility_persistent&& other)
+ : _base(other.Pass()), handle_(other.handle())
+ {
+ }
+ compatibility_persistent<T>& operator=(compatibility_persistent<T>&&) = default;
+
+ compatibility_persistent() {}
+ compatibility_persistent(v8::Isolate* isolate, v8::Handle<T> v)
+ : _base(isolate, v), handle_(v)
+ {
+ }
+
+ T* operator->() const
+ {
+ return *handle_;
+ }
+
+ v8::Handle<T>& handle() { return handle_; }
+ v8::Handle<T> const& handle() const { return handle_; }
+
+ v8::Handle<T> handle_;
};
template <typename T>
struct compatibility_persistent<T, false> : v8::Persistent<T>
{
typedef v8::Persistent<T> _base;
+
+ compatibility_persistent(compatibility_persistent const&);
+ compatibility_persistent(compatibility_persistent&&);
+ compatibility_persistent& operator=(compatibility_persistent const&);
+ compatibility_persistent& operator=(compatibility_persistent&&);
+
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> >
@@ -345,6 +384,9 @@ 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
{
@@ -369,7 +411,7 @@ 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)->SetAlignedPointerFromInternalField(index, pointer);
+ static_cast<_v8_object_internal_field<>*>(*object)->SetAlignedPointerInInternalField(index, pointer);
}
template <typename T = void, bool = v8_uses_isolate>
@@ -415,7 +457,17 @@ inline void compatibility_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));
+}
} } }
diff --git a/src/bindings/eina_js/eina_js_container.cc b/src/bindings/eina_js/eina_js_container.cc
index f7c205e6eb..d5de4a3ec3 100644
--- a/src/bindings/eina_js/eina_js_container.cc
+++ b/src/bindings/eina_js/eina_js_container.cc
@@ -27,8 +27,7 @@ struct tag { typedef T type; };
namespace {
compatibility_persistent<v8::ObjectTemplate> instance_persistents[container_type_size];
-compatibility_persistent<v8::FunctionTemplate> constructor_persistents[container_type_size];
-v8::Handle<v8::FunctionTemplate> instance_templates[container_type_size];
+v8::Handle<v8::Function> instance_templates[container_type_size];
v8::Local<v8::Object> concat(eina_container_base& lhs, v8::Isolate* isolate, v8::Local<v8::Value> other)
{
@@ -48,9 +47,9 @@ v8::Local<v8::Object> concat(eina_container_base& lhs, v8::Isolate* isolate, v8:
{
v8::Handle<v8::Value> a[] =
{efl::eina::js::compatibility_new<v8::External>(isolate, rhs.concat(lhs))};
- std::cerr << __func__ << ":" << __LINE__<< std::endl;
+ std::cerr << __func__ << ":" << __LINE__<< " " << lhs.get_container_type() << std::endl;
v8::Local<v8::Object> result =
- instance_templates[lhs.get_container_type()]->GetFunction()->NewInstance(1, a);
+ instance_templates[lhs.get_container_type()]->NewInstance(1, a);
std::cerr << __func__ << ":" << __LINE__<< std::endl;
return result;
}
@@ -74,7 +73,7 @@ v8::Local<v8::Object> slice(eina_container_base& self, v8::Isolate* isolate, v8:
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()]
- ->GetFunction()->NewInstance(1, a);
+ ->NewInstance(1, a);
return result;
}
else
@@ -86,7 +85,7 @@ v8::Local<v8::Object> slice(eina_container_base& self, v8::Isolate* isolate, v8:
compatibility_accessor_getter_return_type length
(v8::Local<v8::String>, compatibility_accessor_callback_info_type info)
{
- v8::Local<v8::Object> self_obj = v8::Local<v8::Object>::Cast(info.This());
+ 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;
@@ -367,9 +366,7 @@ void register_class(v8::Isolate* isolate, container_type type, const char* class
efl::eina::js::instance_persistents[type]
= compatibility_persistent<v8::ObjectTemplate> {isolate, instance_t};
- efl::eina::js::constructor_persistents[type]
- = compatibility_persistent<v8::FunctionTemplate> {isolate, constructor};
- efl::eina::js::instance_templates[type] = constructor;
+ efl::eina::js::instance_templates[type] = constructor->GetFunction();
}
} } } }
@@ -382,7 +379,7 @@ EAPI void eina_container_register(v8::Handle<v8::Object>, v8::Isolate* isolate)
, "eina_array", &efl::eina::js::new_eina_array);
}
-EAPI v8::Handle<v8::FunctionTemplate> get_list_instance_template()
+EAPI v8::Handle<v8::Function> get_list_instance_template()
{
return efl::eina::js::instance_templates[efl::eina::js::list_container_type];
}
diff --git a/src/bindings/eo_js/eo_js_call_function.hh b/src/bindings/eo_js/eo_js_call_function.hh
index 5977ff13c6..6cfbb79cc8 100644
--- a/src/bindings/eo_js/eo_js_call_function.hh
+++ b/src/bindings/eo_js/eo_js_call_function.hh
@@ -64,15 +64,15 @@ struct method_caller
}
template <typename R>
- v8::Handle<v8::Value>
+ eina::js::compatibility_return_type
create_return_unique_value(eina::js::compatibility_callback_info_type args
, R const& r) const
{
- return eina::js::get_value_from_c(r, args.GetIsolate());
+ return eina::js::compatibility_return(eina::js::get_value_from_c(r, args.GetIsolate()), args);
}
template <typename Outs>
- v8::Handle<v8::Value>
+ 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
@@ -81,17 +81,17 @@ struct method_caller
}
template <typename Outs>
- v8::Handle<v8::Value>
+ 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 v8::Handle<v8::Value>();
+ return eina::js::compatibility_return();
}
template <typename Outs>
- v8::Handle<v8::Value>
+ 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
@@ -104,7 +104,7 @@ struct method_caller
}
template <typename R, typename Outs>
- v8::Handle<v8::Value>
+ eina::js::compatibility_return_type
create_return_value(eina::js::compatibility_callback_info_type args
, R const& r
, Outs const&
@@ -150,8 +150,9 @@ struct method_caller
}
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
+ 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);
@@ -184,11 +185,8 @@ struct method_caller
{
eo_do
(eo,
- return eina::js::compatibility_return
- (
- aux(args, eina::make_index_sequence<std::tuple_size<parameters_t>::value>()
- , std::is_same<void, typename eina::_mpl::function_return<F>::type>())
- , args)
+ 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&)
diff --git a/src/bindings/eo_js/eo_js_construct_from_eo.hh b/src/bindings/eo_js/eo_js_construct_from_eo.hh
index 93c56f67b6..a3f84d7d02 100644
--- a/src/bindings/eo_js/eo_js_construct_from_eo.hh
+++ b/src/bindings/eo_js/eo_js_construct_from_eo.hh
@@ -19,14 +19,12 @@
namespace efl { namespace eo { namespace js {
-#if 0
-#else
-inline v8::Handle<v8::Value> construct_from_eo(v8::Arguments const& args)
+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 v8::Handle<v8::Value>();
+ return eina::js::compatibility_return();
}
else
{
@@ -35,10 +33,9 @@ inline v8::Handle<v8::Value> construct_from_eo(v8::Arguments const& args)
for(int i = 0; i != args.Length(); ++i)
argv[i] = args[i];
args.Callee()->NewInstance(argc, &argv[0]);
- return v8::Handle<v8::Value>();
+ return eina::js::compatibility_return();
}
}
-#endif
} } }
diff --git a/src/bindings/eo_js/eo_js_constructor.hh b/src/bindings/eo_js/eo_js_constructor.hh
index 4a002c4300..f29f194c2c 100644
--- a/src/bindings/eo_js/eo_js_constructor.hh
+++ b/src/bindings/eo_js/eo_js_constructor.hh
@@ -37,13 +37,14 @@ inline void constructor(v8::FunctionCallbackInfo<v8::Value> const& args)
}
}
#else
-inline v8::Handle<v8::Value> constructor(v8::Arguments const& args)
+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<v8::Handle<v8::Value>(v8::Arguments const&)>*
- f = static_cast<std::function<v8::Handle<v8::Value>(v8::Arguments const&)>*>(data);
+ 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
@@ -53,7 +54,7 @@ inline v8::Handle<v8::Value> constructor(v8::Arguments const& args)
for(int i = 0; i != args.Length(); ++i)
argv[i] = args[i];
args.Callee()->NewInstance(argc, &argv[0]);
- return v8::Handle<v8::Value>();
+ return eina::js::compatibility_return();
}
}
#endif
@@ -75,14 +76,9 @@ struct constructor_caller
}
else
{
-#if 0
- args->GetIsolate()->
-#else
- v8::
-#endif
- ThrowException
+ eina::js::compatibility_throw
(v8::Exception::TypeError
- (v8::String::New/*FromUtf8*/(/*args->GetIsolate(), */"Expected more arguments for this call")));
+ (eina::js::compatibility_new<v8::String>(args->GetIsolate(), "Expected more arguments for this call")));
throw std::logic_error("");
}
}
@@ -108,32 +104,10 @@ struct constructor_caller
}
int* current;
-#if 0
- v8::FunctionCallbackInfo<v8::Value> const* args;
-#else
- v8::Arguments const* args;
-#endif
+ eina::js::compatibility_callback_info_pointer args;
};
-#if 0
- void operator()(v8::FunctionCallbackInfo<v8::Value> const& args) const
- {
- int current_index = 0;
- try
- {
- Eo* eo = eo_add
- (klass
- , NULL
- // , eina::_mpl::for_each(constructors, call{&current_index, &args})
- );
- assert(eo != 0);
- v8::Local<v8::Object> self = args.This();
- self->SetInternalField(0, v8::External::New(args.GetIsolate(), eo));
- }
- catch(std::logic_error const&) {}
- }
-#else
- v8::Handle<v8::Value> operator()(v8::Arguments const& args) const
+ eina::js::compatibility_return_type operator()(eina::js::compatibility_callback_info_type args) const
{
int current_index = 1;
if(args.Length() != 0)
@@ -149,60 +123,32 @@ struct constructor_caller
);
assert(eo != 0);
v8::Local<v8::Object> self = args.This();
- self->SetInternalField(0, v8::External::New(/*args.GetIsolate(),*/ eo));
+ self->SetInternalField(0, eina::js::compatibility_new<v8::External>(args.GetIsolate(), eo));
}
catch(std::logic_error const&) {}
}
else
{
-#if 0
- args->GetIsolate()->
-#else
- v8::
-#endif
- ThrowException
+ eina::js::compatibility_throw
(v8::Exception::TypeError
- (v8::String::New/*FromUtf8*/(/*args->GetIsolate(), */"Expected at least one argument for this call")));
+ (eina::js::compatibility_new<v8::String>(args.GetIsolate(), "Expected at least one argument for this call")));
}
- return v8::Handle<v8::Value>();
+ return eina::js::compatibility_return();
}
-#endif
Eo_Class const* klass;
std::tuple<F...> constructors;
};
-#if 0
template <typename... F>
v8::Handle<v8::Value> constructor_data(v8::Isolate* isolate, Eo_Class const* klass, F... f)
{
- return v8::External::New
- (isolate
- , new std::function<void(v8::FunctionCallbackInfo<v8::Value> const&)>
- (constructor_caller<F...>{klass, std::tuple<F...>{f...}})
- );
-}
-#else
-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 v8::External::New
- (new std::function<v8::Handle<v8::Value>(v8::Arguments const&)>
+ 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...}}));
}
-// inline
-// /*v8::Handle<v8::Value>*/void constructor_data1(v8::Isolate* isolate, Eo_Class const* klass/*, F... f*/)
-// {
-// fprintf(stderr, "function called %s\n", __func__); fflush(stderr);
-// std::cerr << "function called " << __func__ << std::endl;
-// return v8::External::New
-// new std::function<v8::Handle<v8::Value>(v8::Arguments const&)>(
-// std::function<v8::Handle<v8::Value>(v8::Arguments const&)>
-// ((constructor_caller/*<F...>*/{klass, std::tuple<F...>{f...}}));
-// return v8::Handle<v8::Value>();
-// }
-#endif
} } }
diff --git a/src/bindings/eo_js/eo_js_event.hh b/src/bindings/eo_js/eo_js_event.hh
index f78909ba08..843b5bda50 100644
--- a/src/bindings/eo_js/eo_js_event.hh
+++ b/src/bindings/eo_js/eo_js_event.hh
@@ -28,7 +28,7 @@ struct event_information
struct event_callback_information
{
event_information* event_info;
- v8::Persistent<v8::Function> function;
+ eina::js::compatibility_persistent<v8::Function> function;
};
inline Eina_Bool event_callback(void* data, Eo* obj, Eo_Event_Description const*
@@ -39,7 +39,7 @@ inline Eina_Bool event_callback(void* data, Eo* obj, Eo_Event_Description const*
v8::Local<v8::Object> self = (*event->event_info->constructor)->NewInstance(1, a);
v8::Handle<v8::Value> call_args[] = {self};
- event->function->Call(v8::Context::GetCurrent()->Global(), 1, call_args);
+ event->function->Call(v8::Isolate::GetCurrent()->GetCurrentContext()->Global(), 1, call_args);
return EO_CALLBACK_CONTINUE;
}
@@ -61,9 +61,9 @@ inline eina::js::compatibility_return_type event_call(eina::js::compatibility_ca
Eo* eo = static_cast<Eo*>(v8::External::Cast(*external)->Value());
event_callback_information* i = new event_callback_information
- {event, eina::js::compatibility_new<v8::Persistent<v8::Function> >
+ {event, eina::js::compatibility_persistent<v8::Function>
(args.GetIsolate()
- , v8::Handle<v8::Function>(v8::Function::Cast(*arg1->ToObject())))};
+ , 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));
diff --git a/src/bindings/eolian_js/main.cc b/src/bindings/eolian_js/main.cc
index d8251a7adc..dba0cfce83 100644
--- a/src/bindings/eolian_js/main.cc
+++ b/src/bindings/eolian_js/main.cc
@@ -3,6 +3,8 @@
#include "config.h"
#endif
+#ifdef HAVE_NODEJS
+
#include <node/node.h>
#include UV_INCLUDE_HEADER
@@ -46,3 +48,5 @@ void init(v8::Handle<v8::Object> exports)
}
NODE_MODULE(efl, init)
+
+#endif
diff --git a/src/tests/eina_js/eina_js_suite.cc b/src/tests/eina_js/eina_js_suite.cc
index 3385715d57..b4716814ba 100644
--- a/src/tests/eina_js/eina_js_suite.cc
+++ b/src/tests/eina_js/eina_js_suite.cc
@@ -193,7 +193,7 @@ int main(int, char*[])
context->Exit();
}
-//#ifdef USE_NODEJS
+#ifdef HAVE_NODEJS
#include <node/node.h>
namespace {
@@ -237,4 +237,4 @@ void init(v8::Handle<v8::Object> exports)
NODE_MODULE(eina_js_suite, init)
-//#endif
+#endif