forked from enlightenment/efl
eolian: add eolian_type_aliased_base_get
This adds a new API function that is there mainly for convenience (see doc). Also added/updated tests as necessary. @feature
This commit is contained in:
parent
3da89206bf
commit
e089908545
|
@ -1495,6 +1495,23 @@ EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
|
||||||
*/
|
*/
|
||||||
EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
|
EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get the lowest base type of an alias stack.
|
||||||
|
*
|
||||||
|
* If the given type is an alias, it returns the result of a recursive call
|
||||||
|
* to this function on its base type. If it's a regular type, it first tries
|
||||||
|
* to retrieve its base using eolian_type_base_type_get and if the retrieved
|
||||||
|
* base is an alias, returns a recursive call of this function on it. Otherwise
|
||||||
|
* it returns the given type. This is useful in order to retrieve what an
|
||||||
|
* aliased type actually is while still having convenience.
|
||||||
|
*
|
||||||
|
* @param[in] tp the type.
|
||||||
|
* @return the lowest alias base or the given type.
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get the class associated with an EOLIAN_TYPE_CLASS type.
|
* @brief Get the class associated with an EOLIAN_TYPE_CLASS type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -251,6 +251,23 @@ eolian_type_base_type_get(const Eolian_Type *tp)
|
||||||
return tp->base_type;
|
return tp->base_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI const Eolian_Type *
|
||||||
|
eolian_type_aliased_base_get(const Eolian_Type *tp)
|
||||||
|
{
|
||||||
|
if (!tp)
|
||||||
|
return NULL;
|
||||||
|
if (eolian_type_type_get(tp) == EOLIAN_TYPE_REGULAR)
|
||||||
|
{
|
||||||
|
const Eolian_Type *btp = eolian_type_base_type_get(tp);
|
||||||
|
if (btp && (eolian_type_type_get(btp) == EOLIAN_TYPE_ALIAS))
|
||||||
|
return eolian_type_aliased_base_get(btp);
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
else if (eolian_type_type_get(tp) != EOLIAN_TYPE_ALIAS)
|
||||||
|
return tp;
|
||||||
|
return eolian_type_aliased_base_get(tp->base_type);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI const Eolian_Class *
|
EAPI const Eolian_Class *
|
||||||
eolian_type_class_get(const Eolian_Type *tp)
|
eolian_type_class_get(const Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
type Evas.Coord: int; /* Simple type definition */
|
type Evas.Coord: int; /* Simple type definition */
|
||||||
type List_Objects: own(list<Eo *>*); /* A little more complex */
|
type List_Objects: own(list<Eo *>*); /* A little more complex */
|
||||||
|
|
||||||
|
type Evas.Coord2: Evas.Coord;
|
||||||
|
type Evas.Coord3: Evas.Coord2;
|
||||||
|
|
||||||
type @extern Evas.Pants: float; /* not generated */
|
type @extern Evas.Pants: float; /* not generated */
|
||||||
|
|
||||||
type Undef: __undefined_type; /* not generated */
|
type Undef: __undefined_type; /* not generated */
|
||||||
|
|
|
@ -15,6 +15,10 @@ typedef int Evas_Coord;
|
||||||
|
|
||||||
typedef Eina_List *List_Objects;
|
typedef Eina_List *List_Objects;
|
||||||
|
|
||||||
|
typedef Evas_Coord Evas_Coord2;
|
||||||
|
|
||||||
|
typedef Evas_Coord2 Evas_Coord3;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
BAR_FIRST_ITEM = 0,
|
BAR_FIRST_ITEM = 0,
|
||||||
|
|
|
@ -369,6 +369,11 @@ START_TEST(eolian_typedef)
|
||||||
fail_if(!(file = eolian_type_file_get(atype)));
|
fail_if(!(file = eolian_type_file_get(atype)));
|
||||||
fail_if(strcmp(file, "typedef.eo"));
|
fail_if(strcmp(file, "typedef.eo"));
|
||||||
|
|
||||||
|
/* Lowest alias base */
|
||||||
|
fail_if(!(atype = eolian_type_alias_get_by_name("Evas.Coord3")));
|
||||||
|
fail_if(!(atype = eolian_type_aliased_base_get(atype)));
|
||||||
|
fail_if(strcmp(eolian_type_name_get(atype), "int"));
|
||||||
|
|
||||||
/* Complex type */
|
/* Complex type */
|
||||||
fail_if(!(atype = eolian_type_alias_get_by_name("List_Objects")));
|
fail_if(!(atype = eolian_type_alias_get_by_name("List_Objects")));
|
||||||
fail_if(!(type_name = eolian_type_name_get(atype)));
|
fail_if(!(type_name = eolian_type_name_get(atype)));
|
||||||
|
@ -395,6 +400,9 @@ START_TEST(eolian_typedef)
|
||||||
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
||||||
fail_if(!(type_name = eolian_type_name_get(atype)));
|
fail_if(!(type_name = eolian_type_name_get(atype)));
|
||||||
fail_if(strcmp(type_name, "List_Objects"));
|
fail_if(strcmp(type_name, "List_Objects"));
|
||||||
|
/* coord2 and coord3, skip */
|
||||||
|
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
||||||
|
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
||||||
/* not generated extern, skip */
|
/* not generated extern, skip */
|
||||||
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
fail_if(!eina_iterator_next(iter, (void**)&atype));
|
||||||
/* not generated undefined type, skip */
|
/* not generated undefined type, skip */
|
||||||
|
|
Loading…
Reference in New Issue