From ed9dff8fbd422b613042cd9f402018eda28ffc67 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 29 Jun 2016 15:00:17 -0700 Subject: [PATCH] eolian: add support for future. Future is the read only side of a Promise. For now, I am not removing Eina_Promise until everything is in place, but eventually the promise type of eolian will be gone. --- src/Makefile_Eolian.am | 4 ++ src/lib/eolian/eo_lexer.c | 2 +- src/lib/eolian/eo_lexer.h | 2 +- src/lib/eolian/eo_parser.c | 4 +- src/tests/eolian/eolian_generated_future.c | 51 +++++++++++++++++++ src/tests/eolian/generated_future.eo | 58 ++++++++++++++++++++++ 6 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/tests/eolian/eolian_generated_future.c create mode 100644 src/tests/eolian/generated_future.eo diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am index 164495bc0e..dac5638389 100644 --- a/src/Makefile_Eolian.am +++ b/src/Makefile_Eolian.am @@ -112,12 +112,15 @@ tests_eolian_eolian_suite_SOURCES = \ tests/eolian/eolian_parsing.c \ tests/eolian/eolian_generation.c \ tests/eolian/eolian_generated_promise.c \ +tests/eolian/eolian_generated_future.c \ tests/eolian/eolian_suite.c \ tests/eolian/eolian_suite.h tests/eolian/tests_eolian_eolian_suite-eolian_generated_promise.$(OBJEXT): tests/eolian/generated_promise.eo.h tests/eolian/generated_promise.eo.c +tests/eolian/tests_eolian_eolian_suite-eolian_generated_future.$(OBJEXT): tests/eolian/generated_future.eo.h tests/eolian/generated_future.eo.c CLEANFILES += tests/eolian/generated_promise.eo.h tests/eolian/generated_promise.eo.c +CLEANFILES += tests/eolian/generated_future.eo.h tests/eolian/generated_future.eo.c tests_eolian_eolian_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_builddir)/src/tests/eolian \ -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian\" \ @@ -148,4 +151,5 @@ tests/eolian/data/import_types_ref.h \ tests/eolian/data/docs_ref.h \ tests/eolian/data/docs_ref_legacy.h \ tests/eolian/generated_promise.eo \ +tests/eolian/generated_future.eo \ $(EOLIAN_TESTS_EOS) diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 5a55b01ab4..499ff92949 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -75,7 +75,7 @@ static const char * const ctypes[] = NULL, NULL, /* array types */ "Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List", - "Eina_Promise", + "Eina_Promise", "Efl_Future", "Eina_Value", "const char *", "Eina_Stringshare *", "void *", diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index cc36d77fe8..b33f047396 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -53,7 +53,7 @@ enum Tokens KW(static_array), KW(terminated_array), \ \ KW(accessor), KW(array), KW(iterator), KW(hash), KW(list), \ - KW(promise), \ + KW(promise), KW(future), \ KW(generic_value), KW(string), KW(stringshare), \ \ KW(void_ptr), \ diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 0f302c189c..1fc4b97849 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -887,7 +887,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray) _fill_name(eina_stringshare_ref(ls->t.value.s), &def->full_name, &def->name, &def->namespaces); eo_lexer_get(ls); - if (tpid >= KW_accessor && tpid <= KW_promise) + if (tpid >= KW_accessor && tpid <= KW_future) { int bline = ls->line_number, bcol = ls->column; def->type = EOLIAN_TYPE_COMPLEX; @@ -900,7 +900,7 @@ parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray) def->base_type->next_type = parse_type(ls, EINA_FALSE, EINA_FALSE); pop_type(ls); } - else if(tpid == KW_promise && test_next(ls, ',')) + else if((tpid == KW_promise || tpid == KW_future) && test_next(ls, ',')) { def->base_type->next_type = parse_type(ls, EINA_FALSE, EINA_FALSE); pop_type(ls); diff --git a/src/tests/eolian/eolian_generated_future.c b/src/tests/eolian/eolian_generated_future.c new file mode 100644 index 0000000000..47f3251aad --- /dev/null +++ b/src/tests/eolian/eolian_generated_future.c @@ -0,0 +1,51 @@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +struct Generated_Future_Data {}; +typedef struct Generated_Future_Data Generated_Future_Data; + +static void _generated_future_method_progress_type(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, + Efl_Future **future1 EINA_UNUSED) +{ +} + +static Efl_Future * _generated_future_prop1_get(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED) +{ + return NULL; +} + +static void _generated_future_prop2_get(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, int *i EINA_UNUSED, + Efl_Future **future1 EINA_UNUSED) +{ +} + +static void _generated_future_prop3_set(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, + Efl_Future *future1 EINA_UNUSED) +{ +} + +static void _generated_future_method1(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, + Efl_Future **future1 EINA_UNUSED) +{ +} + +static void _generated_future_method2(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, + Efl_Future **future1 EINA_UNUSED) +{ +} + +static void _generated_future_method3(Eo *obj EINA_UNUSED, Generated_Future_Data *pd EINA_UNUSED, + Efl_Future *future1 EINA_UNUSED) +{ + ck_assert(future1 != NULL); +} + +#include "generated_future.eo.h" +#include "generated_future.eo.c" diff --git a/src/tests/eolian/generated_future.eo b/src/tests/eolian/generated_future.eo new file mode 100644 index 0000000000..5e19c90d06 --- /dev/null +++ b/src/tests/eolian/generated_future.eo @@ -0,0 +1,58 @@ +class Generated_Future (Efl.Object) +{ + methods { + method1 { + params { + @inout future1: future; + } + } + method_progress_type { + params { + @inout future1: future; + } + } + method_multiple_args_1 { + params { + @inout future1: future; + @in data: void_ptr; + } + } + method_multiple_args_2 { + params { + @in data: void_ptr; + @inout future1: future; + } + } + method2 { + params { + @out future1: future; + } + } + method3 { + params { + @in future1: future; + } + } + @property prop1 { + get {} + values { + future1: future; + } + } + @property prop2 { + get {} + values { + i: int; + future1: future; + } + } + @property prop3 { + set {} + values { + future1: future; + } + } + } +} + +