forked from enlightenment/efl
eolian: include terminatable checks in ownable check
This commit is contained in:
parent
8ff2bf35fe
commit
59347d4c4b
|
@ -80,13 +80,16 @@ static const Eina_Bool _ownable_types[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
database_type_is_ownable(const Eolian_Type *tp)
|
database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term)
|
||||||
{
|
{
|
||||||
if (tp->is_ptr)
|
if (tp->is_ptr)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
if (tp->type == EOLIAN_TYPE_REGULAR)
|
if (tp->type == EOLIAN_TYPE_REGULAR)
|
||||||
{
|
{
|
||||||
int kwid = eo_lexer_keyword_str_to_id(tp->name);
|
int kwid = eo_lexer_keyword_str_to_id(tp->name);
|
||||||
|
/* don't include bool, it only has 2 values so it's useless */
|
||||||
|
if (term && (kwid >= KW_byte && kwid < KW_bool))
|
||||||
|
return EINA_TRUE;
|
||||||
const char *ct = eo_lexer_get_c_type(kwid);
|
const char *ct = eo_lexer_get_c_type(kwid);
|
||||||
if (!ct)
|
if (!ct)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
@ -117,7 +120,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
|
||||||
if ((tp->type == EOLIAN_TYPE_REGULAR
|
if ((tp->type == EOLIAN_TYPE_REGULAR
|
||||||
|| tp->type == EOLIAN_TYPE_VOID)
|
|| tp->type == EOLIAN_TYPE_VOID)
|
||||||
&& tp->is_const
|
&& tp->is_const
|
||||||
&& ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp)))
|
&& ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp, EINA_FALSE)))
|
||||||
{
|
{
|
||||||
eina_strbuf_append(buf, "const ");
|
eina_strbuf_append(buf, "const ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,26 +131,12 @@ _validate_typedecl(Eolian_Typedecl *tp)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_type_is_terminatable(const Eolian_Type *tp)
|
|
||||||
{
|
|
||||||
if (database_type_is_ownable(tp))
|
|
||||||
return EINA_TRUE;
|
|
||||||
if (tp->type == EOLIAN_TYPE_REGULAR)
|
|
||||||
{
|
|
||||||
int kwid = eo_lexer_keyword_str_to_id(tp->name);
|
|
||||||
/* don't include bool, it only has 2 values so it's useless */
|
|
||||||
return (kwid >= KW_byte && kwid < KW_bool);
|
|
||||||
}
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_validate_type(Eolian_Type *tp)
|
_validate_type(Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp))
|
if ((tp->is_own || tp->freefunc) && !database_type_is_ownable(tp, EINA_FALSE))
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
|
snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
|
||||||
return _type_error(tp, buf);
|
return _type_error(tp, buf);
|
||||||
|
@ -183,7 +169,7 @@ _validate_type(Eolian_Type *tp)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
||||||
if (!_type_is_terminatable(tp->base_type))
|
if (!database_type_is_ownable(tp->base_type, EINA_TRUE))
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf),
|
snprintf(buf, sizeof(buf),
|
||||||
"invalid base type '%s' for terminated array",
|
"invalid base type '%s' for terminated array",
|
||||||
|
|
|
@ -314,7 +314,7 @@ 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);
|
||||||
void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
|
void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
|
||||||
|
|
||||||
Eina_Bool database_type_is_ownable(const Eolian_Type *tp);
|
Eina_Bool database_type_is_ownable(const Eolian_Type *tp, Eina_Bool term);
|
||||||
|
|
||||||
/* expressions */
|
/* expressions */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue