summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-07-30 15:51:08 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-08-04 16:29:13 +0100
commitbe8b3295813576dd8ac161b0916499efa768f7b4 (patch)
tree724344bd67f851bfba989c8228e347ee24ac8e03
parentc0c73dc29dc3130397e887cd8cf98b9afbff2b0c (diff)
downloadefl-be8b3295813576dd8ac161b0916499efa768f7b4.tar.gz
eolian: better error information + fix tests
This provides better location info when failing to resolve EOLIAN_TYPE_CLASS. Also fixes tests I forgot to push before.
-rw-r--r--src/lib/eolian/eo_parser.c18
-rw-r--r--src/tests/eolian/data/object_impl_add_ref.c32
-rw-r--r--src/tests/eolian/data/object_impl_ref.c28
-rw-r--r--src/tests/eolian/data/struct_ref.c6
-rw-r--r--src/tests/eolian/data/typedef_ref.c6
5 files changed, 51 insertions, 39 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index f8d7bd6f1d..ee07d2f19e 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -445,6 +445,7 @@ parse_type_struct_void(Eo_Lexer *ls, Eina_Bool allow_struct)
const char *bnm, *nm;
char *fnm;
buf = push_strbuf(ls);
+ eo_lexer_context_push(ls);
parse_name(ls, buf);
nm = eina_strbuf_string_get(buf);
bnm = get_filename(ls);
@@ -456,8 +457,13 @@ parse_type_struct_void(Eo_Lexer *ls, Eina_Bool allow_struct)
free(fnm);
if (fname)
{
- if (!eolian_class_get_by_name(nm) && !eolian_eo_file_parse(fname))
- eo_lexer_syntax_error(ls, "failed to parse dependency");
+ if (!eolian_class_get_by_name(nm)
+ && !eolian_eo_file_parse(fname))
+ {
+ eo_lexer_context_restore(ls);
+ eo_lexer_syntax_error(ls,
+ "failed to parse dependency");
+ }
def->type = EOLIAN_TYPE_CLASS;
}
}
@@ -467,6 +473,7 @@ parse_type_struct_void(Eo_Lexer *ls, Eina_Bool allow_struct)
free(fnm);
def->type = EOLIAN_TYPE_CLASS;
}
+ eo_lexer_context_pop(ls);
_fill_type_name(def, eina_stringshare_add(nm));
pop_strbuf(ls);
}
@@ -1178,6 +1185,7 @@ parse_class(Eo_Lexer *ls, Eina_Bool allow_ctors, Eolian_Class_Type type)
ls->tmp.kls = calloc(1, sizeof(Eo_Class_Def));
eo_lexer_get(ls);
ls->tmp.kls->type = type;
+ eo_lexer_context_push(ls);
parse_name(ls, buf);
bnm = get_filename(ls);
fnm = database_class_to_filename(eina_strbuf_string_get(buf));
@@ -1185,7 +1193,11 @@ parse_class(Eo_Lexer *ls, Eina_Bool allow_ctors, Eolian_Class_Type type)
eina_stringshare_del(bnm);
free(fnm);
if (!same)
- eo_lexer_syntax_error(ls, "class and file names differ");
+ {
+ eo_lexer_context_restore(ls);
+ eo_lexer_syntax_error(ls, "class and file names differ");
+ }
+ eo_lexer_context_pop(ls);
ls->tmp.kls->name = eina_stringshare_add(eina_strbuf_string_get(buf));
pop_strbuf(ls);
ls->tmp.kls->file = get_filename(ls);
diff --git a/src/tests/eolian/data/object_impl_add_ref.c b/src/tests/eolian/data/object_impl_add_ref.c
index 5527619d3d..a8ced30881 100644
--- a/src/tests/eolian/data/object_impl_add_ref.c
+++ b/src/tests/eolian/data/object_impl_add_ref.c
@@ -1,87 +1,87 @@
#define EFL_BETA_API_SUPPORT
#include <Eo.h>
-#include "object.eo.h"
+#include "object_impl.eo.h"
typedef struct
{
-} Object_Data;
+} Object_Impl_Data;
EOLIAN static Eina_Bool
-_object_a_set(Eo *obj, Object_Data *pd, const char *part, const Eina_List *value)
+_object_impl_a_set(Eo *obj, Object_Impl_Data *pd, const char *part, const Eina_List *value)
{
}
EOLIAN static Eina_List *
-_object_a_get(Eo *obj, Object_Data *pd, const char *part)
+_object_impl_a_get(Eo *obj, Object_Impl_Data *pd, const char *part)
{
}
EOLIAN static void
-_object_b_set(Eo *obj, Object_Data *pd, Eina_List *value)
+_object_impl_b_set(Eo *obj, Object_Impl_Data *pd, Eina_List *value)
{
}
EOLIAN static char *
-_object_foo1(Eo *obj, Object_Data *pd, int a, char *b, double *c)
+_object_impl_foo1(Eo *obj, Object_Impl_Data *pd, int a, char *b, double *c)
{
}
EOLIAN static void
-_object_foo2(const Eo *obj, Object_Data *pd, int a, const char *b)
+_object_impl_foo2(const Eo *obj, Object_Impl_Data *pd, int a, const char *b)
{
}
EOLIAN static void
-_object_constructor_1(Eo *obj, Object_Data *pd, int a, char b)
+_object_impl_constructor_1(Eo *obj, Object_Impl_Data *pd, int a, char b)
{
}
EOLIAN static void
-_object_constructor_2(Eo *obj, Object_Data *pd)
+_object_impl_constructor_2(Eo *obj, Object_Impl_Data *pd)
{
}
EOLIAN static void
-_object_base_constructor(Eo *obj, Object_Data *pd)
+_object_impl_base_constructor(Eo *obj, Object_Impl_Data *pd)
{
- eo_do_super(obj, OBJECT_CLASS, base_constructor();
+ eo_do_super(obj, OBJECT_IMPL_CLASS, base_constructor();
}
EOLIAN static void
-_object_base_destructor(Eo *obj, Object_Data *pd)
+_object_impl_base_destructor(Eo *obj, Object_Impl_Data *pd)
{
}
EOLIAN static void
-_object_class_constructor(Eo_Class *klass)
+_object_impl_class_constructor(Eo_Class *klass)
{
}
EOLIAN static void
-_object_class_destructor(Eo_Class *klass)
+_object_impl_class_destructor(Eo_Class *klass)
{
}
EOLIAN static void
-_object_c_set(Eo *obj, Object_Data *pd, Eina_List *value)
+_object_impl_add_c_set(Eo *obj, Object_Impl_Data *pd, Eina_List *value)
{
}
EOLIAN static Eina_List *
-_object_c_get(Eo *obj, Object_Data *pd)
+_object_impl_add_c_get(Eo *obj, Object_Impl_Data *pd)
{
}
diff --git a/src/tests/eolian/data/object_impl_ref.c b/src/tests/eolian/data/object_impl_ref.c
index 7786159e9b..6590421766 100644
--- a/src/tests/eolian/data/object_impl_ref.c
+++ b/src/tests/eolian/data/object_impl_ref.c
@@ -1,75 +1,75 @@
#define EFL_BETA_API_SUPPORT
#include <Eo.h>
-#include "object.eo.h"
+#include "object_impl.eo.h"
typedef struct
{
-} Object_Data;
+} Object_Impl_Data;
EOLIAN static Eina_Bool
-_object_a_set(Eo *obj, Object_Data *pd, const char *part, const Eina_List *value)
+_object_impl_a_set(Eo *obj, Object_Impl_Data *pd, const char *part, const Eina_List *value)
{
}
EOLIAN static Eina_List *
-_object_a_get(Eo *obj, Object_Data *pd, const char *part)
+_object_impl_a_get(Eo *obj, Object_Impl_Data *pd, const char *part)
{
}
EOLIAN static void
-_object_b_set(Eo *obj, Object_Data *pd, Eina_List *value)
+_object_impl_b_set(Eo *obj, Object_Impl_Data *pd, Eina_List *value)
{
}
EOLIAN static char *
-_object_foo1(Eo *obj, Object_Data *pd, int a, char *b, double *c)
+_object_impl_foo1(Eo *obj, Object_Impl_Data *pd, int a, char *b, double *c)
{
}
EOLIAN static void
-_object_foo2(const Eo *obj, Object_Data *pd, int a, const char *b)
+_object_impl_foo2(const Eo *obj, Object_Impl_Data *pd, int a, const char *b)
{
}
EOLIAN static void
-_object_constructor_1(Eo *obj, Object_Data *pd, int a, char b)
+_object_impl_constructor_1(Eo *obj, Object_Impl_Data *pd, int a, char b)
{
}
EOLIAN static void
-_object_constructor_2(Eo *obj, Object_Data *pd)
+_object_impl_constructor_2(Eo *obj, Object_Impl_Data *pd)
{
}
EOLIAN static void
-_object_base_constructor(Eo *obj, Object_Data *pd)
+_object_impl_base_constructor(Eo *obj, Object_Impl_Data *pd)
{
- eo_do_super(obj, OBJECT_CLASS, base_constructor();
+ eo_do_super(obj, OBJECT_IMPL_CLASS, base_constructor();
}
EOLIAN static void
-_object_base_destructor(Eo *obj, Object_Data *pd)
+_object_impl_base_destructor(Eo *obj, Object_Impl_Data *pd)
{
}
EOLIAN static void
-_object_class_constructor(Eo_Class *klass)
+_object_impl_class_constructor(Eo_Class *klass)
{
}
EOLIAN static void
-_object_class_destructor(Eo_Class *klass)
+_object_impl_class_destructor(Eo_Class *klass)
{
}
diff --git a/src/tests/eolian/data/struct_ref.c b/src/tests/eolian/data/struct_ref.c
index 62cd7b4570..75e3a90ad5 100644
--- a/src/tests/eolian/data/struct_ref.c
+++ b/src/tests/eolian/data/struct_ref.c
@@ -30,9 +30,9 @@ struct _Foo {
#endif
-#define DUMMY_CLASS dummy_class_get()
+#define STRUCT_CLASS struct_class_get()
-const Eo_Class *dummy_class_get(void) EINA_CONST;
+const Eo_Class *struct_class_get(void) EINA_CONST;
/**
*
@@ -41,7 +41,7 @@ const Eo_Class *dummy_class_get(void) EINA_CONST;
* @param[in] idx No description supplied.
*
*/
-EOAPI char * dummy_foo(int idx);
+EOAPI char * struct_foo(int idx);
#endif
diff --git a/src/tests/eolian/data/typedef_ref.c b/src/tests/eolian/data/typedef_ref.c
index c95d884a52..d7a8c8665f 100644
--- a/src/tests/eolian/data/typedef_ref.c
+++ b/src/tests/eolian/data/typedef_ref.c
@@ -10,9 +10,9 @@ typedef Eina_List *List_Objects;
#endif
-#define DUMMY_CLASS dummy_class_get()
+#define TYPEDEF_CLASS typedef_class_get()
-const Eo_Class *dummy_class_get(void) EINA_CONST;
+const Eo_Class *typedef_class_get(void) EINA_CONST;
/**
*
@@ -21,7 +21,7 @@ const Eo_Class *dummy_class_get(void) EINA_CONST;
* @param[in] idx No description supplied.
*
*/
-EOAPI char * dummy_foo(int idx);
+EOAPI char * typedef_foo(int idx);
#endif