forked from enlightenment/efl
parent
f7f8eadbd7
commit
aa4ee17c19
|
@ -41,6 +41,7 @@ include(EFLCheck)
|
|||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/examples/evas)
|
||||
add_subdirectory(src/examples/simple)
|
||||
add_subdirectory(src/examples/eo_isa)
|
||||
|
||||
add_subdirectory(src/tests/mixin)
|
||||
add_subdirectory(src/tests/signals)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
LIST(APPEND EO_ISA_CC_SOURCES
|
||||
main.c
|
||||
simple.c
|
||||
complex.c
|
||||
interface.c
|
||||
mixin.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${EINA_INCLUDE_DIRS}
|
||||
${EVAS_INCLUDE_DIRS}
|
||||
${CMAKE_SOURCE_DIR}/src/lib
|
||||
)
|
||||
|
||||
add_executable(eo_isa ${EO_ISA_CC_SOURCES})
|
||||
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(eo_isa
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(eo_isa eo)
|
|
@ -0,0 +1,18 @@
|
|||
#include "Eo.h"
|
||||
#include "complex.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define MY_CLASS COMPLEX_CLASS
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Complex",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(complex_class_get, &class_desc, SIMPLE_CLASS, NULL);
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef COMPLEX_H
|
||||
#define COMPLEX_H
|
||||
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#define COMPLEX_CLASS complex_class_get()
|
||||
const Eo_Class *complex_class_get(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
#include "Eo.h"
|
||||
#include "interface.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eo_Op INTERFACE_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS INTERFACE_CLASS
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION_CONST(INTERFACE_SUB_ID_A_POWER_3_GET, "Get the a^3"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Interface",
|
||||
EO_CLASS_TYPE_INTERFACE,
|
||||
EO_CLASS_DESCRIPTION_OPS(&INTERFACE_BASE_ID, op_desc, INTERFACE_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(interface_class_get, &class_desc, NULL, NULL)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eo_Op INTERFACE_BASE_ID;
|
||||
|
||||
enum {
|
||||
INTERFACE_SUB_ID_A_POWER_3_GET,
|
||||
INTERFACE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id)
|
||||
|
||||
|
||||
/**
|
||||
* @def interface_a_power_3_get(ret)
|
||||
* @brief Get a^3
|
||||
* @param[out] ret integer pointer to ret - value
|
||||
*/
|
||||
#define interface_a_power_3_get(ret) INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), EO_TYPECHECK(int *, ret)
|
||||
|
||||
#define INTERFACE_CLASS interface_class_get()
|
||||
const Eo_Class *interface_class_get(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "complex.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eo_init();
|
||||
|
||||
Eo *simpleobj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *complexobj = eo_add(COMPLEX_CLASS, NULL);
|
||||
|
||||
printf("Simple: isa-simple:%d isa-complex:%d isa-mixin:%d isa-interface:%d\n",
|
||||
eo_isa(simpleobj, SIMPLE_CLASS),
|
||||
eo_isa(simpleobj, COMPLEX_CLASS),
|
||||
eo_isa(simpleobj, MIXIN_CLASS),
|
||||
eo_isa(simpleobj, INTERFACE_CLASS));
|
||||
printf("Complex: isa-simple:%d isa-complex:%d isa-mixin:%d isa-interface:%d\n",
|
||||
eo_isa(complexobj, SIMPLE_CLASS),
|
||||
eo_isa(complexobj, COMPLEX_CLASS),
|
||||
eo_isa(complexobj, MIXIN_CLASS),
|
||||
eo_isa(complexobj, INTERFACE_CLASS));
|
||||
|
||||
eo_unref(simpleobj);
|
||||
eo_unref(complexobj);
|
||||
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eo_Op MIXIN_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS MIXIN_CLASS
|
||||
|
||||
static void
|
||||
_a_square_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a;
|
||||
eo_query(obj, simple_a_get(&a));
|
||||
int *ret = va_arg(*list, int *);
|
||||
if (ret)
|
||||
*ret = a * a;
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), _a_square_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_A_SQUARE_GET, "Get the value of A^2"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef MIXIN_H
|
||||
#define MIXIN_H
|
||||
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eo_Op MIXIN_BASE_ID;
|
||||
|
||||
enum {
|
||||
MIXIN_SUB_ID_A_SQUARE_GET,
|
||||
MIXIN_SUB_ID_LAST
|
||||
};
|
||||
|
||||
#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
|
||||
|
||||
|
||||
/**
|
||||
* @def mixin_a_square_get(ret)
|
||||
* @brief Get the square of a.
|
||||
* @param[out] ret the square of a
|
||||
*/
|
||||
#define mixin_a_square_get(ret) MIXIN_ID(MIXIN_SUB_ID_A_SQUARE_GET), EO_TYPECHECK(int *, ret)
|
||||
|
||||
#define MIXIN_CLASS mixin_class_get()
|
||||
const Eo_Class *mixin_class_get(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,75 @@
|
|||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int a;
|
||||
} Private_Data;
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
const Private_Data *pd = class_data;
|
||||
int *a;
|
||||
a = va_arg(*list, int *);
|
||||
*a = pd->a;
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
pd->a = a;
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
_a_power_3_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
const Private_Data *pd = class_data;
|
||||
int *ret;
|
||||
ret = va_arg(*list, int *);
|
||||
if (ret)
|
||||
*ret = pd->a * pd->a * pd->a;
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EO_OP_FUNC_CONST(INTERFACE_ID(INTERFACE_SUB_ID_A_POWER_3_GET), _a_power_3_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
|
||||
EO_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "Get property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Private_Data),
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE_CLASS, MIXIN_CLASS, NULL);
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eo.h"
|
||||
#include "interface.h"
|
||||
#include "mixin.h"
|
||||
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
SIMPLE_SUB_ID_A_GET,
|
||||
SIMPLE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
/**
|
||||
* @def simple_a_set(a)
|
||||
* @brief Set value to a-property
|
||||
* @param[in] a integer value to set
|
||||
*/
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
|
||||
/**
|
||||
* @def simple_a_get(a)
|
||||
* @brief Get value of a-property
|
||||
* @param[out] integer pointer to a-value
|
||||
*/
|
||||
#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eo_Class *simple_class_get(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue