add_subdirectory(examples/constructors)
add_subdirectory(examples/function_overrides)
add_subdirectory(examples/composite_objects)
+add_subdirectory(examples/interface)
add_subdirectory(tests EXCLUDE_FROM_ALL)
--- /dev/null
+LIST(APPEND INTERFACE_CC_SOURCES
+ main.c
+ simple.c
+ interface.c
+ interface2.c
+ )
+
+include_directories(
+ ${EINA_INCLUDE_DIRS}
+ ${EVAS_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/lib
+ )
+
+add_executable(interface ${INTERFACE_CC_SOURCES})
+
+get_target_property(eo_LIB_FILE eo LOCATION)
+target_link_libraries(interface
+ ${EINA_LIBRARIES}
+ ${EINA_LDFLAGS_OTHER}
+ ${eo_LIB_FILE}
+ )
+
+add_dependencies(interface eo)
+
+add_test(Example_interface interface)
--- /dev/null
+#include "Eo.h"
+#include "interface.h"
+#include "simple.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_AB_SUM_GET, "i", "Get the sum of a and b."),
+ 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,
+ NULL,
+ NULL
+};
+
+EO_DEFINE_CLASS(interface_class_get, &class_desc, NULL, NULL)
+
--- /dev/null
+#ifndef INTERFACE_H
+#define INTERFACE_H
+
+#include "Eo.h"
+
+extern EAPI Eo_Op INTERFACE_BASE_ID;
+
+enum {
+ INTERFACE_SUB_ID_AB_SUM_GET,
+ INTERFACE_SUB_ID_LAST
+};
+
+#define INTERFACE_ID(sub_id) (INTERFACE_BASE_ID + sub_id)
+
+
+/**
+ * @def interface_ab_sum_get(sum)
+ * @brief Get sum of a,b integer elements
+ * @param[out] sum integer pointer to sum - value
+ */
+#define interface_ab_sum_get(sum) INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum)
+
+#define INTERFACE_CLASS interface_class_get()
+const Eo_Class *interface_class_get(void) EINA_CONST;
+
+#endif
--- /dev/null
+#include "Eo.h"
+#include "interface.h"
+#include "interface2.h"
+#include "simple.h"
+
+#include "config.h"
+
+EAPI Eo_Op INTERFACE2_BASE_ID = 0;
+
+#define MY_CLASS INTERFACE2_CLASS
+
+static const Eo_Op_Description op_desc[] = {
+ EO_OP_DESCRIPTION_CONST(INTERFACE2_SUB_ID_AB_SUM_GET2, "i", "Print the sum of a and b."),
+ EO_OP_DESCRIPTION_SENTINEL
+};
+
+static const Eo_Class_Description class_desc = {
+ "Interface2",
+ EO_CLASS_TYPE_INTERFACE,
+ EO_CLASS_DESCRIPTION_OPS(&INTERFACE2_BASE_ID, op_desc, INTERFACE2_SUB_ID_LAST),
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+EO_DEFINE_CLASS(interface2_class_get, &class_desc, INTERFACE_CLASS, NULL)
+
--- /dev/null
+#ifndef INTERFACE2_H
+#define INTERFACE2_H
+
+#include "Eo.h"
+
+extern EAPI Eo_Op INTERFACE2_BASE_ID;
+
+enum {
+ INTERFACE2_SUB_ID_AB_SUM_GET2,
+ INTERFACE2_SUB_ID_LAST
+};
+
+#define INTERFACE2_ID(sub_id) (INTERFACE2_BASE_ID + sub_id)
+
+
+/**
+ * @def interface2_ab_sum_get2(sum)
+ * @brief Get sum of a,b integer elements
+ * @param[out] sum integer pointer to sum - value
+ */
+#define interface2_ab_sum_get2(sum) INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), EO_TYPECHECK(int *, sum)
+
+#define INTERFACE2_CLASS interface2_class_get()
+const Eo_Class *interface2_class_get(void) EINA_CONST;
+
+#endif
--- /dev/null
+#include "Eo.h"
+#include "simple.h"
+#include "interface.h"
+#include "interface2.h"
+
+#include "../eunit_tests.h"
+
+int
+main(int argc, char *argv[])
+{
+ (void) argc;
+ (void) argv;
+ eo_init();
+
+ Eo *obj = eo_add(SIMPLE_CLASS, NULL);
+
+ eo_do(obj, simple_a_set(1), simple_b_set(2));
+
+ int a, b, sum = 0;
+ eo_do(obj, simple_a_get(&a), simple_b_get(&b), interface_ab_sum_get(&sum));
+ fail_if(sum != a + b);
+
+ sum = 0;
+ eo_do(obj, interface_ab_sum_get(&sum), interface_ab_sum_get(&sum));
+ fail_if(sum != a + b);
+ eo_do(obj, interface2_ab_sum_get2(&sum), interface2_ab_sum_get2(&sum));
+ fail_if(sum != a + b + 1);
+
+ eo_unref(obj);
+ eo_shutdown();
+ return 0;
+}
+
--- /dev/null
+#include "Eo.h"
+#include "interface.h"
+#include "interface2.h"
+#include "simple.h"
+
+#include "config.h"
+
+EAPI Eo_Op SIMPLE_BASE_ID = 0;
+
+typedef struct
+{
+ int a;
+ int b;
+} Private_Data;
+
+#define MY_CLASS SIMPLE_CLASS
+
+#define _GET_SET_FUNC(name) \
+static void \
+_##name##_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list) \
+{ \
+ const Private_Data *pd = class_data; \
+ int *name; \
+ name = va_arg(*list, int *); \
+ *name = pd->name; \
+ printf("%s %d\n", __func__, pd->name); \
+} \
+static void \
+_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
+{ \
+ Private_Data *pd = class_data; \
+ int name; \
+ name = va_arg(*list, int); \
+ pd->name = name; \
+ printf("%s %d\n", __func__, pd->name); \
+}
+
+_GET_SET_FUNC(a)
+_GET_SET_FUNC(b)
+
+static void
+_ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
+{
+ int a, b;
+ eo_query(obj, simple_a_get(&a), simple_b_get(&b));
+ int *sum = va_arg(*list, int *);
+ if (sum)
+ *sum = a + b;
+ printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
+}
+
+static void
+_ab_sum_get2(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
+{
+ int a, b;
+ eo_query(obj, simple_a_get(&a), simple_b_get(&b));
+ int *sum = va_arg(*list, int *);
+ if (sum)
+ *sum = a + b + 1;
+ 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(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
+ EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
+ EO_OP_FUNC_CONST(INTERFACE_ID(INTERFACE_SUB_ID_AB_SUM_GET), _ab_sum_get),
+ EO_OP_FUNC_CONST(INTERFACE2_ID(INTERFACE2_SUB_ID_AB_SUM_GET2), _ab_sum_get2),
+ 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, "i", "Set property A"),
+ EO_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
+ EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
+ EO_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
+ 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),
+ NULL,
+ NULL,
+ _class_constructor,
+ NULL
+};
+
+EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, INTERFACE2_CLASS, NULL);
--- /dev/null
+#ifndef SIMPLE_H
+#define SIMPLE_H
+
+#include "Eo.h"
+
+extern EAPI Eo_Op SIMPLE_BASE_ID;
+
+enum {
+ SIMPLE_SUB_ID_A_SET,
+ SIMPLE_SUB_ID_A_GET,
+ SIMPLE_SUB_ID_B_SET,
+ SIMPLE_SUB_ID_B_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)
+
+/**
+ * @def simple_b_set(b)
+ * @brief Set value to b-property
+ * @param[in] a integer value to set
+ */
+#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
+
+/**
+ * @def simple_b_get(b)
+ * @brief Get value of b-property
+ * @param[out] integer pointer to b-value
+ */
+#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
+
+#define SIMPLE_CLASS simple_class_get()
+const Eo_Class *simple_class_get(void) EINA_CONST;
+
+#endif