aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-11-20 15:21:44 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-11-20 15:21:55 +0000
commitd26152391f697da592c3ae29d0c000dc9bbba613 (patch)
tree173f03630e967b2cd8caf5951e6014de97cfcb7e
parentallow for loading of eo.lua files from module path (diff)
downloadefl-d26152391f697da592c3ae29d0c000dc9bbba613.tar.gz
eolian: add support for @optional ctor tag
This implements task https://phab.enlightenment.org/T1804. @feature
-rw-r--r--src/lib/eolian/database_constructor_api.c7
-rw-r--r--src/lib/eolian/eo_lexer.h5
-rw-r--r--src/lib/eolian/eo_parser.c10
-rw-r--r--src/lib/eolian/eolian_database.h1
-rw-r--r--src/tests/eolian/data/ctor_dtor.eo8
-rw-r--r--src/tests/eolian/eolian_parsing.c2
6 files changed, 27 insertions, 6 deletions
diff --git a/src/lib/eolian/database_constructor_api.c b/src/lib/eolian/database_constructor_api.c
index ccfd11c4d5..9e44e75199 100644
--- a/src/lib/eolian/database_constructor_api.c
+++ b/src/lib/eolian/database_constructor_api.c
@@ -43,3 +43,10 @@ eolian_constructor_function_get(const Eolian_Constructor *ctor)
return eolian_class_function_get_by_name(klass,
ctor->full_name + strlen(klass->full_name) + 1, EOLIAN_UNRESOLVED);
}
+
+EAPI Eina_Bool
+eolian_constructor_is_optional(const Eolian_Constructor *ctor)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ctor, EINA_FALSE);
+ return ctor->is_optional;
+}
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 09d3ca641a..f140ba1c18 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -30,8 +30,9 @@ enum Tokens
KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \
KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \
KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), KWAT(empty), \
- KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(out), \
- KWAT(private), KWAT(protected), KWAT(virtual), KWAT(warn_unused), \
+ KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \
+ KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), KWAT(virtual), \
+ KWAT(warn_unused), \
\
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
KW(long), KW(ulong), KW(llong), KW(ullong), \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 5c2ada78df..8fd51f5a2a 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1633,6 +1633,11 @@ parse_constructor(Eo_Lexer *ls)
ls->tmp.kls->full_name,
ls->t.value.s);
eo_lexer_get(ls);
+ if (ls->t.kw == KW_at_optional)
+ {
+ eo_lexer_get(ls);
+ ctor->is_optional = EINA_TRUE;
+ }
check_next(ls, ';');
return;
}
@@ -1651,6 +1656,11 @@ parse_constructor(Eo_Lexer *ls)
if (ls->t.token != '.') break;
eo_lexer_get(ls);
}
+ if (ls->t.kw == KW_at_optional)
+ {
+ eo_lexer_get(ls);
+ ctor->is_optional = EINA_TRUE;
+ }
check_next(ls, ';');
ctor->full_name = eina_stringshare_add(eina_strbuf_string_get(buf));
pop_strbuf(ls);
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index ddf50a4787..c339076a12 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -182,6 +182,7 @@ struct _Eolian_Constructor
Eolian_Object base;
const Eolian_Class *klass;
Eina_Stringshare *full_name;
+ Eina_Bool is_optional: 1;
};
struct _Eolian_Event
diff --git a/src/tests/eolian/data/ctor_dtor.eo b/src/tests/eolian/data/ctor_dtor.eo
index e1b6cfc66d..6015630974 100644
--- a/src/tests/eolian/data/ctor_dtor.eo
+++ b/src/tests/eolian/data/ctor_dtor.eo
@@ -15,8 +15,8 @@ class Ctor_Dtor (Base) {
Base.constructor;
Base.destructor;
}
- constructors {
- .custom_constructor_1;
- .custom_constructor_2;
- }
+ constructors {
+ .custom_constructor_1;
+ .custom_constructor_2 @optional;
+ }
}
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index d71464b152..03d6a56af1 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -305,6 +305,7 @@ START_TEST(eolian_ctor_dtor)
fail_if(!eolian_class_function_get_by_name(base, "destructor", EOLIAN_METHOD));
fail_if(!(iter = eolian_class_constructors_get(class)));
fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
+ fail_if(eolian_constructor_is_optional(ctor));
fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
fail_if(impl_class != class);
@@ -312,6 +313,7 @@ START_TEST(eolian_ctor_dtor)
fail_if(!eolian_function_is_constructor(impl_func, class));
fail_if(eolian_function_is_constructor(impl_func, base));
fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
+ fail_if(!eolian_constructor_is_optional(ctor));
fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
fail_if(impl_class != class);