eo-multiinherit: Clone from eo-inherit before interface removal
Mixins still to come
This commit is contained in:
parent
09ff6b7b62
commit
6e78b6caa3
|
@ -0,0 +1,13 @@
|
|||
project(
|
||||
'efl-example-eo-multiinherit', 'c',
|
||||
version : '0.0.1',
|
||||
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
|
||||
meson_version : '>= 0.38.0')
|
||||
|
||||
eina = dependency('eina', version : '>=1.20.99')
|
||||
efl = dependency('efl-core', version : '>=1.20.99')
|
||||
dependency('eolian', version : '>=1.20.99')
|
||||
|
||||
inc = include_directories('.')
|
||||
subdir('src')
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _EO_CLASSES_H
|
||||
#define _EO_CLASSES_H 1
|
||||
|
||||
#define EFL_EO_API_SUPPORT 1
|
||||
#ifndef EFL_BETA_API_SUPPORT
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Efl_Core.h>
|
||||
|
||||
#include "example_shape.eo.h"
|
||||
#include "example_rectangle.eo.h"
|
||||
#include "example_square.eo.h"
|
||||
#include "example_circle.eo.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,66 @@
|
|||
#include "eo_inherit.h"
|
||||
|
||||
Example_Shape *
|
||||
_rectangle_create()
|
||||
{
|
||||
Example_Rectangle *rectangle;
|
||||
|
||||
rectangle = efl_add(EXAMPLE_RECTANGLE_CLASS, NULL,
|
||||
efl_name_set(efl_added, "Rectangle"),
|
||||
example_rectangle_width_set(efl_added, 5),
|
||||
example_rectangle_height_set(efl_added, 10));
|
||||
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
Example_Shape *
|
||||
_square_create()
|
||||
{
|
||||
Example_Square *square;
|
||||
|
||||
square = efl_add(EXAMPLE_SQUARE_CLASS, NULL,
|
||||
efl_name_set(efl_added, "Square"),
|
||||
example_rectangle_width_set(efl_added, 7));
|
||||
|
||||
return square;
|
||||
}
|
||||
|
||||
Example_Shape *
|
||||
_circle_create()
|
||||
{
|
||||
Example_Circle *circle;
|
||||
|
||||
circle = efl_add(EXAMPLE_CIRCLE_CLASS, NULL,
|
||||
efl_name_set(efl_added, "Circle"),
|
||||
example_circle_radius_set(efl_added, 5));
|
||||
|
||||
return circle;
|
||||
}
|
||||
|
||||
void
|
||||
_shape_print(Example_Shape *shape)
|
||||
{
|
||||
printf("Shape named %s has area %d\n", efl_name_get(shape), example_shape_area(shape));
|
||||
}
|
||||
|
||||
EAPI_MAIN void
|
||||
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||
{
|
||||
Eo *shape;
|
||||
|
||||
shape = _rectangle_create();
|
||||
_shape_print(shape);
|
||||
efl_unref(shape);
|
||||
|
||||
shape = _square_create();
|
||||
_shape_print(shape);
|
||||
efl_unref(shape);
|
||||
|
||||
shape = _circle_create();
|
||||
_shape_print(shape);
|
||||
efl_unref(shape);
|
||||
|
||||
efl_exit(0);
|
||||
}
|
||||
EFL_MAIN()
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#define EFL_BETA_API_SUPPORT
|
||||
#include <Eo.h>
|
||||
#include "example_circle.eo.h"
|
||||
|
||||
#include "eo_inherit.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int radius;
|
||||
} Example_Circle_Data;
|
||||
|
||||
EOLIAN static void
|
||||
_example_circle_radius_set(Eo *obj EINA_UNUSED, Example_Circle_Data *pd, int radius)
|
||||
{
|
||||
pd->radius = radius;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_circle_radius_get(Eo *obj EINA_UNUSED , Example_Circle_Data *pd)
|
||||
{
|
||||
return pd->radius;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_circle_example_shape_area(Eo *obj EINA_UNUSED, Example_Circle_Data *pd)
|
||||
{
|
||||
return (int)(pd->radius * pd->radius * 3.14159f);
|
||||
}
|
||||
|
||||
#include "example_circle.eo.c"
|
|
@ -0,0 +1,18 @@
|
|||
class Example.Circle (Efl.Object, Example.Shape) {
|
||||
[[A circle shape object]]
|
||||
methods {
|
||||
@property radius {
|
||||
[[The radius of this circle]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
radius: int;
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Example.Shape.area;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#define EFL_BETA_API_SUPPORT
|
||||
#include <Eo.h>
|
||||
#include "example_rectangle.eo.h"
|
||||
|
||||
#include "eo_inherit.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int width, height;
|
||||
} Example_Rectangle_Data;
|
||||
|
||||
EOLIAN static void
|
||||
_example_rectangle_width_set(Eo *obj EINA_UNUSED, Example_Rectangle_Data *pd, int width)
|
||||
{
|
||||
pd->width = width;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_rectangle_width_get(Eo *obj EINA_UNUSED, Example_Rectangle_Data *pd)
|
||||
{
|
||||
return pd->width;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_example_rectangle_height_set(Eo *obj EINA_UNUSED, Example_Rectangle_Data *pd, int height)
|
||||
{
|
||||
pd->height = height;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_rectangle_height_get(Eo *obj EINA_UNUSED, Example_Rectangle_Data *pd)
|
||||
{
|
||||
return pd->height;
|
||||
}
|
||||
|
||||
EOLIAN static int
|
||||
_example_rectangle_example_shape_area(Eo *obj EINA_UNUSED, Example_Rectangle_Data *pd)
|
||||
{
|
||||
return pd->width * pd->height;
|
||||
}
|
||||
|
||||
#include "example_rectangle.eo.c"
|
|
@ -0,0 +1,28 @@
|
|||
class Example.Rectangle (Efl.Object, Example.Shape) {
|
||||
[[A rectangle shape object]]
|
||||
methods {
|
||||
@property width {
|
||||
[[The width of this rectangle]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
width: int; [[Rectangle width]]
|
||||
}
|
||||
}
|
||||
@property height {
|
||||
[[The height of this rectangle]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
height: int; [[Rectangle height]]
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Example.Shape.area;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#define EFL_BETA_API_SUPPORT
|
||||
#include <Eo.h>
|
||||
#include "example_shape.eo.h"
|
||||
|
||||
#include "eo_inherit.h"
|
||||
|
||||
#include "example_shape.eo.c"
|
|
@ -0,0 +1,11 @@
|
|||
interface Example.Shape {
|
||||
[[A generic shape object]]
|
||||
methods {
|
||||
area {
|
||||
[[Calculate the area of the shape.]]
|
||||
params {
|
||||
}
|
||||
return: int;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#define EFL_BETA_API_SUPPORT
|
||||
#include <Eo.h>
|
||||
#include "example_square.eo.h"
|
||||
|
||||
#include "eo_inherit.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
} Example_Square_Data;
|
||||
|
||||
EOLIAN static void
|
||||
_example_square_example_rectangle_width_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int width)
|
||||
{
|
||||
example_rectangle_width_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
|
||||
example_rectangle_height_set(efl_super(obj, EXAMPLE_SQUARE_CLASS), width);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_example_square_example_rectangle_height_set(Eo *obj, Example_Square_Data *pd EINA_UNUSED, int height)
|
||||
{
|
||||
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"
|
|
@ -0,0 +1,7 @@
|
|||
class Example.Square (Example.Rectangle) {
|
||||
[[A square shape object]]
|
||||
implements {
|
||||
Example.Rectangle.width {set;}
|
||||
Example.Rectangle.height {set;}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
eolian_gen = find_program('eolian_gen')
|
||||
|
||||
eo_src = ['example_shape', 'example_rectangle', 'example_square', 'example_circle']
|
||||
eo_csrc = []
|
||||
eo_gen = []
|
||||
|
||||
foreach eo : eo_src
|
||||
eo_file = eo + '.eo'
|
||||
eo_csrc += eo + '.c'
|
||||
|
||||
eo_gen += custom_target('eolian_gen_' + eo_file,
|
||||
input : eo_file,
|
||||
output : [eo_file + '.h'],
|
||||
command : [eolian_gen, '-I', meson.current_source_dir(),
|
||||
'-gchi',
|
||||
'-o', 'i:' + join_paths(meson.current_source_dir(), eo + '.c'),
|
||||
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
|
||||
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'), '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
src = files([
|
||||
'eo_inherit.h',
|
||||
'eo_inherit_main.c',
|
||||
])
|
||||
|
||||
deps = [eina, efl]
|
||||
|
||||
executable('efl_example_eo_multiinherit', src, eo_csrc, eo_gen,
|
||||
dependencies : deps,
|
||||
include_directories : inc,
|
||||
install : true
|
||||
)
|
||||
|
Loading…
Reference in New Issue