forked from enlightenment/efl
eolian: remove static_array and terminated_array
These types are of questionable value and the API was not entirely thought out - remove for now, and if a legitimate use is found later, they may be readded (with a better API), but typically it seems best to redesign the bad APIs around safe containers...
This commit is contained in:
parent
4bae2a7385
commit
1577c576e6
|
@ -41,22 +41,10 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
|
||||||
{
|
{
|
||||||
const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb);
|
const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb);
|
||||||
Eina_Stringshare *ct = NULL;
|
Eina_Stringshare *ct = NULL;
|
||||||
if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
|
ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
|
||||||
{
|
eina_strbuf_append_printf(buf, " %s%s%s;",
|
||||||
ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp),
|
ct, strchr(ct, '*') ? "" : " ",
|
||||||
EOLIAN_C_TYPE_DEFAULT);
|
eolian_typedecl_struct_field_name_get(memb));
|
||||||
eina_strbuf_append_printf(buf, " %s%s%s[%zu];",
|
|
||||||
ct, strchr(ct, '*') ? "" : " ",
|
|
||||||
eolian_typedecl_struct_field_name_get(memb),
|
|
||||||
eolian_type_array_size_get(mtp));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
|
|
||||||
eina_strbuf_append_printf(buf, " %s%s%s;",
|
|
||||||
ct, strchr(ct, '*') ? "" : " ",
|
|
||||||
eolian_typedecl_struct_field_name_get(memb));
|
|
||||||
}
|
|
||||||
eina_stringshare_del(ct);
|
eina_stringshare_del(ct);
|
||||||
const Eolian_Documentation *fdoc
|
const Eolian_Documentation *fdoc
|
||||||
= eolian_typedecl_struct_field_documentation_get(memb);
|
= eolian_typedecl_struct_field_documentation_get(memb);
|
||||||
|
|
|
@ -80,8 +80,6 @@ ffi.cdef [[
|
||||||
EOLIAN_TYPE_VOID,
|
EOLIAN_TYPE_VOID,
|
||||||
EOLIAN_TYPE_REGULAR,
|
EOLIAN_TYPE_REGULAR,
|
||||||
EOLIAN_TYPE_CLASS,
|
EOLIAN_TYPE_CLASS,
|
||||||
EOLIAN_TYPE_STATIC_ARRAY,
|
|
||||||
EOLIAN_TYPE_TERMINATED_ARRAY,
|
|
||||||
EOLIAN_TYPE_UNDEFINED
|
EOLIAN_TYPE_UNDEFINED
|
||||||
} Eolian_Type_Type;
|
} Eolian_Type_Type;
|
||||||
|
|
||||||
|
@ -342,7 +340,6 @@ ffi.cdef [[
|
||||||
const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp);
|
const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp);
|
||||||
|
|
||||||
const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
|
const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
|
||||||
size_t eolian_type_array_size_get(const Eolian_Type *tp);
|
|
||||||
Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
|
Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
|
||||||
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
||||||
Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
|
Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
|
||||||
|
@ -504,9 +501,7 @@ M.type_type = {
|
||||||
VOID = 1,
|
VOID = 1,
|
||||||
REGULAR = 2,
|
REGULAR = 2,
|
||||||
CLASS = 3,
|
CLASS = 3,
|
||||||
STATIC_ARRAY = 4,
|
UNDEFINED = 4
|
||||||
TERMINATED_ARRAY = 5,
|
|
||||||
UNDEFINED = 6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
M.typedecl_type = {
|
M.typedecl_type = {
|
||||||
|
@ -715,10 +710,6 @@ M.Type = ffi.metatype("Eolian_Type", {
|
||||||
return v
|
return v
|
||||||
end,
|
end,
|
||||||
|
|
||||||
array_size_get = function(self)
|
|
||||||
return tonumber(eolian.eolian_type_array_size_get(self))
|
|
||||||
end,
|
|
||||||
|
|
||||||
is_owned = function(self)
|
is_owned = function(self)
|
||||||
return eolian.eolian_type_is_owned(self) ~= 0
|
return eolian.eolian_type_is_owned(self) ~= 0
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -228,8 +228,6 @@ typedef enum
|
||||||
EOLIAN_TYPE_VOID,
|
EOLIAN_TYPE_VOID,
|
||||||
EOLIAN_TYPE_REGULAR,
|
EOLIAN_TYPE_REGULAR,
|
||||||
EOLIAN_TYPE_CLASS,
|
EOLIAN_TYPE_CLASS,
|
||||||
EOLIAN_TYPE_STATIC_ARRAY,
|
|
||||||
EOLIAN_TYPE_TERMINATED_ARRAY,
|
|
||||||
EOLIAN_TYPE_UNDEFINED
|
EOLIAN_TYPE_UNDEFINED
|
||||||
} Eolian_Type_Type;
|
} Eolian_Type_Type;
|
||||||
|
|
||||||
|
@ -1824,16 +1822,6 @@ EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
|
||||||
*/
|
*/
|
||||||
EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
|
EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Get the size of an EOLIAN_TYPE_STATIC_ARRAY.
|
|
||||||
*
|
|
||||||
* @param[in] tp the type.
|
|
||||||
* @return the size or 0.
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI size_t eolian_type_array_size_get(const Eolian_Type *tp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get whether the given type is owned.
|
* @brief Get whether the given type is owned.
|
||||||
*
|
*
|
||||||
|
|
|
@ -319,13 +319,6 @@ eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp)
|
||||||
return eolian_class_get_by_name(unit, tp->full_name);
|
return eolian_class_get_by_name(unit, tp->full_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI size_t
|
|
||||||
eolian_type_array_size_get(const Eolian_Type *tp)
|
|
||||||
{
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, 0);
|
|
||||||
return tp->static_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eolian_type_is_owned(const Eolian_Type *tp)
|
eolian_type_is_owned(const Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -208,17 +208,6 @@ _validate_type(Eolian_Type *tp)
|
||||||
tp->freefunc = eina_stringshare_ref(tpp->freefunc);
|
tp->freefunc = eina_stringshare_ref(tpp->freefunc);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
|
||||||
if (!database_type_is_ownable(tp->base_type, EINA_TRUE))
|
|
||||||
{
|
|
||||||
snprintf(buf, sizeof(buf),
|
|
||||||
"invalid base type '%s' for terminated array",
|
|
||||||
tp->base_type->full_name);
|
|
||||||
return _type_error(tp, buf);
|
|
||||||
}
|
|
||||||
return _validate_type(tp->base_type);
|
|
||||||
case EOLIAN_TYPE_STATIC_ARRAY:
|
|
||||||
return _validate_type(tp->base_type);
|
|
||||||
case EOLIAN_TYPE_CLASS:
|
case EOLIAN_TYPE_CLASS:
|
||||||
{
|
{
|
||||||
/* FIXME: pass unit properly */
|
/* FIXME: pass unit properly */
|
||||||
|
|
|
@ -71,8 +71,6 @@ static const char * const ctypes[] =
|
||||||
|
|
||||||
"void",
|
"void",
|
||||||
|
|
||||||
NULL, NULL, /* array types */
|
|
||||||
|
|
||||||
"Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *",
|
"Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *",
|
||||||
"Eina_List *",
|
"Eina_List *",
|
||||||
"Efl_Future *",
|
"Efl_Future *",
|
||||||
|
|
|
@ -50,8 +50,6 @@ enum Tokens
|
||||||
\
|
\
|
||||||
KW(void), \
|
KW(void), \
|
||||||
\
|
\
|
||||||
KW(static_array), KW(terminated_array), \
|
|
||||||
\
|
|
||||||
KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \
|
KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \
|
||||||
KW(future), \
|
KW(future), \
|
||||||
KW(generic_value), \
|
KW(generic_value), \
|
||||||
|
|
|
@ -751,48 +751,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
|
||||||
def->type = EOLIAN_TYPE_UNDEFINED;
|
def->type = EOLIAN_TYPE_UNDEFINED;
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
}
|
}
|
||||||
else if (ls->t.kw == KW_static_array)
|
|
||||||
{
|
|
||||||
if (!allow_sarray)
|
|
||||||
eo_lexer_syntax_error(ls, "static arrays not allowed in this context");
|
|
||||||
def->type = EOLIAN_TYPE_STATIC_ARRAY;
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
check_next(ls, '<');
|
|
||||||
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
|
||||||
pop_type(ls);
|
|
||||||
check_next(ls, ',');
|
|
||||||
check(ls, TOK_NUMBER);
|
|
||||||
eo_lexer_context_push(ls);
|
|
||||||
if (ls->t.kw == NUM_FLOAT || ls->t.kw == NUM_DOUBLE)
|
|
||||||
{
|
|
||||||
eo_lexer_context_restore(ls);
|
|
||||||
eo_lexer_syntax_error(ls, "integer expected");
|
|
||||||
}
|
|
||||||
eo_lexer_context_pop(ls);
|
|
||||||
switch (ls->t.kw)
|
|
||||||
{
|
|
||||||
case NUM_INT : def->static_size = ls->t.value.i; break;
|
|
||||||
case NUM_UINT : def->static_size = ls->t.value.u; break;
|
|
||||||
case NUM_LONG : def->static_size = ls->t.value.l; break;
|
|
||||||
case NUM_ULONG : def->static_size = ls->t.value.ul; break;
|
|
||||||
case NUM_LLONG : def->static_size = ls->t.value.ll; break;
|
|
||||||
case NUM_ULLONG: def->static_size = ls->t.value.ull; break;
|
|
||||||
default:
|
|
||||||
eo_lexer_syntax_error(ls, "wrong type, internal error");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
check_next(ls, '>');
|
|
||||||
}
|
|
||||||
else if (ls->t.kw == KW_terminated_array)
|
|
||||||
{
|
|
||||||
def->type = EOLIAN_TYPE_TERMINATED_ARRAY;
|
|
||||||
eo_lexer_get(ls);
|
|
||||||
check_next(ls, '<');
|
|
||||||
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
|
||||||
pop_type(ls);
|
|
||||||
check_next(ls, '>');
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int tpid = ls->t.kw;
|
int tpid = ls->t.kw;
|
||||||
|
|
|
@ -162,7 +162,6 @@ struct _Eolian_Type
|
||||||
Eina_Stringshare *full_name;
|
Eina_Stringshare *full_name;
|
||||||
Eina_List *namespaces;
|
Eina_List *namespaces;
|
||||||
Eina_Stringshare *freefunc;
|
Eina_Stringshare *freefunc;
|
||||||
size_t static_size;
|
|
||||||
Eina_Bool is_const :1;
|
Eina_Bool is_const :1;
|
||||||
Eina_Bool is_ptr :1;
|
Eina_Bool is_ptr :1;
|
||||||
Eina_Bool owned :1;
|
Eina_Bool owned :1;
|
||||||
|
|
|
@ -667,8 +667,6 @@ M.Type = Node:clone {
|
||||||
VOID = eolian.type_type.VOID,
|
VOID = eolian.type_type.VOID,
|
||||||
REGULAR = eolian.type_type.REGULAR,
|
REGULAR = eolian.type_type.REGULAR,
|
||||||
CLASS = eolian.type_type.CLASS,
|
CLASS = eolian.type_type.CLASS,
|
||||||
STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
|
|
||||||
TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
|
|
||||||
UNDEFINED = eolian.type_type.UNDEFINED,
|
UNDEFINED = eolian.type_type.UNDEFINED,
|
||||||
|
|
||||||
__ctor = function(self, tp)
|
__ctor = function(self, tp)
|
||||||
|
@ -721,10 +719,6 @@ M.Type = Node:clone {
|
||||||
return self.type:class_get(nil)
|
return self.type:class_get(nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
array_size_get = function(self)
|
|
||||||
return self.type_array_size_get()
|
|
||||||
end,
|
|
||||||
|
|
||||||
is_owned = function(self)
|
is_owned = function(self)
|
||||||
return self.type:is_owned()
|
return self.type:is_owned()
|
||||||
end,
|
end,
|
||||||
|
@ -779,13 +773,6 @@ M.Type = Node:clone {
|
||||||
.. table.concat(stypes, ", ") .. ">")
|
.. table.concat(stypes, ", ") .. ">")
|
||||||
end
|
end
|
||||||
return wrap_type_attrs(self, self:full_name_get())
|
return wrap_type_attrs(self, self:full_name_get())
|
||||||
elseif tpt == self.STATIC_ARRAY then
|
|
||||||
return wrap_type_attrs(self, "static_array<"
|
|
||||||
.. self:base_type_get():serialize() .. ", "
|
|
||||||
.. self:array_size_get() .. ">")
|
|
||||||
elseif tpt == self.TERMINATED_ARRAY then
|
|
||||||
return wrap_type_attrs(self, "terminated_array<"
|
|
||||||
.. self:base_type_get():serialize() .. ">")
|
|
||||||
end
|
end
|
||||||
error("unhandled type type: " .. tpt)
|
error("unhandled type type: " .. tpt)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
struct Named {
|
struct Named {
|
||||||
field: ptr(int);
|
field: ptr(int);
|
||||||
something: string;
|
something: string;
|
||||||
arr: static_array<int, 16>;
|
|
||||||
tarr: terminated_array<string>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Another {
|
struct Another {
|
||||||
|
|
|
@ -15,8 +15,6 @@ typedef struct _Named
|
||||||
{
|
{
|
||||||
int *field;
|
int *field;
|
||||||
const char *something;
|
const char *something;
|
||||||
int arr[16];
|
|
||||||
const char **tarr;
|
|
||||||
} Named;
|
} Named;
|
||||||
|
|
||||||
typedef struct _Another
|
typedef struct _Another
|
||||||
|
|
|
@ -677,21 +677,6 @@ START_TEST(eolian_struct)
|
||||||
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
|
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
|
||||||
fail_if(strcmp(type_name, "const char *"));
|
fail_if(strcmp(type_name, "const char *"));
|
||||||
eina_stringshare_del(type_name);
|
eina_stringshare_del(type_name);
|
||||||
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "arr")));
|
|
||||||
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
|
||||||
fail_if(eolian_type_is_ptr(ftype));
|
|
||||||
fail_if(eolian_type_array_size_get(ftype) != 16);
|
|
||||||
fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_STATIC_ARRAY);
|
|
||||||
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
|
|
||||||
fail_if(strcmp(type_name, "int *"));
|
|
||||||
eina_stringshare_del(type_name);
|
|
||||||
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "tarr")));
|
|
||||||
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
|
||||||
fail_if(eolian_type_is_ptr(ftype));
|
|
||||||
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
|
|
||||||
fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_TERMINATED_ARRAY);
|
|
||||||
fail_if(strcmp(type_name, "const char **"));
|
|
||||||
eina_stringshare_del(type_name);
|
|
||||||
|
|
||||||
/* referencing */
|
/* referencing */
|
||||||
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));
|
||||||
|
|
Loading…
Reference in New Issue