forked from enlightenment/efl
eolian: remove most of the old type APIs
This commit is contained in:
parent
863212f84a
commit
4c4fbfae0b
|
@ -1487,7 +1487,6 @@ EAPI const Eolian_Expression *eolian_typedecl_enum_field_value_get(const Eolian_
|
|||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Stringshare *eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp);
|
||||
EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
|
||||
|
||||
/*
|
||||
|
@ -1499,7 +1498,6 @@ EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typed
|
|||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const Eolian_Documentation *eolian_type_documentation_get(const Eolian_Type *tp);
|
||||
EAPI const Eolian_Documentation *eolian_typedecl_documentation_get(const Eolian_Typedecl *tp);
|
||||
|
||||
/*
|
||||
|
@ -1586,7 +1584,6 @@ EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
|||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_type_is_extern(const Eolian_Type *tp);
|
||||
EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
|
||||
|
||||
/*
|
||||
|
|
|
@ -23,8 +23,6 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
|
|||
return err;
|
||||
switch (type->type)
|
||||
{
|
||||
case EOLIAN_TYPE_ALIAS:
|
||||
return _eval_type(expr, eolian_type_base_type_get(type));
|
||||
case EOLIAN_TYPE_POINTER:
|
||||
{
|
||||
int mask = EOLIAN_MASK_NULL;
|
||||
|
@ -36,15 +34,18 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
|
|||
}
|
||||
case EOLIAN_TYPE_CLASS:
|
||||
return database_expr_eval(expr, EOLIAN_MASK_NULL);
|
||||
case EOLIAN_TYPE_ENUM:
|
||||
return database_expr_eval(expr, EOLIAN_MASK_INT);
|
||||
case EOLIAN_TYPE_REGULAR:
|
||||
{
|
||||
int kw = eo_lexer_keyword_str_to_id(type->name);
|
||||
if (!kw || kw < KW_byte || kw >= KW_void)
|
||||
{
|
||||
const Eolian_Type *base = eolian_type_base_type_get(type);
|
||||
if (base) return _eval_type(expr, base);
|
||||
const Eolian_Typedecl *base = eolian_type_typedecl_get(type);
|
||||
if (!base)
|
||||
return err;
|
||||
if (base->type == EOLIAN_TYPEDECL_ALIAS)
|
||||
return _eval_type(expr, eolian_typedecl_base_type_get(base));
|
||||
else if (base->type == EOLIAN_TYPEDECL_ENUM)
|
||||
return database_expr_eval(expr, EOLIAN_MASK_INT);
|
||||
return err;
|
||||
}
|
||||
switch (kw)
|
||||
|
|
|
@ -207,15 +207,6 @@ eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool
|
|||
return fl->value;
|
||||
}
|
||||
|
||||
EAPI Eina_Stringshare *
|
||||
eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
if (tp->type != EOLIAN_TYPE_ENUM)
|
||||
return NULL;
|
||||
return tp->legacy;
|
||||
}
|
||||
|
||||
EAPI Eina_Stringshare *
|
||||
eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp)
|
||||
{
|
||||
|
@ -225,13 +216,6 @@ eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp)
|
|||
return tp->legacy;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Documentation *
|
||||
eolian_type_documentation_get(const Eolian_Type *tp)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
return tp->doc;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Documentation *
|
||||
eolian_typedecl_documentation_get(const Eolian_Typedecl *tp)
|
||||
{
|
||||
|
@ -256,28 +240,9 @@ eolian_typedecl_file_get(const Eolian_Typedecl *tp)
|
|||
EAPI const Eolian_Type *
|
||||
eolian_type_base_type_get(const Eolian_Type *tp)
|
||||
{
|
||||
Eolian_Type_Type tpt;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
tpt = eolian_type_type_get(tp);
|
||||
if ((tpt != EOLIAN_TYPE_POINTER) && (tpt != EOLIAN_TYPE_ALIAS) &&
|
||||
(tpt != EOLIAN_TYPE_REGULAR))
|
||||
if (tp->type != EOLIAN_TYPE_POINTER)
|
||||
return NULL;
|
||||
if (tpt == EOLIAN_TYPE_REGULAR)
|
||||
{
|
||||
/* for regular types, try looking up if it belongs to a struct,
|
||||
* enum or an alias... otherwise return NULL
|
||||
* but first check for builtins
|
||||
*/
|
||||
int kw = eo_lexer_keyword_str_to_id(tp->full_name);
|
||||
if (!kw || kw < KW_byte || kw >= KW_true)
|
||||
{
|
||||
Eolian_Declaration *decl = eina_hash_find(_decls, tp->full_name);
|
||||
if (decl && decl->type != EOLIAN_DECL_CLASS
|
||||
&& decl->type != EOLIAN_DECL_VAR)
|
||||
return ((const Eolian_Typedecl *)decl->data)->parent;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return tp->base_type;
|
||||
}
|
||||
|
||||
|
@ -304,10 +269,8 @@ eolian_type_typedecl_get(const Eolian_Type *tp)
|
|||
EAPI const Eolian_Type *
|
||||
eolian_typedecl_base_type_get(const Eolian_Typedecl *tp)
|
||||
{
|
||||
Eolian_Typedecl_Type tpt;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
|
||||
tpt = eolian_typedecl_type_get(tp);
|
||||
if (tpt != EOLIAN_TYPEDECL_ALIAS)
|
||||
if (tp->type != EOLIAN_TYPEDECL_ALIAS)
|
||||
return NULL;
|
||||
return tp->base_type;
|
||||
}
|
||||
|
@ -315,18 +278,12 @@ eolian_typedecl_base_type_get(const Eolian_Typedecl *tp)
|
|||
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);
|
||||
if (!tp || tp->type != EOLIAN_TYPE_REGULAR)
|
||||
return tp;
|
||||
}
|
||||
else if (eolian_type_type_get(tp) != EOLIAN_TYPE_ALIAS)
|
||||
const Eolian_Typedecl *btp = eolian_type_typedecl_get(tp);
|
||||
if (btp && (btp->type == EOLIAN_TYPEDECL_ALIAS))
|
||||
return eolian_typedecl_aliased_base_get(btp);
|
||||
return tp;
|
||||
return eolian_type_aliased_base_get(tp->base_type);
|
||||
}
|
||||
|
||||
EAPI const Eolian_Type *
|
||||
|
@ -360,13 +317,6 @@ eolian_type_is_const(const Eolian_Type *tp)
|
|||
return tp->is_const;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_type_is_extern(const Eolian_Type *tp)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE);
|
||||
return tp->is_extern;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
|
||||
{
|
||||
|
|
|
@ -189,11 +189,42 @@ _type_error(const Validator *vs, const Eolian_Type *tp, const char *msg)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_type(const Validator *vs, const Eolian_Type *tp)
|
||||
_validate_typedecl(const Validator *vs, const Eolian_Typedecl *tp)
|
||||
{
|
||||
if (!_validate_doc(vs, tp->doc))
|
||||
return EINA_FALSE;
|
||||
|
||||
switch (tp->type)
|
||||
{
|
||||
case EOLIAN_TYPEDECL_ALIAS:
|
||||
return _validate_type(vs, tp->base_type);
|
||||
case EOLIAN_TYPEDECL_STRUCT:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
|
||||
return succ.success;
|
||||
}
|
||||
case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
|
||||
return EINA_TRUE;
|
||||
case EOLIAN_TYPEDECL_ENUM:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
|
||||
return succ.success;
|
||||
}
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_validate_type(const Validator *vs, const Eolian_Type *tp)
|
||||
{
|
||||
switch (tp->type)
|
||||
{
|
||||
case EOLIAN_TYPE_VOID:
|
||||
|
@ -202,42 +233,23 @@ _validate_type(const Validator *vs, const Eolian_Type *tp)
|
|||
return EINA_TRUE;
|
||||
case EOLIAN_TYPE_REGULAR:
|
||||
{
|
||||
const Eolian_Type *tpp;
|
||||
const Eolian_Typedecl *tpp;
|
||||
/* builtins */
|
||||
int id = eo_lexer_keyword_str_to_id(tp->full_name);
|
||||
if (id)
|
||||
return eo_lexer_is_type_keyword(id);
|
||||
/* user defined */
|
||||
tpp = eolian_type_base_type_get(tp);
|
||||
tpp = eolian_type_typedecl_get(tp);
|
||||
if (!tpp)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
|
||||
return _type_error(vs, tp, buf);
|
||||
}
|
||||
return _validate_type(vs, tpp);
|
||||
return _validate_typedecl(vs, tpp);
|
||||
}
|
||||
case EOLIAN_TYPE_POINTER:
|
||||
case EOLIAN_TYPE_ALIAS:
|
||||
return _validate_type(vs, tp->base_type);
|
||||
case EOLIAN_TYPE_STRUCT:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
|
||||
return succ.success;
|
||||
}
|
||||
case EOLIAN_TYPE_STRUCT_OPAQUE:
|
||||
return EINA_TRUE;
|
||||
case EOLIAN_TYPE_ENUM:
|
||||
{
|
||||
Val_Success succ;
|
||||
succ.vs = vs;
|
||||
succ.success = EINA_TRUE;
|
||||
eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
|
||||
return succ.success;
|
||||
}
|
||||
case EOLIAN_TYPE_CLASS:
|
||||
{
|
||||
if (!eolian_type_class_get(tp))
|
||||
|
@ -391,7 +403,7 @@ static Eina_Bool
|
|||
_type_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||
const Eolian_Type *tp, Val_Success *sc)
|
||||
{
|
||||
sc->success = _validate_type(sc->vs, tp);
|
||||
sc->success = _validate_typedecl(sc->vs, tp->decl);
|
||||
return sc->success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue