eolian: remove parsing of pointers and the corresponding APIs

Everything should be done via the new ptr() system now.
This commit is contained in:
Daniel Kolesa 2016-11-10 16:20:19 +01:00
parent 5c54c53975
commit 8002b3b24e
20 changed files with 32 additions and 76 deletions

View File

@ -74,7 +74,6 @@ ffi.cdef [[
EOLIAN_TYPE_VOID,
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_COMPLEX,
EOLIAN_TYPE_POINTER,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_STATIC_ARRAY,
EOLIAN_TYPE_TERMINATED_ARRAY,
@ -456,11 +455,10 @@ M.type_type = {
VOID = 1,
REGULAR = 2,
COMPLEX = 3,
POINTER = 4,
CLASS = 5,
STATIC_ARRAY = 6,
TERMINATED_ARRAY = 7,
UNDEFINED = 8
CLASS = 4,
STATIC_ARRAY = 5,
TERMINATED_ARRAY = 6,
UNDEFINED = 7
}
M.typedecl_type = {

View File

@ -218,7 +218,6 @@ typedef enum
EOLIAN_TYPE_VOID,
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_COMPLEX,
EOLIAN_TYPE_POINTER,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_STATIC_ARRAY,
EOLIAN_TYPE_TERMINATED_ARRAY,

View File

@ -23,15 +23,6 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
return err;
switch (type->type)
{
case EOLIAN_TYPE_POINTER:
{
int mask = EOLIAN_MASK_NULL;
const Eolian_Type *base = eolian_type_base_type_get(type);
int kw = base->name ? eo_lexer_keyword_str_to_id(base->name) : 0;
if (kw == KW_char)
mask |= EOLIAN_MASK_STRING;
return database_expr_eval(expr, mask);
}
case EOLIAN_TYPE_CLASS:
case EOLIAN_TYPE_COMPLEX:
return database_expr_eval(expr, EOLIAN_MASK_NULL);

View File

@ -223,7 +223,6 @@ _validate_type(const Eolian_Type *tp)
}
return _validate_typedecl(tpp);
}
case EOLIAN_TYPE_POINTER:
case EOLIAN_TYPE_STATIC_ARRAY:
case EOLIAN_TYPE_TERMINATED_ARRAY:
return _validate_type(tp->base_type);

View File

@ -755,7 +755,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
FILL_BASE(def->base, ls, line, col);
def->is_const = EINA_TRUE;
check_match(ls, ')', '(', pline, pcol);
goto parse_ptr;
return def;
}
case KW_ptr:
{
@ -768,7 +768,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
FILL_BASE(def->base, ls, line, col);
def->is_ptr = EINA_TRUE;
check_match(ls, ')', '(', pline, pcol);
goto parse_ptr;
return def;
}
case KW_own:
{
@ -788,7 +788,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
FILL_BASE(def->base, ls, line, col);
def->is_own = EINA_TRUE;
check_match(ls, ')', '(', pline, pcolumn);
goto parse_ptr;
return def;
}
case KW_free:
{
@ -811,7 +811,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
eo_lexer_get(ls);
FILL_BASE(def->base, ls, line, col);
check_match(ls, ')', '(', pline, pcolumn);
goto parse_ptr;
return def;
}
default:
break;
@ -941,28 +941,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
pop_strbuf(ls);
}
}
parse_ptr:
if ((def->type == EOLIAN_TYPE_CLASS) || (def->type == EOLIAN_TYPE_COMPLEX))
{
if (ls->t.token == '*')
eo_lexer_syntax_error(ls, "pointer to complex/class type");
}
if (getenv("EOLIAN_WARN_PTR") && ls->t.token == '*')
{
fprintf(stderr, "eolian:%s:%d:%d: found pointer type\n",
def->base.file, line, col);
}
while (ls->t.token == '*')
{
Eolian_Type *pdef;
pop_type(ls);
pdef = push_type(ls);
FILL_BASE(pdef->base, ls, ls->line_number, ls->column);
pdef->base_type = def;
pdef->type = EOLIAN_TYPE_POINTER;
def = pdef;
eo_lexer_get(ls);
}
return def;
}

View File

@ -596,7 +596,6 @@ M.Type = Node:clone {
VOID = eolian.type_type.VOID,
REGULAR = eolian.type_type.REGULAR,
COMPLEX = eolian.type_type.COMPLEX,
POINTER = eolian.type_type.POINTER,
CLASS = eolian.type_type.CLASS,
STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
@ -708,13 +707,6 @@ M.Type = Node:clone {
end
return wrap_type_attrs(self, self:full_name_get() .. "<"
.. table.concat(stypes, ", ") .. ">")
elseif tpt == self.POINTER then
local btp = self:base_type_get()
local suffix = " *"
if btp:type_get() == self.POINTER then
suffix = "*"
end
return wrap_type_attrs(self, btp:serialize() .. suffix)
elseif tpt == self.STATIC_ARRAY then
return wrap_type_attrs(self, "static_array<"
.. self:base_type_get():serialize() .. ", "

View File

@ -37,7 +37,7 @@ class Class_Simple {
@out c: double (1337.6);
@in d: ptr(int);
}
return: char * (null); [[comment for method return]]
return: ptr(char) (null); [[comment for method return]]
}
bar @c_only {
eo: null;

View File

@ -2,7 +2,7 @@ class Complex_Type {
methods {
@property a {
set {
return: own(list<array<own(Eo**)> >);
return: own(list<array<own(ptr(Eo))> >);
}
get {
}
@ -12,7 +12,7 @@ class Complex_Type {
}
foo {
params {
buf: own(char*);
buf: own(ptr(char));
}
return: own(list<stringshare>); [[comment for method return]]
}

View File

@ -7,7 +7,7 @@ class Consts {
@inout b: char;
@out c: double;
}
return: char * (null); [[comment for method return]]
return: ptr(char) (null); [[comment for method return]]
}
}
}

View File

@ -16,7 +16,7 @@ class Decl {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -39,7 +39,7 @@ class Enum {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -22,7 +22,7 @@ class Extern {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -15,8 +15,8 @@ struct Opaque1;
struct @free(opaque_free) Opaque2;
/* pointers */
type Pointer1: char *;
type Pointer2: free(char *, ptr_free);
type Pointer1: ptr(char);
type Pointer2: free(ptr(char), ptr_free);
class Free_Func {
methods {
@ -24,7 +24,7 @@ class Free_Func {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -2,10 +2,10 @@ class Null {
methods {
foo {
params {
x: char *;
y: char * @nullable;
z: char * @optional;
w: char * @optional @nullable;
x: ptr(char);
y: ptr(char) @nullable;
z: ptr(char) @optional;
w: ptr(char) @optional @nullable;
}
}
}

View File

@ -41,7 +41,7 @@ class Object_Impl (Base) {
@inout b: char;
@out c: double;
}
return: char * (null); [[comment for method return]]
return: ptr(char) (null); [[comment for method return]]
}
foo2 @const {
[[comment foo]]

View File

@ -38,7 +38,7 @@ class Override (Base) {
params {
@in idx: int;
@out a: int (250);
@out str: char * (null);
@out str: ptr(char) (null);
}
}
}

View File

@ -23,10 +23,10 @@ class Struct {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
bar {
return: Named *;
return: ptr(Named);
}
}
}

View File

@ -1,5 +1,5 @@
type Evas.Coord: int; /* Simple type definition */
type List_Objects: own(list<Eo *>); /* A little more complex */
type List_Objects: own(list<ptr(Eo)>); /* A little more complex */
type Evas.Coord2: Evas.Coord;
type Evas.Coord3: Evas.Coord2;
@ -35,7 +35,7 @@ class Typedef {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -16,7 +16,7 @@ class Var {
params {
idx: int;
}
return: own(char*);
return: own(ptr(char));
}
}
}

View File

@ -451,7 +451,7 @@ START_TEST(eolian_complex_type)
fail_if(!!eolian_type_next_type_get(type));
fail_if(!(type_name = eolian_type_c_type_get(type)));
fail_if(!eolian_type_is_own(type));
fail_if(strcmp(type_name, "Eo **"));
fail_if(strcmp(type_name, "Eo *"));
eina_stringshare_del(type_name);
/* Properties parameter type */
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
@ -611,7 +611,7 @@ START_TEST(eolian_simple_parsing)
/* Method */
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
fail_if(!eolian_function_is_beta(fid));
fail_if(eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
/* Function return */
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
fail_if(!tp);
@ -739,9 +739,8 @@ START_TEST(eolian_struct)
/* use in function */
fail_if(!(func = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_POINTER);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
fail_if(!eolian_type_is_ptr(type));
fail_if(!(tdl = eolian_type_typedecl_get(type)));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);