From 543902f2ba13b69b052eb21a4a36324d96f5eeba Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 18 Apr 2018 16:34:49 +0200 Subject: [PATCH] eolian: make doc ref resolution global Doc refs no longer introduce new dependencies into files. Instead, they're parsed globally, and any doc ref lookup is also made globally. This allows unit based dependencies to correspond more to what files actually really need at compile time/runtime, with docs being irrelevant to that; it also simplifies the API. The doc resolution API now takes Eolian_State instead of Eolian_Unit, too. --- src/bin/eolian/docs.c | 58 +++++++++++------------ src/bin/eolian/docs.h | 6 +-- src/bin/eolian/headers.c | 18 +++---- src/bin/eolian/headers.h | 2 +- src/bin/eolian/main.c | 19 ++++---- src/bin/eolian/types.c | 18 +++---- src/bin/eolian/types.h | 2 +- src/bindings/luajit/eolian.lua | 6 +-- src/lib/efl/interfaces/efl_pack_table.eo | 1 + src/lib/eolian/Eolian.h | 4 +- src/lib/eolian/database_validate.c | 7 ++- src/lib/eolian/eolian_database.c | 60 +++++++++++++++--------- src/lib/eolian/eolian_database.h | 6 +++ src/scripts/elua/apps/docgen/doctree.lua | 2 +- src/scripts/pyolian/eolian_lib.py | 2 +- src/tests/eolian/eolian_parsing.c | 4 +- 16 files changed, 122 insertions(+), 93 deletions(-) diff --git a/src/bin/eolian/docs.c b/src/bin/eolian/docs.c index 6dd42a833a..795808549a 100644 --- a/src/bin/eolian/docs.c +++ b/src/bin/eolian/docs.c @@ -19,10 +19,10 @@ _indent_line(Eina_Strbuf *buf, int ind) : DOC_LINE_LIMIT) static void -_generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf, +_generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf, Eina_Bool use_legacy) { - const Eolian_Object *decl = eolian_unit_object_by_name_get(src, refn); + const Eolian_Object *decl = eolian_state_object_by_name_get(state, refn); if (decl) { char *n = strdup(eolian_object_name_get(decl)); @@ -39,7 +39,7 @@ _generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf, Eina_Stringshare *bname = eina_stringshare_add_length(refn, sfx - refn); - const Eolian_Typedecl *tp = eolian_unit_struct_by_name_get(src, bname); + const Eolian_Typedecl *tp = eolian_state_struct_by_name_get(state, bname); if (tp) { if (!eolian_typedecl_struct_field_get(tp, sfx + 1)) @@ -47,13 +47,13 @@ _generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf, eina_stringshare_del(bname); goto noref; } - _generate_ref(src, bname, wbuf, use_legacy); + _generate_ref(state, bname, wbuf, use_legacy); eina_strbuf_append(wbuf, sfx); eina_stringshare_del(bname); return; } - tp = eolian_unit_enum_by_name_get(src, bname); + tp = eolian_state_enum_by_name_get(state, bname); if (tp) { const Eolian_Enum_Type_Field *efl = eolian_typedecl_enum_field_get(tp, sfx + 1); @@ -68,7 +68,7 @@ _generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf, return; } - const Eolian_Class *cl = eolian_unit_class_by_name_get(src, bname); + const Eolian_Class *cl = eolian_state_class_by_name_get(state, bname); const Eolian_Function *fn = NULL; /* match methods and properties; we're only figuring out existence */ Eolian_Function_Type ftype = EOLIAN_UNRESOLVED; @@ -84,7 +84,7 @@ _generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf, while ((mname != refn) && (*mname != '.')) --mname; if (mname == refn) goto noref; bname = eina_stringshare_add_length(refn, mname - refn); - cl = eolian_unit_class_by_name_get(src, bname); + cl = eolian_state_class_by_name_get(state, bname); eina_stringshare_del(bname); } if (cl) @@ -114,7 +114,7 @@ noref: } static int -_append_section(const Eolian_Unit *src, const char *desc, int ind, int curl, +_append_section(const Eolian_State *state, const char *desc, int ind, int curl, Eina_Strbuf *buf, Eina_Strbuf *wbuf, Eina_Bool use_legacy) { Eina_Bool try_note = EINA_TRUE; @@ -166,7 +166,7 @@ _append_section(const Eolian_Unit *src, const char *desc, int ind, int curl, ++desc; if (*(desc - 1) == '.') --desc; Eina_Stringshare *refn = eina_stringshare_add_length(ref, desc - ref); - _generate_ref(src, refn, wbuf, use_legacy); + _generate_ref(state, refn, wbuf, use_legacy); eina_stringshare_del(refn); } else @@ -270,7 +270,7 @@ _append_group(Eina_Strbuf *buf, char *sgrp, int indent) } static void -_gen_doc_brief(const Eolian_Unit *src, const char *summary, const char *since, +_gen_doc_brief(const Eolian_State *state, const char *summary, const char *since, const char *group, const char *el, int indent, Eina_Strbuf *buf, Eina_Bool use_legacy) { @@ -280,7 +280,7 @@ _gen_doc_brief(const Eolian_Unit *src, const char *summary, const char *since, eina_strbuf_append(buf, "/**< "); else eina_strbuf_append(buf, "/** "); - curl = _append_section(src, summary, indent, curl, buf, wbuf, use_legacy); + curl = _append_section(state, summary, indent, curl, buf, wbuf, use_legacy); eina_strbuf_free(wbuf); curl = _append_extra(el, indent, curl, EINA_FALSE, buf); curl = _append_since(since, indent, curl, buf); @@ -301,7 +301,7 @@ _gen_doc_brief(const Eolian_Unit *src, const char *summary, const char *since, } static void -_gen_doc_full(const Eolian_Unit *src, const char *summary, +_gen_doc_full(const Eolian_State *state, const char *summary, const char *description, const char *since, const char *group, const char *el, int indent, Eina_Strbuf *buf, Eina_Bool use_legacy) @@ -315,13 +315,13 @@ _gen_doc_full(const Eolian_Unit *src, const char *summary, curl += _indent_line(buf, indent); eina_strbuf_append(buf, " * @brief "); curl += sizeof(" * @brief ") - 1; - _append_section(src, summary, indent, curl, buf, wbuf, use_legacy); + _append_section(state, summary, indent, curl, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); eina_strbuf_append(buf, " *\n"); curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); - _append_section(src, description, indent, curl + 3, buf, wbuf, use_legacy); + _append_section(state, description, indent, curl + 3, buf, wbuf, use_legacy); curl = _append_extra(el, indent, curl, EINA_TRUE, buf); curl = _append_since(since, indent, curl, buf); eina_strbuf_append_char(buf, '\n'); @@ -338,7 +338,7 @@ _gen_doc_full(const Eolian_Unit *src, const char *summary, } static Eina_Strbuf * -_gen_doc_buf(const Eolian_Unit *src, const Eolian_Documentation *doc, +_gen_doc_buf(const Eolian_State *state, const Eolian_Documentation *doc, const char *group, const char *el, int indent, Eina_Bool use_legacy) { @@ -350,21 +350,21 @@ _gen_doc_buf(const Eolian_Unit *src, const Eolian_Documentation *doc, Eina_Strbuf *buf = eina_strbuf_new(); if (!desc) - _gen_doc_brief(src, sum, since, group, el, indent, buf, use_legacy); + _gen_doc_brief(state, sum, since, group, el, indent, buf, use_legacy); else - _gen_doc_full(src, sum, desc, since, group, el, indent, buf, use_legacy); + _gen_doc_full(state, sum, desc, since, group, el, indent, buf, use_legacy); return buf; } Eina_Strbuf * -eo_gen_docs_full_gen(const Eolian_Unit *src, const Eolian_Documentation *doc, +eo_gen_docs_full_gen(const Eolian_State *state, const Eolian_Documentation *doc, const char *group, int indent, Eina_Bool use_legacy) { - return _gen_doc_buf(src, doc, group, NULL, indent, use_legacy); + return _gen_doc_buf(state, doc, group, NULL, indent, use_legacy); } Eina_Strbuf * -eo_gen_docs_event_gen(const Eolian_Unit *src, const Eolian_Event *ev, +eo_gen_docs_event_gen(const Eolian_State *state, const Eolian_Event *ev, const char *group) { if (!ev) return NULL; @@ -396,11 +396,11 @@ eo_gen_docs_event_gen(const Eolian_Unit *src, const Eolian_Event *ev, return bufs; } - return _gen_doc_buf(src, doc, group, p, 0, EINA_FALSE); + return _gen_doc_buf(state, doc, group, p, 0, EINA_FALSE); } Eina_Strbuf * -eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, +eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid, Eolian_Function_Type ftype, int indent, Eina_Bool use_legacy) { @@ -511,7 +511,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, /* only summary, nothing else; generate standard brief doc */ if (!desc && !par && !vpar && !rdoc && (ftype == EOLIAN_METHOD || !pdoc)) { - _gen_doc_brief(src, sum ? sum : "No description supplied.", since, group, + _gen_doc_brief(state, sum ? sum : "No description supplied.", since, group, NULL, indent, buf, use_legacy); return buf; } @@ -522,7 +522,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, curl += _indent_line(buf, indent); eina_strbuf_append(buf, " * @brief "); curl += sizeof(" * @brief ") - 1; - _append_section(src, sum ? sum : "No description supplied.", + _append_section(state, sum ? sum : "No description supplied.", indent, curl, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); @@ -536,7 +536,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, { curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); - _append_section(src, desc, indent, curl + 3, buf, wbuf, use_legacy); + _append_section(state, desc, indent, curl + 3, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); if (par || rdoc || pdoc || since) { @@ -550,7 +550,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, const char *pdesc = eolian_documentation_description_get(pdoc); curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); - _append_section(src, eolian_documentation_summary_get(pdoc), indent, + _append_section(state, eolian_documentation_summary_get(pdoc), indent, curl + 3, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); if (pdesc) @@ -559,7 +559,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, eina_strbuf_append(buf, " *\n"); curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); - _append_section(src, pdesc, indent, curl + 3, buf, wbuf, use_legacy); + _append_section(state, pdesc, indent, curl + 3, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); } if (par || rdoc || since) @@ -613,7 +613,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, { eina_strbuf_append_char(buf, ' '); curl += 1; - _append_section(src, eolian_documentation_summary_get(adoc), + _append_section(state, eolian_documentation_summary_get(adoc), indent, curl, buf, wbuf, use_legacy); } @@ -646,7 +646,7 @@ eo_gen_docs_func_gen(const Eolian_Unit *src, const Eolian_Function *fid, curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * @return "); curl += sizeof(" * @return ") - 1; - _append_section(src, eolian_documentation_summary_get(rdoc), indent, + _append_section(state, eolian_documentation_summary_get(rdoc), indent, curl, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); if (since) diff --git a/src/bin/eolian/docs.h b/src/bin/eolian/docs.h index 69dbc3e433..79112f9758 100644 --- a/src/bin/eolian/docs.h +++ b/src/bin/eolian/docs.h @@ -14,7 +14,7 @@ * @return A documentation comment * */ -Eina_Strbuf *eo_gen_docs_full_gen(const Eolian_Unit *unit, const Eolian_Documentation *doc, const char *group, int indent, Eina_Bool use_legacy); +Eina_Strbuf *eo_gen_docs_full_gen(const Eolian_State *state, const Eolian_Documentation *doc, const char *group, int indent, Eina_Bool use_legacy); /* * @brief Generate function documentation @@ -27,7 +27,7 @@ Eina_Strbuf *eo_gen_docs_full_gen(const Eolian_Unit *unit, const Eolian_Document * @return A documentation comment * */ -Eina_Strbuf *eo_gen_docs_func_gen(const Eolian_Unit *unit, const Eolian_Function *fid, Eolian_Function_Type ftype, int indent, Eina_Bool use_legacy); +Eina_Strbuf *eo_gen_docs_func_gen(const Eolian_State *state, const Eolian_Function *fid, Eolian_Function_Type ftype, int indent, Eina_Bool use_legacy); /* * @brief Generate event documentation @@ -38,7 +38,7 @@ Eina_Strbuf *eo_gen_docs_func_gen(const Eolian_Unit *unit, const Eolian_Function * @return A documentation comment * */ -Eina_Strbuf *eo_gen_docs_event_gen(const Eolian_Unit *unit, const Eolian_Event *ev, const char *group); +Eina_Strbuf *eo_gen_docs_event_gen(const Eolian_State *state, const Eolian_Event *ev, const char *group); #endif diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c index db6ea537a7..4ebf9a7fdd 100644 --- a/src/bin/eolian/headers.c +++ b/src/bin/eolian/headers.c @@ -66,7 +66,7 @@ eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, } static void -_gen_func(const Eolian_Unit *src, const Eolian_Function *fid, +_gen_func(const Eolian_State *state, const Eolian_Function *fid, Eolian_Function_Type ftype, Eina_Strbuf *buf, char *cname, char *cnameu, Eina_Bool legacy) { @@ -104,7 +104,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid, hasdoc = !!eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY); if (hasdoc) { - Eina_Strbuf *dbuf = eo_gen_docs_func_gen(src, fid, ftype, 0, legacy); + Eina_Strbuf *dbuf = eo_gen_docs_func_gen(state, fid, ftype, 0, legacy); eina_strbuf_append(buf, eina_strbuf_string_get(dbuf)); eina_strbuf_append_char(buf, '\n'); eina_strbuf_free(dbuf); @@ -181,7 +181,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid, } void -eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, +eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy) { if (!cl) @@ -197,7 +197,7 @@ eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, const Eolian_Documentation *doc = eolian_class_documentation_get(cl); if (doc) { - Eina_Strbuf *cdoc = eo_gen_docs_full_gen(src, doc, + Eina_Strbuf *cdoc = eo_gen_docs_full_gen(state, doc, eolian_class_name_get(cl), 0, EINA_FALSE); if (cdoc) { @@ -237,15 +237,15 @@ eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, { case EOLIAN_PROP_GET: case EOLIAN_PROP_SET: - _gen_func(src, fid, ftype, buf, cname, cnameu, legacy); + _gen_func(state, fid, ftype, buf, cname, cnameu, legacy); break; case EOLIAN_PROPERTY: - _gen_func(src, fid, EOLIAN_PROP_SET, buf, cname, cnameu, legacy); + _gen_func(state, fid, EOLIAN_PROP_SET, buf, cname, cnameu, legacy); eina_strbuf_append_char(buf, '\n'); - _gen_func(src, fid, EOLIAN_PROP_GET, buf, cname, cnameu, legacy); + _gen_func(state, fid, EOLIAN_PROP_GET, buf, cname, cnameu, legacy); break; default: - _gen_func(src, fid, EOLIAN_METHOD, buf, cname, cnameu, legacy); + _gen_func(state, fid, EOLIAN_METHOD, buf, cname, cnameu, legacy); } } eina_iterator_free(itr); @@ -282,7 +282,7 @@ events: eina_strbuf_append_printf(buf, "EWAPI extern const " "Efl_Event_Description _%s;\n\n", evn); - Eina_Strbuf *evdbuf = eo_gen_docs_event_gen(src, ev, + Eina_Strbuf *evdbuf = eo_gen_docs_event_gen(state, ev, eolian_class_name_get(cl)); eina_strbuf_append(buf, eina_strbuf_string_get(evdbuf)); eina_strbuf_append_char(buf, '\n'); diff --git a/src/bin/eolian/headers.h b/src/bin/eolian/headers.h index 56e4b4ffdf..94fd89b908 100644 --- a/src/bin/eolian/headers.h +++ b/src/bin/eolian/headers.h @@ -4,6 +4,6 @@ #include "main.h" void eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype); -void eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy); +void eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy); #endif diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c index 09fd0a4b02..db8ea371dd 100644 --- a/src/bin/eolian/main.c +++ b/src/bin/eolian/main.c @@ -318,13 +318,13 @@ void eo_gen_class_names_get(const Eolian_Class *cl, char **cname, } static Eina_Bool -_write_header(const Eolian_State *eos, const Eolian_Unit *src, const char *ofname, +_write_header(const Eolian_State *eos, const Eolian_State *state, const char *ofname, const char *ifname, Eina_Bool legacy) { INF("generating header: %s (legacy: %d)", ofname, legacy); Eina_Strbuf *buf = eina_strbuf_new(); - eo_gen_types_header_gen(src, eolian_state_objects_by_file_get(eos, ifname), + eo_gen_types_header_gen(state, eolian_state_objects_by_file_get(eos, ifname), buf, EINA_TRUE, legacy); buf = _include_guard(ifname, "TYPES", buf); @@ -338,7 +338,7 @@ _write_header(const Eolian_State *eos, const Eolian_Unit *src, const char *ofnam } const Eolian_Class *cl = eolian_state_class_by_file_get(eos, ifname); - eo_gen_header_gen(src, cl, buf, legacy); + eo_gen_header_gen(state, cl, buf, legacy); if (cl || !legacy) { buf = _include_guard(_get_filename(ofname), NULL, buf); @@ -354,13 +354,13 @@ _write_header(const Eolian_State *eos, const Eolian_Unit *src, const char *ofnam } static Eina_Bool -_write_stub_header(const Eolian_State *eos, const Eolian_Unit *src, const char *ofname, +_write_stub_header(const Eolian_State *eos, const Eolian_State *state, const char *ofname, const char *ifname) { INF("generating stub header: %s", ofname); Eina_Strbuf *buf = eina_strbuf_new(); - eo_gen_types_header_gen(src, eolian_state_objects_by_file_get(eos, ifname), + eo_gen_types_header_gen(state, eolian_state_objects_by_file_get(eos, ifname), buf, EINA_FALSE, EINA_FALSE); Eina_Strbuf *cltd = eo_gen_class_typedef_gen(eos, ifname); @@ -551,8 +551,7 @@ main(int argc, char **argv) } } - const Eolian_Unit *src = eolian_state_file_parse(eos, input); - if (!src) + if (!eolian_state_file_parse(eos, input)) { fprintf(stderr, "eolian: could not parse file '%s'\n", input); goto end; @@ -567,11 +566,11 @@ main(int argc, char **argv) Eina_Bool succ = EINA_TRUE; if (gen_what & GEN_H) - succ = _write_header(eos, src, outs[_get_bit_pos(GEN_H)], eobn, EINA_FALSE); + succ = _write_header(eos, eos, outs[_get_bit_pos(GEN_H)], eobn, EINA_FALSE); if (succ && (gen_what & GEN_H_LEGACY)) - succ = _write_header(eos, src, outs[_get_bit_pos(GEN_H_LEGACY)], eobn, EINA_TRUE); + succ = _write_header(eos, eos, outs[_get_bit_pos(GEN_H_LEGACY)], eobn, EINA_TRUE); if (succ && (gen_what & GEN_H_STUB)) - succ = _write_stub_header(eos, src, outs[_get_bit_pos(GEN_H_STUB)], eobn); + succ = _write_stub_header(eos, eos, outs[_get_bit_pos(GEN_H_STUB)], eobn); if (succ && (gen_what & GEN_C)) succ = _write_source(eos, outs[_get_bit_pos(GEN_C)], eobn, !strcmp(ext, ".eot")); if (succ && (gen_what & GEN_C_IMPL)) diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c index 044a6a2e15..b8f7b98452 100644 --- a/src/bin/eolian/types.c +++ b/src/bin/eolian/types.c @@ -3,13 +3,13 @@ #include "docs.h" static Eina_Strbuf * -_type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp, +_type_generate(const Eolian_State *state, const Eolian_Typedecl *tp, Eina_Bool full, Eina_Bool legacy) { char *grp = strdup(eolian_typedecl_name_get(tp)); char *p = strrchr(grp, '.'); if (p) *p = '\0'; - Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_typedecl_documentation_get(tp), + Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_typedecl_documentation_get(tp), grp, 0, legacy); free(grp); if (!buf) buf = eina_strbuf_new(); @@ -53,7 +53,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp, const char *nl = strrchr(eina_strbuf_string_get(buf), '\n'); if (nl) { - Eina_Strbuf *fbuf = eo_gen_docs_full_gen(src, fdoc, NULL, + Eina_Strbuf *fbuf = eo_gen_docs_full_gen(state, fdoc, NULL, strlen(nl), legacy); if (fbuf) eina_strbuf_append_printf(buf, " %s", @@ -107,7 +107,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp, const char *nl = strrchr(eina_strbuf_string_get(buf), '\n'); if (nl) { - Eina_Strbuf *fbuf = eo_gen_docs_full_gen(src, fdoc, NULL, + Eina_Strbuf *fbuf = eo_gen_docs_full_gen(state, fdoc, NULL, strlen(nl), legacy); if (fbuf) eina_strbuf_append_printf(buf, " %s", @@ -160,12 +160,12 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp, } static Eina_Strbuf * -_var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legacy) +_var_generate(const Eolian_State *state, const Eolian_Variable *vr, Eina_Bool legacy) { char *fn = strdup(eolian_variable_name_get(vr)); char *p = strrchr(fn, '.'); if (p) *p = '\0'; - Eina_Strbuf *buf = eo_gen_docs_full_gen(src, eolian_variable_documentation_get(vr), + Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_variable_documentation_get(vr), fn, 0, legacy); if (p) { @@ -203,7 +203,7 @@ _var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legac return buf; } -void eo_gen_types_header_gen(const Eolian_Unit *src, +void eo_gen_types_header_gen(const Eolian_State *state, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Bool full, Eina_Bool legacy) { @@ -218,7 +218,7 @@ void eo_gen_types_header_gen(const Eolian_Unit *src, if (!vr || eolian_variable_is_extern(vr)) continue; - Eina_Strbuf *vbuf = _var_generate(src, vr, legacy); + Eina_Strbuf *vbuf = _var_generate(state, vr, legacy); if (vbuf) { eina_strbuf_append(buf, eina_strbuf_string_get(vbuf)); @@ -248,7 +248,7 @@ void eo_gen_types_header_gen(const Eolian_Unit *src, continue; } - Eina_Strbuf *tbuf = _type_generate(src, tp, full, legacy); + Eina_Strbuf *tbuf = _type_generate(state, tp, full, legacy); if (tbuf) { eina_strbuf_append(buf, eina_strbuf_string_get(tbuf)); diff --git a/src/bin/eolian/types.h b/src/bin/eolian/types.h index 2b8bfe298d..2659b59085 100644 --- a/src/bin/eolian/types.h +++ b/src/bin/eolian/types.h @@ -1,7 +1,7 @@ #ifndef EOLIAN_GEN_TYPES_H #define EOLIAN_GEN_TYPES_H -void eo_gen_types_header_gen(const Eolian_Unit *src, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Bool full, Eina_Bool legacy); +void eo_gen_types_header_gen(const Eolian_State *state, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Bool full, Eina_Bool legacy); void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf); Eina_Strbuf *eo_gen_class_typedef_gen(const Eolian_State *eos, const char *eof); diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index d94961b3b7..2485818d04 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -448,7 +448,7 @@ ffi.cdef [[ void eolian_doc_token_init(Eolian_Doc_Token *tok); Eolian_Doc_Token_Type eolian_doc_token_type_get(const Eolian_Doc_Token *tok); char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok); - Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2); + Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2); ]] local cutil = require("cutil") @@ -1652,9 +1652,9 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", { return ret end, - ref_resolve = function(self, unit) + ref_resolve = function(self, state) local stor = ffi.new("const Eolian_Object *[2]") - local tp = tonumber(eolian.eolian_doc_token_ref_resolve(self, unit, stor, stor + 1)) + local tp = tonumber(eolian.eolian_doc_token_ref_resolve(self, state, stor, stor + 1)) local reft = M.object_type if tp == reft.CLASS then return tp, ffi.cast("const Eolian_Class *", stor[0]) diff --git a/src/lib/efl/interfaces/efl_pack_table.eo b/src/lib/efl/interfaces/efl_pack_table.eo index ff744ec225..5e985ed2da 100644 --- a/src/lib/efl/interfaces/efl_pack_table.eo +++ b/src/lib/efl/interfaces/efl_pack_table.eo @@ -1,4 +1,5 @@ import efl_gfx_types; +import efl_ui_direction; interface Efl.Pack.Table (Efl.Pack.Linear) { diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 3f44929471..e108d834ee 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -3002,12 +3002,12 @@ EAPI char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok); * the first data is is the struct/enum and the second data is the field. * * @param[in] tok the token - * @param[in] unit the unit to look in + * @param[in] state the state to look in * @param[out] data the primary data * @param[out] data2 the secondary data * @return the kind of reference this is */ -EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2); +EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2); #endif diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c index 0ac8a04559..58bd114840 100644 --- a/src/lib/eolian/database_validate.c +++ b/src/lib/eolian/database_validate.c @@ -37,7 +37,12 @@ _validate_docstr(Eina_Stringshare *str, const Eolian_Object *info, Eina_List **r { if (eolian_doc_token_type_get(&tok) == EOLIAN_DOC_TOKEN_REF) { - if (eolian_doc_token_ref_resolve(&tok, info->unit, NULL, NULL) == EOLIAN_OBJECT_UNKNOWN) + /* check staging first, then main */ + Eolian_Object_Type tp = database_doc_token_ref_resolve(&tok, + &info->unit->state->staging.unit, + &info->unit->state->main.unit, + NULL, NULL); + if (tp == EOLIAN_OBJECT_UNKNOWN) { size_t dbgn = (size_t)eina_list_data_get(*rdbg); char *refn = eolian_doc_token_text_get(&tok); diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 43e9c00686..8093230ac8 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -392,8 +392,8 @@ eolian_doc_token_text_get(const Eolian_Doc_Token *tok) } static Eolian_Object_Type -_resolve_event(const Eolian_Unit *src, char *name, const Eolian_Object **data, - const Eolian_Object **data2) +_resolve_event(char *name, const Eolian_Unit *unit1, const Eolian_Unit *unit2, + const Eolian_Object **data1, const Eolian_Object **data2) { /* never trust the user */ if (name[0] == ',') @@ -404,7 +404,9 @@ _resolve_event(const Eolian_Unit *src, char *name, const Eolian_Object **data, return EOLIAN_OBJECT_UNKNOWN; *evname++ = '\0'; - const Eolian_Class *cl = eolian_unit_class_by_name_get(src, name); + const Eolian_Class *cl = eolian_unit_class_by_name_get(unit1, name); + if (!cl && unit2) + cl = eolian_unit_class_by_name_get(unit2, name); if (!cl) return EOLIAN_OBJECT_UNKNOWN; @@ -412,14 +414,15 @@ _resolve_event(const Eolian_Unit *src, char *name, const Eolian_Object **data, if (!ev) return EOLIAN_OBJECT_UNKNOWN; - if (data) *data = &cl->base; + if (data1) *data1 = &cl->base; if (data2) *data2 = &ev->base; return EOLIAN_OBJECT_EVENT; } -EAPI Eolian_Object_Type -eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, - const Eolian_Object **data, const Eolian_Object **data2) +Eolian_Object_Type +database_doc_token_ref_resolve(const Eolian_Doc_Token *tok, + const Eolian_Unit *unit1, const Eolian_Unit *unit2, + const Eolian_Object **data1, const Eolian_Object **data2) { if (tok->type != EOLIAN_DOC_TOKEN_REF) return EOLIAN_OBJECT_UNKNOWN; @@ -434,17 +437,19 @@ eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *uni char *ename = alloca(elen + 1); memcpy(ename, tok->text + 1, elen); ename[elen] = '\0'; - return _resolve_event(unit, ename, data, data2); + return _resolve_event(ename, unit1, unit2, data1, data2); } char *name = alloca(nlen + 1); memcpy(name, tok->text, nlen); name[nlen] = '\0'; - const Eolian_Object *decl = eolian_unit_object_by_name_get(unit, name); + const Eolian_Object *decl = eolian_unit_object_by_name_get(unit1, name); + if (!decl && unit2) + decl = eolian_unit_object_by_name_get(unit2, name); if (decl) { - if (data) *data = decl; + if (data1) *data1 = decl; Eolian_Object_Type tp = eolian_object_type_get(decl); switch (tp) { @@ -469,27 +474,31 @@ eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *uni *suffix++ = '\0'; /* try a struct field */ - const Eolian_Typedecl *tpd = eolian_unit_struct_by_name_get(unit, name); + const Eolian_Typedecl *tpd = eolian_unit_struct_by_name_get(unit1, name); + if (!tpd && unit2) + tpd = eolian_unit_struct_by_name_get(unit2, name); if (tpd) { const Eolian_Struct_Type_Field *fld = eolian_typedecl_struct_field_get(tpd, suffix); /* field itself is invalid */ if (!fld) return EOLIAN_OBJECT_UNKNOWN; - if (data) *data = &tpd->base; + if (data1) *data1 = &tpd->base; if (data2) *data2 = &fld->base; return EOLIAN_OBJECT_STRUCT_FIELD; } /* try an enum field */ - tpd = eolian_unit_enum_by_name_get(unit, name); + tpd = eolian_unit_enum_by_name_get(unit1, name); + if (!tpd && unit2) + tpd = eolian_unit_enum_by_name_get(unit2, name); if (tpd) { const Eolian_Enum_Type_Field *fld = eolian_typedecl_enum_field_get(tpd, suffix); /* field itself is invalid */ if (!fld) return EOLIAN_OBJECT_UNKNOWN; - if (data) *data = &tpd->base; + if (data1) *data1 = &tpd->base; if (data2) *data2 = &fld->base; return EOLIAN_OBJECT_ENUM_FIELD; } @@ -512,7 +521,9 @@ eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *uni *suffix++ = '\0'; } - const Eolian_Class *cl = eolian_unit_class_by_name_get(unit, name); + const Eolian_Class *cl = eolian_unit_class_by_name_get(unit1, name); + if (!cl && unit2) + cl = eolian_unit_class_by_name_get(unit2, name); if (!cl) return EOLIAN_OBJECT_UNKNOWN; @@ -521,11 +532,18 @@ eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *uni return EOLIAN_OBJECT_UNKNOWN; /* got a func */ - if (data) *data = &cl->base; + if (data1) *data1 = &cl->base; if (data2) *data2 = &fid->base; return EOLIAN_OBJECT_FUNCTION; } +EAPI Eolian_Object_Type +eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, + const Eolian_Object **data, const Eolian_Object **data2) +{ + return database_doc_token_ref_resolve(tok, (const Eolian_Unit *)state, NULL, data, data2); +} + void database_unit_init(Eolian_State *state, Eolian_Unit *unit, const char *file) { @@ -872,8 +890,8 @@ _defer_hash_cb(const Eina_Hash *hash EINA_UNUSED, const void *key, Defer_Data *d = fdata; Eolian_Unit *parent = d->parent; /* not a dependency; parse standalone */ - //if ((size_t)data <= 1) - // parent = parent->state; + if ((size_t)data <= 1) + parent = &parent->state->staging.unit; Eolian_Unit *pdep = _eolian_file_parse_nodep(parent, key); return (d->succ = (pdep && _parse_deferred(pdep))); } @@ -1000,7 +1018,7 @@ eolian_state_file_parse(Eolian_State *state, const char *filepath) return NULL; _state_clean(state); - Eolian_Unit *ret = _eolian_file_parse_nodep((Eolian_Unit *)state, filepath); + Eolian_Unit *ret = _eolian_file_parse_nodep(&state->staging.unit, filepath); if (!ret) return NULL; if (!_parse_deferred(ret)) @@ -1023,7 +1041,7 @@ static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key Parse_Data *pd = fdata; Eolian_Unit *unit = NULL; if (pd->ret) - unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_TRUE); + unit = eo_parser_database_fill(&pd->state->staging.unit, data, EINA_TRUE); pd->ret = !!unit; if (pd->ret) pd->ret = _parse_deferred(unit); if (pd->ret) _merge_units(unit); @@ -1054,7 +1072,7 @@ static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key Parse_Data *pd = fdata; Eolian_Unit *unit = NULL; if (pd->ret) - unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_FALSE); + unit = eo_parser_database_fill(&pd->state->staging.unit, data, EINA_FALSE); pd->ret = !!unit; if (pd->ret) pd->ret = _parse_deferred(unit); if (pd->ret) _merge_units(unit); diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 319ec25125..c4232258ad 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -387,6 +387,12 @@ void database_doc_del(Eolian_Documentation *doc); void database_unit_init(Eolian_State *state, Eolian_Unit *unit, const char *file); void database_unit_del(Eolian_Unit *unit); +Eolian_Object_Type database_doc_token_ref_resolve(const Eolian_Doc_Token *tok, + const Eolian_Unit *unit1, + const Eolian_Unit *unit2, + const Eolian_Object **data1, + const Eolian_Object **data2); + /* types */ void database_type_add(Eolian_Unit *unit, Eolian_Typedecl *tp); diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index f5657d5bfc..91f1bd1389 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -1348,7 +1348,7 @@ M.DocTokenizer = util.Object:clone { ref_resolve = function(self, root) -- FIXME: unit - local tp, d1, d2 = self.tok:ref_resolve(eos:unit_get()) + local tp, d1, d2 = self.tok:ref_resolve(eos) local reft = eolian.doc_ref_type local ret = {} if tp == reft.CLASS or tp == reft.FUNC or tp == reft.EVENT then diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index 285064265a..3cd7bad285 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -714,7 +714,7 @@ lib.eolian_doc_token_type_get.restype = c_int lib.eolian_doc_token_text_get.argtypes = (c_void_p,) lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED -# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_Unit *unit, const Eolian_Object **data, const Eolian_Object **data2); +# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2); # lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, ???, ???) # lib.eolian_doc_token_ref_resolve.restype = c_int diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index f61a8f4215..758ff9840e 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -1219,7 +1219,7 @@ EFL_START_TEST(eolian_docs) fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF); txt = eolian_doc_token_text_get(&tok); fail_if(strcmp(txt, "pants")); - fail_if(eolian_doc_token_ref_resolve(&tok, unit, NULL, NULL) != EOLIAN_OBJECT_VARIABLE); + fail_if(eolian_doc_token_ref_resolve(&tok, eos, NULL, NULL) != EOLIAN_OBJECT_VARIABLE); free(txt); tdoc = eolian_documentation_tokenize(tdoc, &tok); fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT); @@ -1230,7 +1230,7 @@ EFL_START_TEST(eolian_docs) fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF); txt = eolian_doc_token_text_get(&tok); fail_if(strcmp(txt, "Docs.meth")); - fail_if(eolian_doc_token_ref_resolve(&tok, unit, NULL, NULL) != EOLIAN_OBJECT_FUNCTION); + fail_if(eolian_doc_token_ref_resolve(&tok, eos, NULL, NULL) != EOLIAN_OBJECT_FUNCTION); free(txt); tdoc = eolian_documentation_tokenize(tdoc, &tok); fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);