aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-09 23:38:19 -0300
committerVinícius dos Santos Oliveira <vini.ipsmaker@expertisesolutions.com.br>2015-06-09 23:38:19 -0300
commitdc48039197e7c315c596dedefca0a0486fd896c3 (patch)
tree02509b4f38cd97b7d773fe0512809a6993c32c0c
parentInitial binding for Ecore_Throttle (diff)
downloadefl-dc48039197e7c315c596dedefca0a0486fd896c3.tar.gz
eina-js: Compatibilization of Eina JS log
-rw-r--r--src/bindings/eina_js/eina_js_log.cc1239
-rw-r--r--src/bindings/eina_js/eina_js_log.hh13
-rw-r--r--src/tests/eina_js/eina_js_suite.cc167
-rw-r--r--[-rwxr-xr-x]src/tests/eina_js/eina_js_suite.js75
4 files changed, 883 insertions, 611 deletions
diff --git a/src/bindings/eina_js/eina_js_log.cc b/src/bindings/eina_js/eina_js_log.cc
index ce29312823..00fbcd3e4e 100644
--- a/src/bindings/eina_js/eina_js_log.cc
+++ b/src/bindings/eina_js/eina_js_log.cc
@@ -2,611 +2,634 @@
#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(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 {
+#include <string>
+#include <eina_js_log.hh>
+#include <eina_js_value.hh>
+#include <eina_js_compatibility.hh>
+
+namespace efl { namespace eina { namespace js {
+
+v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
+ va_list args)
+{
+ using v8::String;
+#if 0
+ /* TODO: unfortunately, the elegant and exception-safe version isn't
+ compiling (yet!) */
+ efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args),
+ efl::eina::steal_stringshare_ref);
+ return compatibility_new<String>(isolate, s.data(), String::kNormalString,
+ s.size());
+#else
+ auto s = eina_stringshare_vprintf(fmt, args);
+ auto ret = compatibility_new<String>(isolate, s);
+ eina_stringshare_del(s);
+ return ret;
+#endif
+}
+
+static compatibility_persistent<v8::Value> js_eina_log_print_cb_data;
+
+static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
+ const char *file, const char *fnc, int line,
+ const char *fmt, void */*data*/, va_list args)
+{
+ using v8::String;
+ using v8::Integer;
+ using v8::Isolate;
+
+ Isolate *const isolate = Isolate::GetCurrent();
+ constexpr unsigned argc = 7;
+
+ v8::Handle<v8::Value> argv[argc] = {
+ compatibility_new<String>(isolate, d->name, String::kNormalString,
+ d->namelen),
+ compatibility_new<String>(isolate, d->color),
+ compatibility_new<Integer>(isolate, static_cast<int>(level)),
+ compatibility_new<String>(isolate, file),
+ compatibility_new<String>(isolate, fnc),
+ compatibility_new<Integer>(isolate, line),
+ to_v8_string(isolate, fmt, args)
+ };
+
+ auto o = js_eina_log_print_cb_data.handle();
+ v8::Function::Cast(*o)->Call(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::Value;
+ using v8::String;
+ using v8::StackTrace;
+ using v8::FunctionTemplate;
+
+ auto print = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
+ || !args[2]->IsString())
+ return compatibility_return();
+
+ Eina_Log_Level level;
+ if (!valid_level_conversion(args[1]->NumberValue(), level))
+ return compatibility_return();
+
+ auto frame = StackTrace::CurrentStackTrace(args.GetIsolate(), 1,
+ StackTrace::kDetailed)
+ ->GetFrame(0);
+
+ eina_log_print(args[0]->NumberValue(), level,
+ *String::Utf8Value(frame->GetScriptNameOrSourceURL()),
+ *String::Utf8Value(frame->GetFunctionName()),
+ frame->GetLineNumber(), "%s",
+ *String::Utf8Value(args[2]));
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, print)
+ ->GetFunction());
+}
+
+EAPI
+void register_log_domain_register(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Local;
+ using v8::String;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
+ return compatibility_return();
+
+ int d = eina_log_domain_register(*String::Utf8Value(args[0]),
+ *String::Utf8Value(args[1]));
+ auto isolate = args.GetIsolate();
+ return compatibility_return(value_cast<Local<Value>>(d, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_domain_unregister(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ eina_log_domain_unregister(args[0]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_domain_registered_level_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Local;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ int l = eina_log_domain_registered_level_get(args[0]->NumberValue());
+ auto isolate = args.GetIsolate();
+ return compatibility_return(value_cast<Local<Value>>(l, isolate), args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_domain_registered_level_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
+ return compatibility_return();
+
+ eina_log_domain_registered_level_set(args[0]->NumberValue(),
+ args[1]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_print_cb_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return compatibility_return();
+
+ js_eina_log_print_cb_data
+ = compatibility_persistent<Value>(args.GetIsolate(), args[0]);
+ eina_log_print_cb_set(js_eina_log_print_cb, NULL);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ eina_log_level_set(args[0]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::Integer;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ int l = eina_log_level_get();
+ auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_level_check(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::Boolean;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ bool b = eina_log_level_check(args[0]->NumberValue());
+ auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_color_disable_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsBoolean())
+ return compatibility_return();
+
+ eina_log_color_disable_set(args[0]->BooleanValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_color_disable_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ bool b = eina_log_color_disable_get();
+ auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_file_disable_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsBoolean())
+ return compatibility_return();
+
+ eina_log_file_disable_set(args[0]->BooleanValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_file_disable_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ bool b = eina_log_file_disable_get();
+ auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_function_disable_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsBoolean())
+ return compatibility_return();
+
+ eina_log_function_disable_set(args[0]->BooleanValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_function_disable_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ bool b = eina_log_function_disable_get();
+ auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_abort_on_critical_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsBoolean())
+ return compatibility_return();
+
+ eina_log_abort_on_critical_set(args[0]->BooleanValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_abort_on_critical_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::Boolean;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ bool b = eina_log_abort_on_critical_get();
+ auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsNumber())
+ return compatibility_return();
+
+ eina_log_abort_on_critical_level_set(args[0]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::Integer;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 0)
+ return compatibility_return();
+
+ int l = eina_log_abort_on_critical_level_get();
+ auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_domain_level_set(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::String;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsNumber())
+ return compatibility_return();
+
+ eina_log_domain_level_set(*String::Utf8Value(args[0]),
+ args[1]->NumberValue());
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_domain_level_get(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::String;
+ using v8::Integer;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 1 || !args[0]->IsString())
+ return compatibility_return();
+
+ int l = eina_log_domain_level_get(*String::Utf8Value(args[0]));
+ auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
+ return compatibility_return(ret, args);
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
+}
+
+EAPI
+void register_log_state_start(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ int value = EINA_LOG_STATE_START;
+ global->Set(name, compatibility_new<v8::Integer>(isolate, value));
+}
+
+EAPI
+void register_log_state_stop(v8::Isolate *isolate,
+ v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ int value = EINA_LOG_STATE_STOP;
+ global->Set(name, compatibility_new<v8::Integer>(isolate, value));
+}
+
+EAPI
+void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
+ v8::Handle<v8::String> name)
+{
+ using v8::Value;
+ using v8::FunctionTemplate;
+ using v8::String;
+
+ auto f = [](compatibility_callback_info_type args)
+ -> compatibility_return_type {
+ if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
+ || !args[2]->IsString()) {
+ return compatibility_return();
+ }
+
+ eina_log_timing(args[0]->NumberValue(),
+ static_cast<Eina_Log_State>(args[1]->NumberValue()),
+ *String::Utf8Value(args[2]));
+ };
+
+ global->Set(name,
+ compatibility_new<FunctionTemplate>(isolate, f)->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 8cf8dc2972..906d82c476 100644
--- a/src/bindings/eina_js/eina_js_log.hh
+++ b/src/bindings/eina_js/eina_js_log.hh
@@ -1,12 +1,21 @@
#ifndef EINA_JS_LOG_HH
#define EINA_JS_LOG_HH
-#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
#include <Eina.hh>
-#include <type_traits>
+#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
+
+#include <eina_js_compatibility.hh>
namespace efl { namespace eina { namespace js {
+using ::efl::eina::js::compatibility_new;
+using ::efl::eina::js::compatibility_return_type;
+using ::efl::eina::js::compatibility_callback_info_type;
+using ::efl::eina::js::compatibility_return;
+using ::efl::eina::js::compatibility_get_pointer_internal_field;
+using ::efl::eina::js::compatibility_set_pointer_internal_field;
+using ::efl::eina::js::compatibility_persistent;
+
void register_log_level_critical(v8::Isolate *isolate,
v8::Handle<v8::Object> global,
v8::Handle<v8::String> name);
diff --git a/src/tests/eina_js/eina_js_suite.cc b/src/tests/eina_js/eina_js_suite.cc
index 42ec6d384f..9c18be545a 100644
--- a/src/tests/eina_js/eina_js_suite.cc
+++ b/src/tests/eina_js/eina_js_suite.cc
@@ -17,6 +17,7 @@
#include <eina_js_list.hh>
#include <eina_js_iterator.hh>
#include <eina_js_error.hh>
+#include <eina_js_log.cc>
const char* ToCString(const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
@@ -108,6 +109,35 @@ efl::eina::js::range_eina_list<int> raw_list;
efl::eina::array<int> array;
+static void eina_log_print_cb_js_test(const Eina_Log_Domain *d,
+ Eina_Log_Level level, const char *file,
+ const char *fnc, int line,
+ const char */*fmt*/, void */*data*/,
+ va_list args)
+{
+ static int index = 0;
+
+ const char *msg = va_arg(args, const char*);
+
+ std::string domains[] = {"", "", "", "mydomain", "mydomain2"};
+ int levels[] = {EINA_LOG_LEVEL_DBG, EINA_LOG_LEVEL_CRITICAL,
+ EINA_LOG_LEVEL_WARN, EINA_LOG_LEVEL_INFO,
+ EINA_LOG_LEVEL_ERR};
+ std::string functions[] = {"f1", "", "f2", "f3", ""};
+ int lines[] = {190, 191, 192, 193, 199};
+ std::string messages[] = {"I changed again", "Cool to Hate",
+ "One Fine Day", "Never Gonna Find Me",
+ "The Kids Aren't Alright"};
+
+ assert(std::string(d->name, d->namelen) == domains[index]);
+ assert(level == levels[index]);
+ assert(file == std::string("eina_js_suite.js"));
+ assert(fnc == functions[index]);
+ assert(line == lines[index]);
+ assert(msg == messages[index]);
+ ++index;
+}
+
void test_setup(v8::Handle<v8::Object> exports)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
@@ -165,6 +195,141 @@ void test_setup(v8::Handle<v8::Object> exports)
, efl::eina::js::compatibility_new<v8::String>(isolate, "value"));
std::cerr << __LINE__ << std::endl;
+
+ // log
+ using namespace efl::eina::js;
+ using v8::String;
+ {
+ int d = eina_log_domain_register("mydomain", "");
+ eina_log_domain_registered_level_set(d, EINA_LOG_LEVEL_DBG);
+ exports->Set(compatibility_new<String>(isolate, "mydomain"),
+ value_cast<v8::Local<v8::Value>>(d, isolate));
+ }
+ register_log_level_critical(isolate, exports,
+ compatibility_new<String>(isolate,
+ "LOG_LEVEL_CRITICAL"));
+ register_log_level_err(isolate, exports,
+ compatibility_new<String>(isolate, "LOG_LEVEL_ERR"));
+ register_log_level_warn(isolate, exports,
+ compatibility_new<String>(isolate, "LOG_LEVEL_WARN"));
+ register_log_level_info(isolate, exports,
+ compatibility_new<String>(isolate, "LOG_LEVEL_INFO"));
+ register_log_level_dbg(isolate, exports,
+ compatibility_new<String>(isolate, "LOG_LEVEL_DBG"));
+ register_log_domain_global(isolate, exports,
+ compatibility_new<String>(isolate,
+ "LOG_DOMAIN_GLOBAL"));
+ register_log_print(isolate, exports,
+ compatibility_new<String>(isolate, "log_print"));
+ register_log_domain_register(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_domain"
+ "_register"));
+ register_log_domain_unregister(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_domain_unregis"
+ "ter"));
+ register_log_domain_registered_level_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log"
+ "_domain"
+ "_register"
+ "ed_level"
+ "_get"));
+ register_log_domain_registered_level_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log"
+ "_domain"
+ "_register"
+ "ed_level"
+ "_set"));
+ register_log_print_cb_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_print_cb_set"));
+ register_log_level_set(isolate, exports,
+ compatibility_new<String>(isolate, "log_level_set"));
+ register_log_level_get(isolate, exports,
+ compatibility_new<String>(isolate, "log_level_get"));
+ register_log_level_check(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_level_check"));
+ register_log_color_disable_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_color_disable"
+ "_set"));
+ register_log_color_disable_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_color_disable"
+ "_get"));
+ register_log_file_disable_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_file_disable"
+ "_set"));
+ register_log_file_disable_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_file_disable"
+ "_get"));
+ register_log_abort_on_critical_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort_on"
+ "_critical"
+ "_set"));
+ register_log_abort_on_critical_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort_on"
+ "_critical"
+ "_get"));
+ register_log_function_disable_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_function"
+ "_disable_set"));
+ register_log_function_disable_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_function"
+ "_disable_get"));
+ register_log_abort_on_critical_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort_on"
+ "_critical"
+ "_set"));
+ register_log_abort_on_critical_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort_on"
+ "_critical"
+ "_get"));
+ register_log_abort_on_critical_level_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort"
+ "_on"
+ "_critical"
+ "_level"
+ "_set"));
+ register_log_abort_on_critical_level_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_abort"
+ "_on"
+ "_critical"
+ "_level"
+ "_get"));
+ register_log_domain_level_set(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_domain_level"
+ "_set"));
+ register_log_domain_level_get(isolate, exports,
+ compatibility_new<String>(isolate,
+ "log_domain_level"
+ "_get"));
+ register_log_state_start(isolate, exports,
+ compatibility_new<String>(isolate,
+ "LOG_STATE_START"));
+ register_log_state_stop(isolate, exports,
+ compatibility_new<String>(isolate, "LOG_STATE_STOP"));
+ register_log_timing(isolate, exports,
+ compatibility_new<String>(isolate, "log_timing"));
+
+ eina_log_print_cb_set(eina_log_print_cb_js_test, NULL);
+ eina_log_level_set(EINA_LOG_LEVEL_DBG);
+ eina_log_abort_on_critical_set(EINA_FALSE);
}
#ifndef HAVE_NODEJS
@@ -212,7 +377,7 @@ int main(int, char*[])
// Enter the execution environment before evaluating any code.
v8::Context::Scope context_scope(context);
v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String>
- (nullptr, "(shell)"));
+ (nullptr, "eina_js_suite.js"));
v8::Local<v8::Object> global = context->Global();
v8::Handle<v8::Object> console = efl::eina::js::compatibility_new<v8::Object>(isolate);
global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "console"), console);
diff --git a/src/tests/eina_js/eina_js_suite.js b/src/tests/eina_js/eina_js_suite.js
index d43b1c77b2..1c73bf52f4 100755..100644
--- a/src/tests/eina_js/eina_js_suite.js
+++ b/src/tests/eina_js/eina_js_suite.js
@@ -186,6 +186,81 @@ console.log("x");
}
assert(captured === true, 'value #12');
+// log
+
+function f1(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_DBG, 'I changed again'); }; f1();
+suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_CRITICAL, 'Cool to Hate');
+function f2(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_WARN, 'One Fine Day'); }; f2();
+function f3(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_INFO, 'Never Gonna Find Me'); }; f3();
+
+mydomain2 = suite.log_domain_register('mydomain2', '');
+suite.log_domain_registered_level_set(mydomain2, suite.LOG_LEVEL_DBG);
+assert(suite.log_domain_registered_level_get(mydomain2) === suite.LOG_LEVEL_DBG, '#1');
+
+suite.log_print(mydomain2, suite.LOG_LEVEL_ERR, "The Kids Aren't Alright");
+
+suite.log_domain_unregister(mydomain2);
+mydomain2 = undefined;
+
+suite.log_color_disable_set(true);
+assert(suite.log_color_disable_get() === true, '#2');
+suite.log_color_disable_set(false);
+assert(suite.log_color_disable_get() === false, '#3');
+
+suite.log_file_disable_set(true);
+assert(suite.log_file_disable_get() === true, '#4');
+suite.log_file_disable_set(false);
+assert(suite.log_file_disable_get() === false, '#5');
+
+suite.log_function_disable_set(true);
+assert(suite.log_function_disable_get() === true, '#6');
+suite.log_function_disable_set(false);
+assert(suite.log_function_disable_get() === false, '#7');
+
+suite.log_abort_on_critical_set(true);
+assert(suite.log_abort_on_critical_get() === true, '#8');
+suite.log_abort_on_critical_set(false);
+assert(suite.log_abort_on_critical_get() === false, '#9');
+
+var entered = false;
+suite.log_print_cb_set(function(domain, color, level, file, func, line, msg) {
+ assert(domain === 'mydomain', '#10');
+ assert(color === '', '#11');
+ assert(level === suite.LOG_LEVEL_WARN, '#12');
+ assert(file === 'eina_js_suite.js', '#13');
+ assert(func === 'f4', '#14');
+ assert(line === 236, '#15');
+ assert(msg === 'What Happened To You', '#16');
+ entered = true;
+});
+
+function f4(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_WARN, 'What Happened To You'); }; f4();
+assert(entered === true, '#17');
+
+assert(suite.log_level_get() === suite.LOG_LEVEL_DBG, '#18');
+assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === true, '#19');
+suite.log_level_set(suite.LOG_LEVEL_CRITICAL);
+assert(suite.log_level_get() === suite.LOG_LEVEL_CRITICAL, '#20');
+assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === false, '#21');
+
+assert(suite.log_abort_on_critical_get() === false, '#22');
+suite.log_abort_on_critical_set(true);
+assert(suite.log_abort_on_critical_get() === true, '#23');
+
+suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_CRITICAL);
+assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_CRITICAL, '#24');
+suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_ERR);
+assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_ERR, '#25');
+
+suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_WARN);
+assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_WARN, '#26');
+suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_INFO);
+assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_INFO, '#27');
+
+assert(typeof(suite.LOG_STATE_START) === 'number', '#28');
+assert(typeof(suite.LOG_STATE_STOP) === 'number', '#29');
+assert(typeof(suite.log_timing) === 'function', '#30');
+
// finished tests
console.log ("Test execution with success");