summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-06-02 13:46:36 +0300
committerAvi Levin <avi.levin@samsung.com>2015-06-02 15:30:04 +0300
commit0814891a3879d999e5bbb08657a176cd031d5477 (patch)
tree63ada08b5f6f264d9346ecea0152d1551df73664
parent193a59c253d445190a261814698ecf7b2d927e73 (diff)
Eolian_info: prevent double edges and double classes in graph printing
-rw-r--r--src/bin/.main.c.swpbin24576 -> 24576 bytes
-rw-r--r--src/bin/main.c69
2 files changed, 51 insertions, 18 deletions
diff --git a/src/bin/.main.c.swp b/src/bin/.main.c.swp
index 237d49d..20d9a2e 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 983e6ec..8126c5b 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -186,7 +186,8 @@ static void _print_graph( Eina_Inlist *classes_list)
186{ 186{
187 _Class_Node *node = NULL; 187 _Class_Node *node = NULL;
188 Eina_Inlist *nnode; 188 Eina_Inlist *nnode;
189 189 Eina_Hash *classes_hash = NULL;
190 classes_hash = eina_hash_string_superfast_new(NULL);
190 191
191 fprintf(_file, "digraph \"Best Eo Graph_Ever\" { \n\ 192 fprintf(_file, "digraph \"Best Eo Graph_Ever\" { \n\
192 fontname = \"Bitstream Vera Sans\" \n\ 193 fontname = \"Bitstream Vera Sans\" \n\
@@ -202,16 +203,35 @@ static void _print_graph( Eina_Inlist *classes_list)
202 arrowtail = \"empty\" \n\ 203 arrowtail = \"empty\" \n\
203 ]\n"); 204 ]\n");
204 205
205 206 /* print classes info */
206 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node) 207 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node)
207 { 208 {
208 // printf("class name %s\n", node->class); 209 // printf("class name %s\n", node->class);
209 _print_class(node); 210 if(node->class && !eina_hash_find(classes_hash, node->class))
210 fprintf(_file, "\"%s\" -> \"%s\"\n", node->parent, node->class); 211 {
212 _print_class(node->class);
213 eina_hash_add(classes_hash, node->class, node->class);
214 }
215 if(node->parent && !eina_hash_find(classes_hash, node->parent))
216 {
217 _print_class(node->parent);
218 eina_hash_add(classes_hash, node->parent, node->parent);
219 }
220
221 }
222 eina_hash_free(classes_hash);
223
224/*print classes edges */
225 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node)
226 {
227 if(node->parent && node->class)
228 fprintf(_file, "\"%s\" -> \"%s\"\n", node->class, node->parent);
211 } 229 }
212 230
213 fprintf(_file, "}\n"); 231 fprintf(_file, "}\n");
214 232
233
234 /* Delete the inlist */
215 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node) 235 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node)
216 { 236 {
217 classes_list = eina_inlist_remove(classes_list, 237 classes_list = eina_inlist_remove(classes_list,
@@ -222,14 +242,32 @@ static void _print_graph( Eina_Inlist *classes_list)
222 242
223} 243}
224 244
225static Eina_Inlist* _prints_class_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list) 245static Eina_Inlist *
246_add_class_edge(const char *class_name, const char *parent_name, Eina_Inlist *classes_list)
226{ 247{
227 const char* class_name = eolian_class_full_name_get(ekl); 248 _Class_Node* d;
249 _Class_Node *node = NULL;
250 Eina_Inlist *nnode;
251
252 /* dont add double edges */
253 EINA_INLIST_FOREACH_SAFE(classes_list, nnode, node)
254 {
255 if(!strcmp(parent_name, node->parent) &&
256 !strcmp(class_name, node->class))
257 return classes_list;
258 }
228 259
229 _Class_Node* d = malloc(sizeof(*d)); 260 d = malloc(sizeof(*d));
261 d->parent = parent_name;
230 d->class = class_name; 262 d->class = class_name;
231 d->parent = NULL; 263
232 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d)); 264 return eina_inlist_append(classes_list, EINA_INLIST_GET(d));
265}
266
267static Eina_Inlist* _prints_class_mode(const Eolian_Class *ekl, Eina_Inlist *classes_list)
268{
269 classes_list = _add_class_edge(
270 eolian_class_full_name_get(ekl), NULL, classes_list);
233 271
234 return classes_list; 272 return classes_list;
235} 273}
@@ -250,10 +288,8 @@ static Eina_Inlist* _prints_inherit_tree_mode(const Eolian_Class *ekl, Eina_Inli
250 ekl=eolian_class_get_by_name(ekl_name); 288 ekl=eolian_class_get_by_name(ekl_name);
251 _push_queue(ekl); 289 _push_queue(ekl);
252 290
253 _Class_Node* d = malloc(sizeof(*d)); 291 classes_list = _add_class_edge(
254 d->class = class_name; 292 class_name, eolian_class_full_name_get(ekl), classes_list);
255 d->parent = eolian_class_full_name_get(ekl);
256 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d));
257 } 293 }
258 eina_iterator_free(lst); 294 eina_iterator_free(lst);
259 } 295 }
@@ -276,13 +312,10 @@ static Eina_Inlist* _prints_inherits_from_mode(const Eolian_Class *ekl, Eina_Inl
276 const char *ekl_i; 312 const char *ekl_i;
277 EINA_ITERATOR_FOREACH(lst_i, ekl_i) 313 EINA_ITERATOR_FOREACH(lst_i, ekl_i)
278 { 314 {
279 // printf("i class name %s\n", ekl_i);
280 if(ekl_i == class_name){ 315 if(ekl_i == class_name){
281 316
282 _Class_Node* d = malloc(sizeof(*d)); 317 classes_list = _add_class_edge(
283 d->class = eolian_class_full_name_get(ekl); 318 eolian_class_full_name_get(ekl), class_name, classes_list);
284 d->parent = class_name;
285 classes_list = eina_inlist_append(classes_list, EINA_INLIST_GET(d));
286 } 319 }
287 } 320 }
288 eina_iterator_free(lst_i); 321 eina_iterator_free(lst_i);