summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-06 16:33:45 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commitb789d6e1ec253e9f939f73dda993980d4e869b5c (patch)
treedb7d15fa65db6a823f23318872c5d0aaf5b07bbb
parent2d28fce231ba91611f5c759f76a529fdbef109a4 (diff)
eolian gen2: complete impl generator
-rw-r--r--src/bin/eolian2/sources.c72
1 files changed, 62 insertions, 10 deletions
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index f5c0e3f0ee..e51b5f33ab 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -817,6 +817,64 @@ static void
817_gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype, 817_gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
818 Eina_Bool var_as_ret, Eina_Strbuf *params, Eina_Strbuf *params_full) 818 Eina_Bool var_as_ret, Eina_Strbuf *params, Eina_Strbuf *params_full)
819{ 819{
820 Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
821
822 /* property keys */
823 {
824 Eina_Iterator *itr = eolian_property_keys_get(fid, ftype);
825 Eolian_Function_Parameter *pr;
826 EINA_ITERATOR_FOREACH(itr, pr)
827 {
828 const char *prn = eolian_parameter_name_get(pr);
829 const Eolian_Type *pt = eolian_parameter_type_get(pr);
830 Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
831
832 eina_strbuf_append(params, ", ");
833 eina_strbuf_append(params, prn);
834
835 eina_strbuf_append_printf(params_full, ", %s", ptn);
836 if (!strchr(ptn, '*'))
837 eina_strbuf_append_char(params_full, ' ');
838 eina_strbuf_append(params_full, prn);
839
840 eina_stringshare_del(ptn);
841 }
842 eina_iterator_free(itr);
843 }
844
845 /* property values or method params if applicable */
846 if (!var_as_ret)
847 {
848 Eina_Iterator *itr;
849 if (is_prop)
850 itr = eolian_property_values_get(fid, ftype);
851 else
852 itr = eolian_function_parameters_get(fid);
853 Eolian_Function_Parameter *pr;
854 EINA_ITERATOR_FOREACH(itr, pr)
855 {
856 Eolian_Parameter_Dir pd = eolian_parameter_direction_get(pr);
857 const char *prn = eolian_parameter_name_get(pr);
858 const Eolian_Type *pt = eolian_parameter_type_get(pr);
859 Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
860
861 Eina_Bool had_star = !!strchr(ptn, '*');
862 const char *add_star = _get_add_star(ftype, pd);
863
864 eina_strbuf_append(params, ", ");
865 eina_strbuf_append(params, prn);
866
867 eina_strbuf_append(params_full, ", ");
868 eina_strbuf_append(params_full, ptn);
869 if (!had_star)
870 eina_strbuf_append_char(params_full, ' ');
871 eina_strbuf_append(params_full, add_star);
872 eina_strbuf_append(params_full, prn);
873
874 eina_stringshare_del(ptn);
875 }
876 eina_iterator_free(itr);
877 }
820} 878}
821 879
822static void 880static void
@@ -834,7 +892,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
834 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel); 892 eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel);
835 893
836 char fname[256], iname[256]; 894 char fname[256], iname[256];
837 if (impl_same_class) 895 if (!impl_same_class)
838 snprintf(iname, sizeof(iname), "%s_%s", cnamel, ocnamel); 896 snprintf(iname, sizeof(iname), "%s_%s", cnamel, ocnamel);
839 else 897 else
840 snprintf(iname, sizeof(iname), "%s", cnamel); 898 snprintf(iname, sizeof(iname), "%s", cnamel);
@@ -849,7 +907,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
849 return; 907 return;
850 } 908 }
851 909
852 printf("generating function %s...", fname); 910 printf("generating function %s...\n", fname);
853 911
854 Eina_Bool var_as_ret = EINA_FALSE; 912 Eina_Bool var_as_ret = EINA_FALSE;
855 const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); 913 const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype);
@@ -893,10 +951,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
893 _gen_params(fid, ftype, var_as_ret, params, params_full); 951 _gen_params(fid, ftype, var_as_ret, params, params_full);
894 952
895 if (eina_strbuf_length_get(params_full)) 953 if (eina_strbuf_length_get(params_full))
896 { 954 eina_strbuf_append(buf, eina_strbuf_string_get(params_full));
897 eina_strbuf_append(buf, ", ");
898 eina_strbuf_append(buf, eina_strbuf_string_get(params_full));
899 }
900 955
901 eina_strbuf_append(buf, ")\n{\n"); 956 eina_strbuf_append(buf, ")\n{\n");
902 957
@@ -911,10 +966,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
911 eina_strbuf_append_printf(buf, "(efl_super(obj, %s_%s)", 966 eina_strbuf_append_printf(buf, "(efl_super(obj, %s_%s)",
912 cnameu, _cl_type_str_get(cl)); 967 cnameu, _cl_type_str_get(cl));
913 if (eina_strbuf_length_get(params)) 968 if (eina_strbuf_length_get(params))
914 { 969 eina_strbuf_append(buf, eina_strbuf_string_get(params));
915 eina_strbuf_append(buf, ", ");
916 eina_strbuf_append(buf, eina_strbuf_string_get(params));
917 }
918 eina_strbuf_append(buf, ");\n"); 970 eina_strbuf_append(buf, ");\n");
919 } 971 }
920 eina_strbuf_append(buf, "\n}\n\n"); 972 eina_strbuf_append(buf, "\n}\n\n");