eolian: add API to expose the new @move and @by_ref tags

This commit is contained in:
Daniel Kolesa 2019-08-30 17:04:44 +02:00
parent fbcad90fec
commit 7dc7cbf076
4 changed files with 152 additions and 0 deletions

View File

@ -1883,6 +1883,26 @@ EAPI const Eolian_Documentation *eolian_parameter_documentation_get(const Eolian
*/
EAPI Eina_Bool eolian_parameter_is_optional(const Eolian_Function_Parameter *param_desc);
/*
* @brief Get whether a parameter is by reference.
*
* @param[in] param_desc parameter handle
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_parameter_is_by_ref(const Eolian_Function_Parameter *param_desc);
/*
* @brief Get whether a parameter is moved into the callee.
*
* @param[in] param_desc parameter handle
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_parameter_is_move(const Eolian_Function_Parameter *param_desc);
/*
* @brief Get the return type of a function.
*
@ -1949,6 +1969,38 @@ EAPI const Eolian_Documentation *eolian_function_return_documentation_get(const
*/
EAPI Eina_Bool eolian_function_return_allow_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
/*
* @brief Get whether a parameter is by reference.
*
* @param[in] function_id id of the function
* @param[in] ftype type of the function
* @return EINA_TRUE and EINA_FALSE respectively
*
* The type of the function is needed because a given function can represent a
* property, that can be set and get functions.
*
* Acceptable input types are METHOD, PROP_GET and PROP_SET.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_return_is_by_ref(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
/*
* @brief Get whether a parameter is moved into the callee.
*
* @param[in] function_id id of the function
* @param[in] ftype type of the function
* @return EINA_TRUE and EINA_FALSE respectively
*
* The type of the function is needed because a given function can represent a
* property, that can be set and get functions.
*
* Acceptable input types are METHOD, PROP_GET and PROP_SET.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_return_is_move(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
/*
* @brief Indicates if a function object is const.
*
@ -2502,6 +2554,26 @@ EAPI const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(
*/
EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get whether a struct field is by reference.
*
* @param[in] fl the field.
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_typedecl_struct_field_is_by_ref(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get whether a struct field is moved with the struct.
*
* @param[in] fl the field.
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_typedecl_struct_field_is_move(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get an iterator to all fields of an enum type.
*

View File

@ -286,6 +286,58 @@ eolian_function_return_allow_unused(const Eolian_Function *fid,
}
}
EAPI Eina_Bool
eolian_function_return_is_by_ref(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);
switch (ftype)
{
case EOLIAN_METHOD:
if (fid->type != EOLIAN_METHOD)
return EINA_FALSE;
return fid->get_return_by_ref;
case EOLIAN_PROP_GET:
if ((fid->type != EOLIAN_PROP_GET) && (fid->type != EOLIAN_PROPERTY))
return EINA_FALSE;
return !fid->get_return_by_ref;
case EOLIAN_PROP_SET:
if ((fid->type != EOLIAN_PROP_SET) && (fid->type != EOLIAN_PROPERTY))
return EINA_FALSE;
return !fid->set_return_by_ref;
default:
return EINA_FALSE;
}
}
EAPI Eina_Bool
eolian_function_return_is_move(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);
switch (ftype)
{
case EOLIAN_METHOD:
if (fid->type != EOLIAN_METHOD)
return EINA_FALSE;
return fid->get_return_move;
case EOLIAN_PROP_GET:
if ((fid->type != EOLIAN_PROP_GET) && (fid->type != EOLIAN_PROPERTY))
return EINA_FALSE;
return !fid->get_return_move;
case EOLIAN_PROP_SET:
if ((fid->type != EOLIAN_PROP_SET) && (fid->type != EOLIAN_PROPERTY))
return EINA_FALSE;
return !fid->set_return_move;
default:
return EINA_FALSE;
}
}
EAPI Eina_Bool
eolian_function_object_is_const(const Eolian_Function *fid)
{

View File

@ -39,3 +39,17 @@ eolian_parameter_is_optional(const Eolian_Function_Parameter *param)
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
return param->optional;
}
EAPI Eina_Bool
eolian_parameter_is_move(const Eolian_Function_Parameter *param)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
return param->move;
}
EAPI Eina_Bool
eolian_parameter_is_by_ref(const Eolian_Function_Parameter *param)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
return param->by_ref;
}

View File

@ -63,6 +63,20 @@ eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl)
return fl->type;
}
EAPI Eina_Bool
eolian_typedecl_struct_field_is_by_ref(const Eolian_Struct_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, EINA_FALSE);
return fl->by_ref;
}
EAPI Eina_Bool
eolian_typedecl_struct_field_is_move(const Eolian_Struct_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, EINA_FALSE);
return fl->move;
}
EAPI Eina_Iterator *
eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
{