aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-07 19:21:08 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-07 19:21:08 -0200
commit583b069c5b45a9cb5d8dfe7a6752e87b0d949ee1 (patch)
tree9658db932e4c5ee91f7dfd67c6e24b66e30cc838
parentStarted compatibilization for nodejs/libv8/libuv (diff)
downloadefl-583b069c5b45a9cb5d8dfe7a6752e87b0d949ee1.tar.gz
Continue work on compatilization with v8 versions
-rw-r--r--src/bindings/eina_js/eina_js_accessor.cc31
-rw-r--r--src/bindings/eina_js/eina_js_accessor.hh129
-rw-r--r--src/bindings/eina_js/eina_js_array.hh4
-rw-r--r--src/bindings/eina_js/eina_js_compatibility.hh72
-rw-r--r--src/bindings/eina_js/eina_js_container.cc635
-rw-r--r--src/bindings/eina_js/eina_js_container.hh8
-rw-r--r--src/bindings/eina_js/eina_js_error.cc13
-rw-r--r--src/bindings/eina_js/eina_js_iterator.cc31
-rw-r--r--src/bindings/eina_js/eina_js_iterator.hh106
-rw-r--r--src/bindings/eina_js/eina_js_list.hh4
-rw-r--r--src/bindings/eina_js/eina_js_log.cc1216
-rw-r--r--src/bindings/eina_js/eina_js_log.hh4
-rw-r--r--src/bindings/eina_js/eina_js_value.cc254
-rw-r--r--src/bindings/eo_js/eo_js_call_function.hh52
-rw-r--r--src/bindings/eo_js/eo_js_event.hh8
-rw-r--r--src/bindings/eo_js/eo_js_get_value.hh28
-rw-r--r--src/bindings/eo_js/eo_js_get_value_from_c.hh8
-rw-r--r--src/tests/eina_js/eina_js_accessor.cc37
-rw-r--r--src/tests/eina_js/eina_js_error.cc36
-rw-r--r--src/tests/eina_js/eina_js_iterator.cc38
-rw-r--r--src/tests/eina_js/eina_js_log.cc275
-rw-r--r--src/tests/eina_js/eina_js_suite.cc40
-rw-r--r--src/tests/eina_js/eina_js_value.cc125
23 files changed, 1599 insertions, 1555 deletions
diff --git a/src/bindings/eina_js/eina_js_accessor.cc b/src/bindings/eina_js/eina_js_accessor.cc
index e954d70f7e..7c9b9d3e73 100644
--- a/src/bindings/eina_js/eina_js_accessor.cc
+++ b/src/bindings/eina_js/eina_js_accessor.cc
@@ -2,34 +2,33 @@
#include <config.h>
#endif
+#include <Eina.hh>
+
+#include V8_INCLUDE_HEADER
#include <eina_js_accessor.hh>
+#include <eina_js_compatibility.hh>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
EAPI void register_destroy_accessor(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
v8::Handle<v8::String> name)
{
- using v8::Value;
- using v8::Object;
- using v8::Handle;
- using v8::FunctionTemplate;
- using v8::FunctionCallbackInfo;
-
typedef void (*deleter_t)(void*);
- auto f = [](const FunctionCallbackInfo<Value> &info) {
+ auto f = [](compatibility_callback_info_type info) -> compatibility_return_type
+ {
if (info.Length() != 1 || !info[0]->IsObject())
- return;
+ return compatibility_return();
- Handle<Object> o = info[0]->ToObject();
+ v8::Handle<v8::Object> o = info[0]->ToObject();
- deleter_t deleter = reinterpret_cast<deleter_t>
- (o->GetAlignedPointerFromInternalField(1));
- deleter(o->GetAlignedPointerFromInternalField(0));
- };
+ deleter_t deleter = compatibility_get_pointer_internal_field<deleter_t>(o, 1);
+ deleter(compatibility_get_pointer_internal_field<>(o, 0));
+ return compatibility_return();
+ };
- global->Set(name, FunctionTemplate::New(isolate, f)->GetFunction());
+ global->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
}
-} } // namespace efl { namespace js {
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/eina_js/eina_js_accessor.hh b/src/bindings/eina_js/eina_js_accessor.hh
index 807af4075c..533fc9cc89 100644
--- a/src/bindings/eina_js/eina_js_accessor.hh
+++ b/src/bindings/eina_js/eina_js_accessor.hh
@@ -6,88 +6,91 @@
#include <memory>
#include <eina_js_value.hh>
+#include <eina_js_compatibility.hh>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
/* Creates a copy from \p a accessor and exports it to be manipulated by the JS
code */
template<class T>
v8::Local<v8::Object> export_accessor(::efl::eina::accessor<T> &a,
v8::Isolate *isolate)
-{
- using v8::Local;
- using v8::Value;
- using v8::String;
- using v8::FunctionCallbackInfo;
- using v8::FunctionTemplate;
- using v8::ObjectTemplate;
-
- typedef ::efl::eina::accessor<T> value_type;
- typedef value_type *ptr_type;
- typedef void (*deleter_t)(void*);
-
- auto obj_tpl = ObjectTemplate::New(isolate);
- obj_tpl->SetInternalFieldCount(2);
-
- auto ret = obj_tpl->NewInstance();
-
- auto get = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- auto idx = [&info]() -> std::size_t {
- auto idx = info[0];
-
- if (idx->IsInt32())
- return idx->ToInt32()->Value();
- else if (idx->IsUint32())
- return idx->ToUint32()->Value();
- else
- return idx->ToNumber()->Value();
- }();
-
- void *ptr = info.Holder()->GetAlignedPointerFromInternalField(0);
- auto &value = *static_cast<ptr_type>(ptr);
- info.GetReturnValue().Set(value_cast<Local<Value>>(value[idx],
- info.GetIsolate()));
- };
-
- ret->Set(String::NewFromUtf8(isolate, "get"),
- FunctionTemplate::New(isolate, get)->GetFunction());
-
- {
- deleter_t deleter = [](void *a) {
- delete static_cast<ptr_type>(a);
- };
- std::unique_ptr<value_type> ptr(new value_type(a));
- ret->SetAlignedPointerInInternalField(0, ptr.get());
- ret->SetAlignedPointerInInternalField(1,
- reinterpret_cast<void*>(deleter));
- ptr.release();
- }
-
- return ret;
-}
+ ;
+// {
+// using v8::Local;
+// using v8::Value;
+// using v8::String;
+// using v8::FunctionCallbackInfo;
+// using v8::FunctionTemplate;
+// using v8::ObjectTemplate;
+
+// typedef ::efl::eina::accessor<T> value_type;
+// typedef value_type *ptr_type;
+// typedef void (*deleter_t)(void*);
+
+// auto obj_tpl = compatibility_new<ObjectTemplate>(isolate);
+// obj_tpl->SetInternalFieldCount(2);
+
+// auto ret = obj_tpl->NewInstance();
+
+// auto get = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// auto idx = [&info]() -> std::size_t {
+// auto idx = info[0];
+
+// if (idx->IsInt32())
+// return idx->ToInt32()->Value();
+// else if (idx->IsUint32())
+// return idx->ToUint32()->Value();
+// else
+// return idx->ToNumber()->Value();
+// }();
+
+// void *ptr = info.Holder()->GetAlignedPointerFromInternalField(0);
+// auto &value = *static_cast<ptr_type>(ptr);
+// info.GetReturnValue().Set(value_cast<Local<Value>>(value[idx],
+// info.GetIsolate()));
+// };
+
+// ret->Set(String::NewFromUtf8(isolate, "get"),
+// FunctionTemplate::New(isolate, get)->GetFunction());
+
+// {
+// deleter_t deleter = [](void *a) {
+// delete static_cast<ptr_type>(a);
+// };
+// std::unique_ptr<value_type> ptr(new value_type(a));
+// ret->SetAlignedPointerInInternalField(0, ptr.get());
+// ret->SetAlignedPointerInInternalField(1,
+// reinterpret_cast<void*>(deleter));
+// ptr.release();
+// }
+
+// return ret;
+// }
/* Extracts and returns a copy from the internal accessor object from the JS
object */
template<class T>
::efl::eina::accessor<T> import_accessor(v8::Handle<v8::Object> o)
-{
- typedef ::efl::eina::accessor<T> value_type;
- typedef value_type *ptr_type;
+ ;
+// {
+// typedef ::efl::eina::accessor<T> value_type;
+// typedef value_type *ptr_type;
- ptr_type acc = reinterpret_cast<ptr_type>
- (o->GetAlignedPointerFromInternalField(0));
+// ptr_type acc = reinterpret_cast<ptr_type>
+// (o->GetAlignedPointerFromInternalField(0));
- return value_type(*acc);
-}
+// return value_type(*acc);
+// }
/* Registers the function to destroy the accessor objects to the JS code */
void register_destroy_accessor(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
v8::Handle<v8::String> name);
-} } // namespace efl::js
+} } } // namespace efl::js
#endif /* EINA_JS_ACCESSOR_HH */
diff --git a/src/bindings/eina_js/eina_js_array.hh b/src/bindings/eina_js/eina_js_array.hh
index 9e85ec4ede..0a52b04df7 100644
--- a/src/bindings/eina_js/eina_js_array.hh
+++ b/src/bindings/eina_js/eina_js_array.hh
@@ -9,7 +9,7 @@
#include <iterator>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
template <typename T>
struct eina_array : eina_container_common<efl::eina::array
@@ -70,6 +70,6 @@ struct range_eina_array : eina_container_common<efl::eina::range_array<T> >
js::container_type get_container_type() const { return array_container_type; }
};
-} }
+} } }
#endif
diff --git a/src/bindings/eina_js/eina_js_compatibility.hh b/src/bindings/eina_js/eina_js_compatibility.hh
index 8a75b29c37..ca77e73ad2 100644
--- a/src/bindings/eina_js/eina_js_compatibility.hh
+++ b/src/bindings/eina_js/eina_js_compatibility.hh
@@ -245,6 +245,78 @@ compatibility_throw(v8::Local<v8::Value> exception)
{
return compatibility_throw_impl(exception, std::integral_constant<bool, v8_uses_isolate>());
}
+
+template <typename T>
+struct compatibility_persistent
+{
+};
+
+template <typename T = std::integral_constant<bool, v8_uses_isolate> >
+struct _v8_object_internal_field;
+
+template <>
+struct _v8_object_internal_field<std::true_type> : v8::Object
+{
+};
+
+template <>
+struct _v8_object_internal_field<std::false_type> : v8::Object
+{
+ void* GetAlignedPointerFromInternalField(int index)
+ {
+ return GetPointerFromInternalField(index);
+ }
+};
+
+template <typename T = void*>
+inline T compatibility_get_pointer_internal_field(v8::Handle<v8::Object> object, std::size_t index)
+{
+ return reinterpret_cast<T>
+ (static_cast<_v8_object_internal_field<>*>(*object)->GetAlignedPointerFromInternalField(index));
+}
+
+template <typename T = void, bool = v8_uses_isolate>
+struct compatibility_handle_scope_impl;
+
+template <typename T>
+struct compatibility_handle_scope_impl<T, true> : v8::HandleScope
+{
+ compatibility_handle_scope_impl(v8::Isolate* isolate)
+ : HandleScope(isolate)
+ {}
+};
+
+template <typename T>
+struct compatibility_handle_scope_impl<T, false> : v8::HandleScope
+{
+ compatibility_handle_scope_impl(v8::Isolate*)
+ {}
+};
+
+using compatibility_handle_scope = compatibility_handle_scope_impl<>;
+
+template <bool = v8_uses_isolate>
+struct _v8_initialize_icu;
+
+template <>
+struct _v8_initialize_icu<true> : v8::V8
+{
+};
+
+template <>
+struct _v8_initialize_icu<false> : v8::V8
+{
+ static bool InitializeICU(const char* = NULL)
+ {
+ return true;
+ }
+};
+
+inline void compatibility_initialize()
+{
+ v8::V8::Initialize();
+ static_cast<_v8_initialize_icu<>*>(nullptr)->InitializeICU();
+}
} } }
diff --git a/src/bindings/eina_js/eina_js_container.cc b/src/bindings/eina_js/eina_js_container.cc
index b92a39f4af..25f03e925e 100644
--- a/src/bindings/eina_js/eina_js_container.cc
+++ b/src/bindings/eina_js/eina_js_container.cc
@@ -18,331 +18,332 @@
#include <iostream>
-namespace efl { namespace js {
-
-template <typename T>
-struct tag { typedef T type; };
-
-namespace {
-
-v8::UniquePersistent<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(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();
+// }
-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/bindings/eina_js/eina_js_container.hh b/src/bindings/eina_js/eina_js_container.hh
index 7328b71d52..aefe61f5a6 100644
--- a/src/bindings/eina_js/eina_js_container.hh
+++ b/src/bindings/eina_js/eina_js_container.hh
@@ -3,7 +3,9 @@
#include <algorithm>
-namespace efl { namespace js {
+#include <eina_js_compatibility.hh>
+
+namespace efl { namespace eina { namespace js {
enum container_type
{
@@ -44,7 +46,7 @@ struct eina_container_type_specific
{
v8::Local<v8::Value> get(v8::Isolate* isolate, std::size_t index) const
{
- return v8::Number::New(isolate, *std::next(container_get().begin(), index));
+ return efl::eina::js::compatibility_new<v8::Number>(isolate, *std::next(container_get().begin(), index));
}
int index_of(v8::Isolate*, v8::Local<v8::Value> v) const
{
@@ -84,6 +86,6 @@ struct eina_container_type_specific
C const& container_get() const { return static_cast<eina_container_common<C>const&>(*this)._container; }
};
-} }
+} } }
#endif
diff --git a/src/bindings/eina_js/eina_js_error.cc b/src/bindings/eina_js/eina_js_error.cc
index fceffb1492..a80f486233 100644
--- a/src/bindings/eina_js/eina_js_error.cc
+++ b/src/bindings/eina_js/eina_js_error.cc
@@ -3,6 +3,7 @@
#endif
#include <eina_js_error.hh>
+#include <eina_js_compatibility.hh>
namespace efl { namespace eina {namespace js {
@@ -17,12 +18,12 @@ void convert_error_to_javascript_exception(v8::Isolate *isolate)
if (!err)
return;
- Local<Object> je = compatibility_new<v8::Object>(isolate);
- je->Set(String::NewFromUtf8(isolate, "code"),
- String::NewFromUtf8(isolate, "Eina_Error"));
- je->Set(String::NewFromUtf8(isolate, "value"),
- String::NewFromUtf8(isolate, eina_error_msg_get(err)));
- isolate->ThrowException(je);
+ Local<Object> je = eina::js::compatibility_new<v8::Object>(isolate);
+ je->Set(compatibility_new<v8::String>(isolate, "code"),
+ compatibility_new<v8::String>(isolate, "Eina_Error"));
+ je->Set(compatibility_new<v8::String>(isolate, "value"),
+ compatibility_new<v8::String>(isolate, eina_error_msg_get(err)));
+ compatibility_throw(isolate, je);
}
} } } // namespace efl { namespace js {
diff --git a/src/bindings/eina_js/eina_js_iterator.cc b/src/bindings/eina_js/eina_js_iterator.cc
index dfacd65d55..92e4f15321 100644
--- a/src/bindings/eina_js/eina_js_iterator.cc
+++ b/src/bindings/eina_js/eina_js_iterator.cc
@@ -2,35 +2,34 @@
#include <config.h>
#endif
+#include <Eina.hh>
#include <eina_js_iterator.hh>
+#include <eina_js_compatibility.hh>
-namespace efl { namespace js {
+#include V8_INCLUDE_HEADER
+
+namespace efl { namespace eina { namespace js {
EAPI
void register_destroy_iterator(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
v8::Handle<v8::String> name)
{
- using v8::Value;
- using v8::Object;
- using v8::Handle;
- using v8::FunctionTemplate;
- using v8::FunctionCallbackInfo;
-
typedef void (*deleter_t)(void*);
- auto f = [](const FunctionCallbackInfo<Value> &info) {
+ auto f = [](compatibility_callback_info_type info) -> compatibility_return_type
+ {
if (info.Length() != 1 || !info[0]->IsObject())
- return;
+ return compatibility_return();
- Handle<Object> o = info[0]->ToObject();
+ v8::Handle<v8::Object> o = info[0]->ToObject();
- deleter_t deleter = reinterpret_cast<deleter_t>
- (o->GetAlignedPointerFromInternalField(1));
- deleter(o->GetAlignedPointerFromInternalField(0));
- };
+ deleter_t deleter = compatibility_get_pointer_internal_field<deleter_t>(o, 1);
+ deleter(compatibility_get_pointer_internal_field<>(o, 0));
+ return compatibility_return();
+ };
- global->Set(name, FunctionTemplate::New(isolate, f)->GetFunction());
+ global->Set(name, compatibility_new<v8::FunctionTemplate>(isolate, f)->GetFunction());
}
-} } // namespace efl { namespace js {
+} } } // namespace efl { namespace js {
diff --git a/src/bindings/eina_js/eina_js_iterator.hh b/src/bindings/eina_js/eina_js_iterator.hh
index cebaf79a83..bcf575eba4 100644
--- a/src/bindings/eina_js/eina_js_iterator.hh
+++ b/src/bindings/eina_js/eina_js_iterator.hh
@@ -7,7 +7,7 @@
#include <eina_js_value.hh>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
/* Exports the \p iterator to be manipulated by the JS code. The iterator should
remain alive as long as there is JS code referencing it. The JS code is able
@@ -23,67 +23,69 @@ namespace efl { namespace js {
template<class T>
v8::Local<v8::Object> export_iterator(::efl::eina::iterator<T> *i,
v8::Isolate *isolate)
-{
- using v8::Local;
- using v8::Value;
- using v8::Object;
- using v8::String;
- using v8::FunctionCallbackInfo;
- using v8::FunctionTemplate;
- using v8::ObjectTemplate;
-
- typedef ::efl::eina::iterator<T> value_type;
- typedef value_type *ptr_type;
- typedef void (*deleter_t)(void*);
-
- auto obj_tpl = ObjectTemplate::New(isolate);
- obj_tpl->SetInternalFieldCount(2);
-
- auto ret = obj_tpl->NewInstance();
-
- auto next = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- void *ptr = info.This()->GetAlignedPointerFromInternalField(0);
- auto &value = *static_cast<ptr_type>(ptr);
- Local<Object> o = v8::Object::New(info.GetIsolate());
- o->Set(String::NewFromUtf8(info.GetIsolate(), "value"),
- value_cast<Local<Value>>(*value, info.GetIsolate()));
- info.GetReturnValue().Set(o);
- ++value;
- };
-
- ret->Set(String::NewFromUtf8(isolate, "next"),
- FunctionTemplate::New(isolate, next)->GetFunction());
-
- {
- deleter_t deleter = [](void *i) {
- delete static_cast<ptr_type>(i);
- };
- ret->SetAlignedPointerInInternalField(0, i);
- ret->SetAlignedPointerInInternalField(1,
- reinterpret_cast<void*>(deleter));
- }
-
- return ret;
-}
+ ;
+// {
+// using v8::Local;
+// using v8::Value;
+// using v8::Object;
+// using v8::String;
+// using v8::FunctionCallbackInfo;
+// using v8::FunctionTemplate;
+// using v8::ObjectTemplate;
+
+// typedef ::efl::eina::iterator<T> value_type;
+// typedef value_type *ptr_type;
+// typedef void (*deleter_t)(void*);
+
+// auto obj_tpl = ObjectTemplate::New(isolate);
+// obj_tpl->SetInternalFieldCount(2);
+
+// auto ret = obj_tpl->NewInstance();
+
+// auto next = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// void *ptr = info.This()->GetAlignedPointerFromInternalField(0);
+// auto &value = *static_cast<ptr_type>(ptr);
+// Local<Object> o = v8::Object::New(info.GetIsolate());
+// o->Set(String::NewFromUtf8(info.GetIsolate(), "value"),
+// value_cast<Local<Value>>(*value, info.GetIsolate()));
+// info.GetReturnValue().Set(o);
+// ++value;
+// };
+
+// ret->Set(String::NewFromUtf8(isolate, "next"),
+// FunctionTemplate::New(isolate, next)->GetFunction());
+
+// {
+// deleter_t deleter = [](void *i) {
+// delete static_cast<ptr_type>(i);
+// };
+// ret->SetAlignedPointerInInternalField(0, i);
+// ret->SetAlignedPointerInInternalField(1,
+// reinterpret_cast<void*>(deleter));
+// }
+
+// return ret;
+// }
/* Extracts and returns a copy from the internal iterator object from the JS
object. */
template<class T>
::efl::eina::iterator<T> *import_iterator(v8::Handle<v8::Object> o)
-{
- typedef ::efl::eina::iterator<T> value_type;
- typedef value_type *ptr_type;
+ ;
+// {
+// typedef ::efl::eina::iterator<T> value_type;
+// typedef value_type *ptr_type;
- return reinterpret_cast<ptr_type>(o->GetAlignedPointerFromInternalField(0));
-}
+// return reinterpret_cast<ptr_type>(o->GetAlignedPointerFromInternalField(0));
+// }
void register_destroy_iterator(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
v8::Handle<v8::String> name);
-} } // namespace efl::js
+} } } // namespace efl::js
#endif /* EINA_JS_ITERATOR_HH */
diff --git a/src/bindings/eina_js/eina_js_list.hh b/src/bindings/eina_js/eina_js_list.hh
index 420e7ed7f4..b45a9fddf2 100644
--- a/src/bindings/eina_js/eina_js_list.hh
+++ b/src/bindings/eina_js/eina_js_list.hh
@@ -9,7 +9,7 @@
#include <iterator>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
template <typename C>
struct eina_container_common : eina_container_type_specific<C, typename C::value_type>
@@ -122,6 +122,6 @@ struct range_eina_list : eina_container_common<efl::eina::range_list<T> >
js::container_type get_container_type() const { return list_container_type; }
};
-} }
+} } }
#endif
diff --git a/src/bindings/eina_js/eina_js_log.cc b/src/bindings/eina_js/eina_js_log.cc
index c9d34c5f55..ce29312823 100644
--- a/src/bindings/eina_js/eina_js_log.cc
+++ b/src/bindings/eina_js/eina_js_log.cc
@@ -2,611 +2,611 @@
#include <config.h>
#endif
-#include <string>
-#include <eina_js_log.hh>
-#include <eina_js_value.hh>
-#include <eina_js_compatibility.hh>
-
-namespace efl { namespace eina { namespace js {
-
-v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
- va_list args)
-{
-#if 0
- /* TODO: unfortunately, the elegant and exception-safe version isn't
- compiling (yet!) */
- efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args),
- efl::eina::steal_stringshare_ref);
- return v8::String::NewFromUtf8(isolate, s.data(), v8::String::kNormalString,
- s.size());
-#else
- auto s = eina_stringshare_vprintf(fmt, args);
- auto ret = compatibility_new<v8::String>(isolate, s);
- eina_stringshare_del(s);
- return ret;
-#endif
-}
-
-static struct {
- void reset(v8::Isolate *isolate, v8::Handle<v8::Value> functor)
- {
- persistent.Reset(isolate, functor);
- this->isolate = isolate;
- }
-
- v8::Local<v8::Value> functor()
- {
- return v8::Local<v8::Value>::New(isolate, persistent);
- }
-
- v8::Persistent<v8::Value, v8::CopyablePersistentTraits<v8::Value>>
- persistent;
- v8::Isolate *isolate;
-} js_eina_log_print_cb_data;
-
-static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
- const char *file, const char *fnc, int line,
- const char *fmt, void */*data*/, va_list args)
-{
- v8::Isolate *const isolate = js_eina_log_print_cb_data.isolate;
- constexpr unsigned argc = 7;
-
- v8::Handle<v8::Value> argv[argc] = {
- v8::String::NewFromUtf8(isolate, d->name, v8::String::kNormalString,
- d->namelen),
- v8::String::NewFromUtf8(isolate, d->color),
- v8::Integer::New(isolate, static_cast<int>(level)),
- v8::String::NewFromUtf8(isolate, file),
- v8::String::NewFromUtf8(isolate, fnc),
- v8::Integer::New(isolate, line),
- to_v8_string(isolate, fmt, args)
- };
-
- auto o = js_eina_log_print_cb_data.functor();
- v8::Function::Cast(*o)->Call(v8::Undefined(isolate), argc, argv);
-}
-
-static bool valid_level_conversion(int src, Eina_Log_Level &dst)
-{
- if (src != EINA_LOG_LEVEL_CRITICAL && src != EINA_LOG_LEVEL_ERR
- && src != EINA_LOG_LEVEL_WARN && src != EINA_LOG_LEVEL_INFO
- && src != EINA_LOG_LEVEL_DBG)
- return false;
-
- dst = static_cast<Eina_Log_Level>(src);
- return true;
-}
-
-EAPI
-void register_log_level_critical(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_LEVEL_CRITICAL;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_LEVEL_ERR;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_level_warn(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_LEVEL_WARN;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_level_info(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_LEVEL_INFO;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_LEVEL_DBG;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_domain_global(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_DOMAIN_GLOBAL;
- global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
-}
-
-EAPI
-void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::String;
- using v8::StackTrace;
- using v8::FunctionTemplate;
-
- auto print = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber()
- || !info[2]->IsString())
- return;
-
- Eina_Log_Level level;
- if (!valid_level_conversion(info[1]->NumberValue(), level))
- return;
-
- auto frame = StackTrace::CurrentStackTrace(info.GetIsolate(), 1,
- StackTrace::kDetailed)
- ->GetFrame(0);
-
- eina_log_print(info[0]->NumberValue(), level,
- *String::Utf8Value(frame->GetScriptNameOrSourceURL()),
- *String::Utf8Value(frame->GetFunctionName()),
- frame->GetLineNumber(), "%s",
- *String::Utf8Value(info[2]));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, print)->GetFunction());
-}
-
-EAPI
-void register_log_domain_register(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Local;
- using v8::String;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsString())
- return;
-
- int d = eina_log_domain_register(*String::Utf8Value(info[0]),
- *String::Utf8Value(info[1]));
- info.GetReturnValue().Set(value_cast<Local<Value>>
- (d, info.GetIsolate()));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_domain_unregister(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- eina_log_domain_unregister(info[0]->NumberValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_domain_registered_level_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Local;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- int l = eina_log_domain_registered_level_get(info[0]->NumberValue());
- info.GetReturnValue().Set(value_cast<Local<Value>>
- (l, info.GetIsolate()));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_domain_registered_level_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 2 || !info[0]->IsNumber() || !info[1]->IsNumber())
- return;
-
- eina_log_domain_registered_level_set(info[0]->NumberValue(),
- info[1]->NumberValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_print_cb_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsFunction())
- return;
-
- js_eina_log_print_cb_data.reset(info.GetIsolate(), info[0]);
- eina_log_print_cb_set(js_eina_log_print_cb, NULL);
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- eina_log_level_set(info[0]->NumberValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::Integer;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- int l = eina_log_level_get();
- info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_level_check(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::Boolean;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- bool b = eina_log_level_check(info[0]->NumberValue());
- info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_color_disable_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsBoolean())
- return;
-
- eina_log_color_disable_set(info[0]->BooleanValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_color_disable_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Boolean;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- bool b = eina_log_color_disable_get();
- info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_file_disable_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsBoolean())
- return;
-
- eina_log_file_disable_set(info[0]->BooleanValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_file_disable_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Boolean;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- bool b = eina_log_file_disable_get();
- info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_function_disable_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsBoolean())
- return;
-
- eina_log_function_disable_set(info[0]->BooleanValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_function_disable_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Boolean;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- bool b = eina_log_function_disable_get();
- info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_abort_on_critical_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsBoolean())
- return;
-
- eina_log_abort_on_critical_set(info[0]->BooleanValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_abort_on_critical_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::Boolean;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- bool b = eina_log_abort_on_critical_get();
- info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsNumber())
- return;
-
- eina_log_abort_on_critical_level_set(info[0]->NumberValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::Integer;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 0)
- return;
-
- int l = eina_log_abort_on_critical_level_get();
- info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_domain_level_set(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::String;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsNumber())
- return;
-
- eina_log_domain_level_set(*String::Utf8Value(info[0]),
- info[1]->NumberValue());
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_domain_level_get(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::String;
- using v8::Integer;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1 || !info[0]->IsString())
- return;
-
- int l = eina_log_domain_level_get(*String::Utf8Value(info[0]));
- info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-EAPI
-void register_log_state_start(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_STATE_START;
- global->Set(name, v8::Integer::New(isolate, value));
-}
-
-EAPI
-void register_log_state_stop(v8::Isolate *isolate,
- v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- int value = EINA_LOG_STATE_STOP;
- global->Set(name, v8::Integer::New(isolate, value));
-}
-
-EAPI
-void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::FunctionCallbackInfo;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::String;
-
- auto func = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber()
- || !info[2]->IsString())
- return;
-
- eina_log_timing(info[0]->NumberValue(),
- static_cast<Eina_Log_State>(info[1]->NumberValue()),
- *String::Utf8Value(info[2]));
- };
-
- global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
-}
-
-} } } // namespace efl { namespace js {
+// #include <string>
+// #include <eina_js_log.hh>
+// #include <eina_js_value.hh>
+// #include <eina_js_compatibility.hh>
+
+// namespace efl { namespace eina { namespace js {
+
+// v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
+// va_list args)
+// {
+// #if 0
+// /* TODO: unfortunately, the elegant and exception-safe version isn't
+// compiling (yet!) */
+// efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args),
+// efl::eina::steal_stringshare_ref);
+// return v8::String::NewFromUtf8(isolate, s.data(), v8::String::kNormalString,
+// s.size());
+// #else
+// auto s = eina_stringshare_vprintf(fmt, args);
+// auto ret = compatibility_new<v8::String>(isolate, s);
+// eina_stringshare_del(s);
+// return ret;
+// #endif
+// }
+
+// static struct {
+// void reset(v8::Isolate *isolate, v8::Handle<v8::Value> functor)
+// {
+// persistent.Reset(isolate, functor);
+// // this->isolate = isolate;
+// }
+
+// v8::Local<v8::Value> functor()
+// {
+// return v8::Local<v8::Value>::New(v8::Isolate::GetIsolate(), persistent);
+// }
+
+// v8::Persistent<v8::Value/*, v8::CopyablePersistentTraits<v8::Value>*/>
+// persistent;
+// // v8::Isolate *isolate;
+// } js_eina_log_print_cb_data;
+
+// static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
+// const char *file, const char *fnc, int line,
+// const char *fmt, void */*data*/, va_list args)
+// {
+// v8::Isolate *const isolate = js_eina_log_print_cb_data.isolate;
+// constexpr unsigned argc = 7;
+
+// v8::Handle<v8::Value> argv[argc] = {
+// v8::String::NewFromUtf8(isolate, d->name, v8::String::kNormalString,
+// d->namelen),
+// v8::String::NewFromUtf8(isolate, d->color),
+// v8::Integer::New(isolate, static_cast<int>(level)),
+// v8::String::NewFromUtf8(isolate, file),
+// v8::String::NewFromUtf8(isolate, fnc),
+// v8::Integer::New(isolate, line),
+// to_v8_string(isolate, fmt, args)
+// };
+
+// auto o = js_eina_log_print_cb_data.functor();
+// v8::Function::Cast(*o)->Call(v8::Undefined(isolate), argc, argv);
+// }
+
+// static bool valid_level_conversion(int src, Eina_Log_Level &dst)
+// {
+// if (src != EINA_LOG_LEVEL_CRITICAL && src != EINA_LOG_LEVEL_ERR
+// && src != EINA_LOG_LEVEL_WARN && src != EINA_LOG_LEVEL_INFO
+// && src != EINA_LOG_LEVEL_DBG)
+// return false;
+
+// dst = static_cast<Eina_Log_Level>(src);
+// return true;
+// }
+
+// EAPI
+// void register_log_level_critical(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_LEVEL_CRITICAL;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_LEVEL_ERR;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_level_warn(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_LEVEL_WARN;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_level_info(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_LEVEL_INFO;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_LEVEL_DBG;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_domain_global(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_DOMAIN_GLOBAL;
+// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
+// }
+
+// EAPI
+// void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::String;
+// using v8::StackTrace;
+// using v8::FunctionTemplate;
+
+// auto print = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber()
+// || !info[2]->IsString())
+// return;
+
+// Eina_Log_Level level;
+// if (!valid_level_conversion(info[1]->NumberValue(), level))
+// return;
+
+// auto frame = StackTrace::CurrentStackTrace(info.GetIsolate(), 1,
+// StackTrace::kDetailed)
+// ->GetFrame(0);
+
+// eina_log_print(info[0]->NumberValue(), level,
+// *String::Utf8Value(frame->GetScriptNameOrSourceURL()),
+// *String::Utf8Value(frame->GetFunctionName()),
+// frame->GetLineNumber(), "%s",
+// *String::Utf8Value(info[2]));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, print)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_register(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Local;
+// using v8::String;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsString())
+// return;
+
+// int d = eina_log_domain_register(*String::Utf8Value(info[0]),
+// *String::Utf8Value(info[1]));
+// info.GetReturnValue().Set(value_cast<Local<Value>>
+// (d, info.GetIsolate()));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_unregister(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// eina_log_domain_unregister(info[0]->NumberValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_registered_level_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Local;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// int l = eina_log_domain_registered_level_get(info[0]->NumberValue());
+// info.GetReturnValue().Set(value_cast<Local<Value>>
+// (l, info.GetIsolate()));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_registered_level_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 2 || !info[0]->IsNumber() || !info[1]->IsNumber())
+// return;
+
+// eina_log_domain_registered_level_set(info[0]->NumberValue(),
+// info[1]->NumberValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_print_cb_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsFunction())
+// return;
+
+// js_eina_log_print_cb_data.reset(info.GetIsolate(), info[0]);
+// eina_log_print_cb_set(js_eina_log_print_cb, NULL);
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// eina_log_level_set(info[0]->NumberValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::Integer;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// int l = eina_log_level_get();
+// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_level_check(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::Boolean;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// bool b = eina_log_level_check(info[0]->NumberValue());
+// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_color_disable_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsBoolean())
+// return;
+
+// eina_log_color_disable_set(info[0]->BooleanValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_color_disable_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Boolean;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// bool b = eina_log_color_disable_get();
+// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_file_disable_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsBoolean())
+// return;
+
+// eina_log_file_disable_set(info[0]->BooleanValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_file_disable_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Boolean;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// bool b = eina_log_file_disable_get();
+// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_function_disable_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsBoolean())
+// return;
+
+// eina_log_function_disable_set(info[0]->BooleanValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_function_disable_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Boolean;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// bool b = eina_log_function_disable_get();
+// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_abort_on_critical_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsBoolean())
+// return;
+
+// eina_log_abort_on_critical_set(info[0]->BooleanValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_abort_on_critical_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::Boolean;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// bool b = eina_log_abort_on_critical_get();
+// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsNumber())
+// return;
+
+// eina_log_abort_on_critical_level_set(info[0]->NumberValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::Integer;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 0)
+// return;
+
+// int l = eina_log_abort_on_critical_level_get();
+// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_level_set(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::String;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsNumber())
+// return;
+
+// eina_log_domain_level_set(*String::Utf8Value(info[0]),
+// info[1]->NumberValue());
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_domain_level_get(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::String;
+// using v8::Integer;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1 || !info[0]->IsString())
+// return;
+
+// int l = eina_log_domain_level_get(*String::Utf8Value(info[0]));
+// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// EAPI
+// void register_log_state_start(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_STATE_START;
+// global->Set(name, v8::Integer::New(isolate, value));
+// }
+
+// EAPI
+// void register_log_state_stop(v8::Isolate *isolate,
+// v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// int value = EINA_LOG_STATE_STOP;
+// global->Set(name, v8::Integer::New(isolate, value));
+// }
+
+// EAPI
+// void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::FunctionCallbackInfo;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::String;
+
+// auto func = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber()
+// || !info[2]->IsString())
+// return;
+
+// eina_log_timing(info[0]->NumberValue(),
+// static_cast<Eina_Log_State>(info[1]->NumberValue()),
+// *String::Utf8Value(info[2]));
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction());
+// }
+
+// } } } // namespace efl { namespace js {
diff --git a/src/bindings/eina_js/eina_js_log.hh b/src/bindings/eina_js/eina_js_log.hh
index 58a852c3d5..40bf16b204 100644
--- a/src/bindings/eina_js/eina_js_log.hh
+++ b/src/bindings/eina_js/eina_js_log.hh
@@ -5,7 +5,7 @@
#include <Eina.hh>
#include <type_traits>
-namespace efl { namespace js {
+namespace efl { namespace eina { namespace js {
void register_log_level_critical(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
@@ -121,6 +121,6 @@ void register_log_state_stop(v8::Isolate *isolate,
void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
v8::Handle<v8::String> name);
-} } // namespace efl::js
+} } } // namespace efl::js
#endif /* EINA_JS_LOG_HH */
diff --git a/src/bindings/eina_js/eina_js_value.cc b/src/bindings/eina_js/eina_js_value.cc
index 4c91e10b0b..2877d8a3ce 100644
--- a/src/bindings/eina_js/eina_js_value.cc
+++ b/src/bindings/eina_js/eina_js_value.cc
@@ -1,132 +1,132 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <eina_js_value.hh>
-#include <eina_js_compatibility.hh>
-
-namespace efl { namespace eina { namespace js {
-
-namespace {
-
-compatibility_return_type eina_value_set(compatibility_callback_info_type args)
-{
- if (args.Length() != 1)
- return compatibility_return(args);
-
- void *ptr = args.Holder()->GetAlignedPointerFromInternalField(0);
- Isolate *isolate = args.GetIsolate();
- try {
- *static_cast<ptr_type>(ptr) = value_cast<value_type>(info[0]);
- } catch(const std::bad_cast &e) {
- Local<Object> je = Object::New(isolate);
- je->Set(String::NewFromUtf8(isolate, "code"),
- String::NewFromUtf8(isolate, "std::bad_cast"));
- isolate->ThrowException(je);
- } catch(const ::efl::eina::system_error &e) {
- Local<Object> je = Object::New(isolate);
- je->Set(String::NewFromUtf8(isolate, "code"),
- String::NewFromUtf8(isolate, "std::error_code"));
- je->Set(String::NewFromUtf8(isolate, "category"),
- String::NewFromUtf8(isolate, e.code().category().name()));
- je->Set(String::NewFromUtf8(isolate, "value"),
- Integer::New(isolate, e.code().value()));
- isolate->ThrowException(je);
- }
-}
-
-compatibility_return_type eina_value_get(compatibility_callback_info_type args)
-{
- void *ptr = info.Holder()->GetAlignedPointerFromInternalField(0);
- auto &value = *static_cast<ptr_type>(ptr);
- info.GetReturnValue().Set(value_cast<Local<Value>>
- (value, info.GetIsolate()));
-}
-
-compatibility_return_type eina_value_constructor(compatibility_callback_info_type args)
-{
- if (info.Length() != 1)
- return;
-
- try {
- std::unique_ptr<value_type>
- ptr(new value_type(value_cast<value_type>(info[0])));
- ret->SetAlignedPointerInInternalField(0, ptr.get());
- ptr.release();
- } catch(const std::bad_cast &e) {
- Local<Object> je = Object::New(isolate);
- je->Set(String::NewFromUtf8(isolate, "code"),
- String::NewFromUtf8(isolate, "std::bad_cast"));
- isolate->ThrowException(je);
- } catch(const ::efl::eina::system_error &e) {
- Local<Object> je = Object::New(isolate);
- je->Set(String::NewFromUtf8(isolate, "code"),
- String::NewFromUtf8(isolate, "std::error_code"));
- je->Set(String::NewFromUtf8(isolate, "category"),
- String::NewFromUtf8(isolate, e.code().category().name()));
- je->Set(String::NewFromUtf8(isolate, "value"),
- Integer::New(isolate, e.code().value()));
- isolate->ThrowException(je);
- }
-}
-
-}
+// #ifdef HAVE_CONFIG_H
+// #include <config.h>
+// #endif
+
+// #include <eina_js_value.hh>
+// #include <eina_js_compatibility.hh>
+
+// namespace efl { namespace eina { namespace js {
+
+// namespace {
+
+// compatibility_return_type eina_value_set(compatibility_callback_info_type args)
+// {
+// if (args.Length() != 1)
+// return compatibility_return();
+
+// void *ptr = args.Holder()->GetAlignedPointerFromInternalField(0);
+// v8::Isolate *isolate = args.GetIsolate();
+// try {
+// *static_cast<ptr_type>(ptr) = value_cast<value_type>(info[0]);
+// } catch(const std::bad_cast &e) {
+// Local<Object> je = Object::New(isolate);
+// je->Set(String::NewFromUtf8(isolate, "code"),
+// String::NewFromUtf8(isolate, "std::bad_cast"));
+// isolate->ThrowException(je);
+// } catch(const ::efl::eina::system_error &e) {
+// Local<Object> je = Object::New(isolate);
+// je->Set(String::NewFromUtf8(isolate, "code"),
+// String::NewFromUtf8(isolate, "std::error_code"));
+// je->Set(String::NewFromUtf8(isolate, "category"),
+// String::NewFromUtf8(isolate, e.code().category().name()));
+// je->Set(String::NewFromUtf8(isolate, "value"),
+// Integer::New(isolate, e.code().value()));
+// isolate->ThrowException(je);
+// }
+// }
+
+// compatibility_return_type eina_value_get(compatibility_callback_info_type args)
+// {
+// void *ptr = info.Holder()->GetAlignedPointerFromInternalField(0);
+// auto &value = *static_cast<ptr_type>(ptr);
+// info.GetReturnValue().Set(value_cast<Local<Value>>
+// (value, info.GetIsolate()));
+// }
+
+// compatibility_return_type eina_value_constructor(compatibility_callback_info_type args)
+// {
+// if (info.Length() != 1)
+// return;
+
+// try {
+// std::unique_ptr<value_type>
+// ptr(new value_type(value_cast<value_type>(info[0])));
+// ret->SetAlignedPointerInInternalField(0, ptr.get());
+// ptr.release();
+// } catch(const std::bad_cast &e) {
+// Local<Object> je = Object::New(isolate);
+// je->Set(String::NewFromUtf8(isolate, "code"),
+// String::NewFromUtf8(isolate, "std::bad_cast"));
+// isolate->ThrowException(je);
+// } catch(const ::efl::eina::system_error &e) {
+// Local<Object> je = Object::New(isolate);
+// je->Set(String::NewFromUtf8(isolate, "code"),
+// String::NewFromUtf8(isolate, "std::error_code"));
+// je->Set(String::NewFromUtf8(isolate, "category"),
+// String::NewFromUtf8(isolate, e.code().category().name()));
+// je->Set(String::NewFromUtf8(isolate, "value"),
+// Integer::New(isolate, e.code().value()));
+// isolate->ThrowException(je);
+// }
+// }
+
+// }
-EAPI
-void register_make_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::Isolate;
- using v8::Local;
- using v8::Value;
- using v8::Integer;
- using v8::String;
- using v8::Object;
- using v8::FunctionTemplate;
- using v8::FunctionCallbackInfo;
-
- typedef ::efl::eina::value value_type;
- typedef value_type *ptr_type;
-
- v8::FunctionTemplate constructor
- = compatibility_new<FunctionTemplate>(isolate, &eina_value_constructor);
+// EAPI
+// void register_make_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::Isolate;
+// using v8::Local;
+// using v8::Value;
+// using v8::Integer;
+// using v8::String;
+// using v8::Object;
+// using v8::FunctionTemplate;
+// using v8::FunctionCallbackInfo;
+
+// typedef ::efl::eina::value value_type;
+// typedef value_type *ptr_type;
+
+// v8::FunctionTemplate constructor
+// = compatibility_new<FunctionTemplate>(isolate, &eina_value_constructor);
- auto instance = constructor->InstanceTemplate();
- instance_template->SetInternalFieldCount(1);
+// auto instance = constructor->InstanceTemplate();
+// instance_template->SetInternalFieldCount(1);
- auto prototype = constructor->PrototypeTemplate();
+// auto prototype = constructor->PrototypeTemplate();
- prototype->Set(compatibility_new<v8::String>(isolate, "set")
- , compatibility_new<FunctionTemplate>(isolate, &eina_value_set));
- prototype->Set(compatibility_new<v8::String>(isolate, "get")
- , compatibility_new<FunctionTemplate>(isolate, &eina_value_get));
+// prototype->Set(compatibility_new<v8::String>(isolate, "set")
+// , compatibility_new<FunctionTemplate>(isolate, &eina_value_set));
+// prototype->Set(compatibility_new<v8::String>(isolate, "get")
+// , compatibility_new<FunctionTemplate>(isolate, &eina_value_get));
- global->Set(name, constructor->GetFunction());
-}
-
-EAPI
-void register_destroy_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
- v8::Handle<v8::String> name)
-{
- using v8::Local;
- using v8::Value;
- using v8::FunctionTemplate;
- using v8::FunctionCallbackInfo;
-
- typedef ::efl::eina::value value_type;
- typedef value_type *ptr_type;
-
- auto dtor = [](const FunctionCallbackInfo<Value> &info) {
- if (info.Length() != 1)
- return;
-
- auto o = info[0]->ToObject();
- delete static_cast<ptr_type>(o->GetAlignedPointerFromInternalField(0));
- o->SetAlignedPointerInInternalField(0, nullptr);
- assert(o->GetAlignedPointerFromInternalField(0) == nullptr);
- };
-
- global->Set(name, FunctionTemplate::New(isolate, dtor)->GetFunction());
-}
-
-} } } // namespace efl { namespace js {
+// global->Set(name, constructor->GetFunction());
+// }
+
+// EAPI
+// void register_destroy_value(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+// v8::Handle<v8::String> name)
+// {
+// using v8::Local;
+// using v8::Value;
+// using v8::FunctionTemplate;
+// using v8::FunctionCallbackInfo;
+
+// typedef ::efl::eina::value value_type;
+// typedef value_type *ptr_type;
+
+// auto dtor = [](const FunctionCallbackInfo<Value> &info) {
+// if (info.Length() != 1)
+// return;
+
+// auto o = info[0]->ToObject();
+// delete static_cast<ptr_type>(o->GetAlignedPointerFromInternalField(0));
+// o->SetAlignedPointerInInternalField(0, nullptr);
+// assert(o->GetAlignedPointerFromInternalField(0) == nullptr);
+// };
+
+// global->Set(name, FunctionTemplate::New(isolate, dtor)->GetFunction());
+// }
+
+// } } } // namespace efl { namespace js {
diff --git a/src/bindings/eo_js/eo_js_call_function.hh b/src/bindings/eo_js/eo_js_call_function.hh
index 7904b0b4c6..98eadd39a1 100644
--- a/src/bindings/eo_js/eo_js_call_function.hh
+++ b/src/bindings/eo_js/eo_js_call_function.hh
@@ -19,12 +19,12 @@
namespace efl { namespace eo { namespace js {
-inline compatibility_return_type call_function(compatibility_callback_info_type args)
+inline eina::js::compatibility_return_type call_function(eina::js::compatibility_callback_info_type args)
{
std::cerr << "call_function" << std::endl;
void* data = v8::External::Cast(*args.Data())->Value();
- std::function<compatibility_return_type(compatibility_callback_info_type)>*
- f = static_cast<std::function<compatibility_return_type(compatibility_callback_info_type)>*>(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);
}
@@ -40,7 +40,7 @@ struct method_caller
template <typename U, std::size_t I, typename Outs>
static
typename std::tuple_element<I, parameters_t>::type
- get_value(compatibility_callback_info_type args, Outs& /*outs*/, v8::Isolate* isolate
+ get_value(eina::js::compatibility_callback_info_type args, Outs& /*outs*/, v8::Isolate* isolate
, std::false_type)
{
std::cout << "is NOT out" << std::endl;
@@ -55,7 +55,7 @@ struct method_caller
typename std::tuple_element
<eina::_mpl::tuple_find<std::integral_constant<std::size_t, I>, Out>::value
, Outs>::type>::type
- get_value(compatibility_callback_info_type, Outs& outs, v8::Isolate*
+ get_value(eina::js::compatibility_callback_info_type, Outs& outs, v8::Isolate*
, std::true_type)
{
std::cout << "is out" << std::endl;
@@ -65,7 +65,7 @@ struct method_caller
template <typename R>
v8::Handle<v8::Value>
- create_return_unique_value(compatibility_callback_info_type args
+ create_return_unique_value(eina::js::compatibility_callback_info_type args
, R const& r) const
{
return js::get_value_from_c(r, args.GetIsolate());
@@ -73,7 +73,7 @@ struct method_caller
template <typename Outs>
v8::Handle<v8::Value>
- create_return_value(compatibility_callback_info_type args
+ 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
{
@@ -82,7 +82,7 @@ struct method_caller
template <typename Outs>
v8::Handle<v8::Value>
- create_return_value(compatibility_callback_info_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
{
@@ -92,20 +92,20 @@ struct method_caller
template <typename Outs>
v8::Handle<v8::Value>
- create_return_value(compatibility_callback_info_type args
+ create_return_value(eina::js::compatibility_callback_info_type args
, Outs const& outs
, typename std::enable_if<(std::tuple_size<Outs>::value > 1)>::type* = 0) const
{
v8::Isolate* isolate = args.GetIsolate();
int const length = std::tuple_size<Outs>::value;
- v8::Local<v8::Array> ret = compatibility_new<v8::Array>(isolate, length);
+ v8::Local<v8::Array> ret = eina::js::compatibility_new<v8::Array>(isolate, length);
set_return<0u>(isolate, ret, outs, eina::make_index_sequence<std::tuple_size<Outs>::value>());
- return compatibility_return(ret, args);
+ return eina::js::compatibility_return(ret, args);
}
template <typename R, typename Outs>
v8::Handle<v8::Value>
- create_return_value(compatibility_callback_info_type args
+ create_return_value(eina::js::compatibility_callback_info_type args
, R const& r
, Outs const&
, typename std::enable_if<std::tuple_size<Outs>::value == 0>::type* = 0) const
@@ -123,23 +123,23 @@ struct method_caller
}
template <typename R, typename Outs>
- compatibility_return_type
- create_return_value(compatibility_callback_info_type args
+ eina::js::compatibility_return_type
+ create_return_value(eina::js::compatibility_callback_info_type args
, R const& r
, Outs const& outs
, typename std::enable_if<std::tuple_size<Outs>::value != 0>::type* = 0) const
{
v8::Isolate* isolate = args.GetIsolate();
int const length = std::tuple_size<Outs>::value + 1;
- v8::Local<v8::Array> ret = compatibility_new<v8::Array>(isolate, length);
+ v8::Local<v8::Array> ret = eina::js::compatibility_new<v8::Array>(isolate, length);
ret->Set(0, js::get_value_from_c(r, isolate));
set_return<1u>(isolate, ret, outs, eina::make_index_sequence<std::tuple_size<Outs>::value>());
- return compatibility_return(ret, args);
+ return eina::js::compatibility_return(ret, args);
}
template <std::size_t... I>
- compatibility_return_type
- aux(compatibility_callback_info_type args, eina::index_sequence<I...>
+ eina::js::compatibility_return_type
+ aux(eina::js::compatibility_callback_info_type args, eina::index_sequence<I...>
, std::true_type) const
{
typename eina::_mpl::tuple_transform<Out, out_transform<parameters_t> >::type outs {};
@@ -150,7 +150,7 @@ struct method_caller
}
template <std::size_t... I>
- compatibility_return_type aux(compatibility_callback_info_type args, eina::index_sequence<I...>
+ eina::js::compatibility_return_type aux(eina::js::compatibility_callback_info_type args, eina::index_sequence<I...>
, std::false_type) const
{
typename eina::_mpl::tuple_transform<Out, out_transform<parameters_t> >::type outs {};
@@ -171,7 +171,7 @@ struct method_caller
};
};
- compatibility_return_type operator()(compatibility_callback_info_type args)
+ eina::js::compatibility_return_type operator()(eina::js::compatibility_callback_info_type args)
{
std::cerr << "call function operator()(args)" << std::endl;
int input_parameters = std::tuple_size<In>::value;
@@ -184,7 +184,7 @@ struct method_caller
{
eo_do
(eo,
- return compatibility_return
+ 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>())
@@ -193,14 +193,14 @@ struct method_caller
}
catch(std::logic_error const&)
{
- return compatibility_return();
+ return eina::js::compatibility_return();
}
}
else
{
- return compatibility_throw
+ return eina::js::compatibility_throw
(v8::Exception::TypeError
- (compatibility_new<v8::String>(nullptr, "Expected more arguments for this call")));
+ (eina::js::compatibility_new<v8::String>(nullptr, "Expected more arguments for this call")));
}
}
@@ -210,8 +210,8 @@ struct method_caller
template <typename In, typename Out, typename Ownership, typename F>
v8::Handle<v8::Value> call_function_data(v8::Isolate* isolate, F f)
{
- return compatibility_new<v8::External>
- (isolate, new std::function<compatibility_return_type(compatibility_callback_info_type const&)>
+ return eina::js::compatibility_new<v8::External>
+ (isolate, new std::function<eina::js::compatibility_return_type(eina::js::compatibility_callback_info_type const&)>
(method_caller<In, Out, Ownership, F>{f}));
}
diff --git a/src/bindings/eo_js/eo_js_event.hh b/src/bindings/eo_js/eo_js_event.hh
index 9d9056b1fa..928a0ccedc 100644
--- a/src/bindings/eo_js/eo_js_event.hh
+++ b/src/bindings/eo_js/eo_js_event.hh
@@ -35,7 +35,7 @@ inline Eina_Bool event_callback(void* data, Eo* obj, Eo_Event_Description const*
, void* /*event_info*/)
{
event_callback_information* event = static_cast<event_callback_information*>(data);
- v8::Handle<v8::Value> a[] = {compatibility_new<v8::External>(nullptr, obj)};
+ v8::Handle<v8::Value> a[] = {eina::js::compatibility_new<v8::External>(nullptr, obj)};
v8::Local<v8::Object> self = (*event->event_info->constructor)->NewInstance(1, a);
v8::Handle<v8::Value> call_args[] = {self};
@@ -44,7 +44,7 @@ inline Eina_Bool event_callback(void* data, Eo* obj, Eo_Event_Description const*
return EO_CALLBACK_CONTINUE;
}
-inline compatibility_return_type event_call(compatibility_callback_info_type args)
+inline eina::js::compatibility_return_type event_call(eina::js::compatibility_callback_info_type args)
{
if(args.Length() >= 1)
{
@@ -61,7 +61,7 @@ inline compatibility_return_type event_call(compatibility_callback_info_type arg
Eo* eo = static_cast<Eo*>(v8::External::Cast(*external)->Value());
event_callback_information* i = new event_callback_information
- {event, compatibility_new<v8::Persistent<v8::Function> >
+ {event, eina::js::compatibility_new<v8::Persistent<v8::Function> >
(args.GetIsolate()
, v8::Handle<v8::Function>(v8::Function::Cast(*arg1->ToObject())))};
@@ -72,7 +72,7 @@ inline compatibility_return_type event_call(compatibility_callback_info_type arg
else
{
}
- return compatibility_return();
+ return eina::js::compatibility_return();
}
} } }
diff --git a/src/bindings/eo_js/eo_js_get_value.hh b/src/bindings/eo_js/eo_js_get_value.hh
index 1083580915..0ab4a9f136 100644
--- a/src/bindings/eo_js/eo_js_get_value.hh
+++ b/src/bindings/eo_js/eo_js_get_value.hh
@@ -31,9 +31,9 @@ inline int get_value_from_javascript
return v->Uint32Value();
else
{
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
throw std::logic_error("");
}
@@ -56,9 +56,9 @@ inline char* get_value_from_javascript
}
else
{
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
throw std::logic_error("");
}
@@ -92,9 +92,9 @@ inline Eo* get_value_from_javascript
}
}
}
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
throw std::logic_error("");
return nullptr;
}
@@ -112,9 +112,9 @@ inline T get_value_from_javascript
return static_cast<T>(v->Uint32Value());
else
{
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Integral type")));
throw std::logic_error("");
}
@@ -132,9 +132,9 @@ inline int get_value_from_javascript
}
else
{
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected Boolean type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected Boolean type")));
throw std::logic_error("");
}
@@ -154,9 +154,9 @@ inline double get_value_from_javascript
}
else
{
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected floating point type")));
throw std::logic_error("");
}
return 0.0;
@@ -169,9 +169,9 @@ inline T get_value_from_javascript
&& !std::is_enum<T>::value>::type* = 0)
{
std::cerr << "Trying to convert to " << typeid(T).name() << " to call a C function" << std::endl;
- compatibility_throw
+ eina::js::compatibility_throw
(isolate, v8::Exception::TypeError
- (compatibility_new<v8::String>(isolate, "Not implemented yet")));
+ (eina::js::compatibility_new<v8::String>(isolate, "Not implemented yet")));
throw std::logic_error("");
}
diff --git a/src/bindings/eo_js/eo_js_get_value_from_c.hh b/src/bindings/eo_js/eo_js_get_value_from_c.hh
index bf2d2ca89a..074c29462e 100644
--- a/src/bindings/eo_js/eo_js_get_value_from_c.hh
+++ b/src/bindings/eo_js/eo_js_get_value_from_c.hh
@@ -18,7 +18,7 @@ inline v8::Local<v8::Value>
get_value_from_c(T v, v8::Isolate* isolate
, typename std::enable_if<std::is_integral<T>::value && !std::is_same<T,bool>::value>::type* = 0)
{
- return compatibility_new<v8::Integer>(isolate, v);
+ return eina::js::compatibility_new<v8::Integer>(isolate, v);
}
template <typename T>
@@ -26,7 +26,7 @@ inline v8::Local<v8::Value>
get_value_from_c(T v, v8::Isolate* isolate
, typename std::enable_if<std::is_same<T,bool>::value>::type* = 0)
{
- return compatibility_new<v8::Boolean>(isolate, v);
+ return eina::js::compatibility_new<v8::Boolean>(isolate, v);
}
// template <typename T>
@@ -42,13 +42,13 @@ inline v8::Local<v8::Value>
get_value_from_c(T v, v8::Isolate* isolate
, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
{
- return compatibility_new<v8::Number>(isolate, v);
+ return eina::js::compatibility_new<v8::Number>(isolate, v);
}
inline v8::Local<v8::Value>
get_value_from_c(const char* v, v8::Isolate* isolate)
{
- return compatibility_new<v8::String>(isolate, v);
+ return eina::js::compatibility_new<v8::String>(isolate, v);
}
inline v8::Local<v8::Value>
diff --git a/src/tests/eina_js/eina_js_accessor.cc b/src/tests/eina_js/eina_js_accessor.cc
index 925a494c5a..dceebc1d7c 100644
--- a/src/tests/eina_js/eina_js_accessor.cc
+++ b/src/tests/eina_js/eina_js_accessor.cc
@@ -4,13 +4,17 @@
#include <cassert>
#include <eina_js_accessor.hh>
+#include <eina_js_compatibility.hh>
#include <Eo.hh>
+#include <Eina.hh>
-void print(const v8::FunctionCallbackInfo<v8::Value> &args)
+#include <iostream>
+
+efl::eina::js::compatibility_return_type print(efl::eina::js::compatibility_callback_info_type args)
{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -21,6 +25,7 @@ void print(const v8::FunctionCallbackInfo<v8::Value> &args)
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
static const char script[] =
@@ -36,15 +41,15 @@ int main(int argc, char *argv[])
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
- v8::V8::Initialize();
- v8::V8::InitializeICU();
+ efl::eina::js::compatibility_initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::New();
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context
- = v8::Context::New(isolate, NULL, v8::ObjectTemplate::New(isolate));
+ = efl::eina::js::compatibility_new<v8::Context>
+ (isolate, nullptr, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -56,11 +61,11 @@ int main(int argc, char *argv[])
v8::Context::Scope context_scope(context);
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, print)->GetFunction());
- efl::js::register_destroy_accessor(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "destroy_accessor"));
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, print)->GetFunction());
+ efl::eina::js::register_destroy_accessor
+ (isolate, global
+ , efl::eina::js::compatibility_new<v8::String>(isolate, "destroy_accessor"));
Eina_Array *array = [](){
static int impl[2] = {42, 24};
@@ -71,16 +76,16 @@ int main(int argc, char *argv[])
}();
efl::eina::accessor<int> acc(eina_array_accessor_new(array));
- v8::Local<v8::Object> wrapped_acc = efl::js::export_accessor(acc, isolate);
+ v8::Local<v8::Object> wrapped_acc = efl::eina::js::export_accessor(acc, isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "acc"), wrapped_acc);
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "acc"), wrapped_acc);
- assert(efl::js::import_accessor<int>(wrapped_acc)[0] == 42);
+ assert(efl::eina::js::import_accessor<int>(wrapped_acc)[0] == 42);
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope h(isolate);
v8::TryCatch try_catch;
- auto source = v8::String::NewFromUtf8(isolate, script);
+ auto source = efl::eina::js::compatibility_new<v8::String>(isolate, script);
v8::Handle<v8::Script> script = v8::Script::Compile(std::move(source));
assert(!script.IsEmpty());
diff --git a/src/tests/eina_js/eina_js_error.cc b/src/tests/eina_js/eina_js_error.cc
index 5fb22aea7f..4f8ee211ae 100644
--- a/src/tests/eina_js/eina_js_error.cc
+++ b/src/tests/eina_js/eina_js_error.cc
@@ -4,13 +4,14 @@
#include <cassert>
#include <eina_js_error.hh>
+#include <eina_js_compatibility.hh>
#include <Eo.hh>
-void print(const v8::FunctionCallbackInfo<v8::Value> &args)
+efl::eina::js::compatibility_return_type print(efl::eina::js::compatibility_callback_info_type args)
{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -21,18 +22,21 @@ void print(const v8::FunctionCallbackInfo<v8::Value> &args)
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
-void clear_eina_error(const v8::FunctionCallbackInfo<v8::Value> &args)
+efl::eina::js::compatibility_return_type clear_eina_error(efl::eina::js::compatibility_callback_info_type args)
{
eina_error_set(0);
efl::js::convert_error_to_javascript_exception(args.GetIsolate());
+ return efl::eina::js::compatibility_return();
}
-void set_eina_error(const v8::FunctionCallbackInfo<v8::Value> &args)
+efl::eina::js::compatibility_return_type set_eina_error(efl::eina::js::compatibility_callback_info_type args)
{
eina_error_set(eina_error_msg_static_register("foobar"));
efl::js::convert_error_to_javascript_exception(args.GetIsolate());
+ return efl::eina::js::compatibility_return();
}
static const char script[] =
@@ -62,15 +66,15 @@ int main(int argc, char *argv[])
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
- v8::V8::Initialize();
- v8::V8::InitializeICU();
+ efl::eina::js::compatibility_initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::New();
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context
- = v8::Context::New(isolate, NULL, v8::ObjectTemplate::New(isolate));
+ = efl::eina::js::compatibility_new<v8::Context>
+ (isolate, nullptr, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -82,19 +86,19 @@ int main(int argc, char *argv[])
v8::Context::Scope context_scope(context);
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, print)->GetFunction());
- global->Set(v8::String::NewFromUtf8(isolate, "clear_eina_error"),
- v8::FunctionTemplate::New(isolate, clear_eina_error)
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, print)->GetFunction());
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "clear_eina_error"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, clear_eina_error)
->GetFunction());
- global->Set(v8::String::NewFromUtf8(isolate, "set_eina_error"),
- v8::FunctionTemplate::New(isolate, set_eina_error)
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "set_eina_error"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, set_eina_error)
->GetFunction());
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::TryCatch try_catch;
- auto source = v8::String::NewFromUtf8(isolate, script);
+ auto source = efl::eina::js::compatibility_new<v8::String>(isolate, script);
v8::Handle<v8::Script> script = v8::Script::Compile(std::move(source));
assert(!script.IsEmpty());
diff --git a/src/tests/eina_js/eina_js_iterator.cc b/src/tests/eina_js/eina_js_iterator.cc
index 8c559587d4..1bec1ae69f 100644
--- a/src/tests/eina_js/eina_js_iterator.cc
+++ b/src/tests/eina_js/eina_js_iterator.cc
@@ -4,13 +4,17 @@
#include <cassert>
#include <eina_js_iterator.hh>
+#include <eina_js_compatibility.hh>
#include <Eo.hh>
+#include <Eina.hh>
-void print(const v8::FunctionCallbackInfo<v8::Value> &args)
+#include <iostream>
+
+efl::eina::js::compatibility_return_type print(efl::eina::js::compatibility_callback_info_type args)
{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -21,6 +25,7 @@ void print(const v8::FunctionCallbackInfo<v8::Value> &args)
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
static const char script[] =
@@ -36,15 +41,15 @@ int main(int argc, char *argv[])
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
- v8::V8::Initialize();
- v8::V8::InitializeICU();
+ efl::eina::js::compatibility_initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::New();
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context
- = v8::Context::New(isolate, NULL, v8::ObjectTemplate::New(isolate));
+ = efl::eina::js::compatibility_new<v8::Context>
+ (isolate, nullptr, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -56,12 +61,11 @@ int main(int argc, char *argv[])
v8::Context::Scope context_scope(context);
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, print)->GetFunction());
- efl::js
- ::register_destroy_iterator(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "destroy_iterator"));
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, print)->GetFunction());
+ efl::eina::js::register_destroy_iterator
+ (isolate, global
+ , efl::eina::js::compatibility_new<v8::String>(isolate, "destroy_iterator"));
Eina_Array *array = [](){
static int impl[3] = {42, 24, 0};
@@ -73,16 +77,16 @@ int main(int argc, char *argv[])
}();
efl::eina::iterator<int> it(eina_array_iterator_new(array));
- v8::Local<v8::Object> wrapped_it = efl::js::export_iterator(&it, isolate);
+ v8::Local<v8::Object> wrapped_it = efl::eina::js::export_iterator(&it, isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "it"), wrapped_it);
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "it"), wrapped_it);
- assert(**efl::js::import_iterator<int>(wrapped_it) == 42);
+ assert(**efl::eina::js::import_iterator<int>(wrapped_it) == 42);
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::TryCatch try_catch;
- auto source = v8::String::NewFromUtf8(isolate, script);
+ auto source = efl::eina::js::compatibility_new<v8::String>(isolate, script);
v8::Handle<v8::Script> script = v8::Script::Compile(std::move(source));
assert(!script.IsEmpty());
diff --git a/src/tests/eina_js/eina_js_log.cc b/src/tests/eina_js/eina_js_log.cc
index 530d8596fe..c5f4f6fa93 100644
--- a/src/tests/eina_js/eina_js_log.cc
+++ b/src/tests/eina_js/eina_js_log.cc
@@ -8,11 +8,11 @@
#include <eina_js_log.hh>
#include <Eo.hh>
-void print(const v8::FunctionCallbackInfo<v8::Value> &args)
+efl::eina::js::compatibility_return_type print(efl::eina::js::compatibility_callback_info_type args)
{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -23,6 +23,7 @@ void print(const v8::FunctionCallbackInfo<v8::Value> &args)
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
static void eina_log_print_cb_js_test(const Eina_Log_Domain *d,
@@ -141,15 +142,15 @@ int main(int argc, char *argv[])
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
- v8::V8::Initialize();
- v8::V8::InitializeICU();
+ efl::eina::js::compatibility_initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::New();
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context
- = v8::Context::New(isolate, NULL, v8::ObjectTemplate::New(isolate));
+ = efl::eina::js::compatibility_new<v8::Context>
+ (isolate, nullptr, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -161,175 +162,123 @@ int main(int argc, char *argv[])
v8::Context::Scope context_scope(context);
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, print)->GetFunction());
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, print)->GetFunction());
{
int d = eina_log_domain_register("mydomain", "");
eina_log_domain_registered_level_set(d, EINA_LOG_LEVEL_DBG);
- global->Set(v8::String::NewFromUtf8(isolate, "mydomain"),
- efl::js::value_cast<v8::Local<v8::Value>>(d, isolate));
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "mydomain"),
+ efl::eina::js::value_cast<v8::Local<v8::Value>>(d, isolate));
}
- efl::js::register_log_level_critical(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_LEVEL"
- "_CRITICAL"));
- efl::js::register_log_level_err(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_LEVEL_ERR"));
- efl::js::register_log_level_warn(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_LEVEL_WARN"));
- efl::js::register_log_level_info(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_LEVEL_INFO"));
- efl::js::register_log_level_dbg(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_LEVEL_DBG"));
- efl::js::register_log_domain_global(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_DOMAIN"
- "_GLOBAL"));
- efl::js::register_log_print(isolate, global,
- v8::String::NewFromUtf8(isolate, "log_print"));
- efl::js::register_log_domain_register(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_domain"
- "_register"));
- efl::js::register_log_domain_unregister(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_domain"
- "_unregis"
- "ter"));
- efl::js
- ::register_log_domain_registered_level_get(isolate, global,
- v8::String
- ::NewFromUtf8(isolate,
- "log_domain"
- "_registered_level"
- "_get"));
- efl::js
- ::register_log_domain_registered_level_set(isolate, global,
- v8::String
- ::NewFromUtf8(isolate,
- "log_domain"
- "_registered_level"
- "_set"));
- efl::js::register_log_print_cb_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_print_cb"
- "_set"));
- efl::js::register_log_level_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_level_set"));
- efl::js::register_log_level_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_level_get"));
- efl::js::register_log_level_check(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_level"
- "_check"));
- efl::js::register_log_color_disable_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_color"
- "_disable"
- "_set"));
- efl::js::register_log_color_disable_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_color"
- "_disable"
- "_get"));
- efl::js::register_log_file_disable_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_file"
- "_disable"
- "_set"));
- efl::js::register_log_file_disable_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_file"
- "_disable"
- "_get"));
- efl::js
- ::register_log_abort_on_critical_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_set"));
- efl::js
- ::register_log_abort_on_critical_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_get"));
- efl::js
- ::register_log_function_disable_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_function"
- "_disable"
- "_set"));
- efl::js
- ::register_log_function_disable_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_function"
- "_disable"
- "_get"));
- efl::js
- ::register_log_abort_on_critical_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_set"));
- efl::js
- ::register_log_abort_on_critical_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_get"));
- efl::js
- ::register_log_abort_on_critical_level_set(isolate, global,
- v8::String
- ::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_level_set"));
- efl::js
- ::register_log_abort_on_critical_level_get(isolate, global,
- v8::String
- ::NewFromUtf8(isolate,
- "log_abort_on"
- "_critical"
- "_level_get"));
- efl::js::register_log_domain_level_set(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_domain"
- "_level"
- "_set"));
- efl::js::register_log_domain_level_get(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_domain"
- "_level"
- "_get"));
- efl::js::register_log_state_start(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_STATE"
- "_START"));
- efl::js::register_log_state_stop(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "LOG_STATE_STOP"));
- efl::js::register_log_timing(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "log_timing"));
+ efl::eina::js::register_log_level_critical
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>
+ (isolate, "LOG_LEVEL_CRITICAL"));
+ efl::eina::js::register_log_level_err
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_LEVEL_ERR"));
+ efl::eina::js::register_log_level_warn
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_LEVEL_WARN"));
+ efl::eina::js::register_log_level_info
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_LEVEL_INFO"));
+ efl::eina::js::register_log_level_dbg
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_LEVEL_DBG"));
+ efl::eina::js::register_log_domain_global
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_DOMAIN_GLOBAL"));
+ efl::eina::js::register_log_print
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_print"));
+ efl::eina::js::register_log_domain_register
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_register"));
+ efl::eina::js::register_log_domain_unregister
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_unregister"));
+ efl::eina::js::register_log_domain_registered_level_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_registered_level_get"));
+ efl::eina::js::register_log_domain_registered_level_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_registered_level_set"));
+ efl::eina::js::register_log_print_cb_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_print_cb_set"));
+ efl::eina::js::register_log_level_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_level_set"));
+ efl::eina::js::register_log_level_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_level_get"));
+ efl::eina::js::register_log_level_check
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_level_check"));
+ efl::eina::js::register_log_color_disable_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_color_disable_set"));
+ efl::eina::js::register_log_color_disable_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_color_disable_get"));
+ efl::eina::js::register_log_file_disable_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_file_disable_set"));
+ efl::eina::js::register_log_file_disable_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_file_disable_get"));
+ efl::eina::js::register_log_abort_on_critical_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_set"));
+ efl::eina::js::register_log_abort_on_critical_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_get"));
+ efl::eina::js::register_log_function_disable_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_function_disable_set"));
+ efl::eina::js::register_log_function_disable_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_function_disable_get"));
+ efl::eina::js::register_log_abort_on_critical_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_set"));
+ efl::eina::js::register_log_abort_on_critical_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_get"));
+ efl::eina::js::register_log_abort_on_critical_level_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_level_set"));
+ efl::eina::js::register_log_abort_on_critical_level_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_abort_on_critical_level_get"));
+ efl::eina::js::register_log_domain_level_set
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_level_set"));
+ efl::eina::js::register_log_domain_level_get
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_domain_level_get"));
+ efl::eina::js::register_log_state_start
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_STATE_START"));
+ efl::eina::js::register_log_state_stop
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "LOG_STATE_STOP"));
+ efl::eina::js::register_log_timing
+ (isolate, global,
+ efl::eina::js::compatibility_new<v8::String>(isolate, "log_timing"));
eina_log_print_cb_set(eina_log_print_cb_js_test, NULL);
eina_log_level_set(EINA_LOG_LEVEL_DBG);
eina_log_abort_on_critical_set(EINA_FALSE);
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = [&]() {
- auto source = v8::String::NewFromUtf8(isolate, raw_script);
- auto filename = v8::String::NewFromUtf8(isolate, "offspring.js");
- return v8::Script::Compile(source, filename);
+ auto source = efl::eina::js::compatibility_new<v8::String>(isolate, raw_script);
+ auto filename = efl::eina::js::compatibility_new<v8::String>(isolate, "offspring.js");
+ return v8::Script::Compile(source, filename);
}();
assert(!script.IsEmpty());
diff --git a/src/tests/eina_js/eina_js_suite.cc b/src/tests/eina_js/eina_js_suite.cc
index dd4c91143d..2c1191cfa8 100644
--- a/src/tests/eina_js/eina_js_suite.cc
+++ b/src/tests/eina_js/eina_js_suite.cc
@@ -70,7 +70,7 @@ bool ExecuteString(v8::Isolate* isolate,
v8::Handle<v8::String> source,
v8::Handle<v8::Value> name)
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::TryCatch try_catch;
v8::ScriptOrigin origin(name);
v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin);
@@ -106,10 +106,11 @@ bool ExecuteString(v8::Isolate* isolate,
}
}
-void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
+efl::eina::js::compatibility_return_type Print(efl::eina::js::compatibility_callback_info_type args)
+{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -121,24 +122,24 @@ void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
EAPI void eina_container_register(v8::Handle<v8::ObjectTemplate> global, v8::Isolate* isolate);
EAPI v8::Handle<v8::FunctionTemplate> get_list_instance_template();
-int main(int argc, char* argv[])
+int main(int, char*[])
{
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
-
- v8::V8::InitializeICU();
- v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
+
+ efl::eina::js::compatibility_initialize();
v8::Isolate* isolate = v8::Isolate::New();
assert(isolate != 0);
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context;
efl::eina::ptr_list<int> list;
@@ -146,13 +147,13 @@ int main(int argc, char* argv[])
list.push_back(new int(10));
list.push_back(new int(15));
- efl::js::range_eina_list<int> raw_list(list.native_handle());
+ efl::eina::js::range_eina_list<int> raw_list(list.native_handle());
{
// Create a template for the global object.
- v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ v8::Handle<v8::ObjectTemplate> global = efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate);
// Bind the global 'print' function to the C++ Print callback.
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, Print));
+ 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"),
@@ -167,7 +168,7 @@ int main(int argc, char* argv[])
// global->Set(v8::String::NewFromUtf8(isolate, "version"),
// v8::FunctionTemplate::New(isolate, Version));
- context = v8::Context::New(isolate, NULL, global);
+ context = efl::eina::js::compatibility_new<v8::Context>(isolate, nullptr, global);
}
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -177,15 +178,16 @@ int main(int argc, char* argv[])
{
// Enter the execution environment before evaluating any code.
v8::Context::Scope context_scope(context);
- v8::Local<v8::String> name(v8::String::NewFromUtf8(context->GetIsolate(), "(shell)"));
+ v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String>
+ (nullptr, "(shell)"));
- v8::Handle<v8::Value> a[] = {v8::External::New(isolate, &raw_list)};
- context->Global()->Set(v8::String::NewFromUtf8(isolate, "raw_list")
+ v8::Handle<v8::Value> a[] = {efl::eina::js::compatibility_new<v8::External>(isolate, &raw_list)};
+ context->Global()->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "raw_list")
, get_list_instance_template()->GetFunction()->NewInstance(1, a));
- v8::HandleScope handle_scope(context->GetIsolate());
- ExecuteString(context->GetIsolate(),
- v8::String::NewFromUtf8(context->GetIsolate(), script),
+ efl::eina::js::compatibility_handle_scope handle_scope(v8::Isolate::GetCurrent());
+ ExecuteString(v8::Isolate::GetCurrent(),
+ efl::eina::js::compatibility_new<v8::String>(v8::Isolate::GetCurrent(), script),
name);
}
context->Exit();
diff --git a/src/tests/eina_js/eina_js_value.cc b/src/tests/eina_js/eina_js_value.cc
index 92c8cbdd6d..d9a16137c9 100644
--- a/src/tests/eina_js/eina_js_value.cc
+++ b/src/tests/eina_js/eina_js_value.cc
@@ -6,11 +6,11 @@
#include <eina_js_value.hh>
#include <Eo.hh>
-void print(const v8::FunctionCallbackInfo<v8::Value> &args)
+efl::eina::js::compatibility_return_type print(efl::eina::js::compatibility_callback_info_type args)
{
bool first = true;
for (int i = 0; i < args.Length(); i++) {
- v8::HandleScope handle_scope(args.GetIsolate());
+ efl::eina::js::compatibility_handle_scope handle_scope(args.GetIsolate());
if (first) {
first = false;
} else {
@@ -21,6 +21,7 @@ void print(const v8::FunctionCallbackInfo<v8::Value> &args)
}
printf("\n");
fflush(stdout);
+ return efl::eina::js::compatibility_return();
}
static const char script[] =
@@ -70,15 +71,15 @@ int main(int argc, char *argv[])
efl::eina::eina_init eina_init;
efl::eo::eo_init eo_init;
- v8::V8::Initialize();
- v8::V8::InitializeICU();
+ efl::eina::js::compatibility_initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::New();
v8::Isolate::Scope isolate_scope(isolate);
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::Handle<v8::Context> context
- = v8::Context::New(isolate, NULL, v8::ObjectTemplate::New(isolate));
+ = efl::eina::js::compatibility_new<v8::Context>
+ (isolate, nullptr, efl::eina::js::compatibility_new<v8::ObjectTemplate>(isolate));
if (context.IsEmpty()) {
fprintf(stderr, "Error creating context\n");
@@ -90,182 +91,182 @@ int main(int argc, char *argv[])
v8::Context::Scope context_scope(context);
v8::Handle<v8::Object> global = context->Global();
- global->Set(v8::String::NewFromUtf8(isolate, "print"),
- v8::FunctionTemplate::New(isolate, print)->GetFunction());
- efl::js::register_make_value(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "make_value"));
- efl::js::register_destroy_value(isolate, global,
- v8::String::NewFromUtf8(isolate,
- "destroy_value"));
+ global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "print"),
+ efl::eina::js::compatibility_new<v8::FunctionTemplate>(isolate, print)->GetFunction());
+ efl::eina::js::register_make_value
+ (isolate, global
+ , efl::eina::js::compatibility_new<v8::String>(isolate, "make_value"));
+ efl::eina::js::register_destroy_value
+ (isolate, global
+ , efl::eina::js::compatibility_new<v8::String>(isolate, "destroy_value"));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<uint64_t>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<uint64_t>::max()),
isolate)->NumberValue()
== double(UINT64_MAX));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned char>::max()),
isolate)->IsUint32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned char>::max()),
isolate)->Uint32Value() == UINT8_MAX);
if (sizeof(short) > sizeof(int32_t)) {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned short>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned short>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<unsigned short>::max()));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<short>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<short>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<short>::max()));
} else {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned short>::max()),
isolate)->IsUint32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned short>::max()),
isolate)->Uint32Value()
== std::numeric_limits<unsigned short>::max());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<short>::max()),
isolate)->IsInt32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<short>::max()),
isolate)->Int32Value()
== std::numeric_limits<short>::max());
}
if (sizeof(int) > sizeof(int32_t)) {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned int>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned int>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<unsigned int>::max()));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<int>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<int>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<int>::max()));
} else {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned int>::max()),
isolate)->IsUint32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned int>::max()),
isolate)->Uint32Value()
== std::numeric_limits<unsigned int>::max());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<int>::max()),
isolate)->IsInt32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<int>::max()),
isolate)->Int32Value()
== std::numeric_limits<int>::max());
}
if (sizeof(long) > sizeof(int32_t)) {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned long>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned long>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<unsigned long>::max()));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<long>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<long>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<long>::max()));
} else {
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned long>::max()),
isolate)->IsUint32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<unsigned long>::max()),
isolate)->Uint32Value()
== std::numeric_limits<unsigned long>::max());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<long>::max()),
isolate)->IsInt32());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<long>::max()),
isolate)->Int32Value()
== std::numeric_limits<long>::max());
}
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<float>::max()),
isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::numeric_limits<float>::max()),
isolate)->NumberValue()
== double(std::numeric_limits<float>::max()));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(42.42), isolate)->IsNumber());
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(42.42), isolate)->NumberValue()
== 42.42);
assert(efl::eina::get<int>
- (efl::js::value_cast<efl::eina::value>
- (v8::Boolean::New(isolate, true))) == 1);
+ (efl::eina::js::value_cast<efl::eina::value>
+ (efl::eina::js::compatibility_new<v8::Boolean>(isolate, true))) == 1);
assert(efl::eina::get<int32_t>
- (efl::js::value_cast<efl::eina::value>
- (v8::Integer::New(isolate, INT32_MAX))) == INT32_MAX);
+ (efl::eina::js::value_cast<efl::eina::value>
+ (efl::eina::js::compatibility_new<v8::Integer>(isolate, INT32_MAX))) == INT32_MAX);
assert(efl::eina::get<uint32_t>
- (efl::js::value_cast<efl::eina::value>
- (v8::Integer::NewFromUnsigned(isolate, UINT32_MAX)))
+ (efl::eina::js::value_cast<efl::eina::value>
+ (efl::eina::js::compatibility_new<v8::Integer>(isolate, UINT32_MAX)))
== UINT32_MAX);
assert(efl::eina::get<double>
- (efl::js::value_cast<efl::eina::value>
- (v8::Number::New(isolate,
+ (efl::eina::js::value_cast<efl::eina::value>
+ (efl::eina::js::compatibility_new<v8::Number>(isolate,
std::numeric_limits<double>::max())))
== std::numeric_limits<double>::max());
{
const char utf8_data[] = "MatroŇ°ka";
- assert(efl::js::value_cast<efl::eina::value>
- (v8::String::NewFromUtf8(isolate, utf8_data))
+ assert(efl::eina::js::value_cast<efl::eina::value>
+ (efl::eina::js::compatibility_new<v8::String>(isolate, utf8_data))
== efl::eina::value(std::string(utf8_data)));
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(std::string(utf8_data)), isolate)
- ->StrictEquals(v8::String::NewFromUtf8(isolate, utf8_data)));
+ ->StrictEquals(efl::eina::js::compatibility_new<v8::String>(isolate, utf8_data)));
#ifndef EINA_JS_TEST_SKIP_STRINGSHARE
- assert(efl::js::value_cast<v8::Local<v8::Value>>
+ assert(efl::eina::js::value_cast<v8::Local<v8::Value>>
(efl::eina::value(efl::eina::stringshare(utf8_data)), isolate)
- ->StrictEquals(v8::String::NewFromUtf8(isolate, utf8_data)));
+ ->StrictEquals(efl::eina::js::compatibility_new<v8::String>(isolate, utf8_data)));
#endif // EINA_JS_TEST_SKIP_STRINGSHARE
}
{
- v8::HandleScope handle_scope(isolate);
+ efl::eina::js::compatibility_handle_scope handle_scope(isolate);
v8::TryCatch try_catch;
- auto source = v8::String::NewFromUtf8(isolate, script);
+ auto source = efl::eina::js::compatibility_new<v8::String>(isolate, script);
v8::Handle<v8::Script> script = v8::Script::Compile(std::move(source));
assert(!script.IsEmpty());