forked from enlightenment/efl
eolian: remove parsing of pointers and the corresponding APIs
Everything should be done via the new ptr() system now.
This commit is contained in:
parent
5c54c53975
commit
8002b3b24e
|
@ -74,7 +74,6 @@ ffi.cdef [[
|
||||||
EOLIAN_TYPE_VOID,
|
EOLIAN_TYPE_VOID,
|
||||||
EOLIAN_TYPE_REGULAR,
|
EOLIAN_TYPE_REGULAR,
|
||||||
EOLIAN_TYPE_COMPLEX,
|
EOLIAN_TYPE_COMPLEX,
|
||||||
EOLIAN_TYPE_POINTER,
|
|
||||||
EOLIAN_TYPE_CLASS,
|
EOLIAN_TYPE_CLASS,
|
||||||
EOLIAN_TYPE_STATIC_ARRAY,
|
EOLIAN_TYPE_STATIC_ARRAY,
|
||||||
EOLIAN_TYPE_TERMINATED_ARRAY,
|
EOLIAN_TYPE_TERMINATED_ARRAY,
|
||||||
|
@ -456,11 +455,10 @@ M.type_type = {
|
||||||
VOID = 1,
|
VOID = 1,
|
||||||
REGULAR = 2,
|
REGULAR = 2,
|
||||||
COMPLEX = 3,
|
COMPLEX = 3,
|
||||||
POINTER = 4,
|
CLASS = 4,
|
||||||
CLASS = 5,
|
STATIC_ARRAY = 5,
|
||||||
STATIC_ARRAY = 6,
|
TERMINATED_ARRAY = 6,
|
||||||
TERMINATED_ARRAY = 7,
|
UNDEFINED = 7
|
||||||
UNDEFINED = 8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
M.typedecl_type = {
|
M.typedecl_type = {
|
||||||
|
|
|
@ -218,7 +218,6 @@ typedef enum
|
||||||
EOLIAN_TYPE_VOID,
|
EOLIAN_TYPE_VOID,
|
||||||
EOLIAN_TYPE_REGULAR,
|
EOLIAN_TYPE_REGULAR,
|
||||||
EOLIAN_TYPE_COMPLEX,
|
EOLIAN_TYPE_COMPLEX,
|
||||||
EOLIAN_TYPE_POINTER,
|
|
||||||
EOLIAN_TYPE_CLASS,
|
EOLIAN_TYPE_CLASS,
|
||||||
EOLIAN_TYPE_STATIC_ARRAY,
|
EOLIAN_TYPE_STATIC_ARRAY,
|
||||||
EOLIAN_TYPE_TERMINATED_ARRAY,
|
EOLIAN_TYPE_TERMINATED_ARRAY,
|
||||||
|
|
|
@ -23,15 +23,6 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
|
||||||
return err;
|
return err;
|
||||||
switch (type->type)
|
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_CLASS:
|
||||||
case EOLIAN_TYPE_COMPLEX:
|
case EOLIAN_TYPE_COMPLEX:
|
||||||
return database_expr_eval(expr, EOLIAN_MASK_NULL);
|
return database_expr_eval(expr, EOLIAN_MASK_NULL);
|
||||||
|
|
|
@ -223,7 +223,6 @@ _validate_type(const Eolian_Type *tp)
|
||||||
}
|
}
|
||||||
return _validate_typedecl(tpp);
|
return _validate_typedecl(tpp);
|
||||||
}
|
}
|
||||||
case EOLIAN_TYPE_POINTER:
|
|
||||||
case EOLIAN_TYPE_STATIC_ARRAY:
|
case EOLIAN_TYPE_STATIC_ARRAY:
|
||||||
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
case EOLIAN_TYPE_TERMINATED_ARRAY:
|
||||||
return _validate_type(tp->base_type);
|
return _validate_type(tp->base_type);
|
||||||
|
|
|
@ -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);
|
FILL_BASE(def->base, ls, line, col);
|
||||||
def->is_const = EINA_TRUE;
|
def->is_const = EINA_TRUE;
|
||||||
check_match(ls, ')', '(', pline, pcol);
|
check_match(ls, ')', '(', pline, pcol);
|
||||||
goto parse_ptr;
|
return def;
|
||||||
}
|
}
|
||||||
case KW_ptr:
|
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);
|
FILL_BASE(def->base, ls, line, col);
|
||||||
def->is_ptr = EINA_TRUE;
|
def->is_ptr = EINA_TRUE;
|
||||||
check_match(ls, ')', '(', pline, pcol);
|
check_match(ls, ')', '(', pline, pcol);
|
||||||
goto parse_ptr;
|
return def;
|
||||||
}
|
}
|
||||||
case KW_own:
|
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);
|
FILL_BASE(def->base, ls, line, col);
|
||||||
def->is_own = EINA_TRUE;
|
def->is_own = EINA_TRUE;
|
||||||
check_match(ls, ')', '(', pline, pcolumn);
|
check_match(ls, ')', '(', pline, pcolumn);
|
||||||
goto parse_ptr;
|
return def;
|
||||||
}
|
}
|
||||||
case KW_free:
|
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);
|
eo_lexer_get(ls);
|
||||||
FILL_BASE(def->base, ls, line, col);
|
FILL_BASE(def->base, ls, line, col);
|
||||||
check_match(ls, ')', '(', pline, pcolumn);
|
check_match(ls, ')', '(', pline, pcolumn);
|
||||||
goto parse_ptr;
|
return def;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -941,28 +941,6 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
|
||||||
pop_strbuf(ls);
|
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;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -596,7 +596,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,
|
||||||
COMPLEX = eolian.type_type.COMPLEX,
|
COMPLEX = eolian.type_type.COMPLEX,
|
||||||
POINTER = eolian.type_type.POINTER,
|
|
||||||
CLASS = eolian.type_type.CLASS,
|
CLASS = eolian.type_type.CLASS,
|
||||||
STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
|
STATIC_ARRAY = eolian.type_type.STATIC_ARRAY,
|
||||||
TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
|
TERMINATED_ARRAY = eolian.type_type.TERMINATED_ARRAY,
|
||||||
|
@ -708,13 +707,6 @@ M.Type = Node:clone {
|
||||||
end
|
end
|
||||||
return wrap_type_attrs(self, self:full_name_get() .. "<"
|
return wrap_type_attrs(self, self:full_name_get() .. "<"
|
||||||
.. table.concat(stypes, ", ") .. ">")
|
.. 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
|
elseif tpt == self.STATIC_ARRAY then
|
||||||
return wrap_type_attrs(self, "static_array<"
|
return wrap_type_attrs(self, "static_array<"
|
||||||
.. self:base_type_get():serialize() .. ", "
|
.. self:base_type_get():serialize() .. ", "
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Class_Simple {
|
||||||
@out c: double (1337.6);
|
@out c: double (1337.6);
|
||||||
@in d: ptr(int);
|
@in d: ptr(int);
|
||||||
}
|
}
|
||||||
return: char * (null); [[comment for method return]]
|
return: ptr(char) (null); [[comment for method return]]
|
||||||
}
|
}
|
||||||
bar @c_only {
|
bar @c_only {
|
||||||
eo: null;
|
eo: null;
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Complex_Type {
|
||||||
methods {
|
methods {
|
||||||
@property a {
|
@property a {
|
||||||
set {
|
set {
|
||||||
return: own(list<array<own(Eo**)> >);
|
return: own(list<array<own(ptr(Eo))> >);
|
||||||
}
|
}
|
||||||
get {
|
get {
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class Complex_Type {
|
||||||
}
|
}
|
||||||
foo {
|
foo {
|
||||||
params {
|
params {
|
||||||
buf: own(char*);
|
buf: own(ptr(char));
|
||||||
}
|
}
|
||||||
return: own(list<stringshare>); [[comment for method return]]
|
return: own(list<stringshare>); [[comment for method return]]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Consts {
|
||||||
@inout b: char;
|
@inout b: char;
|
||||||
@out c: double;
|
@out c: double;
|
||||||
}
|
}
|
||||||
return: char * (null); [[comment for method return]]
|
return: ptr(char) (null); [[comment for method return]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Decl {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Enum {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Extern {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ struct Opaque1;
|
||||||
struct @free(opaque_free) Opaque2;
|
struct @free(opaque_free) Opaque2;
|
||||||
|
|
||||||
/* pointers */
|
/* pointers */
|
||||||
type Pointer1: char *;
|
type Pointer1: ptr(char);
|
||||||
type Pointer2: free(char *, ptr_free);
|
type Pointer2: free(ptr(char), ptr_free);
|
||||||
|
|
||||||
class Free_Func {
|
class Free_Func {
|
||||||
methods {
|
methods {
|
||||||
|
@ -24,7 +24,7 @@ class Free_Func {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ class Null {
|
||||||
methods {
|
methods {
|
||||||
foo {
|
foo {
|
||||||
params {
|
params {
|
||||||
x: char *;
|
x: ptr(char);
|
||||||
y: char * @nullable;
|
y: ptr(char) @nullable;
|
||||||
z: char * @optional;
|
z: ptr(char) @optional;
|
||||||
w: char * @optional @nullable;
|
w: ptr(char) @optional @nullable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Object_Impl (Base) {
|
||||||
@inout b: char;
|
@inout b: char;
|
||||||
@out c: double;
|
@out c: double;
|
||||||
}
|
}
|
||||||
return: char * (null); [[comment for method return]]
|
return: ptr(char) (null); [[comment for method return]]
|
||||||
}
|
}
|
||||||
foo2 @const {
|
foo2 @const {
|
||||||
[[comment foo]]
|
[[comment foo]]
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Override (Base) {
|
||||||
params {
|
params {
|
||||||
@in idx: int;
|
@in idx: int;
|
||||||
@out a: int (250);
|
@out a: int (250);
|
||||||
@out str: char * (null);
|
@out str: ptr(char) (null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ class Struct {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
bar {
|
bar {
|
||||||
return: Named *;
|
return: ptr(Named);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
type Evas.Coord: int; /* Simple type definition */
|
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.Coord2: Evas.Coord;
|
||||||
type Evas.Coord3: Evas.Coord2;
|
type Evas.Coord3: Evas.Coord2;
|
||||||
|
@ -35,7 +35,7 @@ class Typedef {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Var {
|
||||||
params {
|
params {
|
||||||
idx: int;
|
idx: int;
|
||||||
}
|
}
|
||||||
return: own(char*);
|
return: own(ptr(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ START_TEST(eolian_complex_type)
|
||||||
fail_if(!!eolian_type_next_type_get(type));
|
fail_if(!!eolian_type_next_type_get(type));
|
||||||
fail_if(!(type_name = eolian_type_c_type_get(type)));
|
fail_if(!(type_name = eolian_type_c_type_get(type)));
|
||||||
fail_if(!eolian_type_is_own(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);
|
eina_stringshare_del(type_name);
|
||||||
/* Properties parameter type */
|
/* Properties parameter type */
|
||||||
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
||||||
|
@ -611,7 +611,7 @@ START_TEST(eolian_simple_parsing)
|
||||||
/* Method */
|
/* Method */
|
||||||
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
||||||
fail_if(!eolian_function_is_beta(fid));
|
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 */
|
/* Function return */
|
||||||
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
|
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
|
||||||
fail_if(!tp);
|
fail_if(!tp);
|
||||||
|
@ -739,9 +739,8 @@ START_TEST(eolian_struct)
|
||||||
/* use in function */
|
/* use in function */
|
||||||
fail_if(!(func = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
|
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(!(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_type_get(type) != EOLIAN_TYPE_REGULAR);
|
||||||
|
fail_if(!eolian_type_is_ptr(type));
|
||||||
fail_if(!(tdl = eolian_type_typedecl_get(type)));
|
fail_if(!(tdl = eolian_type_typedecl_get(type)));
|
||||||
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue