summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-12 15:05:46 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-12 15:05:46 +0200
commitd3d63ea8d39378b254728390809c44163bbadb63 (patch)
tree19476db8d1c5decacede3676d497721f682e18f0
parente5d016bb63a55b38e6a8d7f4fa953b35861174e1 (diff)
eolian gen: utilize the new class C name getter instead of manual concat
-rw-r--r--src/bin/eolian/headers.c8
-rw-r--r--src/bin/eolian/sources.c61
2 files changed, 27 insertions, 42 deletions
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index 63ec73a5b1..af95b17fc8 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -217,9 +217,11 @@ eo_gen_header_gen(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy)
217 eina_strbuf_free(cdoc); 217 eina_strbuf_free(cdoc);
218 } 218 }
219 } 219 }
220 eina_strbuf_append_printf(buf, "#define %s_%s %s_%s_get()\n\n", 220
221 cnameu, _cl_type_str_get(cl, EINA_TRUE), 221 Eina_Stringshare *mname = eolian_class_c_name_get(cl);
222 cnamel, _cl_type_str_get(cl, EINA_FALSE)); 222 eina_strbuf_append_printf(buf, "#define %s %s_%s_get()\n\n",
223 mname, cnamel, _cl_type_str_get(cl, EINA_FALSE));
224 eina_stringshare_del(mname);
223 225
224 eina_strbuf_append_printf(buf, "EWAPI const Efl_Class *%s_%s_get(void);\n", 226 eina_strbuf_append_printf(buf, "EWAPI const Efl_Class *%s_%s_get(void);\n",
225 cnamel, _cl_type_str_get(cl, EINA_FALSE)); 227 cnamel, _cl_type_str_get(cl, EINA_FALSE));
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index 2c95db5700..7148f1208d 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -1,23 +1,6 @@
1#include "main.h" 1#include "main.h"
2#include "docs.h" 2#include "docs.h"
3 3
4static const char *
5_cl_type_str_get(const Eolian_Class *cl)
6{
7 switch (eolian_class_type_get(cl))
8 {
9 case EOLIAN_CLASS_REGULAR:
10 case EOLIAN_CLASS_ABSTRACT:
11 return "CLASS";
12 case EOLIAN_CLASS_MIXIN:
13 return "MIXIN";
14 case EOLIAN_CLASS_INTERFACE:
15 return "INTERFACE";
16 default:
17 return NULL;
18 }
19}
20
21/* Used to store the function names that will have to be appended 4/* Used to store the function names that will have to be appended
22 * with __eolian during C generation. Needed when params have to 5 * with __eolian during C generation. Needed when params have to
23 * be initialized and for future features. 6 * be initialized and for future features.
@@ -279,8 +262,8 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
279 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp) 262 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp)
280 : eina_stringshare_add("void"); 263 : eina_stringshare_add("void");
281 264
282 char *cname = NULL, *cnameu = NULL, *cnamel = NULL, *ocnamel = NULL; 265 char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
283 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); 266 eo_gen_class_names_get(cl, &cname, NULL, &cnamel);
284 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel); 267 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel);
285 268
286 if (impl_need) 269 if (impl_need)
@@ -505,7 +488,11 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
505 if (!eolian_function_is_class(fid)) 488 if (!eolian_function_is_class(fid))
506 eina_strbuf_append(lbuf, "obj"); 489 eina_strbuf_append(lbuf, "obj");
507 else 490 else
508 eina_strbuf_append_printf(lbuf, "%s_%s", cnameu, _cl_type_str_get(cl)); 491 {
492 Eina_Stringshare *mname = eolian_class_c_name_get(cl);
493 eina_strbuf_append_printf(lbuf, mname);
494 eina_stringshare_del(mname);
495 }
509 if (has_params) 496 if (has_params)
510 eina_strbuf_append_printf(lbuf, ", %s", eina_strbuf_string_get(params)); 497 eina_strbuf_append_printf(lbuf, ", %s", eina_strbuf_string_get(params));
511 eina_strbuf_append(lbuf, ");\n}\n"); 498 eina_strbuf_append(lbuf, ");\n}\n");
@@ -516,7 +503,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
516 } 503 }
517 504
518 free(cname); 505 free(cname);
519 free(cnameu);
520 free(cnamel); 506 free(cnamel);
521 free(ocnamel); 507 free(ocnamel);
522 508
@@ -665,8 +651,8 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
665 651
666 _funcs_params_init = eina_hash_pointer_new(NULL); 652 _funcs_params_init = eina_hash_pointer_new(NULL);
667 653
668 char *cname = NULL, *cnameu = NULL, *cnamel = NULL; 654 char *cname = NULL, *cnamel = NULL;
669 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); 655 eo_gen_class_names_get(cl, &cname, NULL, &cnamel);
670 656
671 /* event section, they come first */ 657 /* event section, they come first */
672 { 658 {
@@ -790,12 +776,10 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
790 eina_strbuf_append(buf, ", NULL"); 776 eina_strbuf_append(buf, ", NULL");
791 EINA_ITERATOR_FOREACH(itr, iname) 777 EINA_ITERATOR_FOREACH(itr, iname)
792 { 778 {
793 char *inameu = NULL;
794 const Eolian_Class *icl = eolian_class_get_by_name(iname); 779 const Eolian_Class *icl = eolian_class_get_by_name(iname);
795 eo_gen_class_names_get(icl, NULL, &inameu, NULL); 780 Eina_Stringshare *mname = eolian_class_c_name_get(icl);
796 eina_strbuf_append(buf, ", "); 781 eina_strbuf_append_printf(buf, ", %s", mname);
797 eina_strbuf_append_printf(buf, "%s_%s", inameu, _cl_type_str_get(icl)); 782 eina_stringshare_del(mname);
798 free(inameu);
799 } 783 }
800 eina_iterator_free(itr); 784 eina_iterator_free(itr);
801 } 785 }
@@ -810,7 +794,6 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
810 794
811 /* and we're done */ 795 /* and we're done */
812 free(cname); 796 free(cname);
813 free(cnameu);
814 free(cnamel); 797 free(cnamel);
815 eina_hash_free(_funcs_params_init); 798 eina_hash_free(_funcs_params_init);
816} 799}
@@ -883,7 +866,7 @@ static void
883_gen_proto(const Eolian_Class *cl, const Eolian_Function *fid, 866_gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
884 Eolian_Function_Type ftype, Eina_Strbuf *buf, 867 Eolian_Function_Type ftype, Eina_Strbuf *buf,
885 const Eolian_Implement *impl, const char *dtype, 868 const Eolian_Implement *impl, const char *dtype,
886 const char *cnamel, const char *cnameu) 869 const char *cnamel)
887{ 870{
888 Eina_Bool impl_same_class = (eolian_implement_class_get(impl) == cl); 871 Eina_Bool impl_same_class = (eolian_implement_class_get(impl) == cl);
889 if (impl_same_class && eolian_function_is_virtual_pure(fid, ftype)) 872 if (impl_same_class && eolian_function_is_virtual_pure(fid, ftype))
@@ -962,11 +945,12 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
962 if (!strcmp(efname + strlen(efname) - sizeof("destructor") + 1, "destructor")) 945 if (!strcmp(efname + strlen(efname) - sizeof("destructor") + 1, "destructor"))
963 { 946 {
964 Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype, EINA_FALSE); 947 Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype, EINA_FALSE);
948 Eina_Stringshare *mname = eolian_class_c_name_get(cl);
965 eina_strbuf_append(buf, " "); 949 eina_strbuf_append(buf, " ");
966 eina_strbuf_append(buf, fcn); 950 eina_strbuf_append(buf, fcn);
967 eina_stringshare_del(fcn); 951 eina_stringshare_del(fcn);
968 eina_strbuf_append_printf(buf, "(efl_super(obj, %s_%s)", 952 eina_strbuf_append_printf(buf, "(efl_super(obj, %s)", mname);
969 cnameu, _cl_type_str_get(cl)); 953 eina_stringshare_del(mname);
970 if (eina_strbuf_length_get(params)) 954 if (eina_strbuf_length_get(params))
971 eina_strbuf_append(buf, eina_strbuf_string_get(params)); 955 eina_strbuf_append(buf, eina_strbuf_string_get(params));
972 eina_strbuf_append(buf, ");\n"); 956 eina_strbuf_append(buf, ");\n");
@@ -984,8 +968,8 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
984 if (!cl) 968 if (!cl)
985 return; 969 return;
986 970
987 char *cname = NULL, *cnameu = NULL, *cnamel = NULL; 971 char *cname = NULL, *cnamel = NULL;
988 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); 972 eo_gen_class_names_get(cl, &cname, NULL, &cnamel);
989 973
990 Eina_Strbuf *beg = eina_strbuf_new(); 974 Eina_Strbuf *beg = eina_strbuf_new();
991 975
@@ -1037,14 +1021,14 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
1037 { 1021 {
1038 case EOLIAN_PROP_GET: 1022 case EOLIAN_PROP_GET:
1039 case EOLIAN_PROP_SET: 1023 case EOLIAN_PROP_SET:
1040 _gen_proto(cl, fid, ftype, buf, imp, adt, cnamel, cnameu); 1024 _gen_proto(cl, fid, ftype, buf, imp, adt, cnamel);
1041 break; 1025 break;
1042 case EOLIAN_PROPERTY: 1026 case EOLIAN_PROPERTY:
1043 _gen_proto(cl, fid, EOLIAN_PROP_SET, buf, imp, adt, cnamel, cnameu); 1027 _gen_proto(cl, fid, EOLIAN_PROP_SET, buf, imp, adt, cnamel);
1044 _gen_proto(cl, fid, EOLIAN_PROP_GET, buf, imp, adt, cnamel, cnameu); 1028 _gen_proto(cl, fid, EOLIAN_PROP_GET, buf, imp, adt, cnamel);
1045 break; 1029 break;
1046 default: 1030 default:
1047 _gen_proto(cl, fid, EOLIAN_UNRESOLVED, buf, imp, adt, cnamel, cnameu); 1031 _gen_proto(cl, fid, EOLIAN_UNRESOLVED, buf, imp, adt, cnamel);
1048 } 1032 }
1049 } 1033 }
1050 eina_iterator_free(itr); 1034 eina_iterator_free(itr);
@@ -1089,6 +1073,5 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
1089 eina_strbuf_append_printf(buf, "#include \"%s.eo.c\"\n", cnamel); 1073 eina_strbuf_append_printf(buf, "#include \"%s.eo.c\"\n", cnamel);
1090 1074
1091 free(cname); 1075 free(cname);
1092 free(cnameu);
1093 free(cnamel); 1076 free(cnamel);
1094} 1077}