diff options
author | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2015-01-08 16:02:04 -0200 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2015-01-08 16:02:04 -0200 |
commit | 9c21c736728332464df9969ae00c47b43f63680d (patch) | |
tree | 323061b4bdc519002c9292848ea425ac2d19015c | |
parent | c1d3adfc6e92bcd7faa98c5844b5bcb4aba7dc3f (diff) | |
download | efl-9c21c736728332464df9969ae00c47b43f63680d.tar.gz |
eina-js: Compatibilization of Eina JS containers
-rw-r--r-- | src/Makefile_Eina_Js.am | 2 | ||||
-rw-r--r-- | src/Makefile_Eo_Js.am | 2 | ||||
-rw-r--r-- | src/bindings/eina_js/eina_js_compatibility.hh | 107 | ||||
-rw-r--r-- | src/bindings/eina_js/eina_js_container.cc | 140 | ||||
-rw-r--r-- | src/bindings/eina_js/eina_js_get_value.hh (renamed from src/bindings/eo_js/eo_js_get_value.hh) | 6 | ||||
-rw-r--r-- | src/bindings/eina_js/eina_js_get_value_from_c.hh (renamed from src/bindings/eo_js/eo_js_get_value_from_c.hh) | 13 | ||||
-rw-r--r-- | src/bindings/eo_js/eo_js_call_function.hh | 14 | ||||
-rw-r--r-- | src/bindings/eo_js/eo_js_construct_from_eo.hh | 4 | ||||
-rw-r--r-- | src/bindings/eo_js/eo_js_constructor.hh | 9 | ||||
-rw-r--r-- | src/bindings/eo_js/eo_js_event.hh | 4 |
10 files changed, 216 insertions, 85 deletions
diff --git a/src/Makefile_Eina_Js.am b/src/Makefile_Eina_Js.am index dd90dce43c..b1e41a282b 100644 --- a/src/Makefile_Eina_Js.am +++ b/src/Makefile_Eina_Js.am @@ -19,7 +19,6 @@ lib_eina_js_libeina_js_la_DEPENDENCIES = @EINA_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@ lib_eina_js_libeina_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ lib_eina_js_libeina_js_la_SOURCES = \ -bindings/eina_js/eina_js_compatibility.hh \ bindings/eina_js/eina_js_container.cc \ bindings/eina_js/eina_js_value.cc \ bindings/eina_js/eina_js_error.cc \ @@ -33,6 +32,7 @@ bindings/eina_cxx/Eina.hh #installed_einacxxheadersdir = $(includedir)/eina-cxx-@VMAJ@/eina-cxx #dist_installed_einacxxheaders_DATA = \ +bindings/eina_js/eina_js_compatibility.hh \ bindings/eina_cxx/eina_accessor.hh \ bindings/eina_cxx/eina_array.hh \ bindings/eina_cxx/eina_clone_allocators.hh \ diff --git a/src/Makefile_Eo_Js.am b/src/Makefile_Eo_Js.am index 43c8579ac0..3a2ba0da74 100644 --- a/src/Makefile_Eo_Js.am +++ b/src/Makefile_Eo_Js.am @@ -7,8 +7,6 @@ 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_get_value_from_c.hh \ -bindings/eo_js/eo_js_get_value.hh \ bindings/eo_js/eo_js_event.hh \ bindings/eo_js/eo_js_construct_from_eo.hh \ bindings/eo_js/Eo_Js.hh diff --git a/src/bindings/eina_js/eina_js_compatibility.hh b/src/bindings/eina_js/eina_js_compatibility.hh index ca77e73ad2..e0749461d7 100644 --- a/src/bindings/eina_js/eina_js_compatibility.hh +++ b/src/bindings/eina_js/eina_js_compatibility.hh @@ -9,6 +9,12 @@ namespace v8 { template <typename T> struct FunctionCallbackInfo; +template <typename T> +struct PropertyCallbackInfo; +template <typename T> +struct UniquePersistent; + +class AccessorInfo; } @@ -58,14 +64,64 @@ struct _libv8_callback_info_test { }; +template <typename T = v8::ObjectTemplate, typename Enable = void> +struct _libv8_property_callback_info_test; + +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::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 +{ +}; + 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; +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_callback_info, ""); static_assert(!v8_uses_isolate, ""); @@ -158,10 +214,10 @@ auto compatibility_new(nullptr_t, Args...args) -> , args...); } -template <typename T> -inline void compatibility_return_impl(T object, compatibility_callback_info_type, std::true_type) +template <typename T, typename U> +inline void compatibility_return_impl(T object, U const& info, std::true_type) { - // should set to info.ReturnValue(object); + info.ReturnValue().Set(object); } template <typename T> @@ -170,6 +226,13 @@ compatibility_return_impl(T object, compatibility_callback_info_type, std::false { 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 @@ -178,6 +241,13 @@ 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> @@ -246,11 +316,27 @@ 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 +struct compatibility_persistent<T, true> : v8::UniquePersistent<T> { + typedef v8::UniquePersistent<T> _base; + using _base::_base; }; +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) + { + } +}; + template <typename T = std::integral_constant<bool, v8_uses_isolate> > struct _v8_object_internal_field; @@ -266,6 +352,10 @@ struct _v8_object_internal_field<std::false_type> : v8::Object { return GetPointerFromInternalField(index); } + void SetAlignedPointerFromInternalField(int index, void* p) + { + SetPointerInInternalField(index, p); + } }; template <typename T = void*> @@ -275,6 +365,13 @@ inline T compatibility_get_pointer_internal_field(v8::Handle<v8::Object> object, (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)->SetAlignedPointerFromInternalField(index, pointer); +} + template <typename T = void, bool = v8_uses_isolate> struct compatibility_handle_scope_impl; @@ -317,6 +414,8 @@ inline void compatibility_initialize() v8::V8::Initialize(); static_cast<_v8_initialize_icu<>*>(nullptr)->InitializeICU(); } + + } } } diff --git a/src/bindings/eina_js/eina_js_container.cc b/src/bindings/eina_js/eina_js_container.cc index eba4094662..a4dda20367 100644 --- a/src/bindings/eina_js/eina_js_container.cc +++ b/src/bindings/eina_js/eina_js_container.cc @@ -13,6 +13,7 @@ #include <eina_ptrlist.hh> #include <eina_js_list.hh> #include <eina_js_array.hh> +#include <eina_js_get_value_from_c.hh> #include <tuple> @@ -25,7 +26,6 @@ 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]; @@ -77,22 +77,26 @@ v8::Local<v8::Object> slice(eina_container_base& self, v8::Isolate* isolate, v8: std::abort(); } -void length(v8::Local<v8::String>, v8::PropertyCallbackInfo<v8::Value> const& info) +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()); - eina_container_base* self = static_cast<eina_container_base*>(self_obj->GetAlignedPointerFromInternalField(0)); - info.GetReturnValue().Set((uint32_t)self->size()); + eina_container_base* self = static_cast<eina_container_base*> + (compatibility_get_pointer_internal_field(self_obj, 0)); + return compatibility_return(compatibility_new<v8::Number>(nullptr, self->size()), info); } -void index_get(uint32_t index, v8::PropertyCallbackInfo<v8::Value>const& 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*>(self_obj->GetAlignedPointerFromInternalField(0)); - info.GetReturnValue().Set(self->get(info.GetIsolate(), index)); + 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); } -void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args) +compatibility_return_type new_eina_list(compatibility_callback_info_type args) { if(args.IsConstructCall()) { @@ -100,7 +104,8 @@ void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args) { 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)); + compatibility_set_pointer_internal_field + (args.This(), 0, dynamic_cast<void*>(p)); } else { @@ -111,7 +116,8 @@ void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args) 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)); + compatibility_set_pointer_internal_field + (args.This(), 0, dynamic_cast<void*>(base)); } else std::abort(); @@ -119,9 +125,10 @@ void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args) } else std::abort(); + return compatibility_return(); } -void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args) +compatibility_return_type new_eina_array(compatibility_callback_info_type args) { if(args.IsConstructCall()) { @@ -129,7 +136,8 @@ void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args) { 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)); + compatibility_set_pointer_internal_field + (args.This(), 0, dynamic_cast<void*>(p)); } else { @@ -140,7 +148,8 @@ void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args) 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)); + compatibility_set_pointer_internal_field + (args.This(), 0, dynamic_cast<void*>(base)); } else std::abort(); @@ -148,6 +157,7 @@ void new_eina_array(v8::FunctionCallbackInfo<v8::Value> const& args) } else std::abort(); + return compatibility_return(); } template <typename F> @@ -171,13 +181,13 @@ struct function_result<R(*)(Sig...)> 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...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 - , v8::FunctionCallbackInfo<v8::Value> const& args + , compatibility_callback_info_type args , typename std::enable_if <is_persistent<typename std::tuple_element<I, Sig>::type>::value>::type* = 0) { @@ -188,7 +198,7 @@ get_element(v8::Isolate* isolate 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 + , compatibility_callback_info_type args , typename std::enable_if <!is_persistent<typename std::tuple_element<I, Sig>::type>::value>::type* = 0) { @@ -198,7 +208,7 @@ get_element(v8::Isolate* /*isolate*/ 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 + , compatibility_callback_info_type args , T* self, F* f , eina::index_sequence<N...>) { @@ -215,55 +225,67 @@ R call_impl(v8::Isolate* isolate } template <typename Sig, typename T, typename F, typename R> -void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<R>) +compatibility_return_type call_generic_impl(compatibility_callback_info_type args, tag<R>) { - T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0)); + T* self = static_cast<T*> + (compatibility_get_pointer_internal_field<>(args.This(), 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>())); + 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> -void call_generic_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>) +compatibility_return_type call_generic_impl(compatibility_callback_info_type args, tag<void>) { - T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0)); + 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> -void call_generic(v8::FunctionCallbackInfo<v8::Value> const& args) +compatibility_return_type call_generic(compatibility_callback_info_type args) { - efl::js::call_generic_impl<Sig, T, F>(args, tag<R>()); + return efl::eina::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>) +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*>(args.This()->GetAlignedPointerFromInternalField(0)); + T* self = static_cast<T*> + (compatibility_get_pointer_internal_field(args.This(), 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>())); + 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> -void call_function_impl(v8::FunctionCallbackInfo<v8::Value> const& args, tag<void>) +compatibility_return_type call_function_impl(compatibility_callback_info_type args, tag<void>) { - T* self = static_cast<T*>(args.This()->GetAlignedPointerFromInternalField(0)); + 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> -void call_function(v8::FunctionCallbackInfo<v8::Value> const& args) +compatibility_return_type call_function(compatibility_callback_info_type args) { std::cout << "R: " << typeid(R).name() << std::endl; - efl::js::call_function_impl<Sig, T, F>(args, tag<R>()); + return efl::eina::js::call_function_impl<Sig, T, F>(args, tag<R>()); } template <typename T, typename F> @@ -271,12 +293,12 @@ void register_(v8::Isolate* isolate, const char* name, F f, v8::Handle<v8::Objec , 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 + 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> - , v8::External::New + , compatibility_new<v8::External> (isolate, reinterpret_cast<void*>(f)))); } @@ -289,23 +311,23 @@ void register_(v8::Isolate* isolate, const char* name, F&& f, v8::Handle<v8::Obj (std::declval<T&>(), std::declval<v8::Isolate*>() , std::declval<Sig>()...) ); - template_->Set(v8::String::NewFromUtf8(isolate, name) - , v8::FunctionTemplate::New + template_->Set(compatibility_new<v8::String>(isolate, name) + , compatibility_new<v8::FunctionTemplate> (isolate - , &efl::js::call_generic<std::tuple<Sig...>, result_type, T, F> - , v8::External::New + , &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::Handle<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate(); instance_t->SetInternalFieldCount(1); - instance_t->SetIndexedPropertyHandler(& efl::js::index_get); + instance_t->SetIndexedPropertyHandler(& efl::eina::js::index_get); v8::Local<v8::ObjectTemplate> prototype = constructor->PrototypeTemplate(); - prototype->SetAccessor(v8::String::NewFromUtf8(isolate, "length"), &efl::js::length); + prototype->SetAccessor(compatibility_new<v8::String>(isolate, "length"), &efl::eina::js::length); using namespace std::placeholders; js::register_<js::eina_container_base> @@ -325,26 +347,30 @@ v8::Local<v8::ObjectTemplate> register_template(v8::Isolate* isolate, v8::Handle } void register_class(v8::Isolate* isolate, container_type type, const char* class_name - , v8::FunctionCallback callback) + , compatibility_function_callback callback) { - v8::Handle<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(isolate, callback); - constructor->SetClassName(v8::String::NewFromUtf8(isolate, class_name)); + 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::js::register_template(isolate, constructor); + v8::Local<v8::ObjectTemplate> instance_t = efl::eina::js::register_template(isolate, constructor); - efl::js::instance_persistents[type] = v8::UniquePersistent<v8::ObjectTemplate> (isolate, instance_t); - efl::js::instance_templates[type] = constructor; + efl::eina::js::instance_persistents[type] + = compatibility_persistent<v8::ObjectTemplate> {isolate, instance_t}; + efl::eina::js::instance_templates[type] = constructor; } } } } } -EAPI void eina_container_register(v8::Handle<v8::ObjectTemplate>, v8::Isolate* isolate) +EAPI void eina_container_register(v8::Handle<v8::Object>, 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); + 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::FunctionTemplate> get_list_instance_template() { - return efl::js::instance_templates[efl::js::list_container_type]; + return efl::eina::js::instance_templates[efl::eina::js::list_container_type]; } diff --git a/src/bindings/eo_js/eo_js_get_value.hh b/src/bindings/eina_js/eina_js_get_value.hh index 0ab4a9f136..6a63d4f5e4 100644 --- a/src/bindings/eo_js/eo_js_get_value.hh +++ b/src/bindings/eina_js/eina_js_get_value.hh @@ -1,5 +1,5 @@ -#ifndef EFL_EO_JS_GET_VALUE_HH -#define EFL_EO_JS_GET_VALUE_HH +#ifndef EFL_EINA_JS_GET_VALUE_HH +#define EFL_EINA_JS_GET_VALUE_HH #include <eina_js_compatibility.hh> @@ -10,7 +10,7 @@ #include <iostream> #include <typeinfo> -namespace efl { namespace eo { namespace js { +namespace efl { namespace eina { namespace js { template <typename T> struct value_tag diff --git a/src/bindings/eo_js/eo_js_get_value_from_c.hh b/src/bindings/eina_js/eina_js_get_value_from_c.hh index 074c29462e..5ec35f88d9 100644 --- a/src/bindings/eo_js/eo_js_get_value_from_c.hh +++ b/src/bindings/eina_js/eina_js_get_value_from_c.hh @@ -1,5 +1,5 @@ -#ifndef EFL_EO_JS_GET_VALUE_FROM_C_HH -#define EFL_EO_JS_GET_VALUE_FROM_C_HH +#ifndef EFL_EINA_JS_GET_VALUE_FROM_C_HH +#define EFL_EINA_JS_GET_VALUE_FROM_C_HH #include <eina_js_compatibility.hh> @@ -9,7 +9,7 @@ #include <cstdlib> #include <typeinfo> -namespace efl { namespace eo { namespace js { +namespace efl { namespace eina { namespace js { template <typename T> struct print_tag {}; @@ -28,6 +28,13 @@ get_value_from_c(T v, v8::Isolate* isolate { 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> diff --git a/src/bindings/eo_js/eo_js_call_function.hh b/src/bindings/eo_js/eo_js_call_function.hh index 98eadd39a1..5977ff13c6 100644 --- a/src/bindings/eo_js/eo_js_call_function.hh +++ b/src/bindings/eo_js/eo_js_call_function.hh @@ -8,8 +8,8 @@ #include <eina_function.hh> #include <Eo.h> -#include <eo_js_get_value.hh> -#include <eo_js_get_value_from_c.hh> +#include <eina_js_get_value.hh> +#include <eina_js_get_value_from_c.hh> #include <cstdlib> #include <functional> @@ -44,9 +44,9 @@ struct method_caller , std::false_type) { std::cout << "is NOT out" << std::endl; - return js::get_value_from_javascript + return eina::js::get_value_from_javascript (args[I], isolate - , js::value_tag<typename std::tuple_element + , 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> @@ -68,7 +68,7 @@ struct method_caller create_return_unique_value(eina::js::compatibility_callback_info_type args , R const& r) const { - return js::get_value_from_c(r, args.GetIsolate()); + return eina::js::get_value_from_c(r, args.GetIsolate()); } template <typename Outs> @@ -118,7 +118,7 @@ struct method_caller , Outs const& outs, eina::index_sequence<S...>) const { std::initializer_list<int> l - = {(r->Set(S+Offset, js::get_value_from_c(std::get<S>(outs), isolate)),0)...}; + = {(r->Set(S+Offset, eina::js::get_value_from_c(std::get<S>(outs), isolate)),0)...}; static_cast<void>(l); } @@ -132,7 +132,7 @@ struct method_caller 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, js::get_value_from_c(r, isolate)); + 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); } 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 f4a23c879a..93c56f67b6 100644 --- a/src/bindings/eo_js/eo_js_construct_from_eo.hh +++ b/src/bindings/eo_js/eo_js_construct_from_eo.hh @@ -8,8 +8,8 @@ #include <eina_function.hh> #include <Eo.h> -#include <eo_js_get_value.hh> -#include <eo_js_get_value_from_c.hh> +#include <eina_js_get_value.hh> +#include <eina_js_get_value_from_c.hh> #include <cstdlib> #include <functional> diff --git a/src/bindings/eo_js/eo_js_constructor.hh b/src/bindings/eo_js/eo_js_constructor.hh index c7210731c3..4a002c4300 100644 --- a/src/bindings/eo_js/eo_js_constructor.hh +++ b/src/bindings/eo_js/eo_js_constructor.hh @@ -7,7 +7,7 @@ #include <eina_function.hh> #include <Eo.h> -#include <eo_js_get_value.hh> +#include <eina_js_get_value.hh> #include <cstdlib> #include <functional> @@ -94,9 +94,9 @@ struct constructor_caller { typename std::tuple_element<I, typename eina::_mpl::function_params<U>::type>::type tmp = - js::get_value_from_javascript + eina::js::get_value_from_javascript (v, isolate - , js::value_tag<typename std::tuple_element + , eina::js::value_tag<typename std::tuple_element <I, typename eina::_mpl::function_params<U>::type>::type>()); return tmp; } @@ -140,7 +140,8 @@ struct constructor_caller { try { - Eo* parent = js::get_value_from_javascript(args[0], args.GetIsolate(), js::value_tag<Eo*>()); + Eo* parent = eina::js::get_value_from_javascript + (args[0], args.GetIsolate(), eina::js::value_tag<Eo*>()); Eo* eo = eo_add (klass , parent diff --git a/src/bindings/eo_js/eo_js_event.hh b/src/bindings/eo_js/eo_js_event.hh index 928a0ccedc..f78909ba08 100644 --- a/src/bindings/eo_js/eo_js_event.hh +++ b/src/bindings/eo_js/eo_js_event.hh @@ -8,8 +8,8 @@ #include <eina_function.hh> #include <Eo.h> -#include <eo_js_get_value.hh> -#include <eo_js_get_value_from_c.hh> +#include <eina_js_get_value.hh> +#include <eina_js_get_value_from_c.hh> #include <cstdlib> #include <functional> |