}
static void
-_append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type *tp)
+_append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type *tp, const char *ctp)
{
if (exp)
{
free(sn);
return;
}
- Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT);
if (strchr(ctp, '*'))
{
eina_strbuf_append(buf, "NULL");
return;
}
- eina_stringshare_del(ctp);
/* enums and remaining regulars... 0 should do */
eina_strbuf_append(buf, "0");
}
}
static void
-_gen_reflect_get(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt,
+_gen_reflect_get(Eina_Strbuf *buf, const char *cnamel,
+ const Eolian_Function_Parameter *pr,
const Eolian_Function *fid, Eina_Hash *refh)
{
+ const Eolian_Type *valt = eolian_parameter_type_get(pr);
if (eolian_type_is_ptr(valt))
return;
cnamel, eolian_function_name_get(fid));
eina_strbuf_append(buf, "{\n");
- Eina_Stringshare *ct = eolian_type_c_type_get(valt, EOLIAN_C_TYPE_RETURN);
+ Eina_Stringshare *ct = eolian_parameter_c_type_get(pr, EINA_TRUE);
const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : "";
Eina_Stringshare *fcn = eolian_function_full_c_name_get(fid, EOLIAN_PROP_GET);
}
static void
-_gen_reflect_set(Eina_Strbuf *buf, const char *cnamel, const Eolian_Type *valt,
+_gen_reflect_set(Eina_Strbuf *buf, const char *cnamel,
+ const Eolian_Function_Parameter *pr,
const Eolian_Function *fid, Eina_Hash *refh)
{
+ const Eolian_Type *valt = eolian_parameter_type_get(pr);
if (eolian_type_is_ptr(valt))
return;
eina_strbuf_append(buf, "{\n");
eina_strbuf_append(buf, " Eina_Error r = 0;");
- Eina_Stringshare *ct = eolian_type_c_type_get(valt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ct = eolian_parameter_c_type_get(pr, EINA_FALSE);
const char *starsp = (ct[strlen(ct) - 1] != '*') ? " " : "";
eina_strbuf_append_printf(buf, " %s%scval;\n", ct, starsp);
eina_stringshare_del(ct);
}
static void
-_emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const Eolian_Type *rtp, Eina_Strbuf *params_full,
+_emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const char *rtpn, Eina_Strbuf *params_full,
const char *ocnamel, const char *func_suffix, Eina_Strbuf *params, const char *function_name)
{
eina_strbuf_append(buf, "EOAPI ");
- if (rtp)
- eina_strbuf_append(buf, eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN));
- else
- eina_strbuf_append(buf, "void");
+ eina_strbuf_append(buf, rtpn);
eina_strbuf_append(buf, " ");
eina_strbuf_append(buf, function_name);
eina_strbuf_append(buf, "(");
eina_strbuf_append(buf, ")\n");
eina_strbuf_append(buf, "{\n");
eina_strbuf_append_printf(buf, " %s();\n", eolian_class_c_get_function_name_get(eolian_function_class_get(fid)));
- if (rtp)
+ if (strcmp(rtpn, "void"))
eina_strbuf_append(buf, " return ");
else
eina_strbuf_append(buf, " ");
Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
Eina_Bool var_as_ret = EINA_FALSE;
/* assume we're not generating reflection api by default */
- const Eolian_Type *reflect_type = NULL;
+ const Eolian_Function_Parameter *reflect_param = NULL;
const Eolian_Expression *def_ret = NULL;
const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype);
+ Eina_Stringshare *rtpn = NULL;
if (rtp)
{
is_auto = EINA_FALSE; /* can't do auto if func returns */
def_ret = eolian_function_return_default_value_get(fid, ftype);
+ rtpn = eolian_function_return_c_type_get(fid, ftype);
}
const char *func_suffix = "";
rtp = eolian_parameter_type_get(pr);
/* reflect only when returning 1 val */
if (!eolian_parameter_is_by_ref(pr))
- reflect_type = rtp;
+ reflect_param = pr;
var_as_ret = EINA_TRUE;
def_ret = eolian_parameter_default_value_get(pr);
+ rtpn = eolian_parameter_c_type_get(pr, EINA_TRUE);
}
eina_iterator_free(itr);
}
{
Eolian_Function_Parameter *pr = d1;
if (!eolian_parameter_is_by_ref(pr))
- reflect_type = eolian_parameter_type_get(pr);
+ reflect_param = pr;
}
eina_iterator_free(itr);
}
{
Eina_Iterator *itr = eolian_property_keys_get(fid, ftype);
if (itr) /* has keys: no reflection */
- reflect_type = NULL;
+ reflect_param = NULL;
Eolian_Function_Parameter *pr;
EINA_ITERATOR_FOREACH(itr, pr)
{
const char *prn = eolian_parameter_name_get(pr);
- const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE);
if (eina_strbuf_length_get(params))
eina_strbuf_append(params, ", ");
const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr);
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE);
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
impl_need = EINA_FALSE;
- Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)
- : eina_stringshare_add("void");
+ if (!rtpn)
+ rtpn = eina_stringshare_add("void");
char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
eo_gen_class_names_get(cl, &cname, NULL, &cnamel);
if (rtp)
{
eina_strbuf_append(buf, " return ");
- _append_defval(buf, def_ret, rtp);
+ _append_defval(buf, def_ret, rtp, rtpn);
eina_strbuf_append(buf, ";\n");
}
eina_strbuf_append(buf, "}\n\n");
if (impl_same_class && !eolian_function_is_static(fid))
{
/* generate reflection implementation */
- if (reflect_type)
+ if (reflect_param)
{
if (ftype == EOLIAN_PROP_GET)
- _gen_reflect_get(buf, cnamel, reflect_type, fid, refh);
+ _gen_reflect_get(buf, cnamel, reflect_param, fid, refh);
else
- _gen_reflect_set(buf, cnamel, reflect_type, fid, refh);
+ _gen_reflect_set(buf, cnamel, reflect_param, fid, refh);
}
void *data;
if (strcmp(rtpn, "void"))
{
eina_strbuf_append_printf(buf, ", %s, ", rtpn);
- _append_defval(buf, def_ret, rtp);
+ _append_defval(buf, def_ret, rtp, rtpn);
}
if (fallback_free_ownership)
eina_stringshare_del(eofn);
}
if (impl_same_class && eolian_function_is_static(fid))
- _emit_class_function(buf, fid, rtp, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype));
+ _emit_class_function(buf, fid, rtpn, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype));
free(cname);
free(cnamel);
EINA_ITERATOR_FOREACH(itr, pr)
{
const char *prn = eolian_parameter_name_get(pr);
- const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE);
eina_strbuf_append(params, ", ");
eina_strbuf_append(params, prn);
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_parameter_c_type_get(pr, EINA_FALSE);
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
{
Eina_Bool var_as_ret = EINA_FALSE;
const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype);
+ Eina_Stringshare *rtpn = NULL;
if ((ftype == EOLIAN_PROP_GET) && !rtp)
{
void *d1, *d2;
{
Eolian_Function_Parameter *pr = d1;
rtp = eolian_parameter_type_get(pr);
+ rtpn = eolian_parameter_c_type_get(pr, EINA_FALSE);
var_as_ret = EINA_TRUE;
}
eina_iterator_free(itr);
eina_strbuf_append(buf, "EOLIAN static ");
if (rtp)
{
- Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
+ if (!rtpn)
+ rtpn = eolian_function_return_c_type_get(fid, ftype);
eina_strbuf_append(buf, rtpn);
eina_stringshare_del(rtpn);
}
/* Method */
fail_if(!(fid = eolian_class_function_by_name_get(class, "foo", EOLIAN_METHOD)));
fail_if(!eolian_function_is_beta(fid));
- fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
/* Function return */
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
fail_if(!tp);
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(strcmp(eolian_type_short_name_get(eolian_parameter_type_get(param)), "int"));
- fail_if(!eolian_type_is_ptr(eolian_parameter_type_get(param)));
+ fail_if(!eolian_parameter_is_by_ref(param));
fail_if(strcmp(eolian_parameter_name_get(param), "d"));
fail_if(eina_iterator_next(iter, &dummy));
eina_iterator_free(iter);
fail_if(strcmp(file, "struct.eo"));
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
- fail_if(!eolian_type_is_ptr(ftype));
+ fail_if(!eolian_typedecl_struct_field_is_by_ref(field));
fail_if(!(type_name = eolian_type_short_name_get(ftype)));
fail_if(strcmp(type_name, "int"));
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
- fail_if(eolian_type_is_ptr(ftype));
+ fail_if(eolian_typedecl_struct_field_is_by_ref(field));
fail_if(!(type_name = eolian_typedecl_struct_field_c_type_get(field)));
fail_if(strcmp(type_name, "const char *"));
eina_stringshare_del(type_name);
fail_if(!(func = eolian_class_function_by_name_get(class, "bar", EOLIAN_METHOD)));
fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
- fail_if(!eolian_type_is_ptr(type));
+ fail_if(!eolian_function_return_is_by_ref(func, EOLIAN_METHOD));
fail_if(!(tdl = eolian_type_typedecl_get(type)));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);