summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-06-02 13:41:49 +0300
committerAvi Levin <avi.levin@samsung.com>2015-06-02 15:28:10 +0300
commit193a59c253d445190a261814698ecf7b2d927e73 (patch)
treebef91dc95dbab59298fa7e98b84fb8b162043496
parent0a808b618b24a10c2fdbf86cdbd25e303db08742 (diff)
Eolian_info: cleaning code and fixing minor bugs
-rw-r--r--.gitignore1
-rw-r--r--notes70
-rw-r--r--src/bin/.main.c.swpbin24576 -> 24576 bytes
-rw-r--r--src/bin/main.c102
4 files changed, 128 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 8708600..c04e721 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
3*.o 3*.o
4*.pyc 4*.pyc
5/build 5/build
6notes
diff --git a/notes b/notes
index f23452f..22ce927 100644
--- a/notes
+++ b/notes
@@ -1,5 +1,7 @@
1dot -Tpng class.dot -o class.png 1dot -Tpng class.dot -o class.png
2 2
3dot -Tsvg test.dot -o test.svg
4
3efreet.config.home.get = get the user home directory 5efreet.config.home.get = get the user home directory
4to save in ~/.config/app/ 6to save in ~/.config/app/
5 7
@@ -20,3 +22,71 @@ efreet_shutdown();
20 22
21./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 23./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
22 24
25regex:
26http://www.peope.net/old/regex.html
27regex_t regex;
28int reti;
29char msgbuf[100];
30
31/* Compile regular expression */
32reti = regcomp(&regex, "^a[1-9]", 0);
33if( reti ){ fprintf(stderr, "Could not compile regex\n"); exit(1); }
34
35/* Execute regular expression */
36reti = regexec(&regex, "at", 0, NULL, 0);
37if( !reti ){
38 puts("Match");
39}
40else if( reti == REG_NOMATCH ){
41 puts("No match");
42}
43else{
44 regerror(reti, &regex, msgbuf, sizeof(msgbuf));
45 fprintf(stderr, "Regex match failed: %s\n", msgbuf);
46 exit(1);
47}
48
49/* Free compiled regular expression if you want to use the regex_t again */
50regfree(&regex);
51
52
53
54
55static Eina_Inlist* _prints_inherit_tree_text(const Eolian_Class *ekl, Eina_Inlist *classes_list)
56{
57 int depth = 0;
58 _push_queue(ekl);
59 int count_cur = 1, count_childs = 0;
60 // _print_class(_win_kl);
61 printf("\n**Depth: %d**\n", depth);
62
63 while((ekl = _pop_queue()))
64 {
65 Eina_Iterator *lst = eolian_class_inherits_get(ekl);
66
67 if(count_cur==0)
68 {
69 count_cur = count_childs;
70 count_childs =0;
71 depth++;
72 printf("\n** Depth: %d **\n", depth);
73 }
74 count_cur--;
75 const char *ekli_name;
76 EINA_ITERATOR_FOREACH(lst, ekl_name)
77 {
78
79 ekl=eolian_class_get_by_name(ekl_name);
80
81 // _print_class(_win_kl);
82
83 _push_queue(ekl);
84 count_childs++;
85 // _prints_inherits_recur(_win_kl, depth+1);
86 }
87 eina_iterator_free(lst);
88
89 }
90 return classes_list;
91}
92
diff --git a/src/bin/.main.c.swp b/src/bin/.main.c.swp
index fecd950..237d49d 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 4b7e710..983e6ec 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -39,8 +39,9 @@ int _eolian_info_log_dom;
39#endif 39#endif
40#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_info_log_dom, __VA_ARGS__) 40#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_info_log_dom, __VA_ARGS__)
41 41
42static Eina_Inlist* _prints_inherit_tree(const char* class_path, Eina_Inlist *classes_list); 42static Eina_Inlist* _prints_inherit_tree_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list);
43static Eina_Inlist* _prints_inherits_from(const char* class_path, Eina_Inlist *classes_list); 43static Eina_Inlist* _prints_inherits_from_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list);
44static Eina_Inlist* _prints_class_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list);
44static void _file_filter(const Eolian_Class *ekl, Eina_Strbuf *buf); 45static void _file_filter(const Eolian_Class *ekl, Eina_Strbuf *buf);
45static void _event_filter(const Eolian_Class *ekl, Eina_Strbuf *buf); 46static void _event_filter(const Eolian_Class *ekl, Eina_Strbuf *buf);
46 47
@@ -51,12 +52,13 @@ FILE* _file = NULL;
51typedef struct 52typedef struct
52{ 53{
53 const char *name_l, *name_s; 54 const char *name_l, *name_s;
54 Eina_Inlist* (*func)(const char*, Eina_Inlist *classes_list); 55 Eina_Inlist* (*func)(const Eolian_Class *ekl, Eina_Inlist *classes_list);
55} _mode; 56} _mode;
56 57
57static _mode _modes[] = { 58static _mode _modes[] = {
58 {"inheritance_tree", "i_t",_prints_inherit_tree}, 59 {"inheritance_tree", "i_t",_prints_inherit_tree_mode},
59 {"inherited_from", "i_f", _prints_inherits_from}, 60 {"inherited_from", "i_f", _prints_inherits_from_mode},
61 {"class", "cl", _prints_class_mode},
60 {NULL, NULL, NULL} 62 {NULL, NULL, NULL}
61}; 63};
62 64
@@ -132,20 +134,27 @@ static void _event_filter(const Eolian_Class *ekl, Eina_Strbuf *buf)
132 eina_iterator_free(lst_events); 134 eina_iterator_free(lst_events);
133} 135}
134 136
135static void _print_class(_Class_Node *node) 137static void _print_class(const char *class_name)
136{ 138{
137 // printf("Class %s\n", eolian_class_file_get(_win_kl)); 139 // printf("Class %s\n", eolian_class_file_get(_win_kl));
138 140
139 const Eolian_Class *ekl = eolian_class_get_by_name(node->class); 141 const Eolian_Class *ekl = eolian_class_get_by_name(class_name);
140 const char* desc = eolian_class_description_get(ekl); 142 const char* desc = eolian_class_description_get(ekl);
141 fprintf(_file, "\"%s\" [tooltip= \"%s\" ", 143 fprintf(_file, "\"%s\" [tooltip= \"%s\" ",
142 node->class, ( desc ? desc : node->class)); 144 class_name, ( desc ? desc : class_name));
143 145
144 _filter *current_f = _filters; 146 _filter *current_f = _filters;
145 int i = 0; 147 int i = 0;
146 148
147 fprintf(_file, "label=\"{"); 149 fprintf(_file, "label=\"{");
148 150
151
152/* Allways print class name */
153 fprintf(_file, "<f%d> ", i);
154 i++;
155 fprintf(_file, "%s\n", class_name);
156
157
149 Eina_Strbuf *buf = eina_strbuf_new(); 158 Eina_Strbuf *buf = eina_strbuf_new();
150 159
151 while(current_f->name != NULL ) 160 while(current_f->name != NULL )
@@ -213,18 +222,21 @@ static void _print_graph( Eina_Inlist *classes_list)
213 222
214} 223}
215 224
216static Eina_Inlist* _prints_inherit_tree(const char* class_path, Eina_Inlist *classes_list) 225static Eina_Inlist* _prints_class_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list)
217{ 226{
218 int depth = 0; 227 const char* class_name = eolian_class_full_name_get(ekl);
219 228
220 eolian_file_parse(class_path); 229 _Class_Node* d = malloc(sizeof(*d));
221 const Eolian_Class *ekl = eolian_class_get_by_file(class_path); 230 d->class = class_name;
222 if(!ekl) 231 d->parent = NULL;
223 { 232 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d));
224 233
225 ERR("Class %s no found", class_path); 234 return classes_list;
226 return classes_list; 235}
227 } 236
237static Eina_Inlist* _prints_inherit_tree_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list)
238{
239 int depth = 0;
228 240
229 _push_queue(ekl); 241 _push_queue(ekl);
230 242
@@ -239,23 +251,20 @@ static Eina_Inlist* _prints_inherit_tree(const char* class_path, Eina_Inlist *cl
239 _push_queue(ekl); 251 _push_queue(ekl);
240 252
241 _Class_Node* d = malloc(sizeof(*d)); 253 _Class_Node* d = malloc(sizeof(*d));
242 d->class = eolian_class_full_name_get(ekl); 254 d->class = class_name;
243 d->parent = class_name; 255 d->parent = eolian_class_full_name_get(ekl);
244 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d)); 256 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d));
245
246 } 257 }
247 eina_iterator_free(lst); 258 eina_iterator_free(lst);
248
249 } 259 }
260 queue_size = 0;
261
250 return classes_list; 262 return classes_list;
251} 263}
252 264
253static Eina_Inlist* _prints_inherits_from(const char* class_path, Eina_Inlist *classes_list) 265static Eina_Inlist* _prints_inherits_from_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list)
254{ 266{
255
256 eolian_all_eo_files_parse();
257 Eina_Iterator *lst = eolian_all_classes_get(); 267 Eina_Iterator *lst = eolian_all_classes_get();
258 const Eolian_Class *ekl = eolian_class_get_by_file(class_path);
259 const char* class_name = eolian_class_full_name_get(ekl); 268 const char* class_name = eolian_class_full_name_get(ekl);
260 269
261 EINA_ITERATOR_FOREACH(lst, ekl) 270 EINA_ITERATOR_FOREACH(lst, ekl)
@@ -270,17 +279,13 @@ static Eina_Inlist* _prints_inherits_from(const char* class_path, Eina_Inlist *c
270 // printf("i class name %s\n", ekl_i); 279 // printf("i class name %s\n", ekl_i);
271 if(ekl_i == class_name){ 280 if(ekl_i == class_name){
272 281
273 _Class_Node* d = malloc(sizeof(*d)); 282 _Class_Node* d = malloc(sizeof(*d));
274 d->class = eolian_class_full_name_get(ekl); 283 d->class = eolian_class_full_name_get(ekl);
275 d->parent = class_name; 284 d->parent = class_name;
276 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d)); 285 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d));
277 // printf("adding class name %s\n", eolian_class_file_get(ekl));
278
279 } 286 }
280 } 287 }
281
282 eina_iterator_free(lst_i); 288 eina_iterator_free(lst_i);
283
284 } 289 }
285 eina_iterator_free(lst); 290 eina_iterator_free(lst);
286 291
@@ -319,7 +324,7 @@ int main(int argc, char **argv)
319 }; 324 };
320 int long_index =0, opt; 325 int long_index =0, opt;
321 while ((opt = getopt_long(argc, argv,"vho:I:", long_options, &long_index )) != -1) 326 while ((opt = getopt_long(argc, argv,"vho:I:", long_options, &long_index )) != -1)
322 { 327 {
323 switch (opt) { 328 switch (opt) {
324 case 0: break; 329 case 0: break;
325 case 'v': show = EINA_TRUE; break; 330 case 'v': show = EINA_TRUE; break;
@@ -410,45 +415,52 @@ int main(int argc, char **argv)
410 } 415 }
411 } 416 }
412 417
413 // goto end;
414
415 if(mode) 418 if(mode)
416 { 419 {
417 _mode *current_m = _modes;
418 Eina_Inlist *classes_list = NULL; 420 Eina_Inlist *classes_list = NULL;
421 eolian_all_eo_files_parse();
422 _mode *current_m = _modes;
423 const Eolian_Class *ekl = eolian_class_get_by_file(class_path);
424
425 if(!ekl)
426 {
427 ERR("Class %s not found", class_path);
428 goto end;
429 }
419 430
420 while(current_m->name_l != NULL ) 431 while(current_m->name_l != NULL )
421 { 432 {
422 433
423 if(!strcmp(current_m->name_s, mode) || !strcmp(current_m->name_l, mode)) 434 if(!strcmp(current_m->name_s, mode) || !strcmp(current_m->name_l, mode))
424 { 435 {
425 // printf("found the mode!\n"); 436 // printf("found the mode!\n");
426 classes_list = current_m->func(class_path, classes_list); 437 classes_list = current_m->func(ekl, classes_list);
427 break; 438 break;
428 } 439 }
429 440
430 current_m++; 441 current_m++;
431 } 442 }
432 443
433
434 _file = stdout; 444 _file = stdout;
435 if(output){ 445 if(output)
446 {
447 printf("output = %s\n", output );
436 _file = fopen(output, "w"); 448 _file = fopen(output, "w");
437 if (_file == NULL) 449 if (_file == NULL)
438 { 450 {
439 ERR("Error opening file!\n"); 451 ERR("Error opening file!\n");
440 goto end; 452 goto end;
441 } 453 }
442 } 454 }
443 _print_graph(classes_list); 455 _print_graph(classes_list);
444 if(output) 456 if(output)
445 fclose(_file); 457 fclose(_file);
446 } 458 }
447 459 else
448 else{ 460 {
449 ERR("No mode specified"); 461 ERR("No mode specified");
450 goto end; 462 goto end;
451 } 463 }
452end: 464end:
453 465
454 eina_log_timing(_eolian_info_log_dom, 466 eina_log_timing(_eolian_info_log_dom,