From dedd8cef64be99e59d7b0ca23f2651d06bdf3c7e Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sun, 19 Oct 2014 13:21:11 +0300 Subject: [PATCH] Eolian/Generator: support common descriptions for properties. --- src/bin/eolian/eo_generator.c | 8 ++- src/bin/eolian/legacy_generator.c | 8 ++- src/tests/eolian/data/class_simple_ref_eo.h | 72 +++++++++++++++++++ .../eolian/data/class_simple_ref_legacy.h | 63 ++++++++++++++++ src/tests/eolian/eolian_generation.c | 20 ++++++ 5 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 src/tests/eolian/data/class_simple_ref_eo.h create mode 100644 src/tests/eolian/data/class_simple_ref_legacy.h diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c index bc16c75a91..9ab894603d 100644 --- a/src/bin/eolian/eo_generator.c +++ b/src/bin/eolian/eo_generator.c @@ -114,7 +114,6 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia } eina_iterator_free(itr); } - const char *funcdesc = eolian_function_description_get(func, ftype); Eina_Strbuf *str_func = eina_strbuf_new(); if (scope == EOLIAN_SCOPE_PROTECTED) eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname); @@ -127,7 +126,12 @@ eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolia eina_strbuf_append_printf(str_func, "\n"); Eina_Strbuf *linedesc = eina_strbuf_new(); - eina_strbuf_append(linedesc, funcdesc ? funcdesc : "No description supplied."); + const char *common_desc = eolian_function_description_get(func, EOLIAN_UNRESOLVED); + const char *specific_desc = (ftype == EOLIAN_PROP_SET || ftype == EOLIAN_PROP_GET) ? + eolian_function_description_get(func, ftype) : NULL; + if (!common_desc && !specific_desc) eina_strbuf_append(linedesc, "No description supplied."); + if (common_desc) eina_strbuf_append_printf(linedesc, "%s\n", common_desc); + if (specific_desc) eina_strbuf_append(linedesc, specific_desc); if (eina_strbuf_length_get(linedesc)) { eina_strbuf_replace_all(linedesc, "\n", "\n * "); diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c index 7d9a7aabef..5b5a072844 100644 --- a/src/bin/eolian/legacy_generator.c +++ b/src/bin/eolian/legacy_generator.c @@ -90,9 +90,13 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci eina_strbuf_append(fparam, "const "); eina_strbuf_append_printf(fparam, "%s *obj", class_env.full_classname); } - const char *desc = eolian_function_description_get(funcid, ftype); Eina_Strbuf *linedesc = eina_strbuf_new(); - eina_strbuf_append(linedesc, desc ? desc : "No description supplied."); + const char *common_desc = eolian_function_description_get(funcid, EOLIAN_UNRESOLVED); + const char *specific_desc = (ftype == EOLIAN_PROP_SET || ftype == EOLIAN_PROP_GET) ? + eolian_function_description_get(funcid, ftype) : NULL; + if (!common_desc && !specific_desc) eina_strbuf_append(linedesc, "No description supplied."); + if (common_desc) eina_strbuf_append_printf(linedesc, "%s\n", common_desc); + if (specific_desc) eina_strbuf_append(linedesc, specific_desc); if (eina_strbuf_length_get(linedesc)) { eina_strbuf_replace_all(linedesc, "\n", "\n * "); diff --git a/src/tests/eolian/data/class_simple_ref_eo.h b/src/tests/eolian/data/class_simple_ref_eo.h new file mode 100644 index 0000000000..ccdc0fbf09 --- /dev/null +++ b/src/tests/eolian/data/class_simple_ref_eo.h @@ -0,0 +1,72 @@ +#ifndef _EOLIAN_OUTPUT_H_ +#define _EOLIAN_OUTPUT_H_ + +#ifndef _CLASS_SIMPLE_EO_CLASS_TYPE +#define _CLASS_SIMPLE_EO_CLASS_TYPE + +typedef Eo Class_Simple; + +#endif + +#ifndef _CLASS_SIMPLE_EO_TYPES +#define _CLASS_SIMPLE_EO_TYPES + + +#endif +/** + * Class Desc Simple + */ +#define CLASS_SIMPLE_CLASS class_simple_class_get() + +const Eo_Class *class_simple_class_get(void) EINA_CONST; + +/** + * + * Common desc for a + * comment a.set + * + * @param[in] value Value description + * + */ +EOAPI Eina_Bool evas_obj_simple_a_set(int value); + +/** + * + * Common desc for a + * + * + * + */ +EOAPI int evas_obj_simple_a_get(void); + +/** + * + * No description supplied. + * + * + */ +EOAPI void evas_obj_simple_b_set(void); + +/** + * + * comment foo + * + * + * @param[in] a a + * @param[inout] b No description supplied. + * @param[out] c No description supplied. + * + */ +EOAPI char * evas_obj_simple_foo(int a, char *b, double *c); + +/** + * + * No description supplied. + * + * @param[in] x No description supplied. + * + */ +EOAPI int evas_obj_simple_bar(int x); + + +#endif diff --git a/src/tests/eolian/data/class_simple_ref_legacy.h b/src/tests/eolian/data/class_simple_ref_legacy.h new file mode 100644 index 0000000000..176b3ed60f --- /dev/null +++ b/src/tests/eolian/data/class_simple_ref_legacy.h @@ -0,0 +1,63 @@ +#ifndef _EOLIAN_OUTPUT_H_ +#define _EOLIAN_OUTPUT_H_ + +#ifndef _CLASS_SIMPLE_EO_CLASS_TYPE +#define _CLASS_SIMPLE_EO_CLASS_TYPE + +typedef Eo Class_Simple; + +#endif + +#ifndef _CLASS_SIMPLE_EO_TYPES +#define _CLASS_SIMPLE_EO_TYPES + + +#endif +/** + * Class Desc Simple + */ + +/** + * + * Common desc for a + * comment a.set + * + * @param[in] value Value description + */ +EAPI Eina_Bool evas_object_simple_a_set(Class_Simple *obj, int value); + +/** + * + * Common desc for a + * + * + */ +EAPI int evas_object_simple_a_get(const Class_Simple *obj); + +/** + * + * No description supplied. + * + */ +EAPI void evas_object_simple_b_set(Class_Simple *obj); + +/** + * + * comment foo + * + * + * @param[in] a a + * @param[inout] b No description supplied. + * @param[out] c No description supplied. + */ +EAPI char *evas_object_simple_foo(Class_Simple *obj, int a, char *b, double *c); + +/** + * + * No description supplied. + * + * @param[in] x No description supplied. + */ +EAPI int evas_object_simple_bar(Class_Simple *obj, int x); + +#endif diff --git a/src/tests/eolian/eolian_generation.c b/src/tests/eolian/eolian_generation.c index 8161ea9cb3..25fcddf53f 100644 --- a/src/tests/eolian/eolian_generation.c +++ b/src/tests/eolian/eolian_generation.c @@ -156,11 +156,31 @@ START_TEST(eolian_override_generation) } END_TEST +START_TEST(eolian_functions_descriptions) +{ + char output_filepath[PATH_MAX] = ""; + snprintf(output_filepath, PATH_MAX, "%s/eolian_output.h", +#ifdef HAVE_EVIL + (char *)evil_tmpdir_get() +#else + "/tmp" +#endif + ); + remove(output_filepath); + fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "--eo --gh", output_filepath)); + fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_eo.h", output_filepath)); + remove(output_filepath); + fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "--legacy --gh", output_filepath)); + fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_legacy.h", output_filepath)); +} +END_TEST + void eolian_generation_test(TCase *tc) { tcase_add_test(tc, eolian_types_generation); tcase_add_test(tc, eolian_default_values_generation); tcase_add_test(tc, eolian_override_generation); tcase_add_test(tc, eolian_dev_impl_code); + tcase_add_test(tc, eolian_functions_descriptions); }