summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-06 16:13:39 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit2d28fce231ba91611f5c759f76a529fdbef109a4 (patch)
tree4d38e4b7b8932806e872465a6eb44162de5fe63d
parent1ad1eb300bff7bab2300d94ca9d8529eed870f1f (diff)
eolian gen2: complete impl gen besides params
-rw-r--r--src/bin/eolian2/sources.c119
1 files changed, 112 insertions, 7 deletions
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index afeb5d7b83..f5c0e3f0ee 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -814,10 +814,114 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
814} 814}
815 815
816static void 816static void
817_gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
818 Eina_Bool var_as_ret, Eina_Strbuf *params, Eina_Strbuf *params_full)
819{
820}
821
822static void
817_gen_proto(const Eolian_Class *cl, const Eolian_Function *fid, 823_gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
818 Eolian_Function_Type ftype, Eina_Strbuf *buf, 824 Eolian_Function_Type ftype, Eina_Strbuf *buf,
819 const Eolian_Implement *impl, const char *dtype) 825 const Eolian_Implement *impl, const char *dtype,
826 const char *cnamel, const char *cnameu)
820{ 827{
828 Eina_Bool impl_same_class = (eolian_implement_class_get(impl) == cl);
829 if (impl_same_class && eolian_function_is_virtual_pure(fid, ftype))
830 return;
831
832 char *ocnamel = NULL;
833 if (!impl_same_class)
834 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel);
835
836 char fname[256], iname[256];
837 if (impl_same_class)
838 snprintf(iname, sizeof(iname), "%s_%s", cnamel, ocnamel);
839 else
840 snprintf(iname, sizeof(iname), "%s", cnamel);
841
842 snprintf(fname, sizeof(fname), "_%s_%s%s", iname, eolian_function_name_get(fid),
843 (ftype == EOLIAN_PROP_GET)
844 ? "_get" : ((ftype == EOLIAN_PROP_SET) ? "_set" : ""));
845
846 if (_function_exists(fname, buf))
847 {
848 free(ocnamel);
849 return;
850 }
851
852 printf("generating function %s...", fname);
853
854 Eina_Bool var_as_ret = EINA_FALSE;
855 const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype);
856 if ((ftype == EOLIAN_PROP_GET) && !rtp)
857 {
858 void *d1, *d2;
859 Eina_Iterator *itr = eolian_property_values_get(fid, ftype);
860 if (eina_iterator_next(itr, &d1) && !eina_iterator_next(itr, &d2))
861 {
862 Eolian_Function_Parameter *pr = d1;
863 rtp = eolian_parameter_type_get(pr);
864 var_as_ret = EINA_TRUE;
865 }
866 eina_iterator_free(itr);
867 }
868
869 eina_strbuf_append(buf, "EOLIAN static ");
870 if (rtp)
871 {
872 Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp);
873 eina_strbuf_append(buf, rtpn);
874 eina_stringshare_del(rtpn);
875 }
876 else
877 eina_strbuf_append(buf, "void");
878
879 eina_strbuf_append_printf(buf, "\n%s(", fname);
880
881 if (eolian_function_object_is_const(fid))
882 eina_strbuf_append(buf, "const ");
883
884 eina_strbuf_append(buf, "Eo *obj, ");
885 if (dtype[0])
886 eina_strbuf_append_printf(buf, "%s *pd", dtype);
887 else
888 eina_strbuf_append(buf, "void *pd EINA_UNUSED");
889
890 /* gen params here */
891 Eina_Strbuf *params = eina_strbuf_new();
892 Eina_Strbuf *params_full = eina_strbuf_new();
893 _gen_params(fid, ftype, var_as_ret, params, params_full);
894
895 if (eina_strbuf_length_get(params_full))
896 {
897 eina_strbuf_append(buf, ", ");
898 eina_strbuf_append(buf, eina_strbuf_string_get(params_full));
899 }
900
901 eina_strbuf_append(buf, ")\n{\n");
902
903 const char *efname = eolian_function_name_get(fid);
904 if (strlen(efname) >= (sizeof("destructor") - 1) && !impl_same_class)
905 if (!strcmp(efname + strlen(efname) - sizeof("destructor") + 1, "destructor"))
906 {
907 Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype, EINA_FALSE);
908 eina_strbuf_append(buf, " ");
909 eina_strbuf_append(buf, fcn);
910 eina_stringshare_del(fcn);
911 eina_strbuf_append_printf(buf, "(efl_super(obj, %s_%s)",
912 cnameu, _cl_type_str_get(cl));
913 if (eina_strbuf_length_get(params))
914 {
915 eina_strbuf_append(buf, ", ");
916 eina_strbuf_append(buf, eina_strbuf_string_get(params));
917 }
918 eina_strbuf_append(buf, ");\n");
919 }
920 eina_strbuf_append(buf, "\n}\n\n");
921
922 eina_strbuf_free(params_full);
923 eina_strbuf_free(params);
924 free(ocnamel);
821} 925}
822 926
823void 927void
@@ -826,8 +930,8 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
826 if (!cl) 930 if (!cl)
827 return; 931 return;
828 932
829 char *cname = NULL, *cnamel = NULL; 933 char *cname = NULL, *cnameu = NULL, *cnamel = NULL;
830 eo_gen_class_names_get(cl, &cname, NULL, &cnamel); 934 eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel);
831 935
832 Eina_Strbuf *beg = eina_strbuf_new(); 936 Eina_Strbuf *beg = eina_strbuf_new();
833 937
@@ -879,14 +983,14 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
879 { 983 {
880 case EOLIAN_PROP_GET: 984 case EOLIAN_PROP_GET:
881 case EOLIAN_PROP_SET: 985 case EOLIAN_PROP_SET:
882 _gen_proto(cl, fid, ftype, buf, imp, adt); 986 _gen_proto(cl, fid, ftype, buf, imp, adt, cnamel, cnameu);
883 break; 987 break;
884 case EOLIAN_PROPERTY: 988 case EOLIAN_PROPERTY:
885 _gen_proto(cl, fid, EOLIAN_PROP_SET, buf, imp, adt); 989 _gen_proto(cl, fid, EOLIAN_PROP_SET, buf, imp, adt, cnamel, cnameu);
886 _gen_proto(cl, fid, EOLIAN_PROP_GET, buf, imp, adt); 990 _gen_proto(cl, fid, EOLIAN_PROP_GET, buf, imp, adt, cnamel, cnameu);
887 break; 991 break;
888 default: 992 default:
889 _gen_proto(cl, fid, EOLIAN_UNRESOLVED, buf, imp, adt); 993 _gen_proto(cl, fid, EOLIAN_UNRESOLVED, buf, imp, adt, cnamel, cnameu);
890 } 994 }
891 } 995 }
892 eina_iterator_free(itr); 996 eina_iterator_free(itr);
@@ -931,5 +1035,6 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
931 eina_strbuf_append_printf(buf, "#include \"%s.eo.c\"\n", cnamel); 1035 eina_strbuf_append_printf(buf, "#include \"%s.eo.c\"\n", cnamel);
932 1036
933 free(cname); 1037 free(cname);
1038 free(cnameu);
934 free(cnamel); 1039 free(cnamel);
935} 1040}