summaryrefslogtreecommitdiff
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
parente2351f008642dc90d211ad1555079b4d615a3548 (diff)
eolian: add support for @optional ctor tag
This implements task 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)
43 return eolian_class_function_get_by_name(klass, 43 return eolian_class_function_get_by_name(klass,
44 ctor->full_name + strlen(klass->full_name) + 1, EOLIAN_UNRESOLVED); 44 ctor->full_name + strlen(klass->full_name) + 1, EOLIAN_UNRESOLVED);
45} 45}
46
47EAPI Eina_Bool
48eolian_constructor_is_optional(const Eolian_Constructor *ctor)
49{
50 EINA_SAFETY_ON_NULL_RETURN_VAL(ctor, EINA_FALSE);
51 return ctor->is_optional;
52}
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
30 KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \ 30 KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \
31 KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \ 31 KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \
32 KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), KWAT(empty), \ 32 KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), KWAT(empty), \
33 KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(out), \ 33 KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \
34 KWAT(private), KWAT(protected), KWAT(virtual), KWAT(warn_unused), \ 34 KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), KWAT(virtual), \
35 KWAT(warn_unused), \
35 \ 36 \
36 KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \ 37 KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
37 KW(long), KW(ulong), KW(llong), KW(ullong), \ 38 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)
1633 ls->tmp.kls->full_name, 1633 ls->tmp.kls->full_name,
1634 ls->t.value.s); 1634 ls->t.value.s);
1635 eo_lexer_get(ls); 1635 eo_lexer_get(ls);
1636 if (ls->t.kw == KW_at_optional)
1637 {
1638 eo_lexer_get(ls);
1639 ctor->is_optional = EINA_TRUE;
1640 }
1636 check_next(ls, ';'); 1641 check_next(ls, ';');
1637 return; 1642 return;
1638 } 1643 }
@@ -1651,6 +1656,11 @@ parse_constructor(Eo_Lexer *ls)
1651 if (ls->t.token != '.') break; 1656 if (ls->t.token != '.') break;
1652 eo_lexer_get(ls); 1657 eo_lexer_get(ls);
1653 } 1658 }
1659 if (ls->t.kw == KW_at_optional)
1660 {
1661 eo_lexer_get(ls);
1662 ctor->is_optional = EINA_TRUE;
1663 }
1654 check_next(ls, ';'); 1664 check_next(ls, ';');
1655 ctor->full_name = eina_stringshare_add(eina_strbuf_string_get(buf)); 1665 ctor->full_name = eina_stringshare_add(eina_strbuf_string_get(buf));
1656 pop_strbuf(ls); 1666 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
182 Eolian_Object base; 182 Eolian_Object base;
183 const Eolian_Class *klass; 183 const Eolian_Class *klass;
184 Eina_Stringshare *full_name; 184 Eina_Stringshare *full_name;
185 Eina_Bool is_optional: 1;
185}; 186};
186 187
187struct _Eolian_Event 188struct _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) {
15 Base.constructor; 15 Base.constructor;
16 Base.destructor; 16 Base.destructor;
17 } 17 }
18 constructors { 18 constructors {
19 .custom_constructor_1; 19 .custom_constructor_1;
20 .custom_constructor_2; 20 .custom_constructor_2 @optional;
21 } 21 }
22} 22}
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)
305 fail_if(!eolian_class_function_get_by_name(base, "destructor", EOLIAN_METHOD)); 305 fail_if(!eolian_class_function_get_by_name(base, "destructor", EOLIAN_METHOD));
306 fail_if(!(iter = eolian_class_constructors_get(class))); 306 fail_if(!(iter = eolian_class_constructors_get(class)));
307 fail_if(!(eina_iterator_next(iter, (void**)&ctor))); 307 fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
308 fail_if(eolian_constructor_is_optional(ctor));
308 fail_if(!(impl_class = eolian_constructor_class_get(ctor))); 309 fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
309 fail_if(!(impl_func = eolian_constructor_function_get(ctor))); 310 fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
310 fail_if(impl_class != class); 311 fail_if(impl_class != class);
@@ -312,6 +313,7 @@ START_TEST(eolian_ctor_dtor)
312 fail_if(!eolian_function_is_constructor(impl_func, class)); 313 fail_if(!eolian_function_is_constructor(impl_func, class));
313 fail_if(eolian_function_is_constructor(impl_func, base)); 314 fail_if(eolian_function_is_constructor(impl_func, base));
314 fail_if(!(eina_iterator_next(iter, (void**)&ctor))); 315 fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
316 fail_if(!eolian_constructor_is_optional(ctor));
315 fail_if(!(impl_class = eolian_constructor_class_get(ctor))); 317 fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
316 fail_if(!(impl_func = eolian_constructor_function_get(ctor))); 318 fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
317 fail_if(impl_class != class); 319 fail_if(impl_class != class);