Simplify eo-inherit even more

Square does not need "side", can use the parent's setters to make sure width=height always.
This commit is contained in:
Xavi Artigas 2017-11-15 18:20:42 +01:00
parent 1e380eace9
commit ae932ce226
3 changed files with 11 additions and 18 deletions

View File

@ -20,7 +20,7 @@ _square_create()
square = efl_add(EXAMPLE_SQUARE_CLASS, NULL, square = efl_add(EXAMPLE_SQUARE_CLASS, NULL,
efl_name_set(efl_added, "Square"), efl_name_set(efl_added, "Square"),
example_square_side_set(efl_added, 7)); example_rectangle_width_set(efl_added, 7));
return square; return square;
} }

View File

@ -10,16 +10,17 @@ typedef struct
} Example_Square_Data; } Example_Square_Data;
EOLIAN static void EOLIAN static void
_example_square_side_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int size) _example_square_example_rectangle_width_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int width)
{ {
example_rectangle_width_set(obj, size); example_rectangle_width_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
example_rectangle_height_set(obj, size); example_rectangle_height_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
} }
EOLIAN static int EOLIAN static void
_example_square_side_get(Eo *obj, Example_Square_Data *pd EINA_UNUSED) _example_square_example_rectangle_height_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int height)
{ {
return example_rectangle_width_get(obj); example_rectangle_width_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), height);
example_rectangle_height_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), height);
} }
#include "example_square.eo.c" #include "example_square.eo.c"

View File

@ -1,15 +1,7 @@
class Example.Square (Example.Rectangle) { class Example.Square (Example.Rectangle) {
[[A square shape object]] [[A square shape object]]
methods { implements {
@property side { Example.Rectangle.width {set;}
[[The length of both sides of this square]] Example.Rectangle.height {set;}
set {
}
get {
}
values {
size: int; [[Square side length]]
}
}
} }
} }