eolian: inherit since information from struct and enum to field

Summary:
If a struct or enum field doesn't explicitly sets since information, then since
is inherited from struct documentation if it is available.

Reviewers: jptiz, Jaehyun_Cho, woohyun, q66

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8359

Differential Revision: https://phab.enlightenment.org/D10948
This commit is contained in:
Felipe Magno de Almeida 2019-12-24 07:26:33 +09:00 committed by WooHyun Jung
parent 5679a5d2a2
commit b3cc7d403b
5 changed files with 25 additions and 8 deletions

View File

@ -536,6 +536,8 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
qual_end: qual_end:
check_next(ls, ';'); check_next(ls, ';');
FILL_DOC(ls, fdef, doc); FILL_DOC(ls, fdef, doc);
if (def->doc && fdef->doc && def->doc->since && !fdef->doc->since)
fdef->doc->since = eina_stringshare_ref (def->doc->since);
} }
check_match(ls, '}', '{', bline, bcolumn); check_match(ls, '}', '{', bline, bcolumn);
FILL_BASE(def->base, ls, line, column, TYPEDECL); FILL_BASE(def->base, ls, line, column, TYPEDECL);
@ -656,6 +658,8 @@ parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
if (want_next) if (want_next)
eo_lexer_get(ls); eo_lexer_get(ls);
FILL_DOC(ls, fdef, doc); FILL_DOC(ls, fdef, doc);
if (def->doc && fdef->doc && def->doc->since && !fdef->doc->since)
fdef->doc->since = eina_stringshare_ref (def->doc->since);
if (!want_next || ls->t.token == '}') if (!want_next || ls->t.token == '}')
break; break;
} }

View File

@ -29,20 +29,30 @@ typedef Eo Eo_Docs;
*/ */
typedef struct _Foo typedef struct _Foo
{ {
int field1; /**< Field documentation. */ int field1; /**< Field documentation.
*
* @since 1.66 */
float field2; float field2;
short field3; /**< Another field documentation. */ short field3; /**< Another field documentation.
*
* @since 1.66 */
} Foo; } Foo;
/** Docs for enum Bar. /** Docs for enum Bar.
*
* @since 1.55
* *
* @ingroup Bar * @ingroup Bar
*/ */
typedef enum typedef enum
{ {
BAR_BLAH = 0, BAR_BLAH = 0,
BAR_FOO = 1, /**< Docs for foo. */ BAR_FOO = 1, /**< Docs for foo.
BAR_BAR = 2 /**< Docs for bar. */ *
* @since 1.55 */
BAR_BAR = 2 /**< Docs for bar.
*
* @since 1.55 */
} Bar; } Bar;
/** /**

View File

@ -19,7 +19,9 @@ struct Foo {
} }
enum Bar { enum Bar {
[[Docs for enum Bar.]] [[Docs for enum Bar.
@since 1.55
]]
blah = 0, blah = 0,
foo = 1, [[Docs for foo.]] foo = 1, [[Docs for foo.]]
bar = 2 [[Docs for bar.]] bar = 2 [[Docs for bar.]]

View File

@ -1150,7 +1150,8 @@ EFL_START_TEST(eolian_docs)
fail_if(strcmp(eolian_documentation_summary_get(doc), fail_if(strcmp(eolian_documentation_summary_get(doc),
"Docs for enum Bar.")); "Docs for enum Bar."));
fail_if(eolian_documentation_description_get(doc)); fail_if(eolian_documentation_description_get(doc));
fail_if(eolian_documentation_since_get(doc)); fail_if(strcmp(eolian_documentation_since_get(doc),
"1.55"));
fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "blah"))); fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "blah")));
fail_if(eolian_typedecl_enum_field_documentation_get(efl)); fail_if(eolian_typedecl_enum_field_documentation_get(efl));

View File

@ -279,7 +279,7 @@ EFL_START_TEST(eolian_cxx_test_struct_docs)
doc = field_iter->documentation; doc = field_iter->documentation;
ck_assert_str_eq(doc.summary.c_str(), "Field documentation."); ck_assert_str_eq(doc.summary.c_str(), "Field documentation.");
ck_assert_str_eq(doc.description.c_str(), ""); ck_assert_str_eq(doc.description.c_str(), "");
ck_assert_str_eq(doc.since.c_str(), ""); ck_assert_str_eq(doc.since.c_str(), "1.66");
field_iter++; field_iter++;
@ -293,7 +293,7 @@ EFL_START_TEST(eolian_cxx_test_struct_docs)
doc = field_iter->documentation; doc = field_iter->documentation;
ck_assert_str_eq(doc.summary.c_str(), "Another field documentation."); ck_assert_str_eq(doc.summary.c_str(), "Another field documentation.");
ck_assert_str_eq(doc.description.c_str(), ""); ck_assert_str_eq(doc.description.c_str(), "");
ck_assert_str_eq(doc.since.c_str(), ""); ck_assert_str_eq(doc.since.c_str(), "1.66");
} }
EFL_END_TEST EFL_END_TEST