This will allow proper handling of const.
if (rt)
{
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);
eina_stringshare_del(rts);
}
eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
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);
if (rtps[strlen(rtps) - 1] != '*')
eina_strbuf_append_char(buf, ' ');
{
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);
+ Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
++nidx;
if (!first)
eina_strbuf_append(buf, ", ");
const Eolian_Type *prt = eolian_parameter_type_get(pr);
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
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)
{
free(sn);
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, '*'))
{
eina_strbuf_append(buf, "NULL");
{
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);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
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);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
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)
+ Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)
: eina_stringshare_add("void");
char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
{
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);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
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);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
{
eina_strbuf_append(buf, "EOLIAN static ");
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_stringshare_del(rtpn);
}
Eina_Stringshare *ct = NULL;
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];",
ct, strchr(ct, '*') ? "" : " ",
eolian_typedecl_struct_field_name_get(memb),
}
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;",
ct, strchr(ct, '*') ? "" : " ",
eolian_typedecl_struct_field_name_get(memb));
eina_strbuf_append(buf, "void ");
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);
}
{
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_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)
pn = ""; // FIXME add some kind of param1/param2 control for null?
}
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_stringshare_del(ct);
}
eina_str_toupper(&fn);
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_stringshare_del(ct);
free(fn);
typedef enum
{
+ EOLIAN_C_TYPE_DEFAULT = 0,
+ EOLIAN_C_TYPE_PARAM,
+ EOLIAN_C_TYPE_RETURN
+} Eolian_C_Type_Type;
+
+typedef enum
+{
EOLIAN_EXPR_UNKNOWN = 0,
EOLIAN_EXPR_INT,
EOLIAN_EXPR_UINT,
* @brief Get the full C type name of the given 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.
*
* You're responsible for the stringshare.
*
* @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
}
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_Strbuf *buf;