summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-08-15 11:52:11 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-08-21 09:26:05 +0100
commit913e0f09fa789b72fe48d02c042afc49b3a64df9 (patch)
treeeb0b12a82cffb86578e8465b0cb289d1c60212b3 /src
parent60f0450bacbecb7f3d842ba6d1f09229edada103 (diff)
eolian: get rid of the data hash in Eolian_Function
Diffstat (limited to 'src')
-rw-r--r--src/bin/eolian/common_funcs.c6
-rw-r--r--src/bin/eolian/eo_generator.c38
-rw-r--r--src/bin/eolian/legacy_generator.c8
-rw-r--r--src/bin/eolian_cxx/convert_comments.cc5
-rw-r--r--src/lib/eolian/Eolian.h36
-rw-r--r--src/lib/eolian/database_fill.c20
-rw-r--r--src/lib/eolian/database_function.c51
-rw-r--r--src/lib/eolian/database_function_api.c46
-rw-r--r--src/lib/eolian/database_print.c26
-rw-r--r--src/lib/eolian/eolian_database.h16
-rw-r--r--src/tests/eolian/eolian_parsing.c6
11 files changed, 122 insertions, 136 deletions
diff --git a/src/bin/eolian/common_funcs.c b/src/bin/eolian/common_funcs.c
index bd5f5dee9e..13d5ffc5c7 100644
--- a/src/bin/eolian/common_funcs.c
+++ b/src/bin/eolian/common_funcs.c
@@ -79,14 +79,14 @@ _class_func_env_create(const Eolian_Class *class, const char *funcname, Eolian_F
79 if (ftype == EOLIAN_PROP_GET) 79 if (ftype == EOLIAN_PROP_GET)
80 { 80 {
81 suffix = "_get"; 81 suffix = "_get";
82 legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET); 82 legacy = eolian_function_legacy_get(funcid, ftype);
83 } 83 }
84 if (ftype == EOLIAN_PROP_SET) 84 if (ftype == EOLIAN_PROP_SET)
85 { 85 {
86 suffix = "_set"; 86 suffix = "_set";
87 legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET); 87 legacy = eolian_function_legacy_get(funcid, ftype);
88 } 88 }
89 if (!legacy) legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY); 89 if (!legacy) legacy = eolian_function_legacy_get(funcid, EOLIAN_METHOD);
90 90
91 _eolian_class_vars tmp_env; 91 _eolian_class_vars tmp_env;
92 _class_env_create(class, NULL, &tmp_env); 92 _class_env_create(class, NULL, &tmp_env);
diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c
index 02402121a8..be294d35ec 100644
--- a/src/bin/eolian/eo_generator.c
+++ b/src/bin/eolian/eo_generator.c
@@ -85,8 +85,6 @@ eo_fundef_generate(const Eolian_Class *class, Eolian_Function *func, Eolian_Func
85 const char *str_dir[] = {"in", "out", "inout"}; 85 const char *str_dir[] = {"in", "out", "inout"};
86 Eina_Iterator *itr; 86 Eina_Iterator *itr;
87 void *data, *data2; 87 void *data, *data2;
88 char funcname[0xFF];
89 char descname[0xFF];
90 char *tmpstr = malloc(0x1FF); 88 char *tmpstr = malloc(0x1FF);
91 Eina_Bool var_as_ret = EINA_FALSE; 89 Eina_Bool var_as_ret = EINA_FALSE;
92 const Eolian_Type *rettypet = NULL; 90 const Eolian_Type *rettypet = NULL;
@@ -95,30 +93,20 @@ eo_fundef_generate(const Eolian_Class *class, Eolian_Function *func, Eolian_Func
95 Eolian_Object_Scope scope = eolian_function_scope_get(func); 93 Eolian_Object_Scope scope = eolian_function_scope_get(func);
96 94
97 _class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env); 95 _class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env);
98 char *fsuffix = "";
99 rettypet = eolian_function_return_type_get(func, ftype); 96 rettypet = eolian_function_return_type_get(func, ftype);
100 if (ftype == EOLIAN_PROP_GET) 97 if (ftype == EOLIAN_PROP_GET && !rettypet)
101 { 98 {
102 fsuffix = "_get"; 99 itr = eolian_function_parameters_get(func);
103 if (!rettypet) 100 /* We want to check if there is only one parameter */
101 if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2))
104 { 102 {
105 itr = eolian_function_parameters_get(func); 103 rettypet = eolian_parameter_type_get((Eolian_Function_Parameter*)data);
106 /* We want to check if there is only one parameter */ 104 var_as_ret = EINA_TRUE;
107 if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2)) 105 ret_const = eolian_parameter_const_attribute_get(data, EINA_TRUE);
108 {
109 rettypet = eolian_parameter_type_get((Eolian_Function_Parameter*)data);
110 var_as_ret = EINA_TRUE;
111 ret_const = eolian_parameter_const_attribute_get(data, EINA_TRUE);
112 }
113 eina_iterator_free(itr);
114 } 106 }
107 eina_iterator_free(itr);
115 } 108 }
116 if (ftype == EOLIAN_PROP_SET) fsuffix = "_set"; 109 const char *funcdesc = eolian_function_description_get(func, ftype);
117
118 sprintf (funcname, "%s%s", eolian_function_name_get(func), fsuffix);
119 sprintf (descname, "comment%s", fsuffix);
120 const char *funcdesc = eolian_function_description_get(func, descname);
121
122 Eina_Strbuf *str_func = eina_strbuf_new(); 110 Eina_Strbuf *str_func = eina_strbuf_new();
123 if (scope == EOLIAN_SCOPE_PROTECTED) 111 if (scope == EOLIAN_SCOPE_PROTECTED)
124 eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname); 112 eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname);
@@ -727,7 +715,7 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
727 itr = eolian_class_functions_get(class, EOLIAN_CTOR); 715 itr = eolian_class_functions_get(class, EOLIAN_CTOR);
728 EINA_ITERATOR_FOREACH(itr, fn) 716 EINA_ITERATOR_FOREACH(itr, fn)
729 { 717 {
730 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment")); 718 char *desc = _source_desc_get(eolian_function_description_get(fn, EOLIAN_METHOD));
731 eo_op_desc_generate(class, fn, EOLIAN_CTOR, desc, tmpbuf); 719 eo_op_desc_generate(class, fn, EOLIAN_CTOR, desc, tmpbuf);
732 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 720 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
733 free(desc); 721 free(desc);
@@ -749,7 +737,7 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
749 737
750 if (prop_write) 738 if (prop_write)
751 { 739 {
752 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_set")); 740 char *desc = _source_desc_get(eolian_function_description_get(fn, EOLIAN_PROP_SET));
753 741
754 sprintf(tmpstr, "%s_set", funcname); 742 sprintf(tmpstr, "%s_set", funcname);
755 eo_op_desc_generate(class, fn, EOLIAN_PROP_SET, desc, tmpbuf); 743 eo_op_desc_generate(class, fn, EOLIAN_PROP_SET, desc, tmpbuf);
@@ -758,7 +746,7 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
758 } 746 }
759 if (prop_read) 747 if (prop_read)
760 { 748 {
761 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment_get")); 749 char *desc = _source_desc_get(eolian_function_description_get(fn, EOLIAN_PROP_GET));
762 750
763 sprintf(tmpstr, "%s_get", funcname); 751 sprintf(tmpstr, "%s_get", funcname);
764 eo_op_desc_generate(class, fn, EOLIAN_PROP_GET, desc, tmpbuf); 752 eo_op_desc_generate(class, fn, EOLIAN_PROP_GET, desc, tmpbuf);
@@ -772,7 +760,7 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
772 itr = eolian_class_functions_get(class, EOLIAN_METHOD); 760 itr = eolian_class_functions_get(class, EOLIAN_METHOD);
773 EINA_ITERATOR_FOREACH(itr, fn) 761 EINA_ITERATOR_FOREACH(itr, fn)
774 { 762 {
775 char *desc = _source_desc_get(eolian_function_description_get(fn, "comment")); 763 char *desc = _source_desc_get(eolian_function_description_get(fn, EOLIAN_METHOD));
776 eo_op_desc_generate(class, fn, EOLIAN_METHOD, desc, tmpbuf); 764 eo_op_desc_generate(class, fn, EOLIAN_METHOD, desc, tmpbuf);
777 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf)); 765 eina_strbuf_append(str_op, eina_strbuf_string_get(tmpbuf));
778 free(desc); 766 free(desc);
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index 42046a261b..fc323449a7 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -44,13 +44,11 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
44{ 44{
45 _eolian_class_func_vars func_env; 45 _eolian_class_func_vars func_env;
46 const char *funcname = eolian_function_name_get(funcid); 46 const char *funcname = eolian_function_name_get(funcid);
47 const char *suffix = "";
48 const Eolian_Type *rettypet = NULL; 47 const Eolian_Type *rettypet = NULL;
49 const char *rettype = NULL; 48 const char *rettype = NULL;
50 Eina_Bool var_as_ret = EINA_FALSE; 49 Eina_Bool var_as_ret = EINA_FALSE;
51 Eina_Bool add_star = EINA_FALSE; 50 Eina_Bool add_star = EINA_FALSE;
52 Eina_Bool ret_const = EINA_FALSE; 51 Eina_Bool ret_const = EINA_FALSE;
53 char tmpstr[0xFF];
54 Eina_Iterator *itr; 52 Eina_Iterator *itr;
55 void *data, *data2; 53 void *data, *data2;
56 Eina_Strbuf *flags = NULL; 54 Eina_Strbuf *flags = NULL;
@@ -64,7 +62,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
64 rettypet = eolian_function_return_type_get(funcid, ftype); 62 rettypet = eolian_function_return_type_get(funcid, ftype);
65 if (ftype == EOLIAN_PROP_GET) 63 if (ftype == EOLIAN_PROP_GET)
66 { 64 {
67 suffix = "_get";
68 add_star = EINA_TRUE; 65 add_star = EINA_TRUE;
69 if (!rettypet) 66 if (!rettypet)
70 { 67 {
@@ -80,8 +77,6 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
80 } 77 }
81 } 78 }
82 79
83 if (ftype == EOLIAN_PROP_SET) suffix = "_set";
84
85 if (func_env.legacy_func[0] == '\0') goto end; 80 if (func_env.legacy_func[0] == '\0') goto end;
86 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func); 81 eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func);
87 82
@@ -91,8 +86,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, const Eolian_Function *funci
91 eina_strbuf_append(fparam, "const "); 86 eina_strbuf_append(fparam, "const ");
92 eina_strbuf_append_printf(fparam, "%s *obj", class_env.full_classname); 87 eina_strbuf_append_printf(fparam, "%s *obj", class_env.full_classname);
93 } 88 }
94 sprintf (tmpstr, "comment%s", suffix); 89 const char *desc = eolian_function_description_get(funcid, ftype);
95 const char *desc = eolian_function_description_get(funcid, tmpstr);
96 Eina_Strbuf *linedesc = eina_strbuf_new(); 90 Eina_Strbuf *linedesc = eina_strbuf_new();
97 eina_strbuf_append(linedesc, desc ? desc : "No description supplied."); 91 eina_strbuf_append(linedesc, desc ? desc : "No description supplied.");
98 if (eina_strbuf_length_get(linedesc)) 92 if (eina_strbuf_length_get(linedesc))
diff --git a/src/bin/eolian_cxx/convert_comments.cc b/src/bin/eolian_cxx/convert_comments.cc
index 87b0f350c5..c520eb887a 100644
--- a/src/bin/eolian_cxx/convert_comments.cc
+++ b/src/bin/eolian_cxx/convert_comments.cc
@@ -38,11 +38,10 @@ _comment_parameters_list(Eina_Iterator *params)
38} 38}
39 39
40static std::string 40static std::string
41_comment_brief_and_params(Eolian_Function const& function, 41_comment_brief_and_params(Eolian_Function const& function, Eolian_Function_Type ftype = EOLIAN_METHOD)
42 const char *key = EOLIAN_COMMENT)
43{ 42{
44 std::string doc = ""; 43 std::string doc = "";
45 std::string func = safe_str(::eolian_function_description_get(&function, key)); 44 std::string func = safe_str(::eolian_function_description_get(&function, ftype));
46 if (func != "") 45 if (func != "")
47 { 46 {
48 doc += "@brief " + func + "\n\n"; 47 doc += "@brief " + func + "\n\n";
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 0d6271a69b..0a98e90aa8 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -86,13 +86,6 @@ typedef struct _Eolian_Expression Eolian_Expression;
86 */ 86 */
87typedef struct _Eolian_Variable Eolian_Variable; 87typedef struct _Eolian_Variable Eolian_Variable;
88 88
89#define EOLIAN_LEGACY "legacy"
90#define EOLIAN_LEGACY_GET "legacy_get"
91#define EOLIAN_LEGACY_SET "legacy_set"
92#define EOLIAN_COMMENT "comment"
93#define EOLIAN_COMMENT_SET "comment_set"
94#define EOLIAN_COMMENT_GET "comment_get"
95
96typedef enum 89typedef enum
97{ 90{
98 EOLIAN_UNRESOLVED, 91 EOLIAN_UNRESOLVED,
@@ -623,46 +616,47 @@ EAPI Eina_Stringshare *eolian_function_full_c_name_get(const Eolian_Function *fu
623EAPI const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type); 616EAPI const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type);
624 617
625/* 618/*
626 * @brief Returns a specific data for a function. 619 * @brief Returns a legacy name for a function.
627 * 620 *
628 * @param[in] function_id Id of the function 621 * @param[in] function_id Id of the function
629 * @param[in] key key to access the data 622 * @param[in] f_type The function type, for property get/set distinction.
630 * @return the data. 623 * @return the legacy name or NULL.
631 * 624 *
632 * @ingroup Eolian 625 * @ingroup Eolian
633 */ 626 */
634EAPI Eina_Stringshare *eolian_function_data_get(const Eolian_Function *function_id, const char *key); 627EAPI Eina_Stringshare *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
635 628
636/* 629/*
637 * @brief Indicates if a function is virtual pure. 630 * @brief Returns a description for a function.
638 * 631 *
639 * @param[in] function_id Id of the function 632 * @param[in] function_id Id of the function
640 * @return EINA_TRUE if virtual pure, EINA_FALSE othrewise.. 633 * @param[in] f_type The function type, for property get/set distinction.
634 * @return the description or NULL.
641 * 635 *
642 * @ingroup Eolian 636 * @ingroup Eolian
643 */ 637 */
644EAPI Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type); 638EAPI Eina_Stringshare *eolian_function_description_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
645 639
646/* 640/*
647 * @brief Get whether a function is a class method/property. 641 * @brief Indicates if a function is virtual pure.
648 * 642 *
649 * @param[in] function_id Id of the function 643 * @param[in] function_id Id of the function
650 * @return EINA_TRUE and EINA_FALSE respectively 644 * @param[in] f_type The function type, for property get/set distinction.
645 * @return EINA_TRUE if virtual pure, EINA_FALSE othrewise..
651 * 646 *
652 * @ingroup Eolian 647 * @ingroup Eolian
653 */ 648 */
654EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id); 649EAPI Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type);
655 650
656/* 651/*
657 * @brief Returns a specific description for a function. 652 * @brief Get whether a function is a class method/property.
658 * 653 *
659 * @param[in] function_id Id of the function 654 * @param[in] function_id Id of the function
660 * @param[in] key key to access the description 655 * @return EINA_TRUE and EINA_FALSE respectively
661 * @return the description.
662 * 656 *
663 * @ingroup Eolian 657 * @ingroup Eolian
664 */ 658 */
665#define eolian_function_description_get(function_id, key) eolian_function_data_get((function_id), (key)) 659EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
666 660
667/* 661/*
668 * @brief Returns a parameter of a function pointed by its id. 662 * @brief Returns a parameter of a function pointed by its id.
diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c
index b3e2c58076..fb24709824 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -15,8 +15,8 @@ _db_fill_ctor(Eolian_Class *cl, Eo_Method_Def *meth)
15 database_function_return_comment_set(foo_id, EOLIAN_METHOD, 15 database_function_return_comment_set(foo_id, EOLIAN_METHOD,
16 meth->ret->comment); 16 meth->ret->comment);
17 } 17 }
18 18
19 database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); 19 database_function_legacy_set(foo_id, EOLIAN_METHOD, meth->legacy);
20 20
21 EINA_LIST_FOREACH(meth->params, l, param) 21 EINA_LIST_FOREACH(meth->params, l, param)
22 { 22 {
@@ -156,17 +156,9 @@ _db_fill_accessor(Eolian_Function *foo_id, Eo_Class_Def *kls,
156 } 156 }
157 157
158 if (accessor->legacy) 158 if (accessor->legacy)
159 { 159 database_function_legacy_set(foo_id, ftype, accessor->legacy);
160 database_function_data_set(foo_id, ((accessor->type == SETTER)
161 ? EOLIAN_LEGACY_SET
162 : EOLIAN_LEGACY_GET),
163 accessor->legacy);
164 }
165 160
166 database_function_description_set(foo_id, ((accessor->type == SETTER) 161 database_function_description_set(foo_id, ftype, accessor->comment);
167 ? EOLIAN_COMMENT_SET
168 : EOLIAN_COMMENT_GET),
169 accessor->comment);
170 162
171 EINA_LIST_FOREACH(accessor->params, l, acc_param) 163 EINA_LIST_FOREACH(accessor->params, l, acc_param)
172 { 164 {
@@ -280,8 +272,8 @@ _db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth)
280 meth->ret->default_ret_val = NULL; 272 meth->ret->default_ret_val = NULL;
281 } 273 }
282 274
283 database_function_description_set(foo_id, EOLIAN_COMMENT, meth->comment); 275 database_function_description_set(foo_id, EOLIAN_METHOD, meth->comment);
284 database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); 276 database_function_legacy_set(foo_id, EOLIAN_METHOD, meth->legacy);
285 database_function_object_set_as_const(foo_id, meth->obj_const); 277 database_function_object_set_as_const(foo_id, meth->obj_const);
286 database_function_set_as_class(foo_id, meth->is_class); 278 database_function_set_as_class(foo_id, meth->is_class);
287 279
diff --git a/src/lib/eolian/database_function.c b/src/lib/eolian/database_function.c
index eb3956167b..d747e169fd 100644
--- a/src/lib/eolian/database_function.c
+++ b/src/lib/eolian/database_function.c
@@ -9,13 +9,18 @@ database_function_del(Eolian_Function *fid)
9 9
10 if (fid->base.file) eina_stringshare_del(fid->base.file); 10 if (fid->base.file) eina_stringshare_del(fid->base.file);
11 eina_stringshare_del(fid->name); 11 eina_stringshare_del(fid->name);
12 eina_hash_free(fid->data);
13 EINA_LIST_FREE(fid->keys, param) database_parameter_del(param); 12 EINA_LIST_FREE(fid->keys, param) database_parameter_del(param);
14 EINA_LIST_FREE(fid->params, param) database_parameter_del(param); 13 EINA_LIST_FREE(fid->params, param) database_parameter_del(param);
15 database_type_del(fid->get_ret_type); 14 database_type_del(fid->get_ret_type);
16 database_type_del(fid->set_ret_type); 15 database_type_del(fid->set_ret_type);
17 database_expr_del(fid->get_ret_val); 16 database_expr_del(fid->get_ret_val);
18 database_expr_del(fid->set_ret_val); 17 database_expr_del(fid->set_ret_val);
18 if (fid->get_legacy) eina_stringshare_del(fid->get_legacy);
19 if (fid->set_legacy) eina_stringshare_del(fid->set_legacy);
20 if (fid->get_description) eina_stringshare_del(fid->get_description);
21 if (fid->set_description) eina_stringshare_del(fid->set_description);
22 if (fid->get_return_comment) eina_stringshare_del(fid->get_return_comment);
23 if (fid->set_return_comment) eina_stringshare_del(fid->set_return_comment);
19 free(fid); 24 free(fid);
20} 25}
21 26
@@ -25,7 +30,6 @@ database_function_new(const char *function_name, Eolian_Function_Type foo_type)
25 Eolian_Function *fid = calloc(1, sizeof(*fid)); 30 Eolian_Function *fid = calloc(1, sizeof(*fid));
26 fid->name = eina_stringshare_add(function_name); 31 fid->name = eina_stringshare_add(function_name);
27 fid->type = foo_type; 32 fid->type = foo_type;
28 fid->data = eina_hash_string_superfast_new(free);
29 return fid; 33 return fid;
30} 34}
31 35
@@ -74,22 +78,6 @@ database_function_set_as_class(Eolian_Function *fid, Eina_Bool is_class)
74 fid->is_class = is_class; 78 fid->is_class = is_class;
75} 79}
76 80
77void
78database_function_data_set(Eolian_Function *fid, const char *key, const char *data)
79{
80 EINA_SAFETY_ON_NULL_RETURN(key);
81 EINA_SAFETY_ON_NULL_RETURN(fid);
82 if (data)
83 {
84 if (!eina_hash_find(fid->data, key))
85 eina_hash_set(fid->data, key, strdup(data));
86 }
87 else
88 {
89 eina_hash_del(fid->data, key, NULL);
90 }
91}
92
93Eolian_Function_Parameter * 81Eolian_Function_Parameter *
94database_property_key_add(Eolian_Function *fid, Eolian_Type *type, const char *name, const char *description) 82database_property_key_add(Eolian_Function *fid, Eolian_Type *type, const char *name, const char *description)
95{ 83{
@@ -140,15 +128,12 @@ void database_function_return_default_val_set(Eolian_Function *fid, Eolian_Funct
140 128
141void database_function_return_comment_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *ret_comment) 129void database_function_return_comment_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *ret_comment)
142{ 130{
143 const char *key = NULL;
144 switch (ftype) 131 switch (ftype)
145 { 132 {
146 case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break; 133 case EOLIAN_PROP_SET: fid->set_return_comment = eina_stringshare_ref(ret_comment); break;
147 case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break; 134 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: fid->get_return_comment = eina_stringshare_ref(ret_comment); break;
148 case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break;
149 default: return; 135 default: return;
150 } 136 }
151 database_function_data_set(fid, key, ret_comment);
152} 137}
153 138
154void database_function_return_flag_set_as_warn_unused(Eolian_Function *fid, 139void database_function_return_flag_set_as_warn_unused(Eolian_Function *fid,
@@ -169,3 +154,23 @@ database_function_object_set_as_const(Eolian_Function *fid, Eina_Bool is_const)
169 EINA_SAFETY_ON_NULL_RETURN(fid); 154 EINA_SAFETY_ON_NULL_RETURN(fid);
170 fid->obj_is_const = is_const; 155 fid->obj_is_const = is_const;
171} 156}
157
158void database_function_legacy_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *legacy)
159{
160 switch (ftype)
161 {
162 case EOLIAN_PROP_SET: fid->set_legacy = eina_stringshare_ref(legacy); break;
163 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_CTOR: case EOLIAN_PROP_GET: fid->get_legacy = eina_stringshare_ref(legacy); break;
164 default: return;
165 }
166}
167
168void database_function_description_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *desc)
169{
170 switch (ftype)
171 {
172 case EOLIAN_PROP_SET: fid->set_description = eina_stringshare_ref(desc); break;
173 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_CTOR: case EOLIAN_PROP_GET: fid->get_description = eina_stringshare_ref(desc); break;
174 default: return;
175 }
176}
diff --git a/src/lib/eolian/database_function_api.c b/src/lib/eolian/database_function_api.c
index 9cd0656eb7..204df9cfdc 100644
--- a/src/lib/eolian/database_function_api.c
+++ b/src/lib/eolian/database_function_api.c
@@ -56,13 +56,37 @@ eolian_function_full_c_name_get(const Eolian_Function *foo_id, const char *prefi
56 return ret; 56 return ret;
57} 57}
58 58
59EAPI Eina_Stringshare *
60eolian_function_legacy_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
61{
62 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
63 switch (ftype)
64 {
65 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_CTOR: case EOLIAN_PROP_GET: return fid->get_legacy; break;
66 case EOLIAN_PROP_SET: return fid->set_legacy; break;
67 default: return NULL;
68 }
69}
70
71EAPI Eina_Stringshare *
72eolian_function_description_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
73{
74 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
75 switch (ftype)
76 {
77 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_CTOR: case EOLIAN_PROP_GET: return fid->get_description; break;
78 case EOLIAN_PROP_SET: return fid->set_description; break;
79 default: return NULL;
80 }
81}
82
59EAPI Eina_Bool 83EAPI Eina_Bool
60eolian_function_is_virtual_pure(const Eolian_Function *fid, Eolian_Function_Type ftype) 84eolian_function_is_virtual_pure(const Eolian_Function *fid, Eolian_Function_Type ftype)
61{ 85{
62 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); 86 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
63 switch (ftype) 87 switch (ftype)
64 { 88 {
65 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_virtual_pure; break; 89 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_CTOR: case EOLIAN_PROP_GET: return fid->get_virtual_pure; break;
66 case EOLIAN_PROP_SET: return fid->set_virtual_pure; break; 90 case EOLIAN_PROP_SET: return fid->set_virtual_pure; break;
67 default: return EINA_FALSE; 91 default: return EINA_FALSE;
68 } 92 }
@@ -75,13 +99,6 @@ eolian_function_is_class(const Eolian_Function *fid)
75 return fid->is_class; 99 return fid->is_class;
76} 100}
77 101
78EAPI Eina_Stringshare *
79eolian_function_data_get(const Eolian_Function *fid, const char *key)
80{
81 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
82 return eina_hash_find(fid->data, key);
83}
84
85EAPI const Eolian_Function_Parameter * 102EAPI const Eolian_Function_Parameter *
86eolian_function_parameter_get_by_name(const Eolian_Function *fid, const char *param_name) 103eolian_function_parameter_get_by_name(const Eolian_Function *fid, const char *param_name)
87{ 104{
@@ -121,7 +138,7 @@ eolian_function_return_type_get(const Eolian_Function *fid, Eolian_Function_Type
121 switch (ftype) 138 switch (ftype)
122 { 139 {
123 case EOLIAN_PROP_SET: return fid->set_ret_type; 140 case EOLIAN_PROP_SET: return fid->set_ret_type;
124 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_ret_type; 141 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_CTOR: case EOLIAN_PROP_GET: return fid->get_ret_type;
125 default: return NULL; 142 default: return NULL;
126 } 143 }
127} 144}
@@ -132,7 +149,7 @@ eolian_function_return_default_value_get(const Eolian_Function *fid, Eolian_Func
132 switch (ftype) 149 switch (ftype)
133 { 150 {
134 case EOLIAN_PROP_SET: return fid->set_ret_val; 151 case EOLIAN_PROP_SET: return fid->set_ret_val;
135 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_ret_val; 152 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_CTOR: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_ret_val;
136 default: return NULL; 153 default: return NULL;
137 } 154 }
138} 155}
@@ -140,15 +157,12 @@ eolian_function_return_default_value_get(const Eolian_Function *fid, Eolian_Func
140EAPI Eina_Stringshare * 157EAPI Eina_Stringshare *
141eolian_function_return_comment_get(const Eolian_Function *fid, Eolian_Function_Type ftype) 158eolian_function_return_comment_get(const Eolian_Function *fid, Eolian_Function_Type ftype)
142{ 159{
143 const char *key = NULL;
144 switch (ftype) 160 switch (ftype)
145 { 161 {
146 case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_COMMENT; break; 162 case EOLIAN_PROP_SET: return fid->set_return_comment; break;
147 case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_COMMENT; break; 163 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_CTOR: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_return_comment; break;
148 case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_COMMENT; break;
149 default: return NULL; 164 default: return NULL;
150 } 165 }
151 return eolian_function_data_get(fid, key);
152} 166}
153 167
154EAPI Eina_Bool 168EAPI Eina_Bool
@@ -158,7 +172,7 @@ eolian_function_return_is_warn_unused(const Eolian_Function *fid,
158 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); 172 EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
159 switch (ftype) 173 switch (ftype)
160 { 174 {
161 case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_return_warn_unused; 175 case EOLIAN_METHOD: case EOLIAN_PROP_GET: case EOLIAN_CTOR: case EOLIAN_PROPERTY: return fid->get_return_warn_unused;
162 case EOLIAN_PROP_SET: return fid->set_return_warn_unused; 176 case EOLIAN_PROP_SET: return fid->set_return_warn_unused;
163 default: return EINA_FALSE; 177 default: return EINA_FALSE;
164 } 178 }
diff --git a/src/lib/eolian/database_print.c b/src/lib/eolian/database_print.c
index 02ee699d89..a1fd411c02 100644
--- a/src/lib/eolian/database_print.c
+++ b/src/lib/eolian/database_print.c
@@ -44,13 +44,13 @@ static Eina_Bool _function_print(const Eolian_Function *fid, int nb_spaces)
44 case EOLIAN_PROPERTY: 44 case EOLIAN_PROPERTY:
45 { 45 {
46 printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); 46 printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
47 const char *str = eolian_function_description_get(fid, EOLIAN_COMMENT_GET); 47 const char *str = eolian_function_description_get(fid, EOLIAN_PROP_GET);
48 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 48 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
49 str = eolian_function_description_get(fid, EOLIAN_COMMENT_SET); 49 str = eolian_function_description_get(fid, EOLIAN_PROP_SET);
50 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 50 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
51 str = eolian_function_data_get(fid, EOLIAN_LEGACY_GET); 51 str = eolian_function_legacy_get(fid, EOLIAN_PROP_GET);
52 if (str) printf("%*slegacy_get: <%s>\n", nb_spaces + 5, "", str); 52 if (str) printf("%*slegacy_get: <%s>\n", nb_spaces + 5, "", str);
53 str = eolian_function_data_get(fid, EOLIAN_LEGACY_SET); 53 str = eolian_function_legacy_get(fid, EOLIAN_PROP_SET);
54 if (str) printf("%*slegacy_set: <%s>\n", nb_spaces + 5, "", str); 54 if (str) printf("%*slegacy_set: <%s>\n", nb_spaces + 5, "", str);
55 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET); 55 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
56 if (tp) 56 if (tp)
@@ -71,9 +71,9 @@ static Eina_Bool _function_print(const Eolian_Function *fid, int nb_spaces)
71 case EOLIAN_PROP_GET: 71 case EOLIAN_PROP_GET:
72 { 72 {
73 printf("%*sGET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); 73 printf("%*sGET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
74 const char *str = eolian_function_description_get(fid, EOLIAN_COMMENT_GET); 74 const char *str = eolian_function_description_get(fid, EOLIAN_PROP_GET);
75 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 75 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
76 str = eolian_function_data_get(fid, EOLIAN_LEGACY_GET); 76 str = eolian_function_legacy_get(fid, EOLIAN_PROP_GET);
77 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str); 77 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
78 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET); 78 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
79 if (tp) 79 if (tp)
@@ -87,9 +87,9 @@ static Eina_Bool _function_print(const Eolian_Function *fid, int nb_spaces)
87 case EOLIAN_PROP_SET: 87 case EOLIAN_PROP_SET:
88 { 88 {
89 printf("%*sSET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); 89 printf("%*sSET:<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
90 const char *str = eolian_function_description_get(fid, EOLIAN_COMMENT_SET); 90 const char *str = eolian_function_description_get(fid, EOLIAN_PROP_SET);
91 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 91 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
92 str = eolian_function_data_get(fid, EOLIAN_LEGACY_SET); 92 str = eolian_function_legacy_get(fid, EOLIAN_PROP_SET);
93 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str); 93 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
94 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET); 94 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
95 if (tp) 95 if (tp)
@@ -103,9 +103,9 @@ static Eina_Bool _function_print(const Eolian_Function *fid, int nb_spaces)
103 case EOLIAN_METHOD: 103 case EOLIAN_METHOD:
104 { 104 {
105 printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name); 105 printf("%*s<%s> %s\n", nb_spaces, "", ret_desc ? ret_desc : "", fid->name);
106 const char *str = eolian_function_description_get(fid, EOLIAN_COMMENT); 106 const char *str = eolian_function_description_get(fid, EOLIAN_METHOD);
107 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 107 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
108 str = eolian_function_data_get(fid, EOLIAN_LEGACY); 108 str = eolian_function_legacy_get(fid, EOLIAN_METHOD);
109 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str); 109 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
110 tp = eolian_function_return_type_get(fid, EOLIAN_METHOD); 110 tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
111 if (tp) 111 if (tp)
@@ -120,11 +120,11 @@ static Eina_Bool _function_print(const Eolian_Function *fid, int nb_spaces)
120 case EOLIAN_CTOR: 120 case EOLIAN_CTOR:
121 { 121 {
122 //char *str = eina_hash_find(fid->data, "comment"); 122 //char *str = eina_hash_find(fid->data, "comment");
123 const char *str = eolian_function_description_get(fid, EOLIAN_COMMENT); 123 const char *str = eolian_function_description_get(fid, EOLIAN_METHOD);
124 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str); 124 if (str) printf("%*s<%s>\n", nb_spaces + 5, "", str);
125 str = eolian_function_data_get(fid, EOLIAN_LEGACY); 125 str = eolian_function_legacy_get(fid, EOLIAN_METHOD);
126 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str); 126 if (str) printf("%*slegacy: <%s>\n", nb_spaces + 5, "", str);
127 tp = eolian_function_return_type_get(fid, EOLIAN_CTOR); 127 tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
128 if (tp) 128 if (tp)
129 { 129 {
130 printf("%*sreturn type: <", nb_spaces + 5, ""); 130 printf("%*sreturn type: <", nb_spaces + 5, "");
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 38f53652fa..f3578a79e2 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -31,10 +31,6 @@ extern Eina_Prefix *_eolian_prefix;
31#endif 31#endif
32#define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__) 32#define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__)
33 33
34#define EOLIAN_METHOD_RETURN_COMMENT "method_return_comment"
35#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment"
36#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment"
37
38extern Eina_Hash *_classes; 34extern Eina_Hash *_classes;
39extern Eina_Hash *_aliases; 35extern Eina_Hash *_aliases;
40extern Eina_Hash *_structs; 36extern Eina_Hash *_structs;
@@ -91,7 +87,12 @@ struct _Eolian_Function
91 Eolian_Type *set_ret_type; 87 Eolian_Type *set_ret_type;
92 Eolian_Expression *get_ret_val; 88 Eolian_Expression *get_ret_val;
93 Eolian_Expression *set_ret_val; 89 Eolian_Expression *set_ret_val;
94 Eina_Hash *data; 90 Eina_Stringshare *get_legacy;
91 Eina_Stringshare *set_legacy;
92 Eina_Stringshare *get_description;
93 Eina_Stringshare *set_description;
94 Eina_Stringshare *get_return_comment;
95 Eina_Stringshare *set_return_comment;
95 Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */ 96 Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
96 Eina_Bool get_virtual_pure :1; 97 Eina_Bool get_virtual_pure :1;
97 Eina_Bool set_virtual_pure :1; 98 Eina_Bool set_virtual_pure :1;
@@ -310,9 +311,8 @@ Eolian_Function *database_function_new(const char *function_name, Eolian_Functio
310void database_function_del(Eolian_Function *fid); 311void database_function_del(Eolian_Function *fid);
311 312
312void database_function_type_set(Eolian_Function *function_id, Eolian_Function_Type foo_type); 313void database_function_type_set(Eolian_Function *function_id, Eolian_Function_Type foo_type);
313void database_function_data_set(Eolian_Function *function_id, const char *key, const char *description); 314void database_function_legacy_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *legacy);
314#define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc)) 315void database_function_description_set(Eolian_Function *fid, Eolian_Function_Type ftype, const char *desc);
315
316void database_function_return_type_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eolian_Type *ret_type); 316void database_function_return_type_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eolian_Type *ret_type);
317void database_function_return_comment_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, const char *ret_comment); 317void database_function_return_comment_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, const char *ret_comment);
318void database_function_return_default_val_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eolian_Expression *ret_default_value); 318void database_function_return_default_val_set(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eolian_Expression *ret_default_value);
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 9334dd116b..f1fa865109 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -465,10 +465,10 @@ START_TEST(eolian_simple_parsing)
465 /* Property */ 465 /* Property */
466 fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY))); 466 fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
467 fail_if(strcmp(eolian_function_name_get(fid), "a")); 467 fail_if(strcmp(eolian_function_name_get(fid), "a"));
468 string = eolian_function_description_get(fid, EOLIAN_COMMENT_SET); 468 string = eolian_function_description_get(fid, EOLIAN_PROP_SET);
469 fail_if(!string); 469 fail_if(!string);
470 fail_if(strcmp(string, "comment a.set")); 470 fail_if(strcmp(string, "comment a.set"));
471 string = eolian_function_description_get(fid, EOLIAN_COMMENT_GET); 471 string = eolian_function_description_get(fid, EOLIAN_PROP_GET);
472 fail_if(string); 472 fail_if(string);
473 /* Set return */ 473 /* Set return */
474 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET); 474 tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
@@ -498,7 +498,7 @@ START_TEST(eolian_simple_parsing)
498 498
499 /* Method */ 499 /* Method */
500 fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD))); 500 fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
501 string = eolian_function_description_get(fid, EOLIAN_COMMENT); 501 string = eolian_function_description_get(fid, EOLIAN_METHOD);
502 fail_if(!string); 502 fail_if(!string);
503 fail_if(strcmp(string, "comment foo")); 503 fail_if(strcmp(string, "comment foo"));
504 /* Function return */ 504 /* Function return */