static void _gen_func(const Eolian_Unit *src, const Eolian_Function *fid, Eolian_Function_Type ftype, Eina_Strbuf *buf, char *cname, char *cnameu, Eina_Bool legacy) { Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, ftype, legacy); if (!fcn) return; Eina_Bool var_as_ret = EINA_FALSE; const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); if (ftype == EOLIAN_PROP_GET && !rtp) { void *d1, *d2; Eina_Iterator *itr = eolian_property_values_get(fid, ftype); if (eina_iterator_next(itr, &d1) && !eina_iterator_next(itr, &d2)) { rtp = eolian_parameter_type_get((Eolian_Function_Parameter *)d1); var_as_ret = EINA_TRUE; } eina_iterator_free(itr); } Eolian_Object_Scope fsc = eolian_function_scope_get(fid, ftype); /* this one will never be satisfied in legacy */ if (eolian_function_is_beta(fid)) eina_strbuf_append_printf(buf, "#ifdef %s_BETA\n", cnameu); /* XXX: is this right? we expose potentially internal stuff into legacy */ if (!legacy && (fsc == EOLIAN_SCOPE_PROTECTED)) eina_strbuf_append_printf(buf, "#ifdef %s_PROTECTED\n", cnameu); const Eolian_Implement *fimp = eolian_function_implement_get(fid); Eina_Bool hasdoc = !!eolian_implement_documentation_get(fimp, ftype); if (!hasdoc && ((ftype == EOLIAN_PROP_GET) || (ftype == EOLIAN_PROP_SET))) hasdoc = !!eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY); if (hasdoc) { Eina_Strbuf *dbuf = eo_gen_docs_func_gen(src, fid, ftype, 0, legacy); eina_strbuf_append(buf, eina_strbuf_string_get(dbuf)); eina_strbuf_append_char(buf, '\n'); eina_strbuf_free(dbuf); } eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI "); if (rtp) { Eina_Stringshare *rtps = eolian_type_c_type_get(rtp); eina_strbuf_append(buf, rtps); if (rtps[strlen(rtps) - 1] != '*') eina_strbuf_append_char(buf, ' '); eina_stringshare_del(rtps); } else eina_strbuf_append(buf, "void "); eina_strbuf_append(buf, fcn); eina_stringshare_del(fcn); Eina_Bool first = EINA_TRUE; Eina_Strbuf *flagbuf = NULL; int nidx = !legacy || !eolian_function_is_class(fid); eina_strbuf_append_char(buf, '('); if (nidx) { if ((ftype == EOLIAN_PROP_GET) || eolian_function_object_is_const(fid) || eolian_function_is_class(fid)) { eina_strbuf_append(buf, "const "); } if (legacy) eina_strbuf_append_printf(buf, "%s *obj", cname); else eina_strbuf_append(buf, "Eo *obj"); first = EINA_FALSE; } { Eolian_Function_Parameter *pr = NULL; Eina_Iterator *itr = eolian_property_keys_get(fid, ftype); EINA_ITERATOR_FOREACH(itr, pr) { const Eolian_Type *prt = eolian_parameter_type_get(pr); const char *prn = eolian_parameter_name_get(pr); Eina_Stringshare *prtn = eolian_type_c_type_get(prt); ++nidx; if (!first) eina_strbuf_append(buf, ", "); eina_strbuf_append_printf(buf, "%s %s", prtn, prn); eina_stringshare_del(prtn); first = EINA_FALSE; if (!eolian_parameter_is_nonull(pr)) continue; if (!flagbuf) { flagbuf = eina_strbuf_new(); eina_strbuf_append_printf(flagbuf, " EINA_ARG_NONNULL(%d", nidx); } else eina_strbuf_append_printf(flagbuf, ", %d", nidx); } eina_iterator_free(itr); } if (!var_as_ret) { Eina_Iterator *itr = NULL; if (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET) itr = eolian_property_values_get(fid, ftype); else itr = eolian_function_parameters_get(fid); Eolian_Function_Parameter *pr = NULL; EINA_ITERATOR_FOREACH(itr, pr) { const Eolian_Type *prt = eolian_parameter_type_get(pr); const char *prn = eolian_parameter_name_get(pr); Eina_Stringshare *prtn = eolian_type_c_type_get(prt); ++nidx; if (!first) eina_strbuf_append(buf, ", "); eina_strbuf_append(buf, prtn); if (prtn[strlen(prtn) - 1] != '*') eina_strbuf_append_char(buf, ' '); eina_strbuf_append(buf, _get_add_star(ftype, eolian_parameter_direction_get(pr))); eina_strbuf_append(buf, prn); eina_stringshare_del(prtn); first = EINA_FALSE; if (!eolian_parameter_is_nonull(pr)) continue; if (!flagbuf) { flagbuf = eina_strbuf_new(); eina_strbuf_append_printf(flagbuf, " EINA_ARG_NONNULL(%d", nidx); } else eina_strbuf_append_printf(flagbuf, ", %d", nidx); } eina_iterator_free(itr); }
tmpl_eo_retdesc[] =" * @return %s\n"; #endif static Eina_Bool eo_fundef_generate(const Eolian_Class *class, const Eolian_Function *func, Eolian_Function_Type ftype, Eina_Strbuf *functext) { _eolian_class_func_vars func_env; const char *str_dir[] = {"in", "out", "inout"}; Eina_Iterator *itr; void *data, *data2; char *tmpstr = malloc(0x1FF); Eina_Bool var_as_ret = EINA_FALSE; const Eolian_Type *rettypet = NULL; const char *rettype = NULL; Eina_Bool ret_const = EINA_FALSE; Eolian_Object_Scope scope = eolian_function_scope_get(func); _class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env); rettypet = eolian_function_return_type_get(func, ftype); if (ftype == EOLIAN_PROP_GET && !rettypet) { itr = eolian_function_parameters_get(func); /* We want to check if there is only one parameter */ if (eina_iterator_next(itr, &data) && !eina_iterator_next(itr, &data2)) { rettypet = eolian_parameter_type_get((Eolian_Function_Parameter*)data); var_as_ret = EINA_TRUE; ret_const = eolian_parameter_const_attribute_get(data, EINA_TRUE); } eina_iterator_free(itr); }