Compare commits

...

3 Commits

Author SHA1 Message Date
Marcel Hollerbach 610a3f26fb thats the correct header! 2017-11-14 12:08:04 +01:00
Marcel Hollerbach a94d431358 that should not be part of the build file 2017-11-14 12:06:38 +01:00
Marcel Hollerbach 2a3dc84120 lib-sample! 2017-11-14 09:21:07 +01:00
10 changed files with 315 additions and 0 deletions

View File

@ -0,0 +1,14 @@
project(
'efl-example-eo-lib', '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', version : '>=1.20.99')
elm = dependency('elementary', version : '>=1.20.99')
eolian = dependency('eolian', version : '>=1.20.99')
inc = include_directories('.')
subdir('src')

View File

@ -0,0 +1,12 @@
#ifndef LIB_H
#define LIB_H
#include <Eina.h>
#include <Efl.h>
#include <Elementary.h>
#include "example_shape.eo.h"
#include "example_rectangle.eo.h"
#include "example_square.eo.h"
#endif

View File

@ -0,0 +1,50 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include "Lib.h"
Example_Shape *
_rect_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_square_side_set(efl_added, 7));
return square;
}
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 = _rect_create();
_shape_print(shape);
shape = _square_create();
_shape_print(shape);
efl_exit(0);
}
EFL_MAIN()

View File

@ -0,0 +1,51 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include "Lib.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;
}
EOLIAN static void
_example_rectangle_class_constructor(Efl_Class *klass EINA_UNUSED)
{
}
EOLIAN static void
_example_rectangle_class_destructor(Efl_Class *klass EINA_UNUSED)
{
}
#include "example_rectangle.eo.x"

View File

@ -0,0 +1,31 @@
class Example.Rectangle (Efl.Object, Example.Shape) {
[[A rectangle shape object]]
eo_prefix: example_rectangle;
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 {
class.constructor;
class.destructor;
Example.Shape.area;
}
}

View File

@ -0,0 +1,5 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <Eo.h>
#include "Lib.h"
#include "example_shape.eo.x"

View File

@ -0,0 +1,24 @@
interface Example.Shape {
[[A generic shape object]]
eo_prefix: example_shape;
methods {
@property color {
[[The colour that our shape should be filled with]]
set {
}
get {
}
values {
r: int; [[Red component color]]
g: int; [[Green component color]]
b: int; [[Blue component color]]
}
}
area {
[[Calculate the area of the shape.]]
params {
}
return: int;
}
}
}

View File

@ -0,0 +1,63 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <Eo.h>
#include "Lib.h"
typedef struct
{
int size;
} Example_Square_Data;
EOLIAN static void
_example_square_side_set(Eo *obj EINA_UNUSED, Example_Square_Data *pd, int size)
{
pd->size = size;
}
EOLIAN static int
_example_square_side_get(Eo *obj EINA_UNUSED, Example_Square_Data *pd)
{
return pd->size;
}
EOLIAN static void
_example_square_example_rectangle_width_set(Eo *obj EINA_UNUSED, Example_Square_Data *pd, int width)
{
pd->size = width;
}
EOLIAN static int
_example_square_example_rectangle_width_get(Eo *obj EINA_UNUSED, Example_Square_Data *pd)
{
return pd->size;
}
EOLIAN static void
_example_square_example_rectangle_height_set(Eo *obj EINA_UNUSED, Example_Square_Data *pd, int height)
{
pd->size = height;
}
EOLIAN static int
_example_square_example_rectangle_height_get(Eo *obj EINA_UNUSED, Example_Square_Data *pd)
{
return pd->size;
}
EOLIAN static int
_example_square_example_shape_area(Eo *obj EINA_UNUSED, Example_Square_Data *pd)
{
return pd->size * pd->size;
}
EOLIAN static void
_example_square_class_constructor(Efl_Class *klass EINA_UNUSED)
{
}
EOLIAN static void
_example_square_class_destructor(Efl_Class *klass EINA_UNUSED)
{
}
#include "example_square.eo.x"

View File

@ -0,0 +1,23 @@
class Example.Square (Example.Rectangle) {
[[A square shape object]]
eo_prefix: example_square;
methods {
@property side {
[[The length of both sides of this square]]
set {
}
get {
}
values {
size: int; [[Square side length]]
}
}
}
implements {
class.constructor;
class.destructor;
Example.Shape.area;
Example.Rectangle.width {get; set;}
Example.Rectangle.height {get; set;}
}
}

View File

@ -0,0 +1,42 @@
eolian_gen = find_program('eolian_gen')
eo_src = ['example_shape', 'example_rectangle', 'example_square']
eo_csrc = []
eo_gen = []
eo_header_public = []
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 + '.x'],
command : [eolian_gen, '-I', eolian.get_pkgconfig_variable('eoincludedir'),
'-I', meson.source_root() + '/src/',
'-gc', '-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.x'),
'@INPUT@'])
eo_header_public += custom_target('eolian_gen_h' + eo_file,
input : eo_file,
output : [eo_file + '.h'],
command : [eolian_gen, '-I', eolian.get_pkgconfig_variable('eoincludedir'),
'-I', meson.source_root() + '/src/',
'-gh', '-o', 'h:' + join_paths(meson.current_build_dir(),eo_file + '.h'),
'@INPUT@'],
install : true,
install_dir : '/tmp/')
endforeach
src = files([
'Lib.h',
'eo_classes_main.c',
])
deps = [eina, efl, elm]
library('efl_example_eo_lib', src, eo_csrc, eo_gen,
dependencies : deps,
include_directories : inc,
install : true
)