summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-31 18:06:17 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-31 18:13:29 +0100
commitb5794afa580e1aa40222544abeb8dcd3239a5af7 (patch)
treef8ab2bd8caa6590fb3b5b5582f2d3cc476471daf
parentd2df4b382f6ef20640f8872e6a354004ab611aae (diff)
eolian: all dependency parsing is now deferred
-rw-r--r--src/lib/eolian/database_part.c4
-rw-r--r--src/lib/eolian/database_validate.c13
-rw-r--r--src/lib/eolian/eo_parser.c44
-rw-r--r--src/lib/eolian/eolian_database.h7
4 files changed, 32 insertions, 36 deletions
diff --git a/src/lib/eolian/database_part.c b/src/lib/eolian/database_part.c
index dca036aba5..853eeadfca 100644
--- a/src/lib/eolian/database_part.c
+++ b/src/lib/eolian/database_part.c
@@ -9,7 +9,9 @@ void
9database_part_del(Eolian_Part *part) 9database_part_del(Eolian_Part *part)
10{ 10{
11 if (!part) return; 11 if (!part) return;
12 if (part->name) eina_stringshare_del(part->name); 12 eina_stringshare_del(part->name);
13 if (!part->base.validated)
14 eina_stringshare_del(part->klass_name);
13 database_doc_del(part->doc); 15 database_doc_del(part->doc);
14 free(part); 16 free(part);
15} 17}
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 66cf97fb66..1a4c83f6a8 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -415,6 +415,19 @@ _validate_part(const Eolian_Unit *src, Eolian_Part *part, Eina_Hash *nhash)
415 if (!_validate_doc(src, part->doc)) 415 if (!_validate_doc(src, part->doc))
416 return EINA_FALSE; 416 return EINA_FALSE;
417 417
418 /* switch the class name for class */
419 Eolian_Class *pcl = eina_hash_find(src->state->unit.classes, part->klass_name);
420 if (!pcl)
421 {
422 char buf[PATH_MAX];
423 snprintf(buf, sizeof(buf), "unknown part class '%s' (incorrect case?)",
424 part->klass_name);
425 _obj_error(&part->base, buf);
426 return EINA_FALSE;
427 }
428 eina_stringshare_del(part->klass_name);
429 part->klass = pcl;
430
418 return _validate(&part->base); 431 return _validate(&part->base);
419} 432}
420 433
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index f7445bf9bf..3441ad4b84 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -677,22 +677,6 @@ parse_struct_attrs(Eo_Lexer *ls, Eina_Bool is_enum, Eina_Bool *is_extern,
677 } 677 }
678} 678}
679 679
680static Eolian_Class *
681_parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
682{
683 if (eina_hash_find(ls->state->parsing, fname))
684 return NULL;
685 Eolian_Class *cl = NULL;
686 if (!eo_parser_database_fill(ls->unit, fname, EINA_FALSE, &cl) || !cl)
687 {
688 char buf[PATH_MAX];
689 eo_lexer_context_restore(ls);
690 snprintf(buf, sizeof(buf), "error parsing dependency '%s'", name);
691 eo_lexer_syntax_error(ls, buf);
692 }
693 return cl;
694}
695
696static Eolian_Type * 680static Eolian_Type *
697parse_type_void(Eo_Lexer *ls) 681parse_type_void(Eo_Lexer *ls)
698{ 682{
@@ -1525,28 +1509,20 @@ parse_part(Eo_Lexer *ls)
1525 eo_lexer_context_push(ls); 1509 eo_lexer_context_push(ls);
1526 parse_name(ls, buf); 1510 parse_name(ls, buf);
1527 const char *nm = eina_strbuf_string_get(buf); 1511 const char *nm = eina_strbuf_string_get(buf);
1528 const char *bnm = eina_stringshare_ref(ls->filename);
1529 char *fnm = database_class_to_filename(nm); 1512 char *fnm = database_class_to_filename(nm);
1530 if (!compare_class_file(bnm, fnm)) 1513 const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
1514 if (!fname)
1531 { 1515 {
1532 Eolian_Class *dep = NULL;
1533 const char *fname = eina_hash_find(ls->state->filenames_eo, fnm);
1534 eina_stringshare_del(bnm);
1535 free(fnm); 1516 free(fnm);
1536 if (fname) 1517 char ebuf[PATH_MAX];
1537 dep = _parse_dep(ls, fname, nm); 1518 eo_lexer_context_restore(ls);
1538 if (!dep) 1519 snprintf(ebuf, sizeof(ebuf), "unknown class '%s'", nm);
1539 { 1520 eo_lexer_syntax_error(ls, ebuf);
1540 char ebuf[PATH_MAX]; 1521 return;
1541 eo_lexer_context_restore(ls);
1542 snprintf(ebuf, sizeof(ebuf), "unknown class '%s'", nm);
1543 eo_lexer_syntax_error(ls, ebuf);
1544 return;
1545 }
1546 part->klass = dep;
1547 } 1522 }
1548 else 1523 eina_hash_set(ls->state->defer, fnm, fname);
1549 part->klass = ls->tmp.kls; 1524 free(fnm);
1525 part->klass_name = eina_stringshare_add(nm);
1550 pop_strbuf(ls); 1526 pop_strbuf(ls);
1551 check_next(ls, ';'); 1527 check_next(ls, ';');
1552 FILL_DOC(ls, part, doc); 1528 FILL_DOC(ls, part, doc);
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index d6393a9462..69bd5630ac 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -168,7 +168,12 @@ struct _Eolian_Part
168{ 168{
169 Eolian_Object base; 169 Eolian_Object base;
170 Eina_Stringshare *name; 170 Eina_Stringshare *name;
171 Eolian_Class *klass; 171 /* when not validated, class name is stored */
172 union
173 {
174 Eina_Stringshare *klass_name;
175 Eolian_Class *klass;
176 };
172 Eolian_Documentation *doc; 177 Eolian_Documentation *doc;
173}; 178};
174 179