forked from enlightenment/efl
eolian: new API: eolian_type_struct_description_get
This commit is contained in:
parent
295f1f4847
commit
881a8754ab
|
@ -794,6 +794,16 @@ EAPI Eolian_Type eolian_type_struct_field_get(Eolian_Type tp, const char *field)
|
|||
*/
|
||||
EAPI const char *eolian_type_struct_field_description_get(Eolian_Type tp, const char *field);
|
||||
|
||||
/*
|
||||
* @brief Get the description of a struct type.
|
||||
*
|
||||
* @param[in] tp the type.
|
||||
* @return the description when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const char *eolian_type_struct_description_get(Eolian_Type tp);
|
||||
|
||||
/*
|
||||
* @brief Get the return type of a function type.
|
||||
*
|
||||
|
|
|
@ -20,7 +20,10 @@ struct _eo_type_def
|
|||
Eina_List *arguments;
|
||||
Eo_Type_Def *ret_type;
|
||||
};
|
||||
Eina_Hash *fields;
|
||||
struct {
|
||||
Eina_Hash *fields;
|
||||
const char *comment;
|
||||
};
|
||||
};
|
||||
Eina_Bool is_const :1;
|
||||
Eina_Bool is_own :1;
|
||||
|
|
|
@ -231,6 +231,11 @@ parse_struct(Eo_Lexer *ls, const char *name)
|
|||
def->type = EOLIAN_TYPE_STRUCT;
|
||||
def->fields = eina_hash_string_small_new(EINA_FREE_CB(eo_definitions_struct_field_free));
|
||||
check_next(ls, '{');
|
||||
if (ls->t.token == TOK_COMMENT)
|
||||
{
|
||||
def->comment = eina_stringshare_add(ls->t.value);
|
||||
eo_lexer_get(ls);
|
||||
}
|
||||
while (ls->t.token != '}')
|
||||
{
|
||||
const char *fname;
|
||||
|
|
|
@ -97,7 +97,10 @@ typedef struct
|
|||
Eina_List *arguments;
|
||||
Eolian_Type ret_type;
|
||||
};
|
||||
Eina_Hash *fields;
|
||||
struct {
|
||||
Eina_Hash *fields;
|
||||
const char *comment;
|
||||
};
|
||||
};
|
||||
Eina_Bool is_const :1;
|
||||
Eina_Bool is_own :1;
|
||||
|
@ -1186,10 +1189,8 @@ EAPI Eina_Iterator *
|
|||
eolian_type_struct_field_names_list_get(Eolian_Type tp)
|
||||
{
|
||||
_Parameter_Type *tpp = (_Parameter_Type*)tp;
|
||||
Eolian_Type_Type tpt;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
tpt = tpp->type;
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
|
||||
return eina_hash_iterator_key_new(tpp->fields);
|
||||
}
|
||||
|
||||
|
@ -1198,11 +1199,9 @@ eolian_type_struct_field_get(Eolian_Type tp, const char *field)
|
|||
{
|
||||
_Parameter_Type *tpp = (_Parameter_Type*)tp;
|
||||
_Struct_Field_Type *sf = NULL;
|
||||
Eolian_Type_Type tpt;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
|
||||
tpt = tpp->type;
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
|
||||
sf = eina_hash_find(tpp->fields, field);
|
||||
if (!sf) return NULL;
|
||||
return sf->type;
|
||||
|
@ -1213,16 +1212,23 @@ eolian_type_struct_field_description_get(Eolian_Type tp, const char *field)
|
|||
{
|
||||
_Parameter_Type *tpp = (_Parameter_Type*)tp;
|
||||
_Struct_Field_Type *sf = NULL;
|
||||
Eolian_Type_Type tpt;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
|
||||
tpt = tpp->type;
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_STRUCT, NULL);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
|
||||
sf = eina_hash_find(tpp->fields, field);
|
||||
if (!sf) return NULL;
|
||||
return sf->comment;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
eolian_type_struct_description_get(Eolian_Type tp)
|
||||
{
|
||||
_Parameter_Type *tpp = (_Parameter_Type*)tp;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL);
|
||||
return tpp->comment;
|
||||
}
|
||||
|
||||
EAPI Eolian_Type
|
||||
eolian_type_return_type_get(Eolian_Type tp)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue