aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2018-11-22 17:17:29 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2018-11-22 17:21:40 +0100
commitc143746dafa22e9928f599dcde5cdfe9f5e049ca (patch)
treee1ff979e310bcd9b4c795827b0bf28aab0f1374b
parenteolian: implement new inherit behavior (diff)
downloadefl-devs/q66/eolian_inherit_api.tar.gz
eolian: implement new syntax for inheritancedevs/q66/eolian_inherit_api
This new syntax separates the parent class from extensions, in a familiar way to similar to e.g. Java. Since changing everything at once is a lot of effort, implement it alongside for the time being.
-rw-r--r--src/lib/ecore/efl_loop.eo2
-rw-r--r--src/lib/eo/efl_class.eo2
-rw-r--r--src/lib/eo/efl_interface.eo2
-rw-r--r--src/lib/eo/efl_object.eo2
-rw-r--r--src/lib/eo/efl_object_override.eo2
-rw-r--r--src/lib/eolian/eo_lexer.h17
-rw-r--r--src/lib/eolian/eo_parser.c46
-rw-r--r--src/tests/efl_js/benchmark_object.eo2
-rw-r--r--src/tests/efl_mono/test_child.eo2
-rw-r--r--src/tests/efl_mono/test_numberwrapper.eo2
-rw-r--r--src/tests/efl_mono/test_testing.eo2
-rw-r--r--src/tests/eina_cxx/simple.eo2
-rw-r--r--src/tests/elementary/focus_test.eo5
-rw-r--r--src/tests/elementary/focus_test_sub_main.eo5
-rw-r--r--src/tests/eolian/data/ctor_dtor.eo2
-rw-r--r--src/tests/eolian/data/nmsp1_class1.eo2
-rw-r--r--src/tests/eolian/data/object_impl.eo2
-rw-r--r--src/tests/eolian/data/object_impl_add.eo2
-rw-r--r--src/tests/eolian/data/override.eo2
-rw-r--r--src/tests/eolian/data/parts.eo2
-rw-r--r--src/tests/eolian/generated_future.eo2
-rw-r--r--src/tests/eolian_cxx/a.eo2
-rw-r--r--src/tests/eolian_cxx/b.eo2
-rw-r--r--src/tests/eolian_cxx/c.eo2
-rw-r--r--src/tests/eolian_cxx/callback.eo2
-rw-r--r--src/tests/eolian_cxx/complex.eo2
-rw-r--r--src/tests/eolian_cxx/d.eo2
-rw-r--r--src/tests/eolian_cxx/generic.eo2
-rw-r--r--src/tests/eolian_cxx/name1_name2_type_generation.eo2
-rw-r--r--src/tests/eolian_cxx/simple.eo2
-rw-r--r--src/tests/eolian_js/constructor_method_class.eo2
-rw-r--r--src/tests/eolian_js/test_object.eo2
32 files changed, 81 insertions, 48 deletions
diff --git a/src/lib/ecore/efl_loop.eo b/src/lib/ecore/efl_loop.eo
index d3d7fc8aa3..8dcfc3e1e7 100644
--- a/src/lib/ecore/efl_loop.eo
+++ b/src/lib/ecore/efl_loop.eo
@@ -4,7 +4,7 @@ struct Efl.Loop_Arguments {
initialization: bool; [[Set to $true when the program should initialize its internal state. This happen once per process instance.]]
}
-class Efl.Loop (Efl.Task)
+class Efl.Loop extends Efl.Task
{
[[The Efl Main Loop
diff --git a/src/lib/eo/efl_class.eo b/src/lib/eo/efl_class.eo
index b40674d704..b665ec2e8c 100644
--- a/src/lib/eo/efl_class.eo
+++ b/src/lib/eo/efl_class.eo
@@ -1,4 +1,4 @@
-abstract Efl.Class ()
+abstract Efl.Class
{
[[Abstract Efl class]]
data: null;
diff --git a/src/lib/eo/efl_interface.eo b/src/lib/eo/efl_interface.eo
index acf30976de..f2d6b273b0 100644
--- a/src/lib/eo/efl_interface.eo
+++ b/src/lib/eo/efl_interface.eo
@@ -1,4 +1,4 @@
-interface Efl.Interface ()
+interface Efl.Interface
{
[[An interface for other interfaces to inherit from.
This is useful when you want to create interfaces and mixins that expose
diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo
index a0d500bfea..7507e016a6 100644
--- a/src/lib/eo/efl_object.eo
+++ b/src/lib/eo/efl_object.eo
@@ -8,7 +8,7 @@ struct Efl.Event_Description {
restart: bool; [[$true if when the event is triggered again from a callback it'll start from where it was]]
}
-abstract Efl.Object ()
+abstract Efl.Object
{
[[Abstract Efl object class]]
eo_prefix: efl;
diff --git a/src/lib/eo/efl_object_override.eo b/src/lib/eo/efl_object_override.eo
index 01bf0837cb..65f46dad03 100644
--- a/src/lib/eo/efl_object_override.eo
+++ b/src/lib/eo/efl_object_override.eo
@@ -1,4 +1,4 @@
-abstract Efl.Object_Override ()
+abstract Efl.Object_Override
{
[[A special class to pass to #eo_super() when using #eo_override()
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index fc70a0c914..d80535723d 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -25,14 +25,15 @@ enum Tokens
#define KEYWORDS KW(class), KW(const), KW(enum), KW(return), KW(struct), \
\
KW(abstract), KW(constructor), KW(constructors), KW(data), \
- KW(destructor), KW(eo), KW(eo_prefix), KW(event_prefix), KW(events), KW(free), \
- KW(get), KW(implements), KW(import), KW(interface), KW(keys), KW(legacy), \
- KW(legacy_prefix), KW(methods), KW(mixin), KW(params), KW(parse), KW(parts), \
- KW(ptr), KW(set), KW(type), KW(values), KW(var), KWAT(auto), KWAT(beta), \
- KWAT(class), KWAT(const), KWAT(cref), KWAT(empty), KWAT(extern), \
- KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(nullable), \
- KWAT(optional), KWAT(out), KWAT(owned), KWAT(private), KWAT(property), \
- KWAT(protected), KWAT(restart), KWAT(pure_virtual), \
+ KW(destructor), KW(eo), KW(eo_prefix), KW(event_prefix), KW(events), \
+ KW(extends), KW(free), KW(get), KW(implements), KW(import), KW(interface), \
+ KW(keys), KW(legacy), KW(legacy_prefix), KW(methods), KW(mixin), KW(params), \
+ KW(parse), KW(parts), KW(ptr), KW(set), KW(type), KW(values), KW(var), \
+ \
+ KWAT(auto), KWAT(beta), KWAT(class), KWAT(const), KWAT(cref), KWAT(empty), \
+ KWAT(extern), KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), \
+ KWAT(nullable), KWAT(optional), KWAT(out), KWAT(owned), KWAT(private), \
+ KWAT(property), KWAT(protected), KWAT(restart), KWAT(pure_virtual), \
KWAT(warn_unused), \
\
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 858e268710..37bed0ac1f 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -2043,23 +2043,49 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
}
eo_lexer_context_pop(ls);
eo_lexer_dtor_pop(ls);
+
+ Eina_Bool is_reg = (type == EOLIAN_CLASS_REGULAR) || (type == EOLIAN_CLASS_ABSTRACT);
if (ls->t.token != '{')
{
line = ls->line_number;
col = ls->column;
- check_next(ls, '(');
- if (ls->t.token != ')')
+ Eina_Strbuf *ibuf = eina_strbuf_new();
+ eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), ibuf);
+ /* new inherits syntax, keep alongside old for now */
+ if (ls->t.kw == KW_extends || (is_reg && (ls->t.kw == KW_implements)))
+ {
+ Eina_Bool ext = (ls->t.kw == KW_extends);
+ eo_lexer_get(ls);
+ if (is_reg && ext)
+ {
+ /* regular class can have a parent, but just one */
+ _inherit_dep(ls, ibuf, EINA_TRUE);
+ /* if not followed by implements, we're done */
+ if (ls->t.kw != KW_implements)
+ {
+ eo_lexer_dtor_pop(ls);
+ goto inherit_done;
+ }
+ eo_lexer_get(ls);
+ }
+ do
+ _inherit_dep(ls, ibuf, EINA_FALSE);
+ while (test_next(ls, ','));
+ }
+ else
{
- Eina_Strbuf *ibuf = eina_strbuf_new();
- eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), ibuf);
- _inherit_dep(ls, ibuf,
- (type == EOLIAN_CLASS_REGULAR) || (type == EOLIAN_CLASS_ABSTRACT));
- while (test_next(ls, ','))
- _inherit_dep(ls, ibuf, EINA_FALSE);
- eo_lexer_dtor_pop(ls);
+ check_next(ls, '(');
+ if (ls->t.token != ')')
+ {
+ _inherit_dep(ls, ibuf, is_reg);
+ while (test_next(ls, ','))
+ _inherit_dep(ls, ibuf, EINA_FALSE);
+ }
+ check_match(ls, ')', '(', line, col);
}
- check_match(ls, ')', '(', line, col);
+ eo_lexer_dtor_pop(ls);
}
+inherit_done:
line = ls->line_number;
col = ls->column;
check_next(ls, '{');
diff --git a/src/tests/efl_js/benchmark_object.eo b/src/tests/efl_js/benchmark_object.eo
index 4441ac2ffc..65b65665e2 100644
--- a/src/tests/efl_js/benchmark_object.eo
+++ b/src/tests/efl_js/benchmark_object.eo
@@ -1,4 +1,4 @@
-class Benchmark_Object (Efl.Object)
+class Benchmark_Object extends Efl.Object
{
data: null;
methods {
diff --git a/src/tests/efl_mono/test_child.eo b/src/tests/efl_mono/test_child.eo
index d12ba6d3c6..0d37c19346 100644
--- a/src/tests/efl_mono/test_child.eo
+++ b/src/tests/efl_mono/test_child.eo
@@ -1,6 +1,6 @@
import eina_types;
-class Test.Child (Test.Testing) {
+class Test.Child extends Test.Testing {
implements {
class.constructor;
diff --git a/src/tests/efl_mono/test_numberwrapper.eo b/src/tests/efl_mono/test_numberwrapper.eo
index 3402fbd54f..6f749f9c34 100644
--- a/src/tests/efl_mono/test_numberwrapper.eo
+++ b/src/tests/efl_mono/test_numberwrapper.eo
@@ -1,4 +1,4 @@
-class Test.Numberwrapper (Efl.Object) {
+class Test.Numberwrapper extends Efl.Object {
methods {
@property number {
get {
diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo
index 26692ea948..c46963e5c7 100644
--- a/src/tests/efl_mono/test_testing.eo
+++ b/src/tests/efl_mono/test_testing.eo
@@ -91,7 +91,7 @@ function Test.FormatCb {
}
};
-class Test.Testing (Efl.Object, Efl.Part) {
+class Test.Testing extends Efl.Object implements Efl.Part {
parts {
part1: Test.Testing; [[ Part number one. ]]
diff --git a/src/tests/eina_cxx/simple.eo b/src/tests/eina_cxx/simple.eo
index 1a76d231de..8750b700ab 100644
--- a/src/tests/eina_cxx/simple.eo
+++ b/src/tests/eina_cxx/simple.eo
@@ -1,4 +1,4 @@
-class Simple (Efl.Object)
+class Simple extends Efl.Object
{
data: null;
implements {
diff --git a/src/tests/elementary/focus_test.eo b/src/tests/elementary/focus_test.eo
index 8be44ed295..1293b6535a 100644
--- a/src/tests/elementary/focus_test.eo
+++ b/src/tests/elementary/focus_test.eo
@@ -1,4 +1,7 @@
-class Focus.Test(Efl.Object, Efl.Ui.Focus.Object, Efl.Gfx.Entity) {
+class Focus.Test
+ extends Efl.Object
+ implements Efl.Ui.Focus.Object, Efl.Gfx.Entity
+{
methods {
test_size {
params {
diff --git a/src/tests/elementary/focus_test_sub_main.eo b/src/tests/elementary/focus_test_sub_main.eo
index ebf835831f..d259d38787 100644
--- a/src/tests/elementary/focus_test_sub_main.eo
+++ b/src/tests/elementary/focus_test_sub_main.eo
@@ -1,4 +1,7 @@
-class Focus.Test.Sub.Main(Efl.Object, Efl.Ui.Focus.Object, Efl.Ui.Focus.Manager_Sub) {
+class Focus.Test.Sub.Main
+ extends Efl.Object
+ implements Efl.Ui.Focus.Object, Efl.Ui.Focus.Manager_Sub
+{
implements {
Efl.Ui.Focus.Object.focus_manager { get; }
Efl.Ui.Focus.Object.focus_parent { get; }
diff --git a/src/tests/eolian/data/ctor_dtor.eo b/src/tests/eolian/data/ctor_dtor.eo
index 98452b1018..256dcc0a4d 100644
--- a/src/tests/eolian/data/ctor_dtor.eo
+++ b/src/tests/eolian/data/ctor_dtor.eo
@@ -1,4 +1,4 @@
-class Ctor_Dtor (Base) {
+class Ctor_Dtor extends Base {
methods {
custom_constructor_1 {
params {
diff --git a/src/tests/eolian/data/nmsp1_class1.eo b/src/tests/eolian/data/nmsp1_class1.eo
index 42d6c04948..a494e5e1c5 100644
--- a/src/tests/eolian/data/nmsp1_class1.eo
+++ b/src/tests/eolian/data/nmsp1_class1.eo
@@ -1,4 +1,4 @@
-class nmsp1.class1 (nmsp1.nmsp11.class2, nmsp2.class1, no_nmsp)
+class nmsp1.class1 extends nmsp1.nmsp11.class2 implements nmsp2.class1, no_nmsp
{
implements {
nmsp1.nmsp11.class2.a { set; }
diff --git a/src/tests/eolian/data/object_impl.eo b/src/tests/eolian/data/object_impl.eo
index 7019225118..e646a70ea4 100644
--- a/src/tests/eolian/data/object_impl.eo
+++ b/src/tests/eolian/data/object_impl.eo
@@ -1,4 +1,4 @@
-class Object_Impl (Base) {
+class Object_Impl extends Base {
methods {
@property a {
set {
diff --git a/src/tests/eolian/data/object_impl_add.eo b/src/tests/eolian/data/object_impl_add.eo
index 4059110c08..e9e97c009f 100644
--- a/src/tests/eolian/data/object_impl_add.eo
+++ b/src/tests/eolian/data/object_impl_add.eo
@@ -1,4 +1,4 @@
-class Object_Impl_Add (Base) {
+class Object_Impl_Add extends Base {
data: Object_Impl_Data;
methods {
diff --git a/src/tests/eolian/data/override.eo b/src/tests/eolian/data/override.eo
index 16ed52981c..440dc2125b 100644
--- a/src/tests/eolian/data/override.eo
+++ b/src/tests/eolian/data/override.eo
@@ -1,4 +1,4 @@
-class Override (Base) {
+class Override extends Base {
methods {
@property a {
set @pure_virtual {
diff --git a/src/tests/eolian/data/parts.eo b/src/tests/eolian/data/parts.eo
index 286d1e432f..773282d728 100644
--- a/src/tests/eolian/data/parts.eo
+++ b/src/tests/eolian/data/parts.eo
@@ -1,4 +1,4 @@
-class Parts (Override, Base) {
+class Parts extends Override implements Base {
parts {
part1: Override; [[Part 1]]
part2: Base; [[Part 2]]
diff --git a/src/tests/eolian/generated_future.eo b/src/tests/eolian/generated_future.eo
index 96ccc3ad74..4cf5518f93 100644
--- a/src/tests/eolian/generated_future.eo
+++ b/src/tests/eolian/generated_future.eo
@@ -1,4 +1,4 @@
-class Generated_Future (Efl.Object)
+class Generated_Future extends Efl.Object
{
methods {
}
diff --git a/src/tests/eolian_cxx/a.eo b/src/tests/eolian_cxx/a.eo
index de330a4a7f..cc94262821 100644
--- a/src/tests/eolian_cxx/a.eo
+++ b/src/tests/eolian_cxx/a.eo
@@ -1,4 +1,4 @@
-class A (Efl.Object)
+class A extends Efl.Object
{
data: A_Data;
implements {
diff --git a/src/tests/eolian_cxx/b.eo b/src/tests/eolian_cxx/b.eo
index 291865a37a..c293edc9c0 100644
--- a/src/tests/eolian_cxx/b.eo
+++ b/src/tests/eolian_cxx/b.eo
@@ -1,4 +1,4 @@
-class B (A)
+class B extends A
{
data: B_Data;
implements {
diff --git a/src/tests/eolian_cxx/c.eo b/src/tests/eolian_cxx/c.eo
index c784e0f95a..47c96cc1c5 100644
--- a/src/tests/eolian_cxx/c.eo
+++ b/src/tests/eolian_cxx/c.eo
@@ -1,4 +1,4 @@
-class C (A)
+class C extends A
{
data: C_Data;
implements {
diff --git a/src/tests/eolian_cxx/callback.eo b/src/tests/eolian_cxx/callback.eo
index b72e932f60..3f4cd9effe 100644
--- a/src/tests/eolian_cxx/callback.eo
+++ b/src/tests/eolian_cxx/callback.eo
@@ -4,7 +4,7 @@ struct Callback_Event
field2: list<int*>;
}
-class Callback (Efl.Object)
+class Callback extends Efl.Object
{
data: Callback_Data;
events {
diff --git a/src/tests/eolian_cxx/complex.eo b/src/tests/eolian_cxx/complex.eo
index e4400ddb93..13ed1ca385 100644
--- a/src/tests/eolian_cxx/complex.eo
+++ b/src/tests/eolian_cxx/complex.eo
@@ -1,4 +1,4 @@
-class Complex (Efl.Object)
+class Complex extends Efl.Object
{
data: Complex_Data;
methods {
diff --git a/src/tests/eolian_cxx/d.eo b/src/tests/eolian_cxx/d.eo
index 1a5d2b3202..a3bf2a587f 100644
--- a/src/tests/eolian_cxx/d.eo
+++ b/src/tests/eolian_cxx/d.eo
@@ -1,4 +1,4 @@
-class D (B, C)
+class D extends B implements C
{
data: D_Data;
implements {
diff --git a/src/tests/eolian_cxx/generic.eo b/src/tests/eolian_cxx/generic.eo
index d21473c067..6282cbaa95 100644
--- a/src/tests/eolian_cxx/generic.eo
+++ b/src/tests/eolian_cxx/generic.eo
@@ -5,7 +5,7 @@ struct Generic.Event
field2: list<ptr(int)>;
}
-class Generic (Efl.Object)
+class Generic extends Efl.Object
{
data: Generic_Data;
methods {
diff --git a/src/tests/eolian_cxx/name1_name2_type_generation.eo b/src/tests/eolian_cxx/name1_name2_type_generation.eo
index 8e745be7b8..683cf9f031 100644
--- a/src/tests/eolian_cxx/name1_name2_type_generation.eo
+++ b/src/tests/eolian_cxx/name1_name2_type_generation.eo
@@ -1,4 +1,4 @@
-class Name1.Name2.Type_Generation (Efl.Object)
+class Name1.Name2.Type_Generation extends Efl.Object
{
data: Type_Generation_Data;
methods {
diff --git a/src/tests/eolian_cxx/simple.eo b/src/tests/eolian_cxx/simple.eo
index 003a3e65ad..f6f340f131 100644
--- a/src/tests/eolian_cxx/simple.eo
+++ b/src/tests/eolian_cxx/simple.eo
@@ -1,4 +1,4 @@
-class Simple (Efl.Object)
+class Simple extends Efl.Object
{
data: null;
methods {
diff --git a/src/tests/eolian_js/constructor_method_class.eo b/src/tests/eolian_js/constructor_method_class.eo
index ed77e85d70..206f2df966 100644
--- a/src/tests/eolian_js/constructor_method_class.eo
+++ b/src/tests/eolian_js/constructor_method_class.eo
@@ -1,4 +1,4 @@
-class Constructor_Method_Class (Efl.Object)
+class Constructor_Method_Class extends Efl.Object
{
data: Constructor_Method_Class_Data;
methods {
diff --git a/src/tests/eolian_js/test_object.eo b/src/tests/eolian_js/test_object.eo
index ea81366162..d1aed0ac2f 100644
--- a/src/tests/eolian_js/test_object.eo
+++ b/src/tests/eolian_js/test_object.eo
@@ -10,7 +10,7 @@ struct Test.Struct_Ex {
value_enum: Test.Enum_Ex;
}
-class Test.Object (Efl.Object) {
+class Test.Object extends Efl.Object {
methods {
method_integral_in_a_check {
[[ tests integral in ]]