eolian: fix tests and fix class name comparison in parser

This fixes the Eolian testsuite as well as adds a better way to compare where a class
comes from, allowing us to guess EOLIAN_TYPE_CLASS correctly.
This commit is contained in:
Daniel Kolesa 2014-07-30 15:35:57 +01:00
parent 0e4860f215
commit c88c0d9347
17 changed files with 70 additions and 62 deletions

View File

@ -442,23 +442,31 @@ parse_type_struct_void(Eo_Lexer *ls, Eina_Bool allow_struct)
}
else
{
const char *nm, *fpath;
char *fname;
const char *bnm, *nm;
char *fnm;
buf = push_strbuf(ls);
parse_name(ls, buf);
nm = eina_strbuf_string_get(buf);
fname = database_class_to_filename(nm);
fpath = eina_hash_find(_filenames, fname);
free(fname);
if (fpath)
bnm = get_filename(ls);
fnm = database_class_to_filename(nm);
if (strncmp(bnm, fnm, strlen(bnm) - 3))
{
def->type = EOLIAN_TYPE_CLASS;
if (strcmp(ls->source, fpath))
const char *fname = eina_hash_find(_filenames, fnm);
eina_stringshare_del(bnm);
free(fnm);
if (fname)
{
if (!eolian_class_get_by_name(nm) && !eolian_eo_file_parse(fpath))
if (!eolian_class_get_by_name(nm) && !eolian_eo_file_parse(fname))
eo_lexer_syntax_error(ls, "failed to parse dependency");
def->type = EOLIAN_TYPE_CLASS;
}
}
else
{
eina_stringshare_del(bnm);
free(fnm);
def->type = EOLIAN_TYPE_CLASS;
}
_fill_type_name(def, eina_stringshare_add(nm));
pop_strbuf(ls);
}
@ -1173,7 +1181,7 @@ parse_class(Eo_Lexer *ls, Eina_Bool allow_ctors, Eolian_Class_Type type)
parse_name(ls, buf);
bnm = get_filename(ls);
fnm = database_class_to_filename(eina_strbuf_string_get(buf));
same = !!strcmp(bnm, fnm);
same = !strncmp(bnm, fnm, strlen(bnm) - 3);
eina_stringshare_del(bnm);
free(fnm);
if (!same)

View File

@ -1,4 +1,4 @@
class Simple {
class Class_Funcs {
properties {
a @class {
get {

View File

@ -1,4 +1,4 @@
class Simple {
class Class_Simple {
/*@ Class Desc Simple */
legacy_prefix: evas_object_simple;
eo_prefix: evas_obj_simple;

View File

@ -1,4 +1,4 @@
class Const {
class Consts {
properties {
a {
set {

View File

@ -16,7 +16,7 @@ struct @extern Y
field: int;
}
class Dummy {
class Extern {
methods {
foo {
params {

View File

@ -1,33 +0,0 @@
class nmsp1.nmsp11.class2
{
properties {
a {
set {
}
}
}
implements {
virtual.a.set;
}
}
class nmsp2.class1
{
}
class no_nmsp
{
methods {
foo {
}
}
}
class nmsp1.class1 (nmsp1.nmsp11.class2, nmsp2.class1, no_nmsp)
{
implements {
nmsp1.nmsp11.class2.a.set;
nmsp1.bad_class.a.set;
no_nmsp.foo;
}
}

View File

@ -0,0 +1,8 @@
class nmsp1.class1 (nmsp1.nmsp11.class2, nmsp2.class1, no_nmsp)
{
implements {
nmsp1.nmsp11.class2.a.set;
nmsp1.bad_class.a.set;
no_nmsp.foo;
}
}

View File

@ -0,0 +1,12 @@
class nmsp1.nmsp11.class2
{
properties {
a {
set {
}
}
}
implements {
virtual.a.set;
}
}

View File

@ -0,0 +1,3 @@
class nmsp2.class1
{
}

View File

@ -0,0 +1,7 @@
class no_nmsp
{
methods {
foo {
}
}
}

View File

@ -1,4 +1,4 @@
class Object (Base) {
class Object_Impl (Base) {
constructors {
constructor_1 {
params {

View File

@ -1,4 +1,6 @@
class Object (Base) {
class Object_Impl_Add (Base) {
data: Object_Impl_Data;
properties {
c {
set {

View File

@ -1,4 +1,4 @@
class Simple (Base) {
class Override (Base) {
properties {
a {
set {

View File

@ -1,4 +1,4 @@
class Simple {
class Scope {
properties {
a @protected {
get {

View File

@ -19,7 +19,7 @@ type Bar: struct {
b: struct _Foo;
};
class Dummy {
class Struct {
methods {
foo {
params {

View File

@ -1,7 +1,7 @@
type Evas.Coord: int; /* Simple type definition */
type List_Objects: own(Eina.List*)< Eo *>; /* A little more complex */
class Dummy {
class Typedef {
methods {
foo {
params {

View File

@ -21,7 +21,8 @@ START_TEST(eolian_namespaces)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/namespace.eo"));
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo"));
/* Classes existence */
fail_if(!(class11 = eolian_class_get_by_name("nmsp1.class1")));
@ -151,7 +152,7 @@ START_TEST(eolian_override)
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/override.eo"));
/* Class */
fail_if(!(class = eolian_class_get_by_name("Simple")));
fail_if(!(class = eolian_class_get_by_name("Override")));
fail_if(!(base = eolian_class_get_by_name("Base")));
/* Base ctor */
@ -186,7 +187,7 @@ START_TEST(eolian_consts)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"));
fail_if(!(class = eolian_class_get_by_name("Const")));
fail_if(!(class = eolian_class_get_by_name("Consts")));
/* Property */
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
@ -258,7 +259,7 @@ START_TEST(eolian_typedef)
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Dummy")));
fail_if(!(class = eolian_class_get_by_name("Typedef")));
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* Basic type */
@ -410,7 +411,7 @@ START_TEST(eolian_scope)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"));
fail_if(!(class = eolian_class_get_by_name("Simple")));
fail_if(!(class = eolian_class_get_by_name("Scope")));
/* Property scope */
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
@ -447,7 +448,7 @@ START_TEST(eolian_simple_parsing)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"));
fail_if(!(class = eolian_class_get_by_name("Simple")));
fail_if(!(class = eolian_class_get_by_name("Class_Simple")));
fail_if(eolian_class_get_by_file("class_simple.eo") != class);
fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo"));
@ -557,7 +558,7 @@ START_TEST(eolian_struct)
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/struct.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Dummy")));
fail_if(!(class = eolian_class_get_by_name("Struct")));
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* named struct */
@ -624,7 +625,7 @@ START_TEST(eolian_extern)
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/extern.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Dummy")));
fail_if(!(class = eolian_class_get_by_name("Extern")));
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* regular type */
@ -655,7 +656,7 @@ START_TEST(eolian_class_funcs)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo"));
fail_if(!(class = eolian_class_get_by_name("Simple")));
fail_if(!(class = eolian_class_get_by_name("Class_Funcs")));
/* Class properties */
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));