summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-25 16:23:57 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-25 16:25:41 +0200
commit4f8a9b50f405bad270a6ec37cf8c064ba408f86e (patch)
tree087279688ba04714a3e4e9994ecef2297ed7224e /src/lib
parenta4c96ceb73ec714cd7def72979c3d3db84407357 (diff)
eolian: make inherits_get return a list of classes, not strings
Most of the time you need to retrieve the class from the string anyway, so remove this relic of old Eolian and gain some small performance benefits and extra convenience. Subtly breaks API but everything should be updated.
Diffstat (limited to '')
-rw-r--r--src/lib/eolian/Eolian.h2
-rw-r--r--src/lib/eolian/database_class.c3
-rw-r--r--src/lib/eolian/database_validate.c6
-rw-r--r--src/lib/eolian/eo_parser.c10
-rw-r--r--src/lib/eolian/eolian_database.h2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp4
6 files changed, 11 insertions, 16 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index bc8bbb48cf..b69f2c5dfa 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -709,7 +709,7 @@ EAPI Eina_Stringshare* eolian_class_event_prefix_get(const Eolian_Class *klass);
709EAPI Eina_Stringshare *eolian_class_data_type_get(const Eolian_Class *klass); 709EAPI Eina_Stringshare *eolian_class_data_type_get(const Eolian_Class *klass);
710 710
711/* 711/*
712 * @brief Returns an iterator to the names of inherit classes of a class 712 * @brief Returns an iterator to the inherited classes.
713 * 713 *
714 * @param[in] klass the class 714 * @param[in] klass the class
715 * @return the iterator 715 * @return the iterator
diff --git a/src/lib/eolian/database_class.c b/src/lib/eolian/database_class.c
index f3faa9b0cc..fc56325523 100644
--- a/src/lib/eolian/database_class.c
+++ b/src/lib/eolian/database_class.c
@@ -18,9 +18,6 @@ database_class_del(Eolian_Class *cl)
18 18
19 if (cl->base.file) eina_stringshare_del(cl->base.file); 19 if (cl->base.file) eina_stringshare_del(cl->base.file);
20 20
21 EINA_LIST_FREE(cl->inherits, s)
22 if (s) eina_stringshare_del(s);
23
24 EINA_LIST_FREE(cl->implements, impl) 21 EINA_LIST_FREE(cl->implements, impl)
25 database_implement_del(impl); 22 database_implement_del(impl);
26 23
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 0b1dd0e252..28ffd5fe58 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -373,7 +373,7 @@ _validate_class(Eolian_Class *cl, Eina_Hash *nhash)
373 Eolian_Function *func; 373 Eolian_Function *func;
374 Eolian_Event *event; 374 Eolian_Event *event;
375 Eolian_Implement *impl; 375 Eolian_Implement *impl;
376 const char *iname; 376 Eolian_Class *icl;
377 Eina_Bool res = EINA_TRUE; 377 Eina_Bool res = EINA_TRUE;
378 378
379 if (!cl) 379 if (!cl)
@@ -386,9 +386,9 @@ _validate_class(Eolian_Class *cl, Eina_Hash *nhash)
386 if (ahash) 386 if (ahash)
387 nhash = eina_hash_string_small_new(NULL); 387 nhash = eina_hash_string_small_new(NULL);
388 388
389 EINA_LIST_FOREACH(cl->inherits, l, iname) 389 EINA_LIST_FOREACH(cl->inherits, l, icl)
390 { 390 {
391 if (!(res = _validate_class(eina_hash_find(_classes, iname), nhash))) 391 if (!(res = _validate_class(icl, nhash)))
392 goto freehash; 392 goto freehash;
393 } 393 }
394 394
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index a7649e0a0b..e6d8b6bbb4 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2021,8 +2021,7 @@ _inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
2021 default: 2021 default:
2022 break; 2022 break;
2023 } 2023 }
2024 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, 2024 ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits, dep);
2025 eina_stringshare_add(iname));
2026 dep->toplevel = EINA_FALSE; 2025 dep->toplevel = EINA_FALSE;
2027 eo_lexer_context_pop(ls); 2026 eo_lexer_context_pop(ls);
2028} 2027}
@@ -2245,14 +2244,13 @@ _get_impl_class(const Eolian_Class *cl, const char *cln)
2245 if (!cl || !strcmp(cl->full_name, cln)) 2244 if (!cl || !strcmp(cl->full_name, cln))
2246 return cl; 2245 return cl;
2247 Eina_List *l; 2246 Eina_List *l;
2248 const char *s; 2247 Eolian_Class *icl;
2249 EINA_LIST_FOREACH(cl->inherits, l, s) 2248 EINA_LIST_FOREACH(cl->inherits, l, icl)
2250 { 2249 {
2251 /* we can do a depth first search, it's easier and doesn't matter 2250 /* we can do a depth first search, it's easier and doesn't matter
2252 * which part of the inheritance tree we find the class in 2251 * which part of the inheritance tree we find the class in
2253 */ 2252 */
2254 /* FIXME: pass unit properly */ 2253 const Eolian_Class *fcl = _get_impl_class(icl, cln);
2255 const Eolian_Class *fcl = _get_impl_class(eolian_class_get_by_name(NULL, s), cln);
2256 if (fcl) 2254 if (fcl)
2257 return fcl; 2255 return fcl;
2258 } 2256 }
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index c99a47451c..ae53ff94cb 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -91,7 +91,7 @@ struct _Eolian_Class
91 Eina_Stringshare *eo_prefix; 91 Eina_Stringshare *eo_prefix;
92 Eina_Stringshare *ev_prefix; 92 Eina_Stringshare *ev_prefix;
93 Eina_Stringshare *data_type; 93 Eina_Stringshare *data_type;
94 Eina_List *inherits; /* List Eina_Stringshare * */ 94 Eina_List *inherits; /* List Eolian_Class * */
95 Eina_List *properties; /* List prop_name -> Eolian_Function */ 95 Eina_List *properties; /* List prop_name -> Eolian_Function */
96 Eina_List *methods; /* List meth_name -> Eolian_Function */ 96 Eina_List *methods; /* List meth_name -> Eolian_Function */
97 Eina_List *implements; /* List implements name -> Eolian_Implement */ 97 Eina_List *implements; /* List implements name -> Eolian_Implement */
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 3de453eb87..146bfbe861 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -687,10 +687,10 @@ struct klass_def
687 std::function<void(Eolian_Class const*)> inherit_algo = 687 std::function<void(Eolian_Class const*)> inherit_algo =
688 [&] (Eolian_Class const* klass) 688 [&] (Eolian_Class const* klass)
689 { 689 {
690 for(efl::eina::iterator<const char> inherit_iterator ( ::eolian_class_inherits_get(klass)) 690 for(efl::eina::iterator<Eolian_Class const> inherit_iterator ( ::eolian_class_inherits_get(klass))
691 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator) 691 , inherit_last; inherit_iterator != inherit_last; ++inherit_iterator)
692 { 692 {
693 Eolian_Class const* inherit = ::eolian_class_get_by_name(unit, &*inherit_iterator); 693 Eolian_Class const* inherit = &*inherit_iterator;
694 inherits.insert({inherit, {}}); 694 inherits.insert({inherit, {}});
695 inherit_algo(inherit); 695 inherit_algo(inherit);
696 } 696 }