summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-22 16:53:21 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-22 16:53:21 +0100
commit1ffdcda292e008d9d62be9a8da304decb5c6ffb0 (patch)
tree341b4c5c66b882e51d0403745845d632fd65eb14 /src
parentb339313e4b8df1076b7db6fb68d6ea09d337521b (diff)
eolian: simplify eolian_eo_file_parse
This also moves the ctor stuff into database_fill, saving some loops when a class is already parsed.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_fill.c33
-rw-r--r--src/lib/eolian/eolian_database.c52
2 files changed, 38 insertions, 47 deletions
diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c
index 9a24a11389..d07b8d4465 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -212,6 +212,9 @@ _db_fill_class(Eolian_Class *cl)
212Eina_Bool 212Eina_Bool
213eo_parser_database_fill(const char *filename, Eina_Bool eot) 213eo_parser_database_fill(const char *filename, Eina_Bool eot)
214{ 214{
215 Eolian_Constructor *ctor;
216 Eolian_Implement *impl;
217 Eina_Iterator *itr;
215 Eolian_Class *cl; 218 Eolian_Class *cl;
216 Eo_Lexer *ls; 219 Eo_Lexer *ls;
217 220
@@ -245,6 +248,36 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
245 if (!_db_fill_class(cl)) 248 if (!_db_fill_class(cl))
246 goto error; 249 goto error;
247 250
251 itr = eolian_class_implements_get(cl);
252 EINA_ITERATOR_FOREACH(itr, impl)
253 {
254 Eolian_Function_Type impl_type = EOLIAN_UNRESOLVED;
255 const Eolian_Function *impl_func = eolian_implement_function_get(impl, &impl_type);
256 if (!impl_func)
257 {
258 fprintf(stderr, "eolian: unable to find function '%s'\n",
259 eolian_implement_full_name_get(impl));
260 goto error;
261 }
262 else if (eolian_function_is_constructor(impl->foo_id, impl->klass))
263 database_function_constructor_add((Eolian_Function*)impl->foo_id, cl);
264 }
265 eina_iterator_free(itr);
266 itr = eolian_class_constructors_get(cl);
267 EINA_ITERATOR_FOREACH(itr, ctor)
268 {
269 const Eolian_Function *ctor_func = eolian_constructor_function_get(ctor);
270 if (!ctor_func)
271 {
272 fprintf(stderr, "eolian: unable to find function '%s'\n",
273 eolian_constructor_full_name_get(ctor));
274 goto error;
275 }
276 else
277 database_function_constructor_add((Eolian_Function*)ctor_func, ctor->klass);
278 }
279 eina_iterator_free(itr);
280
248done: 281done:
249 if (eot) 282 if (eot)
250 eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE); 283 eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE);
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 7a0348704b..1b0fc06649 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -216,61 +216,19 @@ eolian_eot_file_parse(const char *filepath)
216EAPI Eina_Bool 216EAPI Eina_Bool
217eolian_eo_file_parse(const char *filepath) 217eolian_eo_file_parse(const char *filepath)
218{ 218{
219 Eina_Iterator *itr; 219 char *bfiledup, *bfilename;
220 220
221 if (_database_init_count <= 0) 221 if (_database_init_count <= 0)
222 return EINA_FALSE; 222 return EINA_FALSE;
223 223
224 char *bfiledup = strdup(filepath); 224 bfiledup = strdup(filepath);
225 char *bfilename = basename(bfiledup); 225 bfilename = basename(bfiledup);
226 const Eolian_Class *class = eolian_class_get_by_file(bfilename); 226 if (!eolian_class_get_by_file(bfilename) && !eo_parser_database_fill(filepath, EINA_FALSE))
227 Eolian_Implement *impl;
228 Eolian_Constructor *ctor;
229 if (!class)
230 {
231 if (!eo_parser_database_fill(filepath, EINA_FALSE))
232 {
233 free(bfiledup);
234 goto error;
235 }
236 class = eolian_class_get_by_file(bfilename);
237 }
238 else
239 { 227 {
240 free(bfiledup); 228 free(bfiledup);
241 return EINA_TRUE; 229 goto error;
242 } 230 }
243 free(bfiledup); 231 free(bfiledup);
244 itr = eolian_class_implements_get(class);
245 EINA_ITERATOR_FOREACH(itr, impl)
246 {
247 Eolian_Function_Type impl_type = EOLIAN_UNRESOLVED;
248 const Eolian_Function *impl_func = eolian_implement_function_get(impl, &impl_type);
249 if (!impl_func)
250 {
251 fprintf(stderr, "eolian: unable to find function '%s'\n",
252 eolian_implement_full_name_get(impl));
253 goto error;
254 }
255 else if (eolian_function_is_constructor(impl->foo_id, impl->klass))
256 database_function_constructor_add((Eolian_Function*)impl->foo_id, class);
257 }
258 eina_iterator_free(itr);
259 itr = eolian_class_constructors_get(class);
260 EINA_ITERATOR_FOREACH(itr, ctor)
261 {
262 const Eolian_Function *ctor_func = eolian_constructor_function_get(ctor);
263 if (!ctor_func)
264 {
265 fprintf(stderr, "eolian: unable to find function '%s'\n",
266 eolian_constructor_full_name_get(ctor));
267 goto error;
268 }
269 else
270 database_function_constructor_add((Eolian_Function*)ctor_func, ctor->klass);
271 }
272 eina_iterator_free(itr);
273
274 return EINA_TRUE; 232 return EINA_TRUE;
275 233
276error: 234error: