aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-08 00:34:29 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-08 00:34:29 -0200
commitc1d3adfc6e92bcd7faa98c5844b5bcb4aba7dc3f (patch)
treecf9e4fe14abd2eeb944bfec69ea2a92c4679c919
parentContinue work on compatilization with v8 versions (diff)
downloadefl-c1d3adfc6e92bcd7faa98c5844b5bcb4aba7dc3f.tar.gz
Started testing compatibilization with nodejs
-rw-r--r--configure.ac4
-rw-r--r--src/Makefile_Eina_Js.am78
-rw-r--r--src/Makefile_Eolian_Js.am68
-rw-r--r--src/bindings/eina_js/eina_js_container.cc637
-rw-r--r--src/tests/eina_js/eina_js_suite.cc26
-rwxr-xr-xsrc/tests/eina_js/eina_js_suite.js51
6 files changed, 479 insertions, 385 deletions
diff --git a/configure.ac b/configure.ac
index 907d9ca582..48f5ffc7a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1003,6 +1003,9 @@ 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"])
+AC_DEFINE_IF([HAVE_NODEJS], [test "x${want_js}" = "xnodejs"],
+ [1], [Using NodeJS])
+
AC_LANG_PUSH([C++])
case "$want_js" in
nodejs)
@@ -4778,6 +4781,7 @@ echo " Cryptography..: ${build_crypto}"
echo " X11...........: ${with_x11}"
echo " OpenGL........: ${with_opengl}"
echo " C++11.........: ${have_cxx11}"
+echo " JavaScript....: ${want_js}"
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 8f56f105c7..dd90dce43c 100644
--- a/src/Makefile_Eina_Js.am
+++ b/src/Makefile_Eina_Js.am
@@ -62,38 +62,54 @@ bindings/eina_cxx/eina_value.hh
if EFL_ENABLE_TESTS
-check_PROGRAMS += 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 += tests/eina_js/eina_js_suite \
+TEST_LOG_DRIVER = node
+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_SOURCES = \
+tests/eina_js/eina_js_suite.js: $(top_builddir)/src/tests/eina_js/eina_js_suite.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
+
+$(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
-tests_eina_js_eina_js_value_SOURCES = \
+tests_eina_js_libeina_js_value_la_SOURCES = \
tests/eina_js/eina_js_value.cc
-tests_eina_js_eina_js_error_SOURCES = \
+tests_eina_js_libeina_js_error_la_SOURCES = \
tests/eina_js/eina_js_error.cc
-tests_eina_js_eina_js_accessor_SOURCES = \
+tests_eina_js_libeina_js_accessor_la_SOURCES = \
tests/eina_js/eina_js_accessor.cc
-tests_eina_js_eina_js_log_SOURCES = \
+tests_eina_js_libeina_js_log_la_SOURCES = \
tests/eina_js/eina_js_log.cc
-tests_eina_js_eina_js_iterator_SOURCES = \
+tests_eina_js_libeina_js_iterator_la_SOURCES = \
tests/eina_js/eina_js_iterator.cc
-tests_eina_js_eina_js_suite_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -103,11 +119,11 @@ tests_eina_js_eina_js_suite_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-tests_eina_js_eina_js_suite_LDADD = \
+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_eina_js_suite_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@ @USE_EINA_JS_INTERNAL_LIBS@ @USE_EO_INTERNAL_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_eina_js_value_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -117,10 +133,10 @@ tests_eina_js_eina_js_value_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-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_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_eina_js_error_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -130,10 +146,10 @@ tests_eina_js_eina_js_error_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-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_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_eina_js_accessor_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -143,10 +159,10 @@ tests_eina_js_eina_js_accessor_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-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_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_eina_js_log_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -156,10 +172,10 @@ tests_eina_js_eina_js_log_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-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_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_eina_js_iterator_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
+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\" \
@@ -169,8 +185,8 @@ tests_eina_js_eina_js_iterator_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
@EO_CXX_CFLAGS@ \
@EO_CFLAGS@ \
@EINA_JS_CFLAGS@
-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@
+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@
endif
endif
diff --git a/src/Makefile_Eolian_Js.am b/src/Makefile_Eolian_Js.am
index b8adba2b0d..e185b4143e 100644
--- a/src/Makefile_Eolian_Js.am
+++ b/src/Makefile_Eolian_Js.am
@@ -22,7 +22,7 @@ include Makefile_Eolian_Js_Helper.am
lib_LTLIBRARIES += lib/eolian_js/libeolian_js.la
-lib_eolian_js_libeolian_js_la_SOURCES =\
+lib_eolian_js_libeolian_js_la_SOURCES = \
bindings/eolian_js/main.cc \
$(generated_evas_canvas_js_bindings)
@@ -42,39 +42,39 @@ lib_eolian_js_libeolian_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
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@
+# 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
diff --git a/src/bindings/eina_js/eina_js_container.cc b/src/bindings/eina_js/eina_js_container.cc
index 25f03e925e..eba4094662 100644
--- a/src/bindings/eina_js/eina_js_container.cc
+++ b/src/bindings/eina_js/eina_js_container.cc
@@ -18,332 +18,333 @@
#include <iostream>
-// namespace efl { namespace eina { namespace js {
-
-// template <typename T>
-// struct tag { typedef T type; };
-
-// namespace {
-
-// /*v8::UniquePersistent<v8::ObjectTemplate>*/
-// compatibility_persistent<v8::ObjectTemplate> instance_persistents[container_type_size];
-// v8::Handle<v8::FunctionTemplate> 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(v8::String::NewFromUtf8(isolate, "eina_list")))
-// {
-// eina_container_base& rhs = *static_cast<eina_container_base*>(obj->GetAlignedPointerFromInternalField(0));
-// 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[] = {v8::External::New(isolate, rhs.concat(lhs))};
-// v8::Local<v8::Object> result = instance_templates[lhs.get_container_type()]->GetFunction()->NewInstance(1, a);
-// 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[] = {v8::External::New(isolate, self.slice(i, j))};
-// v8::Local<v8::Object> result = instance_templates[self.get_container_type()]
-// ->GetFunction()->NewInstance(1, a);
-// return result;
-// }
-// else
-// std::cout << "parameters are not integral" << std::endl;
-// std::cout << "Some test failed" << std::endl;
-// std::abort();
-// }
-
-// void length(v8::Local<v8::String>, v8::PropertyCallbackInfo<v8::Value> const& info)
-// {
-// v8::Local<v8::Object> self_obj = v8::Local<v8::Object>::Cast(info.This());
-// eina_container_base* self = static_cast<eina_container_base*>(self_obj->GetAlignedPointerFromInternalField(0));
-// info.GetReturnValue().Set((uint32_t)self->size());
-// }
-
-// void index_get(uint32_t index, v8::PropertyCallbackInfo<v8::Value>const& 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*>(self_obj->GetAlignedPointerFromInternalField(0));
-// info.GetReturnValue().Set(self->get(info.GetIsolate(), index));
-// }
-
-// void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args)
-// {
-// 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;
-// args.This()->SetAlignedPointerInInternalField(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;
-// args.This()->SetAlignedPointerInInternalField(0, dynamic_cast<void*>(base));
-// }
-// else
-// std::abort();
-// }
-// }
-// else
-// std::abort();
-// }
-
-// void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args)
-// {
-// 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;
-// args.This()->SetAlignedPointerInInternalField(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;
-// args.This()->SetAlignedPointerInInternalField(0, dynamic_cast<void*>(base));
-// }
-// else
-// std::abort();
-// }
-// }
-// else
-// std::abort();
-// }
+namespace efl { namespace eina { namespace js {
+
+template <typename T>
+struct tag { typedef T type; };
+
+namespace {
+
+/*v8::UniquePersistent<v8::ObjectTemplate>*/
+compatibility_persistent<v8::ObjectTemplate> instance_persistents[container_type_size];
+v8::Handle<v8::FunctionTemplate> 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::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))};
+ v8::Local<v8::Object> result = instance_templates[lhs.get_container_type()]->GetFunction()->NewInstance(1, a);
+ 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()]
+ ->GetFunction()->NewInstance(1, a);
+ return result;
+ }
+ else
+ std::cout << "parameters are not integral" << std::endl;
+ std::cout << "Some test failed" << std::endl;
+ std::abort();
+}
+
+void length(v8::Local<v8::String>, v8::PropertyCallbackInfo<v8::Value> const& info)
+{
+ v8::Local<v8::Object> self_obj = v8::Local<v8::Object>::Cast(info.This());
+ eina_container_base* self = static_cast<eina_container_base*>(self_obj->GetAlignedPointerFromInternalField(0));
+ info.GetReturnValue().Set((uint32_t)self->size());
+}
+
+void index_get(uint32_t index, v8::PropertyCallbackInfo<v8::Value>const& 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*>(self_obj->GetAlignedPointerFromInternalField(0));
+ info.GetReturnValue().Set(self->get(info.GetIsolate(), index));
+}
+
+void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args)
+{
+ 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;
+ args.This()->SetAlignedPointerInInternalField(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;
+ args.This()->SetAlignedPointerInInternalField(0, dynamic_cast<void*>(base));
+ }
+ else
+ std::abort();
+ }
+ }
+ else
+ std::abort();
+}
+
+void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args)
+{
+ 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;
+ args.This()->SetAlignedPointerInInternalField(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;
+ args.This()->SetAlignedPointerInInternalField(0, dynamic_cast<void*>(base));
+ }
+ else
+ std::abort();
+ }
+ }
+ else
+ std::abort();
+}
-// template <typename F>
-// struct function_params;
+template <typename F>
+struct function_params;
-// template <typename R, typename... Sig>
-// struct function_params<R(*)(Sig...)>
-// {
-// typedef std::tuple<Sig...> type;
-// };
+template <typename R, typename... Sig>
+struct function_params<R(*)(Sig...)>
+{
+ typedef std::tuple<Sig...> type;
+};
-// template <typename F>
-// struct function_result;
+template <typename F>
+struct function_result;
-// template <typename R, typename... Sig>
-// struct function_result<R(*)(Sig...)>
-// {
-// typedef R type;
-// };
+template <typename R, typename... Sig>
+struct function_result<R(*)(Sig...)>
+{
+ typedef R type;
+};
-// template <typename T>
-// struct is_persistent : std::false_type {};
+template <typename T>
+struct is_persistent : std::false_type {};
-// template <typename T, typename U>
-// struct is_persistent<v8::Persistent<T, U> > : std::true_type {};
+template <typename T, typename U>
+struct is_persistent<v8::Persistent<T, U> > : std::true_type {};
-// template <std::size_t I, typename Sig>
-// typename std::tuple_element<I, Sig>::type
-// get_element(v8::Isolate* isolate
-// , v8::FunctionCallbackInfo<v8::Value> const& 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*/
-// , v8::FunctionCallbackInfo<v8::Value> const& 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 <std::size_t I, typename Sig>
+typename std::tuple_element<I, Sig>::type
+get_element(v8::Isolate* isolate
+ , v8::FunctionCallbackInfo<v8::Value> const& 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*/
+ , v8::FunctionCallbackInfo<v8::Value> const& 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
-// , v8::FunctionCallbackInfo<v8::Value> const& 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 << 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>
-// void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<R>)
-// {
-// T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0));
-// F* f = reinterpret_cast<F*>(v8::External::Cast(*args.Data())->Value());
-// args.GetReturnValue().Set
-// (js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
-// , eina::make_index_sequence<std::tuple_size<Sig>::value>()));
-// }
-
-// template <typename Sig, typename T, typename F>
-// void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>)
-// {
-// T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(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>());
-// }
+template <typename Sig, typename R, typename T, typename F, std::size_t... N>
+R call_impl(v8::Isolate* isolate
+ , v8::FunctionCallbackInfo<v8::Value> const& 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 << 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>
+void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<R>)
+{
+ T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0));
+ F* f = reinterpret_cast<F*>(v8::External::Cast(*args.Data())->Value());
+ args.GetReturnValue().Set
+ (js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
+ , eina::make_index_sequence<std::tuple_size<Sig>::value>()));
+}
+
+template <typename Sig, typename T, typename F>
+void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>)
+{
+ T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(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>());
+}
-// template <typename Sig, typename R, typename T, typename F>
-// void call_generic(v8::FunctionCallbackInfo<v8::Value> const& args)
-// {
-// efl::js::call_generic_impl<Sig, T, F>(args, tag<R>());
-// }
-
-// template <typename Sig, typename T, typename F, typename R>
-// void call_function_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<R>)
-// {
-// std::cout << "return type " << typeid(R).name() << std::endl;
-// T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0));
-// F f = reinterpret_cast<F>(v8::External::Cast(*args.Data())->Value());
-// args.GetReturnValue().Set
-// (js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
-// , eina::make_index_sequence<std::tuple_size<Sig>::value>()));
-// }
-
-// template <typename Sig, typename T, typename F>
-// void call_function_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>)
-// {
-// T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(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>());
-// }
-
-// template <typename Sig, typename R, typename T, typename F>
-// void call_function(v8::FunctionCallbackInfo<v8::Value> const& args)
-// {
-// std::cout << "R: " << typeid(R).name() << std::endl;
-// efl::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(v8::String::NewFromUtf8(isolate, name)
-// , v8::FunctionTemplate::New
-// (isolate, &efl::js::call_function
-// <typename eina::_mpl::pop_front<typename function_params<F>::type, 2u>::type
-// , typename function_result<F>::type, T, F>
-// , v8::External::New
-// (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(v8::String::NewFromUtf8(isolate, name)
-// , v8::FunctionTemplate::New
-// (isolate
-// , &efl::js::call_generic<std::tuple<Sig...>, result_type, T, F>
-// , v8::External::New
-// (isolate, new F(std::forward<F>(f)))));
-// }
-
-// v8::Local<v8::ObjectTemplate> register_template(v8::Isolate* isolate, v8::Handle<v8::FunctionTemplate> constructor)
-// {
-// v8::Handle<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate();
-// instance_t->SetInternalFieldCount(1);
-
-// instance_t->SetIndexedPropertyHandler(& efl::js::index_get);
-
-// v8::Local<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate();
-// prototype->SetAccessor(v8::String::NewFromUtf8(isolate, "length"), &efl::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
-// , v8::FunctionCallback callback)
-// {
-// v8::Handle<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(isolate, callback);
-// constructor->SetClassName(v8::String::NewFromUtf8(isolate, class_name));
-
-// v8::Local<v8::ObjectTemplate> instance_t = efl::js::register_template(isolate, constructor);
+template <typename Sig, typename R, typename T, typename F>
+void call_generic(v8::FunctionCallbackInfo<v8::Value> const& args)
+{
+ efl::js::call_generic_impl<Sig, T, F>(args, tag<R>());
+}
+
+template <typename Sig, typename T, typename F, typename R>
+void call_function_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<R>)
+{
+ std::cout << "return type " << typeid(R).name() << std::endl;
+ T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0));
+ F f = reinterpret_cast<F>(v8::External::Cast(*args.Data())->Value());
+ args.GetReturnValue().Set
+ (js::call_impl<Sig, R>(args.GetIsolate(), args, self, f
+ , eina::make_index_sequence<std::tuple_size<Sig>::value>()));
+}
+
+template <typename Sig, typename T, typename F>
+void call_function_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>)
+{
+ T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(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>());
+}
+
+template <typename Sig, typename R, typename T, typename F>
+void call_function(v8::FunctionCallbackInfo<v8::Value> const& args)
+{
+ std::cout << "R: " << typeid(R).name() << std::endl;
+ efl::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(v8::String::NewFromUtf8(isolate, name)
+ , v8::FunctionTemplate::New
+ (isolate, &efl::js::call_function
+ <typename eina::_mpl::pop_front<typename function_params<F>::type, 2u>::type
+ , typename function_result<F>::type, T, F>
+ , v8::External::New
+ (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(v8::String::NewFromUtf8(isolate, name)
+ , v8::FunctionTemplate::New
+ (isolate
+ , &efl::js::call_generic<std::tuple<Sig...>, result_type, T, F>
+ , v8::External::New
+ (isolate, new F(std::forward<F>(f)))));
+}
+
+v8::Local<v8::ObjectTemplate> register_template(v8::Isolate* isolate, v8::Handle<v8::FunctionTemplate> constructor)
+{
+ v8::Handle<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate();
+ instance_t->SetInternalFieldCount(1);
+
+ instance_t->SetIndexedPropertyHandler(& efl::js::index_get);
+
+ v8::Local<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate();
+ prototype->SetAccessor(v8::String::NewFromUtf8(isolate, "length"), &efl::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
+ , v8::FunctionCallback callback)
+{
+ v8::Handle<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(isolate, callback);
+ constructor->SetClassName(v8::String::NewFromUtf8(isolate, class_name));
+
+ v8::Local<v8::ObjectTemplate> instance_t = efl::js::register_template(isolate, constructor);
-// efl::js::instance_persistents[type] = v8::UniquePersistent<v8::ObjectTemplate> (isolate, instance_t);
-// efl::js::instance_templates[type] = constructor;
-// }
+ efl::js::instance_persistents[type] = v8::UniquePersistent<v8::ObjectTemplate> (isolate, instance_t);
+ efl::js::instance_templates[type] = constructor;
+}
-// } } } }
-
-// EAPI void eina_container_register(v8::Handle<v8::ObjectTemplate>, v8::Isolate* isolate)
-// {
-// efl::js::register_class(isolate, efl::js::list_container_type, "eina_list", &efl::js::new_eina_list);
-// efl::js::register_class(isolate, efl::js::array_container_type, "eina_array", &efl::js::new_eina_array);
-// }
-
-// EAPI v8::Handle<v8::FunctionTemplate> get_list_instance_template()
-// {
-// return efl::js::instance_templates[efl::js::list_container_type];
-// }
+} } } }
+
+EAPI void eina_container_register(v8::Handle<v8::ObjectTemplate>, v8::Isolate* isolate)
+{
+ efl::js::register_class(isolate, efl::js::list_container_type, "eina_list", &efl::js::new_eina_list);
+ efl::js::register_class(isolate, efl::js::array_container_type, "eina_array", &efl::js::new_eina_array);
+}
+
+EAPI v8::Handle<v8::FunctionTemplate> get_list_instance_template()
+{
+ return efl::js::instance_templates[efl::js::list_container_type];
+}
diff --git a/src/tests/eina_js/eina_js_suite.cc b/src/tests/eina_js/eina_js_suite.cc
index 2c1191cfa8..64866dc4ed 100644
--- a/src/tests/eina_js/eina_js_suite.cc
+++ b/src/tests/eina_js/eina_js_suite.cc
@@ -125,7 +125,7 @@ efl::eina::js::compatibility_return_type Print(efl::eina::js::compatibility_call
return efl::eina::js::compatibility_return();
}
-EAPI void eina_container_register(v8::Handle<v8::ObjectTemplate> global, v8::Isolate* isolate);
+EAPI void eina_container_register(v8::Handle<v8::Object> global, v8::Isolate* isolate);
EAPI v8::Handle<v8::FunctionTemplate> get_list_instance_template();
int main(int, char*[])
@@ -154,7 +154,6 @@ int main(int, char*[])
// Bind the global 'print' function to the C++ Print callback.
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, Print));
- eina_container_register(global, isolate);
// // Bind the global 'read' function to the C++ Read callback.
// global->Set(v8::String::NewFromUtf8(isolate, "read"),
// v8::FunctionTemplate::New(isolate, Read));
@@ -169,6 +168,7 @@ int main(int, char*[])
// v8::FunctionTemplate::New(isolate, Version));
context = efl::eina::js::compatibility_new<v8::Context>(isolate, nullptr, global);
+ eina_container_register(context->Global(), isolate);
}
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -193,3 +193,25 @@ int main(int, char*[])
context->Exit();
}
+//#ifdef USE_NODEJS
+#include <node/node.h>
+
+namespace {
+
+void init(v8::Handle<v8::Object> exports)
+{
+ try
+ {
+ eina_container_register(exports, v8::Isolate::GetCurrent());
+ }
+ catch(...)
+ {
+ std::cout << "Error" << std::endl;
+ }
+}
+
+}
+
+NODE_MODULE(eina_js_suite, init)
+
+//#endif
diff --git a/src/tests/eina_js/eina_js_suite.js b/src/tests/eina_js/eina_js_suite.js
new file mode 100755
index 0000000000..080059b2a0
--- /dev/null
+++ b/src/tests/eina_js/eina_js_suite.js
@@ -0,0 +1,51 @@
+#!/usr/bin/env node
+
+console.log("teste1");
+
+var suite = require('../../../build/src/tests/eina_js/eina_js_suite');
+
+// function assert(condition, message)
+// {
+// if (!condition) {
+// console.log(\"Assertion failed \", message);
+// throw message || \"Assertion failed\";
+// }
+
+console.log("teste");
+var l1 = raw_list;
+console.log ("l1 ", l1.toString());
+assert (l1.length == 3);
+var l2 = 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]);