summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-06-08 10:00:15 +0300
committerAvi Levin <avi.levin@samsung.com>2015-06-08 10:00:15 +0300
commit9009c070fde2c5b560409ab4677e291a42e137a6 (patch)
tree49f42fd729074ae0c88a96041e0c21ed1054ad2a
parentaea0f1747d36978d0811c2d46becc7bccee230d3 (diff)
Eolian_info: Adding support in setting depth max
Depth in the distance from the root class ( that was given in CLI ). We can add "-d depth" and it will print only classes that their depth is <= depth.
-rw-r--r--src/bin/.main.c.swpbin49152 -> 45056 bytes
-rw-r--r--src/bin/main.c165
2 files changed, 107 insertions, 58 deletions
diff --git a/src/bin/.main.c.swp b/src/bin/.main.c.swp
index 05c4691..be2e39e 100644
--- a/src/bin/.main.c.swp
+++ b/src/bin/.main.c.swp
Binary files differ
diff --git a/src/bin/main.c b/src/bin/main.c
index 838ba3f..f89a224 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -6,14 +6,12 @@
6 6
7int _eolian_info_log_dom; 7int _eolian_info_log_dom;
8 8
9
10/* 9/*
11 * 10 *
12 * ** ./src/bin/eo_info_cmd --mode i_t -I /home/avilog/git/efl1/efl/src/lib/ -I /home/avilog/git/efl1/elementary/src/lib/ --class elm_layout.eo 11 * ** ./src/bin/eo_info_cmd --scope i_t -I /home/avilog/git/efl1/efl/src/lib/ -I /home/avilog/git/efl1/elementary/src/lib/ --class elm_layout.eo
13 * 12 *
14 */ 13 */
15 14
16
17#ifdef ERR 15#ifdef ERR
18# undef ERR 16# undef ERR
19#endif 17#endif
@@ -39,9 +37,9 @@ int _eolian_info_log_dom;
39#endif 37#endif
40#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_info_log_dom, __VA_ARGS__) 38#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_info_log_dom, __VA_ARGS__)
41 39
42static void _prints_inherit_tree_mode(const Eolian_Class *ekl); 40static void _prints_inherit_tree_scope(const Eolian_Class *ekl, int depth_max);
43static void _prints_inherits_from_mode(const Eolian_Class *ekl); 41static void _prints_inherits_from_scope(const Eolian_Class *ekl, int depth_max);
44static void _prints_class_mode(const Eolian_Class *ekl); 42static void _prints_class_scope(const Eolian_Class *ekl, int depth_max);
45static void _file_filter(const Eolian_Class *ekl, Eina_Strbuf *buf); 43static void _file_filter(const Eolian_Class *ekl, Eina_Strbuf *buf);
46static void _event_filter(const Eolian_Class *ekl, Eina_Strbuf *buf); 44static void _event_filter(const Eolian_Class *ekl, Eina_Strbuf *buf);
47 45
@@ -53,13 +51,13 @@ Eina_Inlist *classes_edges_list = NULL;
53typedef struct 51typedef struct
54{ 52{
55 const char *name_l, *name_s; 53 const char *name_l, *name_s;
56 void (*func)(const Eolian_Class *ekl); 54 void (*func)(const Eolian_Class *ekl, int depth_max);
57} _mode; 55} _scope;
58 56
59static _mode _modes[] = { 57static _scope _scopes[] = {
60 {"inheritance_tree", "i_t",_prints_inherit_tree_mode}, 58 {"inheritance_tree", "i_t",_prints_inherit_tree_scope},
61 {"inherited_from", "i_f", _prints_inherits_from_mode}, 59 {"inherited_from", "i_f", _prints_inherits_from_scope},
62 {"class", "cl", _prints_class_mode}, 60 {"class", "cl", _prints_class_scope},
63 {NULL, NULL, NULL} 61 {NULL, NULL, NULL}
64}; 62};
65 63
@@ -139,14 +137,13 @@ static void _print_class(const char *class_name)
139 const Eolian_Class *ekl = eolian_class_get_by_name(class_name); 137 const Eolian_Class *ekl = eolian_class_get_by_name(class_name);
140 const char* desc = eolian_class_description_get(ekl); 138 const char* desc = eolian_class_description_get(ekl);
141 fprintf(_file, "\"%s\" [tooltip= \"%s\" ", 139 fprintf(_file, "\"%s\" [tooltip= \"%s\" ",
142 class_name, ( desc ? desc : class_name)); 140 class_name, ( desc ? eina_str_escape(desc) : class_name));
143 141
144 _filter *current_f = _filters; 142 _filter *current_f = _filters;
145 int i = 0; 143 int i = 0;
146 144
147 fprintf(_file, "label=\"{"); 145 fprintf(_file, "label=\"{");
148 146
149
150/* Allways print class name */ 147/* Allways print class name */
151 fprintf(_file, "<f%d> ", i); 148 fprintf(_file, "<f%d> ", i);
152 i++; 149 i++;
@@ -177,7 +174,6 @@ static void _print_class(const char *class_name)
177 } 174 }
178 eina_strbuf_free(buf); 175 eina_strbuf_free(buf);
179 fprintf(_file, "}\"]\n"); 176 fprintf(_file, "}\"]\n");
180
181} 177}
182 178
183static void _print_graph() 179static void _print_graph()
@@ -232,7 +228,7 @@ static void _print_graph()
232 EINA_INLIST_FOREACH_SAFE(classes_edges_list, nnode, node) 228 EINA_INLIST_FOREACH_SAFE(classes_edges_list, nnode, node)
233 { 229 {
234 if(node->parent && node->class) 230 if(node->parent && node->class)
235 fprintf(_file, "\"%s\" -> \"%s\"\n", node->parent, node->class); 231 fprintf(_file, "\"%s\" -> \"%s\"\n [dir=back]", node->parent, node->class);
236 } 232 }
237 233
238 fprintf(_file, "}\n"); 234 fprintf(_file, "}\n");
@@ -246,7 +242,6 @@ static void _print_graph()
246 242
247 free(node); 243 free(node);
248 } 244 }
249
250} 245}
251 246
252static void 247static void
@@ -272,63 +267,109 @@ _add_class_edge(const char *class_name, const char *parent_name)
272 classes_edges_list = eina_inlist_append(classes_edges_list, EINA_INLIST_GET(d)); 267 classes_edges_list = eina_inlist_append(classes_edges_list, EINA_INLIST_GET(d));
273} 268}
274 269
275static void _prints_class_mode(const Eolian_Class *ekl) 270static void _prints_class_scope(const Eolian_Class *ekl, int depth_max)
276{ 271{
277 _add_class_edge( 272 _add_class_edge(
278 eolian_class_full_name_get(ekl), NULL); 273 eolian_class_full_name_get(ekl), NULL);
279} 274}
280 275
281static void _prints_inherit_tree_mode(const Eolian_Class *ekl) 276static void _prints_inherit_tree_scope_rec(const Eolian_Class *ekl, int depth)
282{ 277{
283 int depth = 0; 278 if(depth<= 0 )
279 return;
280
281 Eina_Iterator *lst = eolian_class_inherits_get(ekl);
282 const char* class_name = eolian_class_full_name_get(ekl);
283 const char* ekl_name;
284 EINA_ITERATOR_FOREACH(lst, ekl_name)
285 {
286 ekl=eolian_class_get_by_name(ekl_name);
287
288 _add_class_edge(
289 class_name, eolian_class_full_name_get(ekl));
290
291 _prints_inherit_tree_scope_rec(ekl, depth - 1);
292 }
293 eina_iterator_free(lst);
284 294
285 _push_queue(ekl); 295}
296
297static void _prints_inherit_tree_scope(const Eolian_Class *ekl, int depth_max)
298{
299 if(depth_max<= 0 )
300 return;
286 301
287 _add_class_edge( 302 _add_class_edge(
288 eolian_class_full_name_get(ekl), NULL); 303 eolian_class_full_name_get(ekl), NULL);
289 304
290 while((ekl = _pop_queue())) 305 _prints_inherit_tree_scope_rec(ekl, depth_max);
306}
307
308static int
309_prints_inherits_from_scope_recur(const Eolian_Class *ekl,
310 Eina_Hash *classes_hash, const char *des_class_name, int depth_max)
311{
312 const char *class_name = eolian_class_full_name_get(ekl);
313 if(class_name == des_class_name)
314 return 1;
315
316 int min_found_depth = -1;
317 Eina_Iterator *lst_i = eolian_class_inherits_get(ekl);
318 const char *ekl_i;
319
320 if(!lst_i) return -1;
321
322 EINA_ITERATOR_FOREACH(lst_i, ekl_i);
291 { 323 {
292 Eina_Iterator *lst = eolian_class_inherits_get(ekl); 324 ekl = eolian_class_get_by_name(ekl_i);
293 const char* class_name = eolian_class_full_name_get(ekl); 325 void *hash = eina_hash_find(classes_hash, ekl);
294 const char* ekl_name; 326 int depth_class = -1;
295 EINA_ITERATOR_FOREACH(lst, ekl_name) 327 if(!hash)
296 { 328 {
297 ekl=eolian_class_get_by_name(ekl_name); 329 depth_class = _prints_inherits_from_scope_recur(
298 _push_queue(ekl); 330 ekl, classes_hash, des_class_name, depth_max);
331 eina_hash_add(classes_hash, ekl, (void*)(int64_t)depth_class );
299 332
300 _add_class_edge(
301 eolian_class_full_name_get(ekl), class_name);
302 } 333 }
303 eina_iterator_free(lst); 334 else depth_class = (int)(int64_t)hash;
335
336 if(depth_class>=0){
337
338 if(depth_class<=depth_max){
339 _add_class_edge(
340 class_name, ekl_i);
341 }
342 if((min_found_depth == -1) ||(min_found_depth>depth_class))
343 min_found_depth = depth_class;
344 }
304 } 345 }
305 queue_size = 0; 346 eina_iterator_free(lst_i);
347
348 return min_found_depth>=0 ? min_found_depth+1 : -1;
306} 349}
307 350
308static void _prints_inherits_from_mode(const Eolian_Class *ekl) 351static void _prints_inherits_from_scope(const Eolian_Class *ekl, int depth_max)
309{ 352{
310 Eina_Iterator *lst = eolian_all_classes_get();
311 const char* class_name = eolian_class_full_name_get(ekl); 353 const char* class_name = eolian_class_full_name_get(ekl);
354 if(depth_max<= 0 )
355 return;
356
357 Eina_Hash *classes_hash = eina_hash_string_superfast_new(NULL);
312 358
313 _add_class_edge( 359 _add_class_edge(
314 class_name, NULL); 360 class_name, NULL);
315 361
362 Eina_Iterator *lst = eolian_all_classes_get();
363
316 EINA_ITERATOR_FOREACH(lst, ekl) 364 EINA_ITERATOR_FOREACH(lst, ekl)
317 { 365 {
318 if(!ekl) continue; 366 if(!eina_hash_find(classes_hash, ekl))
319 Eina_Iterator *lst_i = eolian_class_inherits_get(ekl);
320 if(!lst_i) continue;
321
322 const char *ekl_i;
323 EINA_ITERATOR_FOREACH(lst_i, ekl_i)
324 { 367 {
325 if(ekl_i == class_name){ 368 _prints_inherits_from_scope_recur(
326 369 ekl, classes_hash, class_name, depth_max);
327 _add_class_edge(
328 class_name, eolian_class_full_name_get(ekl));
329 }
330 } 370 }
331 } 371 }
372
332 eina_iterator_free(lst); 373 eina_iterator_free(lst);
333} 374}
334 375
@@ -340,13 +381,13 @@ static void _print_help(const char *program)
340 printf(" --output/-o <outFile> Set output filename to <outFile>\n"); 381 printf(" --output/-o <outFile> Set output filename to <outFile>\n");
341 printf(" --include/-I <includeDir> Add <includeDir> to the list of include dirs for scanning\n"); 382 printf(" --include/-I <includeDir> Add <includeDir> to the list of include dirs for scanning\n");
342 printf(" --scope/-s <scope> Set scope(of classes we will work on) to one of:\n "); 383 printf(" --scope/-s <scope> Set scope(of classes we will work on) to one of:\n ");
343 _mode *current_m = _modes; 384 _scope *current_s = _scopes;
344 385
345 while(current_m->name_l != NULL ) 386 while(current_s->name_l != NULL )
346 { 387 {
347 printf("%s(or %s), ", current_m->name_l, current_m->name_s); 388 printf("%s(or %s), ", current_s->name_l, current_s->name_s);
348 389
349 current_m++; 390 current_s++;
350 } 391 }
351 printf("\n"); 392 printf("\n");
352 printf(" --filters/-f <filter1,...> Set filters(the info of the class\n "\ 393 printf(" --filters/-f <filter1,...> Set filters(the info of the class\n "\
@@ -368,8 +409,9 @@ static void _print_help(const char *program)
368int main(int argc, char **argv) 409int main(int argc, char **argv)
369{ 410{
370 int ret = 1; 411 int ret = 1;
412 int max_depth = 0;
371 char *class_path ="elm_layout.eo";// argv[2]; 413 char *class_path ="elm_layout.eo";// argv[2];
372 char* mode = NULL, *output = NULL, *filter = NULL; 414 char* scope = NULL, *output = NULL, *filter = NULL;
373 Eina_Bool help = EINA_FALSE, show = EINA_FALSE; 415 Eina_Bool help = EINA_FALSE, show = EINA_FALSE;
374 416
375 eina_init(); 417 eina_init();
@@ -390,6 +432,7 @@ int main(int argc, char **argv)
390 {"help", no_argument, 0, 'h'}, 432 {"help", no_argument, 0, 'h'},
391 {"scope", required_argument, 0, 's'}, 433 {"scope", required_argument, 0, 's'},
392 {"output", required_argument, 0, 'o'}, 434 {"output", required_argument, 0, 'o'},
435 {"depth", required_argument, 0, 'd'},
393 {"include", required_argument, 0, 'I'}, 436 {"include", required_argument, 0, 'I'},
394 {"filters", required_argument, 0, 'f'}, 437 {"filters", required_argument, 0, 'f'},
395 {0, 0, 0, 0} 438 {0, 0, 0, 0}
@@ -407,9 +450,15 @@ int main(int argc, char **argv)
407 450
408 break; 451 break;
409 } 452 }
453 case 'd':
454 {
455 max_depth = atoi(optarg);
456
457 break;
458 }
410 case 's': 459 case 's':
411 { 460 {
412 mode = optarg; 461 scope = optarg;
413 462
414 break; 463 break;
415 } 464 }
@@ -468,13 +517,13 @@ int main(int argc, char **argv)
468 } 517 }
469 } 518 }
470 519
471 if(mode) 520 if(scope)
472 { 521 {
473 eolian_all_eo_files_parse(); 522 eolian_all_eo_files_parse();
474 while(name_start < name_end) 523 while(name_start < name_end)
475 { 524 {
476 char *class_path = argv[name_start++]; 525 char *class_path = argv[name_start++];
477 _mode *current_m = _modes; 526 _scope *current_s = _scopes;
478 const Eolian_Class *ekl = NULL; 527 const Eolian_Class *ekl = NULL;
479 if(eina_str_has_extension(class_path, ".eo")) 528 if(eina_str_has_extension(class_path, ".eo"))
480 { 529 {
@@ -491,16 +540,16 @@ int main(int argc, char **argv)
491 goto end; 540 goto end;
492 } 541 }
493 542
494 while(current_m->name_l != NULL ) 543 while(current_s->name_l != NULL )
495 { 544 {
496 545
497 if(!strcmp(current_m->name_s, mode) || !strcmp(current_m->name_l, mode)) 546 if(!strcmp(current_s->name_s, scope) || !strcmp(current_s->name_l, scope))
498 { 547 {
499 current_m->func(ekl); 548 current_s->func(ekl, max_depth);
500 break; 549 break;
501 } 550 }
502 551
503 current_m++; 552 current_s++;
504 } 553 }
505 554
506 } 555 }
@@ -522,7 +571,7 @@ int main(int argc, char **argv)
522 } 571 }
523 else 572 else
524 { 573 {
525 ERR("No mode specified"); 574 ERR("No scope specified");
526 goto end; 575 goto end;
527 } 576 }
528end: 577end: