eolian: Test recognition of struct types used in methods

Summary:
Add code to unit test to check if Eolian correctly recognize a struct
name as a struct type when it is used in a method.

Add new method to struct.eo to create this test.
Update struct_ref.c accordingly.

Reviewers: tasn, q66

Differential Revision: https://phab.enlightenment.org/D3213
This commit is contained in:
Vitor Sousa 2015-10-21 18:14:22 +01:00 committed by Daniel Kolesa
parent 8b48906401
commit d6055e9527
3 changed files with 15 additions and 0 deletions

View File

@ -23,5 +23,8 @@ class Struct {
}
return: own(char*);
}
bar {
return: Named *;
}
}
}

View File

@ -39,5 +39,7 @@ EAPI const Eo_Class *struct_class_get(void) EINA_CONST;
*/
EOAPI char * struct_foo(int idx);
EOAPI Named * struct_bar(void);
#endif

View File

@ -647,6 +647,7 @@ START_TEST(eolian_struct)
const Eolian_Struct_Type_Field *field = NULL;
const Eolian_Type *type = NULL, *ftype = NULL;
const Eolian_Class *class;
const Eolian_Function *func;
const char *type_name;
const char *file;
@ -697,6 +698,15 @@ START_TEST(eolian_struct)
fail_if(!(type = eolian_type_struct_get_by_name("Opaque")));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT_OPAQUE);
/* 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(!(type = eolian_type_base_type_get(type)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
eolian_shutdown();
}
END_TEST