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:
Daniel Kolesa 2017-09-22 18:01:15 +02:00
parent 4bae2a7385
commit 1577c576e6
13 changed files with 5 additions and 135 deletions

View File

@ -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);
Eina_Stringshare *ct = NULL;
if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
{
ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp),
EOLIAN_C_TYPE_DEFAULT);
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));
}
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);
const Eolian_Documentation *fdoc
= eolian_typedecl_struct_field_documentation_get(memb);

View File

@ -80,8 +80,6 @@ ffi.cdef [[
EOLIAN_TYPE_VOID,
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_STATIC_ARRAY,
EOLIAN_TYPE_TERMINATED_ARRAY,
EOLIAN_TYPE_UNDEFINED
} Eolian_Type_Type;
@ -342,7 +340,6 @@ ffi.cdef [[
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);
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_const(const Eolian_Type *tp);
Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
@ -504,9 +501,7 @@ M.type_type = {
VOID = 1,
REGULAR = 2,
CLASS = 3,
STATIC_ARRAY = 4,
TERMINATED_ARRAY = 5,
UNDEFINED = 6
UNDEFINED = 4
}
M.typedecl_type = {
@ -715,10 +710,6 @@ M.Type = ffi.metatype("Eolian_Type", {
return v
end,
array_size_get = function(self)
return tonumber(eolian.eolian_type_array_size_get(self))
end,
is_owned = function(self)
return eolian.eolian_type_is_owned(self) ~= 0
end,

View File

@ -228,8 +228,6 @@ typedef enum
EOLIAN_TYPE_VOID,
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_STATIC_ARRAY,
EOLIAN_TYPE_TERMINATED_ARRAY,
EOLIAN_TYPE_UNDEFINED
} 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);
/*
* @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.
*

View File

@ -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);
}
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
eolian_type_is_owned(const Eolian_Type *tp)
{

View File

@ -208,17 +208,6 @@ _validate_type(Eolian_Type *tp)
tp->freefunc = eina_stringshare_ref(tpp->freefunc);
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:
{
/* FIXME: pass unit properly */

View File

@ -71,8 +71,6 @@ static const char * const ctypes[] =
"void",
NULL, NULL, /* array types */
"Eina_Accessor *", "Eina_Array *", "Eina_Iterator *", "Eina_Hash *",
"Eina_List *",
"Efl_Future *",

View File

@ -50,8 +50,6 @@ enum Tokens
\
KW(void), \
\
KW(static_array), KW(terminated_array), \
\
KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \
KW(future), \
KW(generic_value), \

View File

@ -751,48 +751,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
def->type = EOLIAN_TYPE_UNDEFINED;
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
{
int tpid = ls->t.kw;

View File

@ -162,7 +162,6 @@ struct _Eolian_Type
Eina_Stringshare *full_name;
Eina_List *namespaces;
Eina_Stringshare *freefunc;
size_t static_size;
Eina_Bool is_const :1;
Eina_Bool is_ptr :1;
Eina_Bool owned :1;

View File

@ -667,8 +667,6 @@ M.Type = Node:clone {
VOID = eolian.type_type.VOID,
REGULAR = eolian.type_type.REGULAR,
CLASS = eolian.type_type.CLASS,
STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
UNDEFINED = eolian.type_type.UNDEFINED,
__ctor = function(self, tp)
@ -721,10 +719,6 @@ M.Type = Node:clone {
return self.type:class_get(nil)
end,
array_size_get = function(self)
return self.type_array_size_get()
end,
is_owned = function(self)
return self.type:is_owned()
end,
@ -779,13 +773,6 @@ M.Type = Node:clone {
.. table.concat(stypes, ", ") .. ">")
end
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
error("unhandled type type: " .. tpt)
end

View File

@ -1,8 +1,6 @@
struct Named {
field: ptr(int);
something: string;
arr: static_array<int, 16>;
tarr: terminated_array<string>;
}
struct Another {

View File

@ -15,8 +15,6 @@ typedef struct _Named
{
int *field;
const char *something;
int arr[16];
const char **tarr;
} Named;
typedef struct _Another

View File

@ -677,21 +677,6 @@ START_TEST(eolian_struct)
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
fail_if(strcmp(type_name, "const char *"));
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 */
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));