From af513b6af3a6a19c28c81c4d1ad7edb11bfb1520 Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sun, 19 Oct 2014 11:17:39 +0300 Subject: [PATCH] Eolian: add support for property descriptions. For properties, set and get descriptions were supported but common comment was not. --- src/lib/eolian/database_function.c | 1 + src/lib/eolian/database_function_api.c | 4 ++-- src/lib/eolian/eo_parser.c | 4 ++-- src/lib/eolian/eolian_database.h | 1 + src/tests/eolian/data/class_simple.eo | 1 + src/tests/eolian/eolian_parsing.c | 3 +++ 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/eolian/database_function.c b/src/lib/eolian/database_function.c index c85b8acab1..48fdd30554 100644 --- a/src/lib/eolian/database_function.c +++ b/src/lib/eolian/database_function.c @@ -25,6 +25,7 @@ database_function_del(Eolian_Function *fid) if (fid->set_legacy) eina_stringshare_del(fid->set_legacy); if (fid->get_description) eina_stringshare_del(fid->get_description); if (fid->set_description) eina_stringshare_del(fid->set_description); + if (fid->common_description) eina_stringshare_del(fid->common_description); if (fid->get_return_comment) eina_stringshare_del(fid->get_return_comment); if (fid->set_return_comment) eina_stringshare_del(fid->set_return_comment); free(fid); diff --git a/src/lib/eolian/database_function_api.c b/src/lib/eolian/database_function_api.c index 95bf12c6b9..000dda6c78 100644 --- a/src/lib/eolian/database_function_api.c +++ b/src/lib/eolian/database_function_api.c @@ -92,9 +92,9 @@ eolian_function_description_get(const Eolian_Function *fid, Eolian_Function_Type EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL); switch (ftype) { - case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_description; break; + case EOLIAN_PROP_GET: return fid->get_description; break; case EOLIAN_PROP_SET: return fid->set_description; break; - default: return NULL; + default: return fid->common_description; } } diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index c14efa7bd4..5c2ada78df 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1359,7 +1359,7 @@ body: check_next(ls, '{'); if (ls->t.token == TOK_COMMENT) { - /* just consume the comment for now */ + prop->common_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } for (;;) switch (ls->t.kw) @@ -1455,7 +1455,7 @@ body: check_next(ls, '{'); if (ls->t.token == TOK_COMMENT) { - meth->get_description = eina_stringshare_ref(ls->t.value.s); + meth->common_description = eina_stringshare_ref(ls->t.value.s); eo_lexer_get(ls); } for (;;) switch (ls->t.kw) diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index acf8e61369..ddf50a4787 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -101,6 +101,7 @@ struct _Eolian_Function Eolian_Implement *set_impl; Eina_Stringshare *get_legacy; Eina_Stringshare *set_legacy; + Eina_Stringshare *common_description; Eina_Stringshare *get_description; Eina_Stringshare *set_description; Eina_Stringshare *get_return_comment; diff --git a/src/tests/eolian/data/class_simple.eo b/src/tests/eolian/data/class_simple.eo index a64a9aa891..1f0ae65886 100644 --- a/src/tests/eolian/data/class_simple.eo +++ b/src/tests/eolian/data/class_simple.eo @@ -5,6 +5,7 @@ class Class_Simple { data: Evas_Simple_Data; properties { a { + /*@ Common desc for a */ set { /*@ comment a.set */ diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 2f10ec7d0f..d71464b152 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -548,6 +548,9 @@ START_TEST(eolian_simple_parsing) /* Property */ fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY))); fail_if(strcmp(eolian_function_name_get(fid), "a")); + string = eolian_function_description_get(fid, EOLIAN_PROPERTY); + fail_if(!string); + fail_if(strcmp(string, "Common desc for a")); string = eolian_function_description_get(fid, EOLIAN_PROP_SET); fail_if(!string); fail_if(strcmp(string, "comment a.set")); -- 2.34.1