forked from enlightenment/efl
eolian: change C type serialization API to account for returns
This will allow proper handling of const.
This commit is contained in:
parent
be53198f95
commit
e288f5160b
|
@ -377,7 +377,7 @@ eo_gen_docs_event_gen(const Eolian_Unit *src, const Eolian_Event *ev,
|
||||||
if (rt)
|
if (rt)
|
||||||
{
|
{
|
||||||
p = buf;
|
p = buf;
|
||||||
Eina_Stringshare *rts = eolian_type_c_type_get(rt);
|
Eina_Stringshare *rts = eolian_type_c_type_get(rt, EOLIAN_C_TYPE_DEFAULT);
|
||||||
snprintf(buf, sizeof(buf), "@return %s", rts);
|
snprintf(buf, sizeof(buf), "@return %s", rts);
|
||||||
eina_stringshare_del(rts);
|
eina_stringshare_del(rts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
|
||||||
eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
|
eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
|
||||||
if (rtp)
|
if (rtp)
|
||||||
{
|
{
|
||||||
Eina_Stringshare *rtps = eolian_type_c_type_get(rtp);
|
Eina_Stringshare *rtps = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
|
||||||
eina_strbuf_append(buf, rtps);
|
eina_strbuf_append(buf, rtps);
|
||||||
if (rtps[strlen(rtps) - 1] != '*')
|
if (rtps[strlen(rtps) - 1] != '*')
|
||||||
eina_strbuf_append_char(buf, ' ');
|
eina_strbuf_append_char(buf, ' ');
|
||||||
|
@ -96,7 +96,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
|
||||||
{
|
{
|
||||||
const Eolian_Type *prt = eolian_parameter_type_get(pr);
|
const Eolian_Type *prt = eolian_parameter_type_get(pr);
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
Eina_Stringshare *prtn = eolian_type_c_type_get(prt);
|
Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
|
||||||
++nidx;
|
++nidx;
|
||||||
if (!first)
|
if (!first)
|
||||||
eina_strbuf_append(buf, ", ");
|
eina_strbuf_append(buf, ", ");
|
||||||
|
@ -130,7 +130,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
|
||||||
const Eolian_Type *prt = eolian_parameter_type_get(pr);
|
const Eolian_Type *prt = eolian_parameter_type_get(pr);
|
||||||
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
|
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
Eina_Stringshare *prtn = eolian_type_c_type_get(prt);
|
Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
|
||||||
|
|
||||||
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
|
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,7 +137,7 @@ _append_defval(const Eolian_Unit *src, Eina_Strbuf *buf,
|
||||||
free(sn);
|
free(sn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Eina_Stringshare *ctp = eolian_type_c_type_get(btp);
|
Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT);
|
||||||
if (strchr(ctp, '*'))
|
if (strchr(ctp, '*'))
|
||||||
{
|
{
|
||||||
eina_strbuf_append(buf, "NULL");
|
eina_strbuf_append(buf, "NULL");
|
||||||
|
@ -207,7 +207,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
|
||||||
{
|
{
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
||||||
Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
|
Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
|
||||||
|
|
||||||
if (eina_strbuf_length_get(params))
|
if (eina_strbuf_length_get(params))
|
||||||
eina_strbuf_append(params, ", ");
|
eina_strbuf_append(params, ", ");
|
||||||
|
@ -245,7 +245,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
|
||||||
const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr);
|
const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr);
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
||||||
Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
|
Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
|
||||||
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
|
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
|
||||||
|
|
||||||
Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
|
Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
|
||||||
|
@ -317,7 +317,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
|
||||||
if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
|
if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
|
||||||
impl_need = EINA_FALSE;
|
impl_need = EINA_FALSE;
|
||||||
|
|
||||||
Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp)
|
Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)
|
||||||
: eina_stringshare_add("void");
|
: eina_stringshare_add("void");
|
||||||
|
|
||||||
char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
|
char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
|
||||||
|
@ -828,7 +828,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
||||||
{
|
{
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
||||||
Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
|
Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
|
||||||
|
|
||||||
eina_strbuf_append(params, ", ");
|
eina_strbuf_append(params, ", ");
|
||||||
eina_strbuf_append(params, prn);
|
eina_strbuf_append(params, prn);
|
||||||
|
@ -858,7 +858,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
|
||||||
const char *prn = eolian_parameter_name_get(pr);
|
const char *prn = eolian_parameter_name_get(pr);
|
||||||
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
const Eolian_Type *pt = eolian_parameter_type_get(pr);
|
||||||
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
|
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
|
||||||
Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
|
Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
|
||||||
|
|
||||||
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
|
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
|
||||||
{
|
{
|
||||||
|
@ -938,7 +938,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
|
||||||
eina_strbuf_append(buf, "EOLIAN static ");
|
eina_strbuf_append(buf, "EOLIAN static ");
|
||||||
if (rtp)
|
if (rtp)
|
||||||
{
|
{
|
||||||
Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp);
|
Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
|
||||||
eina_strbuf_append(buf, rtpn);
|
eina_strbuf_append(buf, rtpn);
|
||||||
eina_stringshare_del(rtpn);
|
eina_stringshare_del(rtpn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,8 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
|
||||||
Eina_Stringshare *ct = NULL;
|
Eina_Stringshare *ct = NULL;
|
||||||
if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
|
if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
|
||||||
{
|
{
|
||||||
ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp));
|
ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp),
|
||||||
|
EOLIAN_C_TYPE_DEFAULT);
|
||||||
eina_strbuf_append_printf(buf, " %s%s%s[%zu];",
|
eina_strbuf_append_printf(buf, " %s%s%s[%zu];",
|
||||||
ct, strchr(ct, '*') ? "" : " ",
|
ct, strchr(ct, '*') ? "" : " ",
|
||||||
eolian_typedecl_struct_field_name_get(memb),
|
eolian_typedecl_struct_field_name_get(memb),
|
||||||
|
@ -50,7 +51,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ct = eolian_type_c_type_get(mtp);
|
ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
|
||||||
eina_strbuf_append_printf(buf, " %s%s%s;",
|
eina_strbuf_append_printf(buf, " %s%s%s;",
|
||||||
ct, strchr(ct, '*') ? "" : " ",
|
ct, strchr(ct, '*') ? "" : " ",
|
||||||
eolian_typedecl_struct_field_name_get(memb));
|
eolian_typedecl_struct_field_name_get(memb));
|
||||||
|
@ -145,7 +146,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
|
||||||
eina_strbuf_append(buf, "void ");
|
eina_strbuf_append(buf, "void ");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eina_Stringshare *ct = eolian_type_c_type_get(rtp);
|
Eina_Stringshare *ct = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
|
||||||
eina_strbuf_append_printf(buf, "%s ", ct);
|
eina_strbuf_append_printf(buf, "%s ", ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
|
||||||
{
|
{
|
||||||
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_get(param));
|
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_get(param));
|
||||||
Eina_Stringshare *pn = eolian_parameter_name_get(param);
|
Eina_Stringshare *pn = eolian_parameter_name_get(param);
|
||||||
Eina_Stringshare *pt = eolian_type_c_type_get(eolian_parameter_type_get(param));
|
Eina_Stringshare *pt = eolian_type_c_type_get(eolian_parameter_type_get(param), EOLIAN_C_TYPE_PARAM);
|
||||||
|
|
||||||
if (!pn)
|
if (!pn)
|
||||||
pn = ""; // FIXME add some kind of param1/param2 control for null?
|
pn = ""; // FIXME add some kind of param1/param2 control for null?
|
||||||
|
@ -221,7 +222,7 @@ _var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legac
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eina_Stringshare *ct = eolian_type_c_type_get(vt);
|
Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
|
||||||
eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn);
|
eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn);
|
||||||
eina_stringshare_del(ct);
|
eina_stringshare_del(ct);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +315,7 @@ void eo_gen_types_source_gen(const Eolian_Unit *src,
|
||||||
eina_str_toupper(&fn);
|
eina_str_toupper(&fn);
|
||||||
|
|
||||||
const Eolian_Type *vt = eolian_variable_base_type_get(vr);
|
const Eolian_Type *vt = eolian_variable_base_type_get(vr);
|
||||||
Eina_Stringshare *ct = eolian_type_c_type_get(vt);
|
Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
|
||||||
eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn);
|
eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn);
|
||||||
eina_stringshare_del(ct);
|
eina_stringshare_del(ct);
|
||||||
free(fn);
|
free(fn);
|
||||||
|
|
|
@ -234,6 +234,13 @@ typedef enum
|
||||||
EOLIAN_TYPE_UNDEFINED
|
EOLIAN_TYPE_UNDEFINED
|
||||||
} Eolian_Type_Type;
|
} Eolian_Type_Type;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
EOLIAN_C_TYPE_DEFAULT = 0,
|
||||||
|
EOLIAN_C_TYPE_PARAM,
|
||||||
|
EOLIAN_C_TYPE_RETURN
|
||||||
|
} Eolian_C_Type_Type;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EOLIAN_EXPR_UNKNOWN = 0,
|
EOLIAN_EXPR_UNKNOWN = 0,
|
||||||
|
@ -1883,6 +1890,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
|
||||||
* @brief Get the full C type name of the given type.
|
* @brief Get the full C type name of the given type.
|
||||||
*
|
*
|
||||||
* @param[in] tp the type.
|
* @param[in] tp the type.
|
||||||
|
* @param[in] ctype the context within which the C type string will be used.
|
||||||
* @return The C type name assuming @c tp is not NULL.
|
* @return The C type name assuming @c tp is not NULL.
|
||||||
*
|
*
|
||||||
* You're responsible for the stringshare.
|
* You're responsible for the stringshare.
|
||||||
|
@ -1891,7 +1899,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
|
EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get the name of the given type. For regular or complex types, this
|
* @brief Get the name of the given type. For regular or complex types, this
|
||||||
|
|
|
@ -355,7 +355,7 @@ eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Stringshare *
|
EAPI Eina_Stringshare *
|
||||||
eolian_type_c_type_get(const Eolian_Type *tp)
|
eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Eina_Stringshare *ret;
|
Eina_Stringshare *ret;
|
||||||
Eina_Strbuf *buf;
|
Eina_Strbuf *buf;
|
||||||
|
|
Loading…
Reference in New Issue