summaryrefslogtreecommitdiff
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
parent1f5fadd9d512519eb31e76c88c5f3aaff6ea3094 (diff)
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 ce29312..00fbcd3 100644
--- a/src/bindings/eina_js/eina_js_log.cc
+++ b/src/bindings/eina_js/eina_js_log.cc
@@ -2,611 +2,634 @@
2#include <config.h> 2#include <config.h>
3#endif 3#endif
4 4
5// #include <string> 5#include <string>
6// #include <eina_js_log.hh> 6#include <eina_js_log.hh>
7// #include <eina_js_value.hh> 7#include <eina_js_value.hh>
8// #include <eina_js_compatibility.hh> 8#include <eina_js_compatibility.hh>
9 9
10// namespace efl { namespace eina { namespace js { 10namespace efl { namespace eina { namespace js {
11 11
12// v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt, 12v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
13// va_list args) 13 va_list args)
14// { 14{
15// #if 0 15 using v8::String;
16// /* TODO: unfortunately, the elegant and exception-safe version isn't 16#if 0
17// compiling (yet!) */ 17 /* TODO: unfortunately, the elegant and exception-safe version isn't
18// efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args), 18 compiling (yet!) */
19// efl::eina::steal_stringshare_ref); 19 efl::eina::stringshare s(eina_stringshare_vprintf(fmt, args),
20// return v8::String::NewFromUtf8(isolate, s.data(), v8::String::kNormalString, 20 efl::eina::steal_stringshare_ref);
21// s.size()); 21 return compatibility_new<String>(isolate, s.data(), String::kNormalString,
22// #else 22 s.size());
23// auto s = eina_stringshare_vprintf(fmt, args); 23#else
24// auto ret = compatibility_new<v8::String>(isolate, s); 24 auto s = eina_stringshare_vprintf(fmt, args);
25// eina_stringshare_del(s); 25 auto ret = compatibility_new<String>(isolate, s);
26// return ret; 26 eina_stringshare_del(s);
27// #endif 27 return ret;
28// } 28#endif
29 29}
30// static struct { 30
31// void reset(v8::Isolate *isolate, v8::Handle<v8::Value> functor) 31static compatibility_persistent<v8::Value> js_eina_log_print_cb_data;
32// { 32
33// persistent.Reset(isolate, functor); 33static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
34// // this->isolate = isolate; 34 const char *file, const char *fnc, int line,
35// } 35 const char *fmt, void */*data*/, va_list args)
36 36{
37// v8::Local<v8::Value> functor() 37 using v8::String;
38// { 38 using v8::Integer;
39// return v8::Local<v8::Value>::New(v8::Isolate::GetIsolate(), persistent); 39 using v8::Isolate;
40// } 40
41 41 Isolate *const isolate = Isolate::GetCurrent();
42// v8::Persistent<v8::Value/*, v8::CopyablePersistentTraits<v8::Value>*/> 42 constexpr unsigned argc = 7;
43// persistent; 43
44// // v8::Isolate *isolate; 44 v8::Handle<v8::Value> argv[argc] = {
45// } js_eina_log_print_cb_data; 45 compatibility_new<String>(isolate, d->name, String::kNormalString,
46 46 d->namelen),
47// static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, 47 compatibility_new<String>(isolate, d->color),
48// const char *file, const char *fnc, int line, 48 compatibility_new<Integer>(isolate, static_cast<int>(level)),
49// const char *fmt, void */*data*/, va_list args) 49 compatibility_new<String>(isolate, file),
50// { 50 compatibility_new<String>(isolate, fnc),
51// v8::Isolate *const isolate = js_eina_log_print_cb_data.isolate; 51 compatibility_new<Integer>(isolate, line),
52// constexpr unsigned argc = 7; 52 to_v8_string(isolate, fmt, args)
53 53 };
54// v8::Handle<v8::Value> argv[argc] = { 54
55// v8::String::NewFromUtf8(isolate, d->name, v8::String::kNormalString, 55 auto o = js_eina_log_print_cb_data.handle();
56// d->namelen), 56 v8::Function::Cast(*o)->Call(v8::Undefined(isolate), argc, argv);
57// v8::String::NewFromUtf8(isolate, d->color), 57}
58// v8::Integer::New(isolate, static_cast<int>(level)), 58
59// v8::String::NewFromUtf8(isolate, file), 59static bool valid_level_conversion(int src, Eina_Log_Level &dst)
60// v8::String::NewFromUtf8(isolate, fnc), 60{
61// v8::Integer::New(isolate, line), 61 if (src != EINA_LOG_LEVEL_CRITICAL && src != EINA_LOG_LEVEL_ERR
62// to_v8_string(isolate, fmt, args) 62 && src != EINA_LOG_LEVEL_WARN && src != EINA_LOG_LEVEL_INFO
63// }; 63 && src != EINA_LOG_LEVEL_DBG)
64 64 return false;
65// auto o = js_eina_log_print_cb_data.functor(); 65
66// v8::Function::Cast(*o)->Call(v8::Undefined(isolate), argc, argv); 66 dst = static_cast<Eina_Log_Level>(src);
67// } 67 return true;
68 68}
69// static bool valid_level_conversion(int src, Eina_Log_Level &dst) 69
70// { 70EAPI
71// if (src != EINA_LOG_LEVEL_CRITICAL && src != EINA_LOG_LEVEL_ERR 71void register_log_level_critical(v8::Isolate *isolate,
72// && src != EINA_LOG_LEVEL_WARN && src != EINA_LOG_LEVEL_INFO 72 v8::Handle<v8::Object> global,
73// && src != EINA_LOG_LEVEL_DBG) 73 v8::Handle<v8::String> name)
74// return false; 74{
75 75 int value = EINA_LOG_LEVEL_CRITICAL;
76// dst = static_cast<Eina_Log_Level>(src); 76 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
77// return true; 77}
78// } 78
79 79EAPI
80// EAPI 80void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global,
81// void register_log_level_critical(v8::Isolate *isolate, 81 v8::Handle<v8::String> name)
82// v8::Handle<v8::Object> global, 82{
83// v8::Handle<v8::String> name) 83 int value = EINA_LOG_LEVEL_ERR;
84// { 84 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
85// int value = EINA_LOG_LEVEL_CRITICAL; 85}
86// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 86
87// } 87EAPI
88 88void register_log_level_warn(v8::Isolate *isolate,
89// EAPI 89 v8::Handle<v8::Object> global,
90// void register_log_level_err(v8::Isolate *isolate, v8::Handle<v8::Object> global, 90 v8::Handle<v8::String> name)
91// v8::Handle<v8::String> name) 91{
92// { 92 int value = EINA_LOG_LEVEL_WARN;
93// int value = EINA_LOG_LEVEL_ERR; 93 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
94// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 94}
95// } 95
96 96EAPI
97// EAPI 97void register_log_level_info(v8::Isolate *isolate,
98// void register_log_level_warn(v8::Isolate *isolate, 98 v8::Handle<v8::Object> global,
99// v8::Handle<v8::Object> global, 99 v8::Handle<v8::String> name)
100// v8::Handle<v8::String> name) 100{
101// { 101 int value = EINA_LOG_LEVEL_INFO;
102// int value = EINA_LOG_LEVEL_WARN; 102 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
103// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 103}
104// } 104
105 105EAPI
106// EAPI 106void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global,
107// void register_log_level_info(v8::Isolate *isolate, 107 v8::Handle<v8::String> name)
108// v8::Handle<v8::Object> global, 108{
109// v8::Handle<v8::String> name) 109 int value = EINA_LOG_LEVEL_DBG;
110// { 110 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
111// int value = EINA_LOG_LEVEL_INFO; 111}
112// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 112
113// } 113EAPI
114 114void register_log_domain_global(v8::Isolate *isolate,
115// EAPI 115 v8::Handle<v8::Object> global,
116// void register_log_level_dbg(v8::Isolate *isolate, v8::Handle<v8::Object> global, 116 v8::Handle<v8::String> name)
117// v8::Handle<v8::String> name) 117{
118// { 118 int value = EINA_LOG_DOMAIN_GLOBAL;
119// int value = EINA_LOG_LEVEL_DBG; 119 global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate));
120// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 120}
121// } 121
122 122EAPI
123// EAPI 123void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global,
124// void register_log_domain_global(v8::Isolate *isolate, 124 v8::Handle<v8::String> name)
125// v8::Handle<v8::Object> global, 125{
126// v8::Handle<v8::String> name) 126 using v8::Value;
127// { 127 using v8::String;
128// int value = EINA_LOG_DOMAIN_GLOBAL; 128 using v8::StackTrace;
129// global->Set(name, value_cast<v8::Local<v8::Value>>(value, isolate)); 129 using v8::FunctionTemplate;
130// } 130
131 131 auto print = [](compatibility_callback_info_type args)
132// EAPI 132 -> compatibility_return_type {
133// void register_log_print(v8::Isolate *isolate, v8::Handle<v8::Object> global, 133 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
134// v8::Handle<v8::String> name) 134 || !args[2]->IsString())
135// { 135 return compatibility_return();
136// using v8::FunctionCallbackInfo; 136
137// using v8::Value; 137 Eina_Log_Level level;
138// using v8::String; 138 if (!valid_level_conversion(args[1]->NumberValue(), level))
139// using v8::StackTrace; 139 return compatibility_return();
140// using v8::FunctionTemplate; 140
141 141 auto frame = StackTrace::CurrentStackTrace(args.GetIsolate(), 1,
142// auto print = [](const FunctionCallbackInfo<Value> &info) { 142 StackTrace::kDetailed)
143// if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber() 143 ->GetFrame(0);
144// || !info[2]->IsString()) 144
145// return; 145 eina_log_print(args[0]->NumberValue(), level,
146 146 *String::Utf8Value(frame->GetScriptNameOrSourceURL()),
147// Eina_Log_Level level; 147 *String::Utf8Value(frame->GetFunctionName()),
148// if (!valid_level_conversion(info[1]->NumberValue(), level)) 148 frame->GetLineNumber(), "%s",
149// return; 149 *String::Utf8Value(args[2]));
150 150 };
151// auto frame = StackTrace::CurrentStackTrace(info.GetIsolate(), 1, 151
152// StackTrace::kDetailed) 152 global->Set(name,
153// ->GetFrame(0); 153 compatibility_new<FunctionTemplate>(isolate, print)
154 154 ->GetFunction());
155// eina_log_print(info[0]->NumberValue(), level, 155}
156// *String::Utf8Value(frame->GetScriptNameOrSourceURL()), 156
157// *String::Utf8Value(frame->GetFunctionName()), 157EAPI
158// frame->GetLineNumber(), "%s", 158void register_log_domain_register(v8::Isolate *isolate,
159// *String::Utf8Value(info[2])); 159 v8::Handle<v8::Object> global,
160// }; 160 v8::Handle<v8::String> name)
161 161{
162// global->Set(name, FunctionTemplate::New(isolate, print)->GetFunction()); 162 using v8::Value;
163// } 163 using v8::Local;
164 164 using v8::String;
165// EAPI 165 using v8::FunctionTemplate;
166// void register_log_domain_register(v8::Isolate *isolate, 166
167// v8::Handle<v8::Object> global, 167 auto f = [](compatibility_callback_info_type args)
168// v8::Handle<v8::String> name) 168 -> compatibility_return_type {
169// { 169 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
170// using v8::FunctionCallbackInfo; 170 return compatibility_return();
171// using v8::Value; 171
172// using v8::Local; 172 int d = eina_log_domain_register(*String::Utf8Value(args[0]),
173// using v8::String; 173 *String::Utf8Value(args[1]));
174// using v8::FunctionTemplate; 174 auto isolate = args.GetIsolate();
175 175 return compatibility_return(value_cast<Local<Value>>(d, isolate), args);
176// auto func = [](const FunctionCallbackInfo<Value> &info) { 176 };
177// if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsString()) 177
178// return; 178 global->Set(name,
179 179 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
180// int d = eina_log_domain_register(*String::Utf8Value(info[0]), 180}
181// *String::Utf8Value(info[1])); 181
182// info.GetReturnValue().Set(value_cast<Local<Value>> 182EAPI
183// (d, info.GetIsolate())); 183void register_log_domain_unregister(v8::Isolate *isolate,
184// }; 184 v8::Handle<v8::Object> global,
185 185 v8::Handle<v8::String> name)
186// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 186{
187// } 187 using v8::Value;
188 188 using v8::FunctionTemplate;
189// EAPI 189
190// void register_log_domain_unregister(v8::Isolate *isolate, 190 auto f = [](compatibility_callback_info_type args)
191// v8::Handle<v8::Object> global, 191 -> compatibility_return_type {
192// v8::Handle<v8::String> name) 192 if (args.Length() != 1 || !args[0]->IsNumber())
193// { 193 return compatibility_return();
194// using v8::FunctionCallbackInfo; 194
195// using v8::Value; 195 eina_log_domain_unregister(args[0]->NumberValue());
196// using v8::FunctionTemplate; 196 };
197 197
198// auto func = [](const FunctionCallbackInfo<Value> &info) { 198 global->Set(name,
199// if (info.Length() != 1 || !info[0]->IsNumber()) 199 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
200// return; 200}
201 201
202// eina_log_domain_unregister(info[0]->NumberValue()); 202EAPI
203// }; 203void register_log_domain_registered_level_get(v8::Isolate *isolate,
204 204 v8::Handle<v8::Object> global,
205// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 205 v8::Handle<v8::String> name)
206// } 206{
207 207 using v8::Value;
208// EAPI 208 using v8::Local;
209// void register_log_domain_registered_level_get(v8::Isolate *isolate, 209 using v8::FunctionTemplate;
210// v8::Handle<v8::Object> global, 210
211// v8::Handle<v8::String> name) 211 auto f = [](compatibility_callback_info_type args)
212// { 212 -> compatibility_return_type {
213// using v8::FunctionCallbackInfo; 213 if (args.Length() != 1 || !args[0]->IsNumber())
214// using v8::Value; 214 return compatibility_return();
215// using v8::Local; 215
216// using v8::FunctionTemplate; 216 int l = eina_log_domain_registered_level_get(args[0]->NumberValue());
217 217 auto isolate = args.GetIsolate();
218// auto func = [](const FunctionCallbackInfo<Value> &info) { 218 return compatibility_return(value_cast<Local<Value>>(l, isolate), args);
219// if (info.Length() != 1 || !info[0]->IsNumber()) 219 };
220// return; 220
221 221 global->Set(name,
222// int l = eina_log_domain_registered_level_get(info[0]->NumberValue()); 222 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
223// info.GetReturnValue().Set(value_cast<Local<Value>> 223}
224// (l, info.GetIsolate())); 224
225// }; 225EAPI
226 226void register_log_domain_registered_level_set(v8::Isolate *isolate,
227// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 227 v8::Handle<v8::Object> global,
228// } 228 v8::Handle<v8::String> name)
229 229{
230// EAPI 230 using v8::Value;
231// void register_log_domain_registered_level_set(v8::Isolate *isolate, 231 using v8::FunctionTemplate;
232// v8::Handle<v8::Object> global, 232
233// v8::Handle<v8::String> name) 233 auto f = [](compatibility_callback_info_type args)
234// { 234 -> compatibility_return_type {
235// using v8::FunctionCallbackInfo; 235 if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
236// using v8::Value; 236 return compatibility_return();
237// using v8::FunctionTemplate; 237
238 238 eina_log_domain_registered_level_set(args[0]->NumberValue(),
239// auto func = [](const FunctionCallbackInfo<Value> &info) { 239 args[1]->NumberValue());
240// if (info.Length() != 2 || !info[0]->IsNumber() || !info[1]->IsNumber()) 240 };
241// return; 241
242 242 global->Set(name,
243// eina_log_domain_registered_level_set(info[0]->NumberValue(), 243 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
244// info[1]->NumberValue()); 244}
245// }; 245
246 246EAPI
247// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 247void register_log_print_cb_set(v8::Isolate *isolate,
248// } 248 v8::Handle<v8::Object> global,
249 249 v8::Handle<v8::String> name)
250// EAPI 250{
251// void register_log_print_cb_set(v8::Isolate *isolate, 251 using v8::Value;
252// v8::Handle<v8::Object> global, 252 using v8::FunctionTemplate;
253// v8::Handle<v8::String> name) 253
254// { 254 auto f = [](compatibility_callback_info_type args)
255// using v8::FunctionCallbackInfo; 255 -> compatibility_return_type {
256// using v8::Value; 256 if (args.Length() != 1 || !args[0]->IsFunction())
257// using v8::FunctionTemplate; 257 return compatibility_return();
258 258
259// auto func = [](const FunctionCallbackInfo<Value> &info) { 259 js_eina_log_print_cb_data
260// if (info.Length() != 1 || !info[0]->IsFunction()) 260 = compatibility_persistent<Value>(args.GetIsolate(), args[0]);
261// return; 261 eina_log_print_cb_set(js_eina_log_print_cb, NULL);
262 262 };
263// js_eina_log_print_cb_data.reset(info.GetIsolate(), info[0]); 263
264// eina_log_print_cb_set(js_eina_log_print_cb, NULL); 264 global->Set(name,
265// }; 265 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
266 266}
267// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 267
268// } 268EAPI
269 269void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global,
270// EAPI 270 v8::Handle<v8::String> name)
271// void register_log_level_set(v8::Isolate *isolate, v8::Handle<v8::Object> global, 271{
272// v8::Handle<v8::String> name) 272 using v8::Value;
273// { 273 using v8::FunctionTemplate;
274// using v8::FunctionCallbackInfo; 274
275// using v8::Value; 275 auto f = [](compatibility_callback_info_type args)
276// using v8::FunctionTemplate; 276 -> compatibility_return_type {
277 277 if (args.Length() != 1 || !args[0]->IsNumber())
278// auto func = [](const FunctionCallbackInfo<Value> &info) { 278 return compatibility_return();
279// if (info.Length() != 1 || !info[0]->IsNumber()) 279
280// return; 280 eina_log_level_set(args[0]->NumberValue());
281 281 };
282// eina_log_level_set(info[0]->NumberValue()); 282
283// }; 283 global->Set(name,
284 284 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
285// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 285}
286// } 286
287 287EAPI
288// EAPI 288void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global,
289// void register_log_level_get(v8::Isolate *isolate, v8::Handle<v8::Object> global, 289 v8::Handle<v8::String> name)
290// v8::Handle<v8::String> name) 290{
291// { 291 using v8::Value;
292// using v8::FunctionCallbackInfo; 292 using v8::FunctionTemplate;
293// using v8::Value; 293 using v8::Integer;
294// using v8::FunctionTemplate; 294
295// using v8::Integer; 295 auto f = [](compatibility_callback_info_type args)
296 296 -> compatibility_return_type {
297// auto func = [](const FunctionCallbackInfo<Value> &info) { 297 if (args.Length() != 0)
298// if (info.Length() != 0) 298 return compatibility_return();
299// return; 299
300 300 int l = eina_log_level_get();
301// int l = eina_log_level_get(); 301 auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
302// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l)); 302 return compatibility_return(ret, args);
303// }; 303 };
304 304
305// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 305 global->Set(name,
306// } 306 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
307 307}
308// EAPI 308
309// void register_log_level_check(v8::Isolate *isolate, 309EAPI
310// v8::Handle<v8::Object> global, 310void register_log_level_check(v8::Isolate *isolate,
311// v8::Handle<v8::String> name) 311 v8::Handle<v8::Object> global,
312// { 312 v8::Handle<v8::String> name)
313// using v8::FunctionCallbackInfo; 313{
314// using v8::Value; 314 using v8::Value;
315// using v8::FunctionTemplate; 315 using v8::FunctionTemplate;
316// using v8::Boolean; 316 using v8::Boolean;
317 317
318// auto func = [](const FunctionCallbackInfo<Value> &info) { 318 auto f = [](compatibility_callback_info_type args)
319// if (info.Length() != 1 || !info[0]->IsNumber()) 319 -> compatibility_return_type {
320// return; 320 if (args.Length() != 1 || !args[0]->IsNumber())
321 321 return compatibility_return();
322// bool b = eina_log_level_check(info[0]->NumberValue()); 322
323// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b)); 323 bool b = eina_log_level_check(args[0]->NumberValue());
324// }; 324 auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
325 325 return compatibility_return(ret, args);
326// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 326 };
327// } 327
328 328 global->Set(name,
329// EAPI 329 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
330// void register_log_color_disable_set(v8::Isolate *isolate, 330}
331// v8::Handle<v8::Object> global, 331
332// v8::Handle<v8::String> name) 332EAPI
333// { 333void register_log_color_disable_set(v8::Isolate *isolate,
334// using v8::FunctionCallbackInfo; 334 v8::Handle<v8::Object> global,
335// using v8::Value; 335 v8::Handle<v8::String> name)
336// using v8::FunctionTemplate; 336{
337 337 using v8::Value;
338// auto func = [](const FunctionCallbackInfo<Value> &info) { 338 using v8::FunctionTemplate;
339// if (info.Length() != 1 || !info[0]->IsBoolean()) 339
340// return; 340 auto f = [](compatibility_callback_info_type args)
341 341 -> compatibility_return_type {
342// eina_log_color_disable_set(info[0]->BooleanValue()); 342 if (args.Length() != 1 || !args[0]->IsBoolean())
343// }; 343 return compatibility_return();
344 344
345// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 345 eina_log_color_disable_set(args[0]->BooleanValue());
346// } 346 };
347 347
348// EAPI 348 global->Set(name,
349// void register_log_color_disable_get(v8::Isolate *isolate, 349 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
350// v8::Handle<v8::Object> global, 350}
351// v8::Handle<v8::String> name) 351
352// { 352EAPI
353// using v8::FunctionCallbackInfo; 353void register_log_color_disable_get(v8::Isolate *isolate,
354// using v8::Value; 354 v8::Handle<v8::Object> global,
355// using v8::Boolean; 355 v8::Handle<v8::String> name)
356// using v8::FunctionTemplate; 356{
357 357 using v8::Value;
358// auto func = [](const FunctionCallbackInfo<Value> &info) { 358 using v8::Boolean;
359// if (info.Length() != 0) 359 using v8::FunctionTemplate;
360// return; 360
361 361 auto f = [](compatibility_callback_info_type args)
362// bool b = eina_log_color_disable_get(); 362 -> compatibility_return_type {
363// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b)); 363 if (args.Length() != 0)
364// }; 364 return compatibility_return();
365 365
366// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 366 bool b = eina_log_color_disable_get();
367// } 367 auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
368 368 return compatibility_return(ret, args);
369// EAPI 369 };
370// void register_log_file_disable_set(v8::Isolate *isolate, 370
371// v8::Handle<v8::Object> global, 371 global->Set(name,
372// v8::Handle<v8::String> name) 372 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
373// { 373}
374// using v8::FunctionCallbackInfo; 374
375// using v8::Value; 375EAPI
376// using v8::FunctionTemplate; 376void register_log_file_disable_set(v8::Isolate *isolate,
377 377 v8::Handle<v8::Object> global,
378// auto func = [](const FunctionCallbackInfo<Value> &info) { 378 v8::Handle<v8::String> name)
379// if (info.Length() != 1 || !info[0]->IsBoolean()) 379{
380// return; 380 using v8::Value;
381 381 using v8::FunctionTemplate;
382// eina_log_file_disable_set(info[0]->BooleanValue()); 382
383// }; 383 auto f = [](compatibility_callback_info_type args)
384 384 -> compatibility_return_type {
385// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 385 if (args.Length() != 1 || !args[0]->IsBoolean())
386// } 386 return compatibility_return();
387 387
388// EAPI 388 eina_log_file_disable_set(args[0]->BooleanValue());
389// void register_log_file_disable_get(v8::Isolate *isolate, 389 };
390// v8::Handle<v8::Object> global, 390
391// v8::Handle<v8::String> name) 391 global->Set(name,
392// { 392 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
393// using v8::FunctionCallbackInfo; 393}
394// using v8::Value; 394
395// using v8::Boolean; 395EAPI
396// using v8::FunctionTemplate; 396void register_log_file_disable_get(v8::Isolate *isolate,
397 397 v8::Handle<v8::Object> global,
398// auto func = [](const FunctionCallbackInfo<Value> &info) { 398 v8::Handle<v8::String> name)
399// if (info.Length() != 0) 399{
400// return; 400 using v8::Value;
401 401 using v8::Boolean;
402// bool b = eina_log_file_disable_get(); 402 using v8::FunctionTemplate;
403// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b)); 403
404// }; 404 auto f = [](compatibility_callback_info_type args)
405 405 -> compatibility_return_type {
406// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 406 if (args.Length() != 0)
407// } 407 return compatibility_return();
408 408
409// EAPI 409 bool b = eina_log_file_disable_get();
410// void register_log_function_disable_set(v8::Isolate *isolate, 410 auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
411// v8::Handle<v8::Object> global, 411 return compatibility_return(ret, args);
412// v8::Handle<v8::String> name) 412 };
413// { 413
414// using v8::FunctionCallbackInfo; 414 global->Set(name,
415// using v8::Value; 415 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
416// using v8::FunctionTemplate; 416}
417 417
418// auto func = [](const FunctionCallbackInfo<Value> &info) { 418EAPI
419// if (info.Length() != 1 || !info[0]->IsBoolean()) 419void register_log_function_disable_set(v8::Isolate *isolate,
420// return; 420 v8::Handle<v8::Object> global,
421 421 v8::Handle<v8::String> name)
422// eina_log_function_disable_set(info[0]->BooleanValue()); 422{
423// }; 423 using v8::Value;
424 424 using v8::FunctionTemplate;
425// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 425
426// } 426 auto f = [](compatibility_callback_info_type args)
427 427 -> compatibility_return_type {
428// EAPI 428 if (args.Length() != 1 || !args[0]->IsBoolean())
429// void register_log_function_disable_get(v8::Isolate *isolate, 429 return compatibility_return();
430// v8::Handle<v8::Object> global, 430
431// v8::Handle<v8::String> name) 431 eina_log_function_disable_set(args[0]->BooleanValue());
432// { 432 };
433// using v8::FunctionCallbackInfo; 433
434// using v8::Value; 434 global->Set(name,
435// using v8::Boolean; 435 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
436// using v8::FunctionTemplate; 436}
437 437
438// auto func = [](const FunctionCallbackInfo<Value> &info) { 438EAPI
439// if (info.Length() != 0) 439void register_log_function_disable_get(v8::Isolate *isolate,
440// return; 440 v8::Handle<v8::Object> global,
441 441 v8::Handle<v8::String> name)
442// bool b = eina_log_function_disable_get(); 442{
443// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b)); 443 using v8::Value;
444// }; 444 using v8::Boolean;
445 445 using v8::FunctionTemplate;
446// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 446
447// } 447 auto f = [](compatibility_callback_info_type args)
448 448 -> compatibility_return_type {
449// EAPI 449 if (args.Length() != 0)
450// void register_log_abort_on_critical_set(v8::Isolate *isolate, 450 return compatibility_return();
451// v8::Handle<v8::Object> global, 451
452// v8::Handle<v8::String> name) 452 bool b = eina_log_function_disable_get();
453// { 453 auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
454// using v8::FunctionCallbackInfo; 454 return compatibility_return(ret, args);
455// using v8::Value; 455 };
456// using v8::FunctionTemplate; 456
457 457 global->Set(name,
458// auto func = [](const FunctionCallbackInfo<Value> &info) { 458 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
459// if (info.Length() != 1 || !info[0]->IsBoolean()) 459}
460// return; 460
461 461EAPI
462// eina_log_abort_on_critical_set(info[0]->BooleanValue()); 462void register_log_abort_on_critical_set(v8::Isolate *isolate,
463// }; 463 v8::Handle<v8::Object> global,
464 464 v8::Handle<v8::String> name)
465// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 465{
466// } 466 using v8::Value;
467 467 using v8::FunctionTemplate;
468// EAPI 468
469// void register_log_abort_on_critical_get(v8::Isolate *isolate, 469 auto f = [](compatibility_callback_info_type args)
470// v8::Handle<v8::Object> global, 470 -> compatibility_return_type {
471// v8::Handle<v8::String> name) 471 if (args.Length() != 1 || !args[0]->IsBoolean())
472// { 472 return compatibility_return();
473// using v8::FunctionCallbackInfo; 473
474// using v8::Value; 474 eina_log_abort_on_critical_set(args[0]->BooleanValue());
475// using v8::Boolean; 475 };
476// using v8::FunctionTemplate; 476
477 477 global->Set(name,
478// auto func = [](const FunctionCallbackInfo<Value> &info) { 478 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
479// if (info.Length() != 0) 479}
480// return; 480
481 481EAPI
482// bool b = eina_log_abort_on_critical_get(); 482void register_log_abort_on_critical_get(v8::Isolate *isolate,
483// info.GetReturnValue().Set(Boolean::New(info.GetIsolate(), b)); 483 v8::Handle<v8::Object> global,
484// }; 484 v8::Handle<v8::String> name)
485 485{
486// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 486 using v8::Value;
487// } 487 using v8::Boolean;
488 488 using v8::FunctionTemplate;
489// EAPI 489
490// void register_log_abort_on_critical_level_set(v8::Isolate *isolate, 490 auto f = [](compatibility_callback_info_type args)
491// v8::Handle<v8::Object> global, 491 -> compatibility_return_type {
492// v8::Handle<v8::String> name) 492 if (args.Length() != 0)
493// { 493 return compatibility_return();
494// using v8::FunctionCallbackInfo; 494
495// using v8::Value; 495 bool b = eina_log_abort_on_critical_get();
496// using v8::FunctionTemplate; 496 auto ret = compatibility_new<Boolean>(args.GetIsolate(), b);
497 497 return compatibility_return(ret, args);
498// auto func = [](const FunctionCallbackInfo<Value> &info) { 498 };
499// if (info.Length() != 1 || !info[0]->IsNumber()) 499
500// return; 500 global->Set(name,
501 501 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
502// eina_log_abort_on_critical_level_set(info[0]->NumberValue()); 502}
503// }; 503
504 504EAPI
505// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 505void register_log_abort_on_critical_level_set(v8::Isolate *isolate,
506// } 506 v8::Handle<v8::Object> global,
507 507 v8::Handle<v8::String> name)
508// EAPI 508{
509// void register_log_abort_on_critical_level_get(v8::Isolate *isolate, 509 using v8::Value;
510// v8::Handle<v8::Object> global, 510 using v8::FunctionTemplate;
511// v8::Handle<v8::String> name) 511
512// { 512 auto f = [](compatibility_callback_info_type args)
513// using v8::FunctionCallbackInfo; 513 -> compatibility_return_type {
514// using v8::Value; 514 if (args.Length() != 1 || !args[0]->IsNumber())
515// using v8::FunctionTemplate; 515 return compatibility_return();
516// using v8::Integer; 516
517 517 eina_log_abort_on_critical_level_set(args[0]->NumberValue());
518// auto func = [](const FunctionCallbackInfo<Value> &info) { 518 };
519// if (info.Length() != 0) 519
520// return; 520 global->Set(name,
521 521 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
522// int l = eina_log_abort_on_critical_level_get(); 522}
523// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l)); 523
524// }; 524EAPI
525 525void register_log_abort_on_critical_level_get(v8::Isolate *isolate,
526// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 526 v8::Handle<v8::Object> global,
527// } 527 v8::Handle<v8::String> name)
528 528{
529// EAPI 529 using v8::Value;
530// void register_log_domain_level_set(v8::Isolate *isolate, 530 using v8::FunctionTemplate;
531// v8::Handle<v8::Object> global, 531 using v8::Integer;
532// v8::Handle<v8::String> name) 532
533// { 533 auto f = [](compatibility_callback_info_type args)
534// using v8::FunctionCallbackInfo; 534 -> compatibility_return_type {
535// using v8::Value; 535 if (args.Length() != 0)
536// using v8::FunctionTemplate; 536 return compatibility_return();
537// using v8::String; 537
538 538 int l = eina_log_abort_on_critical_level_get();
539// auto func = [](const FunctionCallbackInfo<Value> &info) { 539 auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
540// if (info.Length() != 2 || !info[0]->IsString() || !info[1]->IsNumber()) 540 return compatibility_return(ret, args);
541// return; 541 };
542 542
543// eina_log_domain_level_set(*String::Utf8Value(info[0]), 543 global->Set(name,
544// info[1]->NumberValue()); 544 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
545// }; 545}
546 546
547// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 547EAPI
548// } 548void register_log_domain_level_set(v8::Isolate *isolate,
549 549 v8::Handle<v8::Object> global,
550// EAPI 550 v8::Handle<v8::String> name)
551// void register_log_domain_level_get(v8::Isolate *isolate, 551{
552// v8::Handle<v8::Object> global, 552 using v8::Value;
553// v8::Handle<v8::String> name) 553 using v8::FunctionTemplate;
554// { 554 using v8::String;
555// using v8::FunctionCallbackInfo; 555
556// using v8::Value; 556 auto f = [](compatibility_callback_info_type args)
557// using v8::FunctionTemplate; 557 -> compatibility_return_type {
558// using v8::String; 558 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsNumber())
559// using v8::Integer; 559 return compatibility_return();
560 560
561// auto func = [](const FunctionCallbackInfo<Value> &info) { 561 eina_log_domain_level_set(*String::Utf8Value(args[0]),
562// if (info.Length() != 1 || !info[0]->IsString()) 562 args[1]->NumberValue());
563// return; 563 };
564 564
565// int l = eina_log_domain_level_get(*String::Utf8Value(info[0])); 565 global->Set(name,
566// info.GetReturnValue().Set(Integer::New(info.GetIsolate(), l)); 566 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
567// }; 567}
568 568
569// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 569EAPI
570// } 570void register_log_domain_level_get(v8::Isolate *isolate,
571 571 v8::Handle<v8::Object> global,
572// EAPI 572 v8::Handle<v8::String> name)
573// void register_log_state_start(v8::Isolate *isolate, 573{
574// v8::Handle<v8::Object> global, 574 using v8::Value;
575// v8::Handle<v8::String> name) 575 using v8::FunctionTemplate;
576// { 576 using v8::String;
577// int value = EINA_LOG_STATE_START; 577 using v8::Integer;
578// global->Set(name, v8::Integer::New(isolate, value)); 578
579// } 579 auto f = [](compatibility_callback_info_type args)
580 580 -> compatibility_return_type {
581// EAPI 581 if (args.Length() != 1 || !args[0]->IsString())
582// void register_log_state_stop(v8::Isolate *isolate, 582 return compatibility_return();
583// v8::Handle<v8::Object> global, 583
584// v8::Handle<v8::String> name) 584 int l = eina_log_domain_level_get(*String::Utf8Value(args[0]));
585// { 585 auto ret = compatibility_new<Integer>(args.GetIsolate(), l);
586// int value = EINA_LOG_STATE_STOP; 586 return compatibility_return(ret, args);
587// global->Set(name, v8::Integer::New(isolate, value)); 587 };
588// } 588
589 589 global->Set(name,
590// EAPI 590 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
591// void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global, 591}
592// v8::Handle<v8::String> name) 592
593// { 593EAPI
594// using v8::FunctionCallbackInfo; 594void register_log_state_start(v8::Isolate *isolate,
595// using v8::Value; 595 v8::Handle<v8::Object> global,
596// using v8::FunctionTemplate; 596 v8::Handle<v8::String> name)
597// using v8::String; 597{
598 598 int value = EINA_LOG_STATE_START;
599// auto func = [](const FunctionCallbackInfo<Value> &info) { 599 global->Set(name, compatibility_new<v8::Integer>(isolate, value));
600// if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber() 600}
601// || !info[2]->IsString()) 601
602// return; 602EAPI
603 603void register_log_state_stop(v8::Isolate *isolate,
604// eina_log_timing(info[0]->NumberValue(), 604 v8::Handle<v8::Object> global,
605// static_cast<Eina_Log_State>(info[1]->NumberValue()), 605 v8::Handle<v8::String> name)
606// *String::Utf8Value(info[2])); 606{
607// }; 607 int value = EINA_LOG_STATE_STOP;
608 608 global->Set(name, compatibility_new<v8::Integer>(isolate, value));
609// global->Set(name, FunctionTemplate::New(isolate, func)->GetFunction()); 609}
610// } 610
611 611EAPI
612// } } } // namespace efl { namespace js { 612void register_log_timing(v8::Isolate *isolate, v8::Handle<v8::Object> global,
613 v8::Handle<v8::String> name)
614{
615 using v8::Value;
616 using v8::FunctionTemplate;
617 using v8::String;
618
619 auto f = [](compatibility_callback_info_type args)
620 -> compatibility_return_type {
621 if (args.Length() != 3 || !args[0]->IsNumber() || !args[1]->IsNumber()
622 || !args[2]->IsString()) {
623 return compatibility_return();
624 }
625
626 eina_log_timing(args[0]->NumberValue(),
627 static_cast<Eina_Log_State>(args[1]->NumberValue()),
628 *String::Utf8Value(args[2]));
629 };
630
631 global->Set(name,
632 compatibility_new<FunctionTemplate>(isolate, f)->GetFunction());
633}
634
635} } } // 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 8cf8dc2..906d82c 100644
--- a/src/bindings/eina_js/eina_js_log.hh
+++ b/src/bindings/eina_js/eina_js_log.hh
@@ -1,12 +1,21 @@
1#ifndef EINA_JS_LOG_HH 1#ifndef EINA_JS_LOG_HH
2#define EINA_JS_LOG_HH 2#define EINA_JS_LOG_HH
3 3
4#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
5#include <Eina.hh> 4#include <Eina.hh>
6#include <type_traits> 5#include EINA_STRINGIZE(V8_INCLUDE_HEADER)
6
7#include <eina_js_compatibility.hh>
7 8
8namespace efl { namespace eina { namespace js { 9namespace efl { namespace eina { namespace js {
9 10
11using ::efl::eina::js::compatibility_new;
12using ::efl::eina::js::compatibility_return_type;
13using ::efl::eina::js::compatibility_callback_info_type;
14using ::efl::eina::js::compatibility_return;
15using ::efl::eina::js::compatibility_get_pointer_internal_field;
16using ::efl::eina::js::compatibility_set_pointer_internal_field;
17using ::efl::eina::js::compatibility_persistent;
18
10void register_log_level_critical(v8::Isolate *isolate, 19void register_log_level_critical(v8::Isolate *isolate,
11 v8::Handle<v8::Object> global, 20 v8::Handle<v8::Object> global,
12 v8::Handle<v8::String> name); 21 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 42ec6d3..9c18be5 100644
--- a/src/tests/eina_js/eina_js_suite.cc
+++ b/src/tests/eina_js/eina_js_suite.cc
@@ -17,6 +17,7 @@
17#include <eina_js_list.hh> 17#include <eina_js_list.hh>
18#include <eina_js_iterator.hh> 18#include <eina_js_iterator.hh>
19#include <eina_js_error.hh> 19#include <eina_js_error.hh>
20#include <eina_js_log.cc>
20 21
21const char* ToCString(const v8::String::Utf8Value& value) { 22const char* ToCString(const v8::String::Utf8Value& value) {
22 return *value ? *value : "<string conversion failed>"; 23 return *value ? *value : "<string conversion failed>";
@@ -108,6 +109,35 @@ efl::eina::js::range_eina_list<int> raw_list;
108 109
109efl::eina::array<int> array; 110efl::eina::array<int> array;
110 111
112static void eina_log_print_cb_js_test(const Eina_Log_Domain *d,
113 Eina_Log_Level level, const char *file,
114 const char *fnc, int line,
115 const char */*fmt*/, void */*data*/,
116 va_list args)
117{
118 static int index = 0;
119
120 const char *msg = va_arg(args, const char*);
121
122 std::string domains[] = {"", "", "", "mydomain", "mydomain2"};
123 int levels[] = {EINA_LOG_LEVEL_DBG, EINA_LOG_LEVEL_CRITICAL,
124 EINA_LOG_LEVEL_WARN, EINA_LOG_LEVEL_INFO,
125 EINA_LOG_LEVEL_ERR};
126 std::string functions[] = {"f1", "", "f2", "f3", ""};
127 int lines[] = {190, 191, 192, 193, 199};
128 std::string messages[] = {"I changed again", "Cool to Hate",
129 "One Fine Day", "Never Gonna Find Me",
130 "The Kids Aren't Alright"};
131
132 assert(std::string(d->name, d->namelen) == domains[index]);
133 assert(level == levels[index]);
134 assert(file == std::string("eina_js_suite.js"));
135 assert(fnc == functions[index]);
136 assert(line == lines[index]);
137 assert(msg == messages[index]);
138 ++index;
139}
140
111void test_setup(v8::Handle<v8::Object> exports) 141void test_setup(v8::Handle<v8::Object> exports)
112{ 142{
113 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 143 v8::Isolate* isolate = v8::Isolate::GetCurrent();
@@ -165,6 +195,141 @@ void test_setup(v8::Handle<v8::Object> exports)
165 , efl::eina::js::compatibility_new<v8::String>(isolate, "value")); 195 , efl::eina::js::compatibility_new<v8::String>(isolate, "value"));
166 196
167 std::cerr << __LINE__ << std::endl; 197 std::cerr << __LINE__ << std::endl;
198
199 // log
200 using namespace efl::eina::js;
201 using v8::String;
202 {
203 int d = eina_log_domain_register("mydomain", "");
204 eina_log_domain_registered_level_set(d, EINA_LOG_LEVEL_DBG);
205 exports->Set(compatibility_new<String>(isolate, "mydomain"),
206 value_cast<v8::Local<v8::Value>>(d, isolate));
207 }
208 register_log_level_critical(isolate, exports,
209 compatibility_new<String>(isolate,
210 "LOG_LEVEL_CRITICAL"));
211 register_log_level_err(isolate, exports,
212 compatibility_new<String>(isolate, "LOG_LEVEL_ERR"));
213 register_log_level_warn(isolate, exports,
214 compatibility_new<String>(isolate, "LOG_LEVEL_WARN"));
215 register_log_level_info(isolate, exports,
216 compatibility_new<String>(isolate, "LOG_LEVEL_INFO"));
217 register_log_level_dbg(isolate, exports,
218 compatibility_new<String>(isolate, "LOG_LEVEL_DBG"));
219 register_log_domain_global(isolate, exports,
220 compatibility_new<String>(isolate,
221 "LOG_DOMAIN_GLOBAL"));
222 register_log_print(isolate, exports,
223 compatibility_new<String>(isolate, "log_print"));
224 register_log_domain_register(isolate, exports,
225 compatibility_new<String>(isolate,
226 "log_domain"
227 "_register"));
228 register_log_domain_unregister(isolate, exports,
229 compatibility_new<String>(isolate,
230 "log_domain_unregis"
231 "ter"));
232 register_log_domain_registered_level_get(isolate, exports,
233 compatibility_new<String>(isolate,
234 "log"
235 "_domain"
236 "_register"
237 "ed_level"
238 "_get"));
239 register_log_domain_registered_level_set(isolate, exports,
240 compatibility_new<String>(isolate,
241 "log"
242 "_domain"
243 "_register"
244 "ed_level"
245 "_set"));
246 register_log_print_cb_set(isolate, exports,
247 compatibility_new<String>(isolate,
248 "log_print_cb_set"));
249 register_log_level_set(isolate, exports,
250 compatibility_new<String>(isolate, "log_level_set"));
251 register_log_level_get(isolate, exports,
252 compatibility_new<String>(isolate, "log_level_get"));
253 register_log_level_check(isolate, exports,
254 compatibility_new<String>(isolate,
255 "log_level_check"));
256 register_log_color_disable_set(isolate, exports,
257 compatibility_new<String>(isolate,
258 "log_color_disable"
259 "_set"));
260 register_log_color_disable_get(isolate, exports,
261 compatibility_new<String>(isolate,
262 "log_color_disable"
263 "_get"));
264 register_log_file_disable_set(isolate, exports,
265 compatibility_new<String>(isolate,
266 "log_file_disable"
267 "_set"));
268 register_log_file_disable_get(isolate, exports,
269 compatibility_new<String>(isolate,
270 "log_file_disable"
271 "_get"));
272 register_log_abort_on_critical_set(isolate, exports,
273 compatibility_new<String>(isolate,
274 "log_abort_on"
275 "_critical"
276 "_set"));
277 register_log_abort_on_critical_get(isolate, exports,
278 compatibility_new<String>(isolate,
279 "log_abort_on"
280 "_critical"
281 "_get"));
282 register_log_function_disable_set(isolate, exports,
283 compatibility_new<String>(isolate,
284 "log_function"
285 "_disable_set"));
286 register_log_function_disable_get(isolate, exports,
287 compatibility_new<String>(isolate,
288 "log_function"
289 "_disable_get"));
290 register_log_abort_on_critical_set(isolate, exports,
291 compatibility_new<String>(isolate,
292 "log_abort_on"
293 "_critical"
294 "_set"));
295 register_log_abort_on_critical_get(isolate, exports,
296 compatibility_new<String>(isolate,
297 "log_abort_on"
298 "_critical"
299 "_get"));
300 register_log_abort_on_critical_level_set(isolate, exports,
301 compatibility_new<String>(isolate,
302 "log_abort"
303 "_on"
304 "_critical"
305 "_level"
306 "_set"));
307 register_log_abort_on_critical_level_get(isolate, exports,
308 compatibility_new<String>(isolate,
309 "log_abort"
310 "_on"
311 "_critical"
312 "_level"
313 "_get"));
314 register_log_domain_level_set(isolate, exports,
315 compatibility_new<String>(isolate,
316 "log_domain_level"
317 "_set"));
318 register_log_domain_level_get(isolate, exports,
319 compatibility_new<String>(isolate,
320 "log_domain_level"
321 "_get"));
322 register_log_state_start(isolate, exports,
323 compatibility_new<String>(isolate,
324 "LOG_STATE_START"));
325 register_log_state_stop(isolate, exports,
326 compatibility_new<String>(isolate, "LOG_STATE_STOP"));
327 register_log_timing(isolate, exports,
328 compatibility_new<String>(isolate, "log_timing"));
329
330 eina_log_print_cb_set(eina_log_print_cb_js_test, NULL);
331 eina_log_level_set(EINA_LOG_LEVEL_DBG);
332 eina_log_abort_on_critical_set(EINA_FALSE);
168} 333}
169 334
170#ifndef HAVE_NODEJS 335#ifndef HAVE_NODEJS
@@ -212,7 +377,7 @@ int main(int, char*[])
212 // Enter the execution environment before evaluating any code. 377 // Enter the execution environment before evaluating any code.
213 v8::Context::Scope context_scope(context); 378 v8::Context::Scope context_scope(context);
214 v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String> 379 v8::Local<v8::String> name(efl::eina::js::compatibility_new<v8::String>
215 (nullptr, "(shell)")); 380 (nullptr, "eina_js_suite.js"));
216 v8::Local<v8::Object> global = context->Global(); 381 v8::Local<v8::Object> global = context->Global();
217 v8::Handle<v8::Object> console = efl::eina::js::compatibility_new<v8::Object>(isolate); 382 v8::Handle<v8::Object> console = efl::eina::js::compatibility_new<v8::Object>(isolate);
218 global->Set(efl::eina::js::compatibility_new<v8::String>(isolate, "console"), console); 383 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 d43b1c7..1c73bf5 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");
186} 186}
187assert(captured === true, 'value #12'); 187assert(captured === true, 'value #12');
188 188
189// log
190
191function f1(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_DBG, 'I changed again'); }; f1();
192suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_CRITICAL, 'Cool to Hate');
193function f2(){ suite.log_print(suite.LOG_DOMAIN_GLOBAL, suite.LOG_LEVEL_WARN, 'One Fine Day'); }; f2();
194function f3(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_INFO, 'Never Gonna Find Me'); }; f3();
195
196mydomain2 = suite.log_domain_register('mydomain2', '');
197suite.log_domain_registered_level_set(mydomain2, suite.LOG_LEVEL_DBG);
198assert(suite.log_domain_registered_level_get(mydomain2) === suite.LOG_LEVEL_DBG, '#1');
199
200suite.log_print(mydomain2, suite.LOG_LEVEL_ERR, "The Kids Aren't Alright");
201
202suite.log_domain_unregister(mydomain2);
203mydomain2 = undefined;
204
205suite.log_color_disable_set(true);
206assert(suite.log_color_disable_get() === true, '#2');
207suite.log_color_disable_set(false);
208assert(suite.log_color_disable_get() === false, '#3');
209
210suite.log_file_disable_set(true);
211assert(suite.log_file_disable_get() === true, '#4');
212suite.log_file_disable_set(false);
213assert(suite.log_file_disable_get() === false, '#5');
214
215suite.log_function_disable_set(true);
216assert(suite.log_function_disable_get() === true, '#6');
217suite.log_function_disable_set(false);
218assert(suite.log_function_disable_get() === false, '#7');
219
220suite.log_abort_on_critical_set(true);
221assert(suite.log_abort_on_critical_get() === true, '#8');
222suite.log_abort_on_critical_set(false);
223assert(suite.log_abort_on_critical_get() === false, '#9');
224
225var entered = false;
226suite.log_print_cb_set(function(domain, color, level, file, func, line, msg) {
227 assert(domain === 'mydomain', '#10');
228 assert(color === '', '#11');
229 assert(level === suite.LOG_LEVEL_WARN, '#12');
230 assert(file === 'eina_js_suite.js', '#13');
231 assert(func === 'f4', '#14');
232 assert(line === 236, '#15');
233 assert(msg === 'What Happened To You', '#16');
234 entered = true;
235});
236
237function f4(){ suite.log_print(suite.mydomain, suite.LOG_LEVEL_WARN, 'What Happened To You'); }; f4();
238assert(entered === true, '#17');
239
240assert(suite.log_level_get() === suite.LOG_LEVEL_DBG, '#18');
241assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === true, '#19');
242suite.log_level_set(suite.LOG_LEVEL_CRITICAL);
243assert(suite.log_level_get() === suite.LOG_LEVEL_CRITICAL, '#20');
244assert(suite.log_level_check(suite.LOG_LEVEL_INFO) === false, '#21');
245
246assert(suite.log_abort_on_critical_get() === false, '#22');
247suite.log_abort_on_critical_set(true);
248assert(suite.log_abort_on_critical_get() === true, '#23');
249
250suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_CRITICAL);
251assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_CRITICAL, '#24');
252suite.log_abort_on_critical_level_set(suite.LOG_LEVEL_ERR);
253assert(suite.log_abort_on_critical_level_get() == suite.LOG_LEVEL_ERR, '#25');
254
255suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_WARN);
256assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_WARN, '#26');
257suite.log_domain_level_set('mydomain', suite.LOG_LEVEL_INFO);
258assert(suite.log_domain_level_get('mydomain') === suite.LOG_LEVEL_INFO, '#27');
259
260assert(typeof(suite.LOG_STATE_START) === 'number', '#28');
261assert(typeof(suite.LOG_STATE_STOP) === 'number', '#29');
262assert(typeof(suite.log_timing) === 'function', '#30');
263
189// finished tests 264// finished tests
190 265
191console.log ("Test execution with success"); 266console.log ("Test execution with success");