EAPI Eina_Bool eolian_parameter_is_move(const Eolian_Function_Parameter *param_desc);
/*
+ * @brief Get the full C type name of the given parameter.
+ *
+ * @param[in] param_desc parameter handle
+ * @param[in] as_return if true, it will be treated as a return type
+ * @return The C type name assuming @c param_desc is not NULL.
+ *
+ * You're responsible for the stringshare. The @c as_return argument is meant
+ * for properties, where the first out-param gets made into a return, which
+ * has different typing characteristics.
+ *
+ * @see eolian_type_c_type_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_parameter_c_type_get(const Eolian_Function_Parameter *param_desc, Eina_Bool as_return);
+
+/*
* @brief Get the return type of a function.
*
* @param[in] function_id id of the function
EAPI Eina_Bool eolian_function_return_is_move(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
/*
+ * @brief Get the full C type name of the return value.
+ *
+ * @param[in] function_id id of the function
+ * @param[in] ftype type of the function
+ * @return The C type name.
+ *
+ * You're responsible for the stringshare.
+ *
+ * @see eolian_type_c_type_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_function_return_c_type_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
+
+/*
* @brief Indicates if a function object is const.
*
* @param[in] function_id id of the function
EAPI Eina_Bool eolian_typedecl_struct_field_is_move(const Eolian_Struct_Type_Field *fl);
/*
+ * @brief Get the full C type name of the struct field.
+ *
+ * @param[in] fl the field.
+ * @return The C type name.
+ *
+ * You're responsible for the stringshare.
+ *
+ * @see eolian_type_c_type_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_struct_field_c_type_get(const Eolian_Struct_Type_Field *fl);
+
+/*
* @brief Get an iterator to all fields of an enum type.
*
* @param[in] tp the type declaration.
}
}
+EAPI Eina_Stringshare *
+eolian_function_return_c_type_get(const Eolian_Function *fid,
+ Eolian_Function_Type ftype)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(ftype != EOLIAN_UNRESOLVED, EINA_FALSE);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(ftype != EOLIAN_PROPERTY, EINA_FALSE);
+ const Eolian_Type *tp = NULL;
+ Eina_Bool by_ref = EINA_FALSE;
+ switch (ftype)
+ {
+ case EOLIAN_METHOD:
+ case EOLIAN_FUNCTION_POINTER:
+ if (fid->type != ftype)
+ return NULL;
+ tp = fid->get_ret_type;
+ by_ref = fid->get_return_by_ref;
+ break;
+ case EOLIAN_PROP_GET:
+ if ((fid->type != EOLIAN_PROP_GET) && (fid->type != EOLIAN_PROPERTY))
+ return NULL;
+ tp = fid->get_ret_type;
+ by_ref = fid->get_return_by_ref;
+ break;
+ case EOLIAN_PROP_SET:
+ if ((fid->type != EOLIAN_PROP_SET) && (fid->type != EOLIAN_PROPERTY))
+ return NULL;
+ tp = fid->set_ret_type;
+ by_ref = fid->set_return_by_ref;
+ break;
+ default:
+ return NULL;
+ }
+ Eina_Strbuf *buf = eina_strbuf_new();
+ database_type_to_str(tp, buf, NULL, EOLIAN_C_TYPE_RETURN, by_ref);
+ Eina_Stringshare *ret = eina_stringshare_add(eina_strbuf_string_get(buf));
+ eina_strbuf_free(buf);
+ return ret;
+}
+
EAPI Eina_Bool
eolian_function_object_is_const(const Eolian_Function *fid)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
return param->by_ref;
}
+
+EAPI Eina_Stringshare *
+eolian_parameter_c_type_get(const Eolian_Function_Parameter *param_desc,
+ Eina_Bool as_return)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(param_desc, NULL);
+ Eina_Strbuf *buf = eina_strbuf_new();
+ database_type_to_str(param_desc->type, buf, NULL,
+ as_return ? EOLIAN_C_TYPE_RETURN : EOLIAN_C_TYPE_PARAM,
+ param_desc->by_ref);
+ Eina_Stringshare *ret = eina_stringshare_add(eina_strbuf_string_get(buf));
+ eina_strbuf_free(buf);
+ return ret;
+}
\ No newline at end of file
void
database_type_to_str(const Eolian_Type *tp,
Eina_Strbuf *buf, const char *name,
- Eolian_C_Type_Type ctype)
+ Eolian_C_Type_Type ctype, Eina_Bool by_ref)
{
if ((tp->type == EOLIAN_TYPE_REGULAR
|| tp->type == EOLIAN_TYPE_CLASS
{
/* handles arrays and pointers as they all serialize to pointers */
database_type_to_str(tp->base_type, buf, NULL,
- EOLIAN_C_TYPE_DEFAULT);
+ EOLIAN_C_TYPE_DEFAULT, EINA_FALSE);
_buf_add_suffix(buf, "*");
if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN))
eina_strbuf_append(buf, " const");
_buf_add_suffix(buf, "*");
if (tp->is_ptr)
_buf_add_suffix(buf, "*");
+ if (by_ref)
+ _buf_add_suffix(buf, "*");
_buf_add_suffix(buf, name);
}
EINA_LIST_FOREACH(tp->field_list, l, sf)
{
database_type_to_str(sf->type, buf, sf->base.name,
- EOLIAN_C_TYPE_DEFAULT);
+ EOLIAN_C_TYPE_DEFAULT, sf->by_ref);
eina_strbuf_append(buf, "; ");
}
eina_strbuf_append(buf, "}");
{
eina_strbuf_append(buf, "typedef ");
database_type_to_str(tp->base_type, buf, tp->base.c_name,
- EOLIAN_C_TYPE_DEFAULT);
+ EOLIAN_C_TYPE_DEFAULT, EINA_FALSE);
}
void
return fl->move;
}
+EAPI Eina_Stringshare *
+eolian_typedecl_struct_field_c_type_get(const Eolian_Struct_Type_Field *fl)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
+ Eina_Strbuf *buf = eina_strbuf_new();
+ database_type_to_str(fl->type, buf, NULL, EOLIAN_C_TYPE_DEFAULT, fl->by_ref);
+ Eina_Stringshare *ret = eina_stringshare_add(eina_strbuf_string_get(buf));
+ eina_strbuf_free(buf);
+ return ret;
+}
+
EAPI Eina_Iterator *
eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
{
Eina_Strbuf *buf;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
buf = eina_strbuf_new();
- database_type_to_str(tp, buf, NULL, ctype);
+ database_type_to_str(tp, buf, NULL, ctype, EINA_FALSE);
ret = eina_stringshare_add(eina_strbuf_string_get(buf));
eina_strbuf_free(buf);
return ret;
void database_type_del(Eolian_Type *tp);
void database_typedecl_del(Eolian_Typedecl *tp);
-void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
+void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype, Eina_Bool by_ref);
void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp);