forked from enlightenment/efl
parent
cc87921515
commit
816a4ad71d
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project(eobj)
|
||||
project(eo)
|
||||
set(VMAJ 0)
|
||||
set(VMIN 1)
|
||||
set(VMIC 0)
|
||||
|
@ -53,10 +53,10 @@ add_subdirectory(doc)
|
|||
|
||||
# PKGCONFIG file.
|
||||
CONFIGURE_FILE(
|
||||
"${PROJECT_SOURCE_DIR}/eobj.pc.in"
|
||||
"${PROJECT_BINARY_DIR}/eobj.pc"
|
||||
"${PROJECT_SOURCE_DIR}/eo.pc.in"
|
||||
"${PROJECT_BINARY_DIR}/eo.pc"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/eobj.pc"
|
||||
INSTALL(FILES "${PROJECT_BINARY_DIR}/eo.pc"
|
||||
DESTINATION "lib/pkgconfig")
|
||||
|
|
|
@ -25,7 +25,7 @@ DOXYFILE_ENCODING = UTF-8
|
|||
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
|
||||
# by quotes) that should identify the project.
|
||||
|
||||
PROJECT_NAME = Eobj
|
||||
PROJECT_NAME = Eo
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||
# This could be handy for archiving the generated documentation or
|
||||
|
@ -793,12 +793,12 @@ COLS_IN_ALPHA_INDEX = 2
|
|||
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
|
||||
# should be ignored while generating the index headers.
|
||||
|
||||
IGNORE_PREFIX = eobj_ \
|
||||
_eobj_ \
|
||||
Eobj_ \
|
||||
_Eobj_ \
|
||||
EOBJ_ \
|
||||
_EOBJ_
|
||||
IGNORE_PREFIX = eo_ \
|
||||
_eo_ \
|
||||
Eo_ \
|
||||
_Eo_ \
|
||||
EO_ \
|
||||
_EO_
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
|
@ -912,13 +912,13 @@ DOCSET_FEEDNAME = "Doxygen generated docs"
|
|||
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
|
||||
# will append .docset to the name.
|
||||
|
||||
DOCSET_BUNDLE_ID = org.enlightenment.Eobj
|
||||
DOCSET_BUNDLE_ID = org.enlightenment.Eo
|
||||
|
||||
# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
|
||||
# the documentation publisher. This should be a reverse domain-name style
|
||||
# string, e.g. com.mycompany.MyDocSet.documentation.
|
||||
|
||||
DOCSET_PUBLISHER_ID = org.enlightenment.Eobj
|
||||
DOCSET_PUBLISHER_ID = org.enlightenment.Eo
|
||||
|
||||
# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
|
||||
|
||||
|
@ -985,7 +985,7 @@ QCH_FILE =
|
|||
# Qt Help Project output. For more information please see
|
||||
# http://doc.trolltech.com/qthelpproject.html#namespace
|
||||
|
||||
QHP_NAMESPACE = org.enlightenment.Eobj
|
||||
QHP_NAMESPACE = org.enlightenment.Eo
|
||||
|
||||
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
|
||||
# Qt Help Project output. For more information please see
|
||||
|
@ -1036,7 +1036,7 @@ GENERATE_ECLIPSEHELP = NO
|
|||
# the directory name containing the HTML and XML files should also have
|
||||
# this name.
|
||||
|
||||
ECLIPSE_DOC_ID = org.enlightenment.Eobj
|
||||
ECLIPSE_DOC_ID = org.enlightenment.Eo
|
||||
|
||||
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
|
||||
# top of each HTML page. The value NO (the default) enables the index and
|
||||
|
@ -1418,14 +1418,16 @@ INCLUDE_FILE_PATTERNS =
|
|||
# undefined via #undef or recursively expanded use the := operator
|
||||
# instead of the = operator.
|
||||
|
||||
PREDEFINED = EOBJ_MAGIC_DEBUG \
|
||||
PREDEFINED = EINA_MAGIC_DEBUG \
|
||||
__UNUSED__= \
|
||||
EOBJ_ARG_NONNULL()= \
|
||||
EOBJ_MALLOC= \
|
||||
EOBJ_WARN_UNUSED_RESULT= \
|
||||
EINA_ARG_NONNULL()= \
|
||||
EINA_MALLOC= \
|
||||
EINA_WARN_UNUSED_RESULT= \
|
||||
EAPI= \
|
||||
EOBJ_PURE= \
|
||||
EOBJ_CONST=
|
||||
EINA_PURE= \
|
||||
EINA_TRUE= \
|
||||
EINA_FALSE= \
|
||||
EINA_CONST=
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
|
||||
# this tag can be used to specify a list of macro names that should be expanded.
|
||||
|
|
|
@ -3,11 +3,11 @@ exec_prefix=${prefix}
|
|||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: Eobj
|
||||
Name: Eo
|
||||
Description: EFL's generic object system library.
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -leobj
|
||||
Libs: -L${libdir} -leo
|
||||
Libs.private:
|
||||
Cflags: -I${includedir}/eobj-@VMAJ@
|
||||
Cflags: -I${includedir}/eo-@VMAJ@
|
||||
|
||||
~
|
|
@ -12,13 +12,13 @@ include_directories(
|
|||
|
||||
add_executable(access ${ACCESS_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(access
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(access eobj)
|
||||
add_dependencies(access eo)
|
||||
|
||||
add_test(Example_access access)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "simple_protected.h"
|
||||
|
||||
|
@ -6,38 +6,38 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op INHERIT_BASE_ID = 0;
|
||||
EAPI Eo_Op INHERIT_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS INHERIT_CLASS
|
||||
|
||||
static void
|
||||
_prot_print(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_prot_print(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Simple_Protected_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||
Simple_Protected_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
||||
(void) list;
|
||||
printf("%s %d\n", __func__, pd->protected_x1);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION_CONST(INHERIT_SUB_ID_PROT_PRINT, "", "Print protected var x1."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION_CONST(INHERIT_SUB_ID_PROT_PRINT, "", "Print protected var x1."),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Inherit",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -46,4 +46,4 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef INHERIT_H
|
||||
#define INHERIT_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op INHERIT_BASE_ID;
|
||||
extern EAPI Eo_Op INHERIT_BASE_ID;
|
||||
|
||||
enum {
|
||||
INHERIT_SUB_ID_PROT_PRINT,
|
||||
|
@ -15,6 +15,6 @@ enum {
|
|||
#define inherit_prot_print() INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT)
|
||||
|
||||
#define INHERIT_CLASS inherit_class_get()
|
||||
const Eobj_Class *inherit_class_get(void) EINA_CONST;
|
||||
const Eo_Class *inherit_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "inherit.h"
|
||||
|
||||
|
@ -7,17 +7,17 @@ main(int argc, char *argv[])
|
|||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(INHERIT_CLASS, NULL);
|
||||
Eo *obj = eo_add(INHERIT_CLASS, NULL);
|
||||
|
||||
eobj_do(obj, simple_a_set(1), inherit_prot_print());
|
||||
eo_do(obj, simple_a_set(1), inherit_prot_print());
|
||||
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
||||
printf("Pub: %d\n", pd->public_x2);
|
||||
|
||||
eobj_unref(obj);
|
||||
eobj_shutdown();
|
||||
eo_unref(obj);
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "simple_protected.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -10,13 +10,13 @@ typedef struct
|
|||
int a;
|
||||
} Private_Data;
|
||||
|
||||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
EAPI const Eo_Event_Description _SIG_A_CHANGED =
|
||||
EO_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
int a;
|
||||
|
@ -27,34 +27,34 @@ _a_set(Eobj *obj, void *class_data, va_list *list)
|
|||
pd->protected.protected_x1 = a + 1;
|
||||
pd->protected.public.public_x2 = a + 2;
|
||||
|
||||
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
eo_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
NULL,
|
||||
|
@ -63,5 +63,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -17,12 +17,12 @@ typedef struct
|
|||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
extern const Eo_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,13 +12,13 @@ include_directories(
|
|||
|
||||
add_executable(composite_objects ${COMPOSITE_OBJECTS_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(composite_objects
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(composite_objects eobj)
|
||||
add_dependencies(composite_objects eo)
|
||||
|
||||
add_test(Example_composite_objects composite_objects)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "comp.h"
|
||||
|
@ -6,50 +6,50 @@
|
|||
|
||||
#include "../eunit_tests.h"
|
||||
|
||||
EAPI Eobj_Op COMP_BASE_ID = 0;
|
||||
EAPI Eo_Op COMP_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS COMP_CLASS
|
||||
|
||||
static void
|
||||
_a_get(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_a_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int *a;
|
||||
a = va_arg(*list, int *);
|
||||
eobj_query_super(obj, simple_a_get(a));
|
||||
eo_query_super(obj, simple_a_get(a));
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
Eobj *simple = eobj_add(SIMPLE_CLASS, obj);
|
||||
eobj_composite_object_attach(obj, simple);
|
||||
eobj_event_callback_forwarder_add(simple, SIG_A_CHANGED, obj);
|
||||
Eo *simple = eo_add(SIMPLE_CLASS, obj);
|
||||
eo_composite_object_attach(obj, simple);
|
||||
eo_event_callback_forwarder_add(simple, SIG_A_CHANGED, obj);
|
||||
|
||||
fail_if(eobj_composite_is(obj));
|
||||
fail_if(!eobj_composite_is(simple));
|
||||
fail_if(eo_composite_is(obj));
|
||||
fail_if(!eo_composite_is(simple));
|
||||
|
||||
eobj_do(obj, eobj_base_data_set("simple-obj", simple, NULL));
|
||||
eo_do(obj, eo_base_data_set("simple-obj", simple, NULL));
|
||||
|
||||
eobj_unref(simple);
|
||||
eo_unref(simple);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Comp",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
_constructor,
|
||||
|
@ -58,6 +58,6 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(comp_class_get, &class_desc, EOBJ_BASE_CLASS,
|
||||
EO_DEFINE_CLASS(comp_class_get, &class_desc, EO_BASE_CLASS,
|
||||
SIMPLE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef COMP_H
|
||||
#define COMP_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define COMP_CLASS comp_class_get()
|
||||
const Eobj_Class *comp_class_get(void) EINA_CONST;
|
||||
const Eo_Class *comp_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "comp.h"
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
|||
static int cb_called = EINA_FALSE;
|
||||
|
||||
static Eina_Bool
|
||||
_a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
_a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
(void) desc;
|
||||
(void) obj;
|
||||
|
@ -16,7 +16,7 @@ _a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *e
|
|||
|
||||
cb_called = EINA_TRUE;
|
||||
|
||||
return EOBJ_CALLBACK_CONTINUE;
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -24,38 +24,38 @@ main(int argc, char *argv[])
|
|||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(COMP_CLASS, NULL);
|
||||
eobj_event_callback_add(obj, SIG_A_CHANGED, _a_changed_cb, NULL);
|
||||
Eo *obj = eo_add(COMP_CLASS, NULL);
|
||||
eo_event_callback_add(obj, SIG_A_CHANGED, _a_changed_cb, NULL);
|
||||
|
||||
int a;
|
||||
eobj_do(obj, simple_a_set(1));
|
||||
eo_do(obj, simple_a_set(1));
|
||||
fail_if(!cb_called);
|
||||
|
||||
eobj_do(obj, simple_a_get(&a));
|
||||
eo_do(obj, simple_a_get(&a));
|
||||
fail_if(a != 1);
|
||||
|
||||
/* disable the callback forwarder, and fail if it's still called. */
|
||||
Eobj *simple;
|
||||
eobj_do(obj, eobj_base_data_get("simple-obj", (void **) &simple));
|
||||
eobj_ref(simple);
|
||||
eobj_event_callback_forwarder_del(simple, SIG_A_CHANGED, obj);
|
||||
Eo *simple;
|
||||
eo_do(obj, eo_base_data_get("simple-obj", (void **) &simple));
|
||||
eo_ref(simple);
|
||||
eo_event_callback_forwarder_del(simple, SIG_A_CHANGED, obj);
|
||||
|
||||
cb_called = EINA_FALSE;
|
||||
eobj_do(obj, simple_a_set(2));
|
||||
eo_do(obj, simple_a_set(2));
|
||||
fail_if(cb_called);
|
||||
|
||||
fail_if(!eobj_composite_is(simple));
|
||||
eobj_composite_object_detach(obj, simple);
|
||||
fail_if(eobj_composite_is(simple));
|
||||
eobj_composite_object_attach(obj, simple);
|
||||
fail_if(!eobj_composite_is(simple));
|
||||
fail_if(!eo_composite_is(simple));
|
||||
eo_composite_object_detach(obj, simple);
|
||||
fail_if(eo_composite_is(simple));
|
||||
eo_composite_object_attach(obj, simple);
|
||||
fail_if(!eo_composite_is(simple));
|
||||
|
||||
eobj_unref(simple);
|
||||
eobj_unref(obj);
|
||||
eo_unref(simple);
|
||||
eo_unref(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
EAPI const Eo_Event_Description _SIG_A_CHANGED =
|
||||
EO_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
|
||||
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
eo_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
_a_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
_a_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
const Simple_Public_Data *pd = class_data;
|
||||
int *a;
|
||||
|
@ -32,32 +32,32 @@ _a_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
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_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
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_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Simple_Public_Data),
|
||||
NULL,
|
||||
|
@ -66,5 +66,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -18,13 +18,13 @@ typedef struct
|
|||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EOBJ_TYPECHECK(int *, a)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
extern const Eo_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,13 +17,13 @@ include_directories(
|
|||
|
||||
add_executable(constructors ${CONSTRUCTORS_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(constructors
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(constructors eobj)
|
||||
add_dependencies(constructors eo)
|
||||
|
||||
add_test(Example_constructors constructors)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "simple2.h"
|
||||
#include "simple3.h"
|
||||
|
@ -17,43 +17,43 @@ main(int argc, char *argv[])
|
|||
int ret = 0;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
fail_if(my_init_count != 2);
|
||||
|
||||
eobj_do(obj, simple_a_set(1), simple_b_set(2));
|
||||
eo_do(obj, simple_a_set(1), simple_b_set(2));
|
||||
|
||||
int a, b;
|
||||
eobj_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_add_and_print(5));
|
||||
eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_add_and_print(5));
|
||||
|
||||
eobj_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
fail_if(my_init_count != 0);
|
||||
|
||||
obj = eobj_add(SIMPLE2_CLASS, NULL);
|
||||
obj = eo_add(SIMPLE2_CLASS, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE3_CLASS, NULL);
|
||||
obj = eo_add(SIMPLE3_CLASS, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
my_init_count = 0;
|
||||
obj = eobj_add(SIMPLE4_CLASS, NULL);
|
||||
obj = eo_add(SIMPLE4_CLASS, NULL);
|
||||
|
||||
fail_if(my_init_count != 2);
|
||||
|
||||
eobj_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
fail_if(my_init_count != 0);
|
||||
|
||||
obj = eobj_add(SIMPLE5_CLASS, NULL);
|
||||
eobj_unref(obj);
|
||||
obj = eo_add(SIMPLE5_CLASS, NULL);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE6_CLASS, NULL);
|
||||
eobj_unref(obj);
|
||||
obj = eo_add(SIMPLE6_CLASS, NULL);
|
||||
eo_unref(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
eo_shutdown();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||
EAPI Eo_Op MIXIN_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS MIXIN_CLASS
|
||||
|
||||
static void
|
||||
_add_and_print_set(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_add_and_print_set(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a, b, x;
|
||||
eobj_query(obj, simple_a_get(&a), simple_b_get(&b));
|
||||
eo_query(obj, simple_a_get(&a), simple_b_get(&b));
|
||||
x = va_arg(*list, const int);
|
||||
printf("%s %d\n", __func__, a + b + x);
|
||||
}
|
||||
|
@ -20,41 +20,41 @@ _add_and_print_set(const Eobj *obj, const void *class_data EINA_UNUSED, va_list
|
|||
extern int my_init_count;
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
my_init_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
|
||||
my_init_count--;
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
_constructor,
|
||||
|
@ -63,5 +63,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL);
|
||||
EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef MIXIN_H
|
||||
#define MIXIN_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op MIXIN_BASE_ID;
|
||||
extern EAPI Eo_Op MIXIN_BASE_ID;
|
||||
|
||||
enum {
|
||||
MIXIN_SUB_ID_ADD_AND_SET,
|
||||
|
@ -12,9 +12,9 @@ enum {
|
|||
|
||||
#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
|
||||
|
||||
#define mixin_add_and_print(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EOBJ_TYPECHECK(int, x)
|
||||
#define mixin_add_and_print(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EO_TYPECHECK(int, x)
|
||||
|
||||
#define MIXIN_CLASS mixin_class_get()
|
||||
const Eobj_Class *mixin_class_get(void) EINA_CONST;
|
||||
const Eo_Class *mixin_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ static char *class_var = NULL;
|
|||
|
||||
#define _GET_SET_FUNC(name) \
|
||||
static void \
|
||||
_##name##_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list) \
|
||||
_##name##_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list) \
|
||||
{ \
|
||||
const Private_Data *pd = class_data; \
|
||||
int *name; \
|
||||
|
@ -27,7 +27,7 @@ _##name##_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list
|
|||
printf("%s %d\n", __func__, pd->name); \
|
||||
} \
|
||||
static void \
|
||||
_##name##_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list) \
|
||||
_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
|
||||
{ \
|
||||
Private_Data *pd = class_data; \
|
||||
int name; \
|
||||
|
@ -42,55 +42,55 @@ _GET_SET_FUNC(b)
|
|||
extern int my_init_count;
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
my_init_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
|
||||
my_init_count--;
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
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_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
|
||||
class_var = malloc(10);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_destructor(Eobj_Class *klass EINA_UNUSED)
|
||||
_class_destructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
free(class_var);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
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 Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Private_Data),
|
||||
_constructor,
|
||||
|
@ -99,6 +99,6 @@ static const Eobj_Class_Description class_desc = {
|
|||
_class_destructor
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS,
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS,
|
||||
MIXIN_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -15,12 +15,12 @@ enum {
|
|||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EOBJ_TYPECHECK(int *, a)
|
||||
#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EOBJ_TYPECHECK(int, b)
|
||||
#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EOBJ_TYPECHECK(int *, b)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
#define simple_a_get(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EO_TYPECHECK(int *, a)
|
||||
#define simple_b_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
|
||||
#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple2.h"
|
||||
|
||||
|
@ -7,17 +7,17 @@
|
|||
#define MY_CLASS SIMPLE2_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
eobj_constructor_error_set(obj);
|
||||
eo_constructor_error_set(obj);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple2",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
_constructor,
|
||||
|
@ -26,5 +26,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple2_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple2_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE2_H
|
||||
#define SIMPLE2_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define SIMPLE2_CLASS simple2_class_get()
|
||||
const Eobj_Class *simple2_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple2_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple3.h"
|
||||
|
||||
|
@ -7,15 +7,15 @@
|
|||
#define MY_CLASS SIMPLE3_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
(void) obj;
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple3",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
_constructor,
|
||||
|
@ -24,5 +24,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple3_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple3_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE3_H
|
||||
#define SIMPLE3_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define SIMPLE3_CLASS simple3_class_get()
|
||||
const Eobj_Class *simple3_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple3_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple.h"
|
||||
#include "simple4.h"
|
||||
|
||||
#define MY_CLASS SIMPLE4_CLASS
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple4",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -17,5 +17,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple4_class_get, &class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple4_class_get, &class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE4_H
|
||||
#define SIMPLE4_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define SIMPLE4_CLASS simple4_class_get()
|
||||
const Eobj_Class *simple4_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple4_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple5.h"
|
||||
|
||||
|
@ -7,15 +7,15 @@
|
|||
#define MY_CLASS SIMPLE5_CLASS
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
(void) obj;
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple5",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -24,5 +24,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple5_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple5_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE5_H
|
||||
#define SIMPLE5_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define SIMPLE5_CLASS simple5_class_get()
|
||||
const Eobj_Class *simple5_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple5_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple6.h"
|
||||
|
||||
|
@ -7,17 +7,17 @@
|
|||
#define MY_CLASS SIMPLE6_CLASS
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
eobj_constructor_error_set(obj);
|
||||
eo_constructor_error_set(obj);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple6",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -26,5 +26,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple6_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple6_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE6_H
|
||||
#define SIMPLE6_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define SIMPLE6_CLASS simple6_class_get()
|
||||
const Eobj_Class *simple6_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple6_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,13 +15,13 @@ include_directories(
|
|||
)
|
||||
|
||||
add_executable(evas ${EVAS_CC_SOURCES})
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(evas
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${EVAS_LIBRARIES}
|
||||
${ELEMENTARY_LIBRARIES}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(evas eobj)
|
||||
add_dependencies(evas eo)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "evas_obj.h"
|
||||
#include "elw_box.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op ELW_BOX_BASE_ID = 0;
|
||||
EAPI Eo_Op ELW_BOX_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -16,50 +16,50 @@ typedef struct
|
|||
#define MY_CLASS ELW_BOX_CLASS
|
||||
|
||||
static void
|
||||
_pack_end(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
_pack_end(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Widget_Data *wd = class_data;
|
||||
Eobj *child_obj;
|
||||
child_obj = va_arg(*list, Eobj *);
|
||||
Eo *child_obj;
|
||||
child_obj = va_arg(*list, Eo *);
|
||||
/* FIXME: Ref and the later uref child_obj here... */
|
||||
elm_box_pack_end(wd->bx, eobj_evas_object_get(child_obj));
|
||||
elm_box_pack_end(wd->bx, eo_evas_object_get(child_obj));
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data)
|
||||
_constructor(Eo *obj, void *class_data)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
Widget_Data *wd = class_data;
|
||||
|
||||
/* FIXME: An hack, because our tree is not yet only Eobj */
|
||||
wd->bx = elm_box_add(eobj_evas_object_get(eobj_parent_get(obj)));
|
||||
/* FIXME: An hack, because our tree is not yet only Eo */
|
||||
wd->bx = elm_box_add(eo_evas_object_get(eo_parent_get(obj)));
|
||||
evas_object_size_hint_align_set(wd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
||||
eobj_evas_object_set(obj, wd->bx);
|
||||
eo_evas_object_set(obj, wd->bx);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Elw Box",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Widget_Data),
|
||||
_constructor,
|
||||
|
@ -68,5 +68,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(elw_box_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(elw_box_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef ELW_BOX_H
|
||||
#define ELW_BOX_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op ELW_BOX_BASE_ID;
|
||||
extern EAPI Eo_Op ELW_BOX_BASE_ID;
|
||||
|
||||
enum {
|
||||
ELW_BOX_SUB_ID_PACK_END,
|
||||
|
@ -17,9 +17,9 @@ enum {
|
|||
* @brief Pack object to the end of the box
|
||||
* @param[in] obj object to pack into box
|
||||
*/
|
||||
#define elw_box_pack_end(obj) ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), EOBJ_TYPECHECK(Eobj *, obj)
|
||||
#define elw_box_pack_end(obj) ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), EO_TYPECHECK(Eo *, obj)
|
||||
|
||||
#define ELW_BOX_CLASS elw_box_class_get()
|
||||
const Eobj_Class *elw_box_class_get(void) EINA_CONST;
|
||||
const Eo_Class *elw_box_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "evas_obj.h"
|
||||
#include "elw_box.h"
|
||||
#include "elw_button.h"
|
||||
|
@ -16,23 +16,23 @@ typedef struct
|
|||
#define MY_CLASS ELW_BOXEDBUTTON_CLASS
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
Eobj *bt = eobj_add(ELW_BUTTON_CLASS, obj);
|
||||
eobj_composite_object_attach(obj, bt);
|
||||
eobj_event_callback_forwarder_add(bt, SIG_CLICKED, obj);
|
||||
eobj_do(bt, evas_obj_visibility_set(EINA_TRUE));
|
||||
Eo *bt = eo_add(ELW_BUTTON_CLASS, obj);
|
||||
eo_composite_object_attach(obj, bt);
|
||||
eo_event_callback_forwarder_add(bt, SIG_CLICKED, obj);
|
||||
eo_do(bt, evas_obj_visibility_set(EINA_TRUE));
|
||||
|
||||
eobj_do(obj, elw_box_pack_end(bt));
|
||||
eobj_unref(bt);
|
||||
eo_do(obj, elw_box_pack_end(bt));
|
||||
eo_unref(bt);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Elw BoxedButton",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
sizeof(Widget_Data),
|
||||
_constructor,
|
||||
|
@ -41,5 +41,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(elw_boxedbutton_class_get, &class_desc, ELW_BOX_CLASS, ELW_BUTTON_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(elw_boxedbutton_class_get, &class_desc, ELW_BOX_CLASS, ELW_BUTTON_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef ELW_BOXEDBUTTON_H
|
||||
#define ELW_BOXEDBUTTON_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define ELW_BOXEDBUTTON_CLASS elw_boxedbutton_class_get()
|
||||
const Eobj_Class *elw_boxedbutton_class_get(void) EINA_CONST;
|
||||
const Eo_Class *elw_boxedbutton_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "evas_obj.h"
|
||||
#include "elw_button.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op ELW_BUTTON_BASE_ID = 0;
|
||||
EAPI Eo_Op ELW_BUTTON_BASE_ID = 0;
|
||||
|
||||
EAPI const Eobj_Event_Description _SIG_CLICKED =
|
||||
EOBJ_EVENT_DESCRIPTION("clicked", "", "Called when there was a click.");
|
||||
EAPI const Eo_Event_Description _SIG_CLICKED =
|
||||
EO_EVENT_DESCRIPTION("clicked", "", "Called when there was a click.");
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -19,18 +19,18 @@ typedef struct
|
|||
#define MY_CLASS ELW_BUTTON_CLASS
|
||||
|
||||
static void
|
||||
_position_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_position_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
(void) obj;
|
||||
Evas_Coord x, y;
|
||||
x = va_arg(*list, Evas_Coord);
|
||||
y = va_arg(*list, Evas_Coord);
|
||||
printf("But set position %d,%d\n", x, y);
|
||||
eobj_do_super(obj, evas_obj_position_set(x, y));
|
||||
eo_do_super(obj, evas_obj_position_set(x, y));
|
||||
}
|
||||
|
||||
static void
|
||||
_text_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
_text_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Widget_Data *wd = class_data;
|
||||
const char *text;
|
||||
|
@ -43,63 +43,63 @@ _btn_clicked(void *data, Evas_Object *evas_obj, void *event_info)
|
|||
{
|
||||
(void) evas_obj;
|
||||
(void) event_info;
|
||||
Eobj *obj = data;
|
||||
eobj_event_callback_call(obj, SIG_CLICKED, NULL);
|
||||
Eo *obj = data;
|
||||
eo_event_callback_call(obj, SIG_CLICKED, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data)
|
||||
_constructor(Eo *obj, void *class_data)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
Widget_Data *wd = class_data;
|
||||
|
||||
/* FIXME: An hack, because our tree is not yet only Eobj */
|
||||
wd->bt = elm_button_add(eobj_evas_object_get(eobj_parent_get(obj)));
|
||||
/* FIXME: An hack, because our tree is not yet only Eo */
|
||||
wd->bt = elm_button_add(eo_evas_object_get(eo_parent_get(obj)));
|
||||
evas_object_size_hint_align_set(wd->bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(wd->bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_smart_callback_add(wd->bt, "clicked", _btn_clicked, obj);
|
||||
|
||||
eobj_evas_object_set(obj, wd->bt);
|
||||
eo_evas_object_set(obj, wd->bt);
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
|
||||
//Widget_Data *wd = class_data;
|
||||
/* FIXME: Commented out because it's automatically done because our tree
|
||||
* is not made of only eobj */
|
||||
* is not made of only eo */
|
||||
//evas_object_del(wd->bt);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), _text_set),
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), _text_set),
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(ELW_BUTTON_SUB_ID_TEXT_SET, "s", "Text of a text supporting evas object."), // FIXME: This ID sholudn't really be defined here...
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(ELW_BUTTON_SUB_ID_TEXT_SET, "s", "Text of a text supporting evas object."), // FIXME: This ID sholudn't really be defined here...
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
SIG_CLICKED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Elw Button",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BUTTON_BASE_ID, op_desc, ELW_BUTTON_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&ELW_BUTTON_BASE_ID, op_desc, ELW_BUTTON_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Widget_Data),
|
||||
_constructor,
|
||||
|
@ -108,5 +108,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(elw_button_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(elw_button_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef ELW_BUTTON_H
|
||||
#define ELW_BUTTON_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op ELW_BUTTON_BASE_ID;
|
||||
extern EAPI Eo_Op ELW_BUTTON_BASE_ID;
|
||||
|
||||
enum {
|
||||
ELW_BUTTON_SUB_ID_TEXT_SET,
|
||||
|
@ -18,12 +18,12 @@ enum {
|
|||
* @param[in] text text to assing to button
|
||||
* FIXME Doesn't belong here, but just for the example...
|
||||
*/
|
||||
#define elw_button_text_set(text) ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), EOBJ_TYPECHECK(const char *, text)
|
||||
#define elw_button_text_set(text) ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), EO_TYPECHECK(const char *, text)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_CLICKED;
|
||||
extern const Eo_Event_Description _SIG_CLICKED;
|
||||
#define SIG_CLICKED (&(_SIG_CLICKED))
|
||||
|
||||
#define ELW_BUTTON_CLASS elw_button_class_get()
|
||||
const Eobj_Class *elw_button_class_get(void) EINA_CONST;
|
||||
const Eo_Class *elw_button_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "evas_obj.h"
|
||||
#include "elw_win.h"
|
||||
|
||||
|
@ -23,15 +23,15 @@ my_win_del(void *data, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data)
|
||||
_constructor(Eo *obj, void *class_data)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
Widget_Data *wd = class_data;
|
||||
|
||||
/* FIXME: Will actually do something about those when I care... */
|
||||
wd->win = elm_win_add(NULL, "eobj-test", ELM_WIN_BASIC);
|
||||
elm_win_title_set(wd->win, "Eobj Test");
|
||||
wd->win = elm_win_add(NULL, "eo-test", ELM_WIN_BASIC);
|
||||
elm_win_title_set(wd->win, "Eo Test");
|
||||
elm_win_autodel_set(wd->win, EINA_TRUE);
|
||||
evas_object_smart_callback_add(wd->win, "delete,request", my_win_del, NULL);
|
||||
|
||||
|
@ -40,13 +40,13 @@ _constructor(Eobj *obj, void *class_data)
|
|||
evas_object_size_hint_weight_set(wd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(wd->bg);
|
||||
|
||||
eobj_evas_object_set(obj, wd->win);
|
||||
eo_evas_object_set(obj, wd->win);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Elw Win",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
sizeof(Widget_Data),
|
||||
_constructor,
|
||||
|
@ -56,5 +56,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
};
|
||||
|
||||
|
||||
EOBJ_DEFINE_CLASS(elw_win_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(elw_win_class_get, &class_desc, EVAS_OBJ_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef ELW_WIN_H
|
||||
#define ELW_WIN_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define ELW_WIN_CLASS elw_win_class_get()
|
||||
const Eobj_Class *elw_win_class_get(void) EINA_CONST;
|
||||
const Eo_Class *elw_win_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "evas_obj.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define MY_CLASS EVAS_OBJ_CLASS
|
||||
|
||||
EAPI Eobj_Op EVAS_OBJ_BASE_ID = 0;
|
||||
EAPI Eo_Op EVAS_OBJ_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -15,9 +15,9 @@ typedef struct
|
|||
} Widget_Data;
|
||||
|
||||
static void
|
||||
_position_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_position_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||
Evas_Object *evas_obj = eo_evas_object_get(obj);
|
||||
Evas_Coord x, y;
|
||||
x = va_arg(*list, Evas_Coord);
|
||||
y = va_arg(*list, Evas_Coord);
|
||||
|
@ -25,9 +25,9 @@ _position_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_size_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_size_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||
Evas_Object *evas_obj = eo_evas_object_get(obj);
|
||||
Evas_Coord w, h;
|
||||
w = va_arg(*list, Evas_Coord);
|
||||
h = va_arg(*list, Evas_Coord);
|
||||
|
@ -35,9 +35,9 @@ _size_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_color_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_color_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||
Evas_Object *evas_obj = eo_evas_object_get(obj);
|
||||
int r, g, b, a;
|
||||
r = va_arg(*list, int);
|
||||
g = va_arg(*list, int);
|
||||
|
@ -47,9 +47,9 @@ _color_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_color_get(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_color_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||
Evas_Object *evas_obj = eo_evas_object_get(obj);
|
||||
int *r, *g, *b, *a;
|
||||
r = va_arg(*list, int *);
|
||||
g = va_arg(*list, int *);
|
||||
|
@ -59,9 +59,9 @@ _color_get(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_visibility_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_visibility_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||
Evas_Object *evas_obj = eo_evas_object_get(obj);
|
||||
Eina_Bool v;
|
||||
v = va_arg(*list, int);
|
||||
if (v) evas_object_show(evas_obj);
|
||||
|
@ -69,69 +69,69 @@ _visibility_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
|||
}
|
||||
|
||||
static void
|
||||
_child_add(Eobj *obj, void *class_data, va_list *list)
|
||||
_child_add(Eo *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Widget_Data *wd = class_data;
|
||||
Eobj *child;
|
||||
child = va_arg(*list, Eobj *);
|
||||
wd->children = eina_list_append(wd->children, eobj_xref(child, obj));
|
||||
Eo *child;
|
||||
child = va_arg(*list, Eo *);
|
||||
wd->children = eina_list_append(wd->children, eo_xref(child, obj));
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
/* Add type check. */
|
||||
Eobj *parent = eobj_parent_get(obj);
|
||||
Eo *parent = eo_parent_get(obj);
|
||||
if (parent)
|
||||
eobj_do(parent, evas_obj_child_add(obj));
|
||||
eo_do(parent, evas_obj_child_add(obj));
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data)
|
||||
_destructor(Eo *obj, void *class_data)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
|
||||
Widget_Data *wd = class_data;
|
||||
|
||||
Eobj *child;
|
||||
Eo *child;
|
||||
EINA_LIST_FREE(wd->children, child)
|
||||
{
|
||||
eobj_xunref(child, obj);
|
||||
eo_xunref(child, obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), _size_set),
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), _color_set),
|
||||
EOBJ_OP_FUNC_CONST(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), _color_get),
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), _visibility_set),
|
||||
EOBJ_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), _child_add),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), _size_set),
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), _color_set),
|
||||
EO_OP_FUNC_CONST(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), _color_get),
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), _visibility_set),
|
||||
EO_OP_FUNC(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), _child_add),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_POSITION_SET, "ii", "Position of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_SIZE_SET, "ii", "Size of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_COLOR_SET, "iiii", "Color of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION_CONST(EVAS_OBJ_SUB_ID_COLOR_GET, "iiii", "Color of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_VISIBILITY_SET, "b", "Visibility of an evas object."),
|
||||
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CHILD_ADD, "o", "Add a child eobj."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_POSITION_SET, "ii", "Position of an evas object."),
|
||||
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_SIZE_SET, "ii", "Size of an evas object."),
|
||||
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_COLOR_SET, "iiii", "Color of an evas object."),
|
||||
EO_OP_DESCRIPTION_CONST(EVAS_OBJ_SUB_ID_COLOR_GET, "iiii", "Color of an evas object."),
|
||||
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_VISIBILITY_SET, "b", "Visibility of an evas object."),
|
||||
EO_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CHILD_ADD, "o", "Add a child eo."),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Evas Object",
|
||||
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&EVAS_OBJ_BASE_ID, op_desc, EVAS_OBJ_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EO_CLASS_DESCRIPTION_OPS(&EVAS_OBJ_BASE_ID, op_desc, EVAS_OBJ_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Widget_Data),
|
||||
_constructor,
|
||||
|
@ -140,4 +140,4 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(evas_object_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(evas_object_class_get, &class_desc, EO_BASE_CLASS, NULL)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef EVAS_OBJ_H
|
||||
#define EVAS_OBJ_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op EVAS_OBJ_BASE_ID;
|
||||
extern EAPI Eo_Op EVAS_OBJ_BASE_ID;
|
||||
|
||||
enum {
|
||||
EVAS_OBJ_SUB_ID_POSITION_SET,
|
||||
|
@ -23,7 +23,7 @@ enum {
|
|||
* @param[in] x object's X position
|
||||
* @param[in] y object's Y position
|
||||
*/
|
||||
#define evas_obj_position_set(x, y) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), EOBJ_TYPECHECK(Evas_Coord, x), EOBJ_TYPECHECK(Evas_Coord, y)
|
||||
#define evas_obj_position_set(x, y) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), EO_TYPECHECK(Evas_Coord, x), EO_TYPECHECK(Evas_Coord, y)
|
||||
|
||||
/**
|
||||
* @def evas_obj_size_set(w, h)
|
||||
|
@ -31,7 +31,7 @@ enum {
|
|||
* @param[in] w object's width
|
||||
* @param[in] h object's height
|
||||
*/
|
||||
#define evas_obj_size_set(w, h) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), EOBJ_TYPECHECK(Evas_Coord, w), EOBJ_TYPECHECK(Evas_Coord, h)
|
||||
#define evas_obj_size_set(w, h) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), EO_TYPECHECK(Evas_Coord, w), EO_TYPECHECK(Evas_Coord, h)
|
||||
|
||||
/**
|
||||
* @def evas_obj_color_set(r, g, b, a)
|
||||
|
@ -41,7 +41,7 @@ enum {
|
|||
* @param[in] b b-value of color
|
||||
* @param[in] a a-value of color
|
||||
*/
|
||||
#define evas_obj_color_set(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), EOBJ_TYPECHECK(int, r), EOBJ_TYPECHECK(int, g), EOBJ_TYPECHECK(int, b), EOBJ_TYPECHECK(int, a)
|
||||
#define evas_obj_color_set(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), EO_TYPECHECK(int, r), EO_TYPECHECK(int, g), EO_TYPECHECK(int, b), EO_TYPECHECK(int, a)
|
||||
|
||||
/**
|
||||
* @def evas_obj_color_get(r, g, b, a)
|
||||
|
@ -51,40 +51,40 @@ enum {
|
|||
* @param[out] b integer pointer for b-value of color
|
||||
* @param[out] a integer pointer for a-value of color
|
||||
*/
|
||||
#define evas_obj_color_get(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), EOBJ_TYPECHECK(int *, r), EOBJ_TYPECHECK(int *, g), EOBJ_TYPECHECK(int *, b), EOBJ_TYPECHECK(int *, a)
|
||||
#define evas_obj_color_get(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), EO_TYPECHECK(int *, r), EO_TYPECHECK(int *, g), EO_TYPECHECK(int *, b), EO_TYPECHECK(int *, a)
|
||||
|
||||
/**
|
||||
* @def evas_obj_visibility_set(v)
|
||||
* @brief Set object's visible property
|
||||
* @param[in] v True/False value
|
||||
*/
|
||||
#define evas_obj_visibility_set(v) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), EOBJ_TYPECHECK(Eina_Bool, v)
|
||||
#define evas_obj_visibility_set(v) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), EO_TYPECHECK(Eina_Bool, v)
|
||||
|
||||
/**
|
||||
* @def evas_obj_child_add(child)
|
||||
* @brief Add child to current object
|
||||
* @param[in] pointer to child object
|
||||
*/
|
||||
#define evas_obj_child_add(child) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), EOBJ_TYPECHECK(Eobj *, child)
|
||||
#define evas_obj_child_add(child) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), EO_TYPECHECK(Eo *, child)
|
||||
|
||||
#define EVAS_OBJ_CLASS evas_object_class_get()
|
||||
const Eobj_Class *evas_object_class_get(void) EINA_CONST;
|
||||
const Eo_Class *evas_object_class_get(void) EINA_CONST;
|
||||
|
||||
#define EVAS_OBJ_STR "Evas_Obj"
|
||||
/* FIXME: Hack in the meanwhile. */
|
||||
static inline Evas_Object *
|
||||
eobj_evas_object_get(const Eobj *obj)
|
||||
eo_evas_object_get(const Eo *obj)
|
||||
{
|
||||
void *data;
|
||||
eobj_query(obj, eobj_base_data_get(EVAS_OBJ_STR, &data));
|
||||
eo_query(obj, eo_base_data_get(EVAS_OBJ_STR, &data));
|
||||
return data;
|
||||
}
|
||||
|
||||
/* FIXME: Hack in the meanwhile. */
|
||||
static inline void
|
||||
eobj_evas_object_set(Eobj *obj, Evas_Object *evas_obj)
|
||||
eo_evas_object_set(Eo *obj, Evas_Object *evas_obj)
|
||||
{
|
||||
eobj_do(obj, eobj_base_data_set(EVAS_OBJ_STR, evas_obj, NULL));
|
||||
eo_do(obj, eo_base_data_set(EVAS_OBJ_STR, evas_obj, NULL));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#include "elw_win.h"
|
||||
|
||||
Eina_Bool
|
||||
_btn_clicked_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
_btn_clicked_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
(void) obj;
|
||||
(void) event_info;
|
||||
const Eobj_Class *klass = eobj_class_get(obj);
|
||||
printf("%s obj-type:'%s' data:'%s'\n", desc->name, eobj_class_name_get(klass), (const char *) data);
|
||||
const Eo_Class *klass = eo_class_get(obj);
|
||||
printf("%s obj-type:'%s' data:'%s'\n", desc->name, eo_class_name_get(klass), (const char *) data);
|
||||
|
||||
return EOBJ_CALLBACK_CONTINUE;
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -27,37 +27,37 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
elm_init(argc, argv);
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *win = eobj_add(ELW_WIN_CLASS, NULL);
|
||||
eobj_do(win, evas_obj_size_set(winw, winh), evas_obj_visibility_set(EINA_TRUE));
|
||||
Eo *win = eo_add(ELW_WIN_CLASS, NULL);
|
||||
eo_do(win, evas_obj_size_set(winw, winh), evas_obj_visibility_set(EINA_TRUE));
|
||||
|
||||
Eobj *bt = eobj_add(ELW_BUTTON_CLASS, win);
|
||||
eobj_do(bt, evas_obj_position_set(25, 25),
|
||||
Eo *bt = eo_add(ELW_BUTTON_CLASS, win);
|
||||
eo_do(bt, evas_obj_position_set(25, 25),
|
||||
evas_obj_size_set(50, 50),
|
||||
evas_obj_color_set(255, 0, 0, 255),
|
||||
elw_button_text_set("Click"),
|
||||
evas_obj_visibility_set(EINA_TRUE));
|
||||
eobj_event_callback_add(bt, SIG_CLICKED, _btn_clicked_cb, "btn");
|
||||
eo_event_callback_add(bt, SIG_CLICKED, _btn_clicked_cb, "btn");
|
||||
|
||||
int r, g, b, a;
|
||||
eobj_do(bt, evas_obj_color_get(&r, &g, &b, &a));
|
||||
eo_do(bt, evas_obj_color_get(&r, &g, &b, &a));
|
||||
printf("RGBa(%d, %d, %d, %d)\n", r, g, b, a);
|
||||
|
||||
Eobj *bx = eobj_add(ELW_BOXEDBUTTON_CLASS, win);
|
||||
eobj_do(bx, evas_obj_position_set(100, 100),
|
||||
Eo *bx = eo_add(ELW_BOXEDBUTTON_CLASS, win);
|
||||
eo_do(bx, evas_obj_position_set(100, 100),
|
||||
evas_obj_size_set(70, 70),
|
||||
evas_obj_color_set(0, 0, 255, 255),
|
||||
elw_button_text_set("Click2"),
|
||||
evas_obj_visibility_set(EINA_TRUE));
|
||||
eobj_event_callback_add(bx, SIG_CLICKED, _btn_clicked_cb, "bxedbtn");
|
||||
eo_event_callback_add(bx, SIG_CLICKED, _btn_clicked_cb, "bxedbtn");
|
||||
|
||||
elm_run();
|
||||
|
||||
eobj_unref(bx);
|
||||
eobj_unref(bt);
|
||||
eobj_unref(win);
|
||||
eobj_shutdown();
|
||||
eo_unref(bx);
|
||||
eo_unref(bt);
|
||||
eo_unref(win);
|
||||
eo_shutdown();
|
||||
elm_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ include_directories(
|
|||
|
||||
add_executable(function_overrides ${FUNCTION_OVERRIDES_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(function_overrides
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(function_overrides eobj)
|
||||
add_dependencies(function_overrides eo)
|
||||
|
||||
add_test(Example_function_overrides function_overrides)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "inherit.h"
|
||||
|
||||
#define MY_CLASS INHERIT_CLASS
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Inherit",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -17,4 +17,4 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(inherit_class_get, &class_desc, SIMPLE_CLASS, NULL);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef INHERIT_H
|
||||
#define INHERIT_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define INHERIT_CLASS inherit_class_get()
|
||||
const Eobj_Class *inherit_class_get(void) EINA_CONST;
|
||||
const Eo_Class *inherit_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "inherit.h"
|
||||
|
@ -8,58 +8,58 @@
|
|||
|
||||
#include "../eunit_tests.h"
|
||||
|
||||
EAPI Eobj_Op INHERIT2_BASE_ID = 0;
|
||||
EAPI Eo_Op INHERIT2_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS INHERIT2_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
eobj_do(obj, simple_a_print());
|
||||
eobj_do_super(obj, simple_a_set(a + 1));
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
eo_do(obj, simple_a_print());
|
||||
eo_do_super(obj, simple_a_set(a + 1));
|
||||
|
||||
fail_if(eobj_do_super(obj, simple_a_print()));
|
||||
fail_if(eo_do_super(obj, simple_a_print()));
|
||||
}
|
||||
|
||||
static void
|
||||
_print(Eobj *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
_print(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
printf("Hey\n");
|
||||
fail_if(eobj_do_super(obj, inherit2_print()));
|
||||
fail_if(eo_do_super(obj, inherit2_print()));
|
||||
}
|
||||
|
||||
static void
|
||||
_print2(Eobj *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
_print2(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
printf("Hey2\n");
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print),
|
||||
EOBJ_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print),
|
||||
EO_OP_FUNC(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "", "Print hey"),
|
||||
EOBJ_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "", "Print hey2"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT, "", "Print hey"),
|
||||
EO_OP_DESCRIPTION(INHERIT2_SUB_ID_PRINT2, "", "Print hey2"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Inherit2",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -68,5 +68,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit2_class_get, &class_desc, INHERIT_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(inherit2_class_get, &class_desc, INHERIT_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef INHERIT2_H
|
||||
#define INHERIT2_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op INHERIT2_BASE_ID;
|
||||
extern EAPI Eo_Op INHERIT2_BASE_ID;
|
||||
|
||||
enum {
|
||||
INHERIT2_SUB_ID_PRINT,
|
||||
|
@ -17,6 +17,6 @@ enum {
|
|||
#define inherit2_print2() INHERIT2_ID(INHERIT2_SUB_ID_PRINT2)
|
||||
|
||||
#define INHERIT2_CLASS inherit2_class_get()
|
||||
const Eobj_Class *inherit2_class_get(void) EINA_CONST;
|
||||
const Eo_Class *inherit2_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "inherit2.h"
|
||||
|
@ -9,29 +9,29 @@
|
|||
#define MY_CLASS INHERIT3_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
eobj_do_super(obj, simple_a_set(a + 1));
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
eo_do_super(obj, simple_a_set(a + 1));
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Inherit3",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -40,5 +40,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(inherit3_class_get, &class_desc, INHERIT2_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(inherit3_class_get, &class_desc, INHERIT2_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef INHERIT3_H
|
||||
#define INHERIT3_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#define INHERIT3_CLASS inherit3_class_get()
|
||||
const Eobj_Class *inherit3_class_get(void) EINA_CONST;
|
||||
const Eo_Class *inherit3_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "inherit.h"
|
||||
#include "inherit2.h"
|
||||
|
@ -11,39 +11,39 @@ main(int argc, char *argv[])
|
|||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(INHERIT2_CLASS, NULL);
|
||||
Eo *obj = eo_add(INHERIT2_CLASS, NULL);
|
||||
|
||||
eobj_do(obj, simple_a_set(1));
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||
eo_do(obj, simple_a_set(1));
|
||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
||||
fail_if(pd->a != 2);
|
||||
|
||||
eobj_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eobj_add(INHERIT3_CLASS, NULL);
|
||||
obj = eo_add(INHERIT3_CLASS, NULL);
|
||||
|
||||
eobj_do(obj, simple_a_set(1));
|
||||
pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||
eo_do(obj, simple_a_set(1));
|
||||
pd = eo_data_get(obj, SIMPLE_CLASS);
|
||||
fail_if(pd->a != 3);
|
||||
|
||||
eobj_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eobj_add(INHERIT2_CLASS, NULL);
|
||||
eobj_do(obj, inherit2_print());
|
||||
eobj_unref(obj);
|
||||
obj = eo_add(INHERIT2_CLASS, NULL);
|
||||
eo_do(obj, inherit2_print());
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(eobj_do(obj, inherit2_print2()));
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(eo_do(obj, inherit2_print2()));
|
||||
|
||||
fail_if(eobj_do_super(obj, simple_a_print()));
|
||||
fail_if(eo_do_super(obj, simple_a_print()));
|
||||
|
||||
eobj_constructor_super(obj);
|
||||
eobj_destructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
|
||||
eobj_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
}
|
||||
|
||||
static void
|
||||
_a_print(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
_a_print(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
const Simple_Public_Data *pd = class_data;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eobj_class_name_get(MY_CLASS), pd->a);
|
||||
printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
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_PRINT), _a_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_PRINT, "", "Print property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
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_PRINT, "", "Print property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Simple_Public_Data),
|
||||
NULL,
|
||||
|
@ -55,5 +55,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -18,13 +18,13 @@ typedef struct
|
|||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
extern const Eo_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,13 +14,13 @@ include_directories(
|
|||
|
||||
add_executable(mixin ${MIXIN_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(mixin
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(mixin eobj)
|
||||
add_dependencies(mixin eo)
|
||||
|
||||
add_test(Example_mixin mixin)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
#include "mixin.h"
|
||||
#include "mixin2.h"
|
||||
|
@ -11,26 +11,26 @@ main(int argc, char *argv[])
|
|||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eobj_do(obj, simple_a_set(1), simple_b_set(2));
|
||||
eo_do(obj, simple_a_set(1), simple_b_set(2));
|
||||
|
||||
int a, b, sum = 0;
|
||||
eobj_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_ab_sum_get(&sum));
|
||||
eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_ab_sum_get(&sum));
|
||||
fail_if(sum != a + b + 2); /* 2 for the two mixins... */
|
||||
|
||||
eobj_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));
|
||||
eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum));
|
||||
|
||||
Mixin2_Public_Data *pd2 = eobj_data_get(obj, MIXIN2_CLASS);
|
||||
Mixin2_Public_Data *pd2 = eo_data_get(obj, MIXIN2_CLASS);
|
||||
fail_if(pd2->count != 6);
|
||||
|
||||
Mixin3_Public_Data *pd3 = eobj_data_get(obj, MIXIN3_CLASS);
|
||||
Mixin3_Public_Data *pd3 = eo_data_get(obj, MIXIN3_CLASS);
|
||||
fail_if(pd3->count != 9);
|
||||
|
||||
eobj_unref(obj);
|
||||
eobj_shutdown();
|
||||
eo_unref(obj);
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||
EAPI Eo_Op MIXIN_BASE_ID = 0;
|
||||
|
||||
#define MY_CLASS MIXIN_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a, b;
|
||||
eobj_query(obj, simple_a_get(&a), simple_b_get(&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", eobj_class_name_get(MY_CLASS), __func__);
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_AB_SUM_GET, "i", "Get the sum of a and b."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION_CONST(MIXIN_SUB_ID_AB_SUM_GET, "i", "Get the sum of a and b."),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||
NULL,
|
||||
0,
|
||||
_constructor,
|
||||
|
@ -60,5 +60,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
|
||||
EO_DEFINE_CLASS(mixin_class_get, &class_desc, NULL, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef MIXIN_H
|
||||
#define MIXIN_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op MIXIN_BASE_ID;
|
||||
extern EAPI Eo_Op MIXIN_BASE_ID;
|
||||
|
||||
enum {
|
||||
MIXIN_SUB_ID_AB_SUM_GET,
|
||||
|
@ -18,9 +18,9 @@ enum {
|
|||
* @brief Get sum of a,b integer elements
|
||||
* @param[out] sum integer pointer to sum - value
|
||||
*/
|
||||
#define mixin_ab_sum_get(sum) MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), EOBJ_TYPECHECK(int *, sum)
|
||||
#define mixin_ab_sum_get(sum) MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), EO_TYPECHECK(int *, sum)
|
||||
|
||||
#define MIXIN_CLASS mixin_class_get()
|
||||
const Eobj_Class *mixin_class_get(void) EINA_CONST;
|
||||
const Eo_Class *mixin_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "mixin2.h"
|
||||
#include "simple.h"
|
||||
|
@ -10,51 +10,51 @@
|
|||
#define MY_CLASS MIXIN2_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(const Eobj *obj, const void *class_data, va_list *list)
|
||||
_ab_sum_get(const Eo *obj, const void *class_data, va_list *list)
|
||||
{
|
||||
/* This cast is a hack just for the tests... */
|
||||
Mixin2_Public_Data *pd = (Mixin2_Public_Data *) class_data;
|
||||
int *sum = va_arg(*list, int *);
|
||||
printf("%s %s\n", eobj_class_name_get(MY_CLASS), __func__);
|
||||
eobj_query_super(obj, mixin_ab_sum_get(sum));
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
eo_query_super(obj, mixin_ab_sum_get(sum));
|
||||
|
||||
++*sum;
|
||||
pd->count += 2;
|
||||
|
||||
{
|
||||
int _a, _b;
|
||||
eobj_query(obj, simple_a_get(&_a), simple_b_get(&_b));
|
||||
eo_query(obj, simple_a_get(&_a), simple_b_get(&_b));
|
||||
fail_if(*sum != _a + _b + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Mixin2",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
sizeof(Mixin2_Public_Data),
|
||||
_constructor,
|
||||
|
@ -63,5 +63,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(mixin2_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MIXIN2_H
|
||||
#define MIXIN2_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -9,6 +9,6 @@ typedef struct
|
|||
} Mixin2_Public_Data;
|
||||
|
||||
#define MIXIN2_CLASS mixin2_class_get()
|
||||
const Eobj_Class *mixin2_class_get(void) EINA_CONST;
|
||||
const Eo_Class *mixin2_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "mixin3.h"
|
||||
#include "simple.h"
|
||||
|
@ -10,51 +10,51 @@
|
|||
#define MY_CLASS MIXIN3_CLASS
|
||||
|
||||
static void
|
||||
_ab_sum_get(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
_ab_sum_get(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
/* This cast is just a hack for the test. */
|
||||
Mixin3_Public_Data *pd = (Mixin3_Public_Data *) class_data;
|
||||
int *sum = va_arg(*list, int *);
|
||||
printf("%s %s\n", eobj_class_name_get(MY_CLASS), __func__);
|
||||
eobj_query_super(obj, mixin_ab_sum_get(sum));
|
||||
printf("%s %s\n", eo_class_name_get(MY_CLASS), __func__);
|
||||
eo_query_super(obj, mixin_ab_sum_get(sum));
|
||||
|
||||
++*sum;
|
||||
pd->count += 3;
|
||||
|
||||
{
|
||||
int _a, _b;
|
||||
eobj_query(obj, simple_a_get(&_a), simple_b_get(&_b));
|
||||
eo_query(obj, simple_a_get(&_a), simple_b_get(&_b));
|
||||
fail_if(*sum != _a + _b + 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_destructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_destructor_super(obj);
|
||||
eo_destructor_super(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(MIXIN_ID(MIXIN_SUB_ID_AB_SUM_GET), _ab_sum_get),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Mixin3",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
sizeof(Mixin3_Public_Data),
|
||||
_constructor,
|
||||
|
@ -63,5 +63,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(mixin3_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(mixin3_class_get, &class_desc, MIXIN_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MIXIN3_H
|
||||
#define MIXIN3_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -9,6 +9,6 @@ typedef struct
|
|||
} Mixin3_Public_Data;
|
||||
|
||||
#define MIXIN3_CLASS mixin3_class_get()
|
||||
const Eobj_Class *mixin3_class_get(void) EINA_CONST;
|
||||
const Eo_Class *mixin3_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "mixin.h"
|
||||
#include "mixin2.h"
|
||||
#include "mixin3.h"
|
||||
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ typedef struct
|
|||
|
||||
#define _GET_SET_FUNC(name) \
|
||||
static void \
|
||||
_##name##_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list) \
|
||||
_##name##_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list) \
|
||||
{ \
|
||||
const Private_Data *pd = class_data; \
|
||||
int *name; \
|
||||
|
@ -27,7 +27,7 @@ _##name##_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list
|
|||
printf("%s %d\n", __func__, pd->name); \
|
||||
} \
|
||||
static void \
|
||||
_##name##_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list) \
|
||||
_##name##_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list) \
|
||||
{ \
|
||||
Private_Data *pd = class_data; \
|
||||
int name; \
|
||||
|
@ -40,31 +40,31 @@ _GET_SET_FUNC(a)
|
|||
_GET_SET_FUNC(b)
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
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_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
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 Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Private_Data),
|
||||
NULL,
|
||||
|
@ -73,4 +73,4 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, MIXIN3_CLASS, MIXIN2_CLASS, NULL);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -20,30 +20,30 @@ enum {
|
|||
* @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), EOBJ_TYPECHECK(int, a)
|
||||
#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), EOBJ_TYPECHECK(int *, a)
|
||||
#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), EOBJ_TYPECHECK(int, b)
|
||||
#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), EOBJ_TYPECHECK(int *, b)
|
||||
#define simple_b_get(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EO_TYPECHECK(int *, b)
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,13 +11,13 @@ include_directories(
|
|||
|
||||
add_executable(signals ${SIGNALS_CC_SOURCES})
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(signals
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
)
|
||||
|
||||
add_dependencies(signals eobj)
|
||||
add_dependencies(signals eo)
|
||||
|
||||
add_test(Example_signals signals)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "../eunit_tests.h"
|
||||
|
@ -6,7 +6,7 @@
|
|||
static int cb_count = 0;
|
||||
|
||||
static Eina_Bool
|
||||
_a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
_a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
(void) desc;
|
||||
(void) obj;
|
||||
|
@ -24,47 +24,47 @@ main(int argc, char *argv[])
|
|||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
eobj_init();
|
||||
eo_init();
|
||||
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS);
|
||||
|
||||
/* The order of these two is undetermined. */
|
||||
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2);
|
||||
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1);
|
||||
eo_event_callback_priority_add(obj, SIG_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2);
|
||||
eo_event_callback_priority_add(obj, SIG_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1);
|
||||
/* This will be called afterwards. */
|
||||
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3);
|
||||
eo_event_callback_priority_add(obj, SIG_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3);
|
||||
/* This will never be called because the previous callback returns NULL. */
|
||||
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4);
|
||||
eo_event_callback_priority_add(obj, SIG_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4);
|
||||
|
||||
eobj_do(obj, simple_a_set(1));
|
||||
eo_do(obj, simple_a_set(1));
|
||||
|
||||
fail_if(cb_count != 3);
|
||||
|
||||
eobj_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 3);
|
||||
eo_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 3);
|
||||
fail_if(pd->cb_count != 3);
|
||||
|
||||
fail_if(eobj_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 12));
|
||||
fail_if(eo_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 12));
|
||||
fail_if(pd->cb_count != 3);
|
||||
|
||||
fail_if(4 != (int) eobj_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 4));
|
||||
fail_if(4 != (int) eo_event_callback_del(obj, SIG_A_CHANGED, _a_changed_cb, (void *) 4));
|
||||
fail_if(pd->cb_count != 2);
|
||||
eobj_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb);
|
||||
eo_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb);
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
fail_if(eobj_event_callback_del_lazy(obj, SIG_A_CHANGED, NULL));
|
||||
fail_if(eo_event_callback_del_lazy(obj, SIG_A_CHANGED, NULL));
|
||||
fail_if(pd->cb_count != 1);
|
||||
fail_if(eobj_event_callback_del(obj, SIG_A_CHANGED, NULL, 0));
|
||||
fail_if(eo_event_callback_del(obj, SIG_A_CHANGED, NULL, 0));
|
||||
fail_if(pd->cb_count != 1);
|
||||
|
||||
eobj_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb);
|
||||
eo_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb);
|
||||
fail_if(pd->cb_count != 0);
|
||||
|
||||
fail_if(eobj_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb));
|
||||
fail_if(eo_event_callback_del_lazy(obj, SIG_A_CHANGED, _a_changed_cb));
|
||||
fail_if(pd->cb_count != 0);
|
||||
|
||||
eobj_unref(obj);
|
||||
eobj_shutdown();
|
||||
eo_unref(obj);
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -11,13 +11,13 @@ typedef struct
|
|||
int a;
|
||||
} Private_Data;
|
||||
|
||||
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
EAPI const Eo_Event_Description _SIG_A_CHANGED =
|
||||
EO_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
int a;
|
||||
|
@ -25,14 +25,14 @@ _a_set(Eobj *obj, void *class_data, va_list *list)
|
|||
pd->a = a;
|
||||
printf("%s %d\n", __func__, pd->a);
|
||||
|
||||
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
eo_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_cb_added(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
_cb_added(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, MY_CLASS);
|
||||
const Eobj_Event_Description *cb_desc = event_info;
|
||||
Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
|
||||
const Eo_Event_Description *cb_desc = event_info;
|
||||
(void) data;
|
||||
(void) desc;
|
||||
|
||||
|
@ -42,14 +42,14 @@ _cb_added(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event
|
|||
pd->cb_count++;
|
||||
|
||||
printf("Added SIG_A_CHANGED callback to %p. Count: %d\n", obj, pd->cb_count);
|
||||
return EOBJ_CALLBACK_CONTINUE;
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||
_cb_deled(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, MY_CLASS);
|
||||
const Eobj_Event_Description *cb_desc = event_info;
|
||||
Simple_Public_Data *pd = eo_data_get(obj, MY_CLASS);
|
||||
const Eo_Event_Description *cb_desc = event_info;
|
||||
(void) data;
|
||||
(void) desc;
|
||||
|
||||
|
@ -59,45 +59,45 @@ _cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event
|
|||
pd->cb_count--;
|
||||
|
||||
printf("Removed SIG_A_CHANGED callback from %p. Count: %d\n", obj, pd->cb_count);
|
||||
return EOBJ_CALLBACK_CONTINUE;
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
eobj_constructor_super(obj);
|
||||
eo_constructor_super(obj);
|
||||
|
||||
eobj_event_callback_add(obj, EOBJ_EV_CALLBACK_ADD, _cb_added, NULL);
|
||||
eobj_event_callback_add(obj, EOBJ_EV_CALLBACK_DEL, _cb_deled, NULL);
|
||||
eo_event_callback_add(obj, EO_EV_CALLBACK_ADD, _cb_added, NULL);
|
||||
eo_event_callback_add(obj, EO_EV_CALLBACK_DEL, _cb_deled, NULL);
|
||||
|
||||
eobj_do(obj, eobj_base_data_set("cb_count", (intptr_t) 0, NULL));
|
||||
eo_do(obj, eo_base_data_set("cb_count", (intptr_t) 0, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
SIG_A_CHANGED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
_constructor,
|
||||
|
@ -106,5 +106,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL);
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -22,12 +22,12 @@ typedef struct
|
|||
* @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), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
extern const Eo_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
LIST(APPEND EOBJ_CC_SOURCES
|
||||
eobj.c
|
||||
eobj_base_class.c
|
||||
LIST(APPEND EO_CC_SOURCES
|
||||
eo.c
|
||||
eo_base_class.c
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DEFL_EOBJ_BUILD=1)
|
||||
ADD_DEFINITIONS(-DEFL_EO_BUILD=1)
|
||||
|
||||
include_directories(
|
||||
${EINA_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
add_library(eobj SHARED ${EOBJ_CC_SOURCES})
|
||||
target_link_libraries(eobj
|
||||
add_library(eo SHARED ${EO_CC_SOURCES})
|
||||
target_link_libraries(eo
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${EFL_COVERAGE_LIBS}
|
||||
)
|
||||
|
||||
set_target_properties(eobj PROPERTIES
|
||||
set_target_properties(eo PROPERTIES
|
||||
COMPILE_FLAGS "${EFL_COVERAGE_CFLAGS}")
|
||||
set_target_properties(eobj PROPERTIES
|
||||
VERSION ${EOBJ_VERSION} SOVERSION ${EOBJ_VERSION_MAJOR})
|
||||
set_target_properties(eobj PROPERTIES OUTPUT_NAME "eobj")
|
||||
set_target_properties(eo PROPERTIES
|
||||
VERSION ${EO_VERSION} SOVERSION ${EO_VERSION_MAJOR})
|
||||
set_target_properties(eo PROPERTIES OUTPUT_NAME "eo")
|
||||
|
||||
INSTALL(TARGETS eobj DESTINATION "lib")
|
||||
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Eobj.h"
|
||||
INSTALL(TARGETS eo DESTINATION "lib")
|
||||
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Eo.h"
|
||||
DESTINATION "include")
|
||||
|
|
|
@ -0,0 +1,969 @@
|
|||
#ifndef EO_H
|
||||
#define EO_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <Eina.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_EO_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif /* ! DLL_EXPORT */
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif /* ! EFL_EO_BUILD */
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
/**
|
||||
* @var _eo_class_creation_lock
|
||||
* This variable is used for locking purposes in the class_get function
|
||||
* defined in #EO_DEFINE_CLASS.
|
||||
* This is just to work around the fact that we need to init locks before
|
||||
* using them.
|
||||
* Don't touch it if you don't know what you are doing.
|
||||
* @internal
|
||||
*/
|
||||
EAPI extern Eina_Lock _eo_class_creation_lock;
|
||||
|
||||
/**
|
||||
* @defgroup Eo Eo Generic Object System
|
||||
*
|
||||
* The Eo generic object system. It was designed to be the base object
|
||||
* system for the EFL.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EO_TYPECHECK(type, x)
|
||||
*
|
||||
* Checks x is castable to type "type" and casts it to it.
|
||||
* @param type The C type to check against.
|
||||
* @param x the variable to test and cast.
|
||||
*/
|
||||
#define EO_TYPECHECK(type, x) \
|
||||
({ \
|
||||
type __x; \
|
||||
__x = x; \
|
||||
(void) __x; \
|
||||
(type) x; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @typedef Eo
|
||||
* The basic Object type.
|
||||
*/
|
||||
typedef struct _Eo Eo;
|
||||
/**
|
||||
* @typedef Eo_Op
|
||||
* The Eo operation type id.
|
||||
*/
|
||||
typedef unsigned int Eo_Op;
|
||||
|
||||
/**
|
||||
* @def EO_NOOP
|
||||
* A special #Eo_Op meaning "No operation".
|
||||
*/
|
||||
#define EO_NOOP ((Eo_Op) 0)
|
||||
|
||||
/**
|
||||
* @typedef eo_op_func_type
|
||||
* The type of the Op functions. This is the type of the functions used by
|
||||
* Eo.
|
||||
*
|
||||
* @see eo_op_func_type_const
|
||||
*/
|
||||
typedef void (*eo_op_func_type)(Eo *, void *class_data, va_list *list);
|
||||
|
||||
/**
|
||||
* @typedef eo_op_func_type_const
|
||||
* The type of the const Op functions. This is the type of the functions used
|
||||
* by Eo. This is the same as #eo_op_func_type, except that this should
|
||||
* be used with functions that don't modify the data.
|
||||
*
|
||||
* @see eo_op_func_type
|
||||
*/
|
||||
typedef void (*eo_op_func_type_const)(const Eo *, const void *class_data, va_list *list);
|
||||
|
||||
/**
|
||||
* @addtogroup Eo_Events Eo's Event Handling
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct _Eo_Event_Description
|
||||
* This struct holds the description of a specific event.
|
||||
*/
|
||||
struct _Eo_Event_Description
|
||||
{
|
||||
const char *name; /**< name of the event. */
|
||||
const char *type; /**< describes the data passed in event_info */
|
||||
const char *doc; /**< Explanation about the event. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eo_Event_Description
|
||||
* A convenience typedef for #_Eo_Event_Description
|
||||
*/
|
||||
typedef struct _Eo_Event_Description Eo_Event_Description;
|
||||
|
||||
/**
|
||||
* @def EO_EVENT_DESCRIPTION(name, type, doc)
|
||||
* An helper macro to help populating #Eo_Event_Description
|
||||
* @param name The name of the event.
|
||||
* @param type The type string of the event.
|
||||
* @param doc Additional doc for the event.
|
||||
* @see Eo_Event_Description
|
||||
*/
|
||||
#define EO_EVENT_DESCRIPTION(name, type, doc) { name, type, doc }
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eo_Class Eo Class
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Eo_Class
|
||||
* The basic Object class type.
|
||||
*/
|
||||
typedef struct _Eo_Class Eo_Class;
|
||||
|
||||
/**
|
||||
* @def EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
|
||||
* A convenience macro to be used for creating the class_get function. This
|
||||
* macro is fairly simple but should still be used as it'll let us improve
|
||||
* things easily.
|
||||
* @param class_get_func_name the name of the wanted class_get function name.
|
||||
* @param class_desc the class description.
|
||||
* @param parent_class The parent class for the function. Look at eo_class_new() for more information.
|
||||
* @param ... List of etxensions. Look at eo_class_new() for more information.
|
||||
*
|
||||
* You must use this macro if you want thread safety in class creation.
|
||||
*/
|
||||
#define EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
|
||||
EAPI const Eo_Class * \
|
||||
class_get_func_name(void) \
|
||||
{ \
|
||||
static volatile char lk_init = 0; \
|
||||
static Eina_Lock _my_lock; \
|
||||
static const Eo_Class * volatile _my_class = NULL; \
|
||||
if (EINA_LIKELY(!!_my_class)) return _my_class; \
|
||||
\
|
||||
eina_lock_take(&_eo_class_creation_lock); \
|
||||
if (!lk_init) \
|
||||
eina_lock_new(&_my_lock); \
|
||||
if (lk_init < 2) eina_lock_take(&_my_lock); \
|
||||
if (!lk_init) \
|
||||
lk_init = 1; \
|
||||
else \
|
||||
{ \
|
||||
if (lk_init < 2) eina_lock_release(&_my_lock); \
|
||||
eina_lock_release(&_eo_class_creation_lock); \
|
||||
return _my_class; \
|
||||
} \
|
||||
eina_lock_release(&_eo_class_creation_lock); \
|
||||
_my_class = eo_class_new(class_desc, parent_class, __VA_ARGS__); \
|
||||
eina_lock_release(&_my_lock); \
|
||||
\
|
||||
eina_lock_take(&_eo_class_creation_lock); \
|
||||
eina_lock_free(&_my_lock); \
|
||||
lk_init = 2; \
|
||||
eina_lock_release(&_eo_class_creation_lock); \
|
||||
return _my_class; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enum representing the possible types of an Eo class.
|
||||
*/
|
||||
enum _Eo_Class_Type
|
||||
{
|
||||
EO_CLASS_TYPE_REGULAR = 0, /**< Regular class. */
|
||||
EO_CLASS_TYPE_REGULAR_NO_INSTANT, /**< Regular non instant-able class. */
|
||||
EO_CLASS_TYPE_INTERFACE, /**< Interface */
|
||||
EO_CLASS_TYPE_MIXIN /**< Mixin */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eo_Class_Type
|
||||
* A convenience typedef for #_Eo_Class_Type.
|
||||
*/
|
||||
typedef enum _Eo_Class_Type Eo_Class_Type;
|
||||
|
||||
/**
|
||||
* @struct _Eo_Op_Func_Description
|
||||
* Used to associate an Op with a func.
|
||||
* @see eo_class_funcs_set
|
||||
*/
|
||||
struct _Eo_Op_Func_Description
|
||||
{
|
||||
Eo_Op op; /**< The op */
|
||||
eo_op_func_type func; /**< The function to call for the op. */
|
||||
Eina_Bool constant; /**< #EINA_TRUE if this function is a const. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eo_Op_Func_Description
|
||||
* A convenience typedef for #_Eo_Op_Func_Description
|
||||
*/
|
||||
typedef struct _Eo_Op_Func_Description Eo_Op_Func_Description;
|
||||
|
||||
/**
|
||||
* @def EO_OP_FUNC(op, func)
|
||||
* A convenience macro to be used when populating the #Eo_Op_Func_Description
|
||||
* array.
|
||||
*
|
||||
* @see EO_OP_FUNC_CONST
|
||||
*/
|
||||
#define EO_OP_FUNC(op, func) { op, EO_TYPECHECK(eo_op_func_type, func), EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @def EO_OP_FUNC_CONST(op, func)
|
||||
* A convenience macro to be used when populating the #Eo_Op_Func_Description
|
||||
* array.
|
||||
* The same as #EO_OP_FUNC but for const functions.
|
||||
*
|
||||
* @see EO_OP_FUNC
|
||||
*/
|
||||
#define EO_OP_FUNC_CONST(op, func) { op, (eo_op_func_type) EO_TYPECHECK(eo_op_func_type_const, func), EINA_TRUE }
|
||||
|
||||
/**
|
||||
* @def EO_OP_FUNC_SENTINEL
|
||||
* A convenience macro to be used when populating the #Eo_Op_Func_Description
|
||||
* array. It must appear at the end of the ARRAY.
|
||||
*/
|
||||
#define EO_OP_FUNC_SENTINEL { 0, NULL, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @struct _Eo_Op_Description
|
||||
* This struct holds the description of a specific op.
|
||||
*/
|
||||
struct _Eo_Op_Description
|
||||
{
|
||||
Eo_Op sub_op; /**< The sub_id of the op in it's class. */
|
||||
const char *name; /**< The name of the op. */
|
||||
const char *type; /**< descripbes the Op's function signature. */
|
||||
const char *doc; /**< Explanation about the Op. */
|
||||
Eina_Bool constant; /**< #EINA_TRUE if this op's implementation should not change the obj. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eo_Op_Description
|
||||
* A convenience typedef for #_Eo_Op_Description
|
||||
*/
|
||||
typedef struct _Eo_Op_Description Eo_Op_Description;
|
||||
|
||||
/**
|
||||
* @struct _Eo_Class_Description
|
||||
* This struct holds the description of a class.
|
||||
* This description should be passed to eo_class_new.
|
||||
* Please use the #EO_CLASS_DESCRIPTION_OPS macro when populating it.
|
||||
*/
|
||||
struct _Eo_Class_Description
|
||||
{
|
||||
const char *name; /**< The name of the class. */
|
||||
Eo_Class_Type type; /**< The type of the class. */
|
||||
struct {
|
||||
Eo_Op *base_op_id;
|
||||
const Eo_Op_Description *descs;
|
||||
size_t count;
|
||||
} ops; /**< The ops description, should be filled using #EO_CLASS_DESCRIPTION_OPS */
|
||||
const Eo_Event_Description **events; /**< The event descriptions for this class. */
|
||||
size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */
|
||||
void (*constructor)(Eo *obj, void *class_data); /**< The constructor of the object. */
|
||||
void (*destructor)(Eo *obj, void *class_data); /**< The destructor of the object. */
|
||||
void (*class_constructor)(Eo_Class *klass); /**< The constructor of the class. */
|
||||
void (*class_destructor)(Eo_Class *klass); /**< The destructor of the class. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eo_Class_Description
|
||||
* A convenience typedef for #_Eo_Class_Description
|
||||
*/
|
||||
typedef struct _Eo_Class_Description Eo_Class_Description;
|
||||
|
||||
/**
|
||||
* @def EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count)
|
||||
* An helper macro to help populating #Eo_Class_Description.
|
||||
* @param base_op_id A pointer to the base op id of the class.
|
||||
* @param op_descs the op descriptions array.
|
||||
* @param count the number of ops in the op descriptions array.
|
||||
*/
|
||||
#define EO_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
|
||||
|
||||
/**
|
||||
* @def EO_OP_DESCRIPTION(op, type, doc)
|
||||
* An helper macro to help populating #Eo_Op_Description
|
||||
* @param sub_id The sub id of the op being described.
|
||||
* @param type The type string for the op.
|
||||
* @param doc Additional doc for the op.
|
||||
* @see Eo_Op_Description
|
||||
* @see EO_OP_DESCRIPTION_CONST
|
||||
* @see EO_OP_DESCRIPTION_SENTINEL
|
||||
*/
|
||||
#define EO_OP_DESCRIPTION(sub_id, type, doc) { sub_id, #sub_id, type, doc, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @def EO_OP_DESCRIPTION_CONST(op, type, doc)
|
||||
* An helper macro to help populating #Eo_Op_Description
|
||||
* This macro is the same as EO_OP_DESCRIPTION but indicates that the op's
|
||||
* implementation should not change the object.
|
||||
* @param sub_id The sub id of the op being described.
|
||||
* @param type The type string for the op.
|
||||
* @param doc Additional doc for the op.
|
||||
* @see Eo_Op_Description
|
||||
* @see EO_OP_DESCRIPTION
|
||||
* @see EO_OP_DESCRIPTION_SENTINEL
|
||||
*/
|
||||
#define EO_OP_DESCRIPTION_CONST(sub_id, type, doc) { sub_id, #sub_id, type, doc, EINA_TRUE }
|
||||
|
||||
/**
|
||||
* @def EO_OP_DESCRIPTION_SENTINEL
|
||||
* An helper macro to help populating #Eo_Op_Description
|
||||
* Should be placed at the end of the array.
|
||||
* @see Eo_Op_Description
|
||||
* @see EO_OP_DESCRIPTION
|
||||
*/
|
||||
#define EO_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, NULL, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @brief Create a new class.
|
||||
* @param desc the class description to create the class with.
|
||||
* @param parent the class to inherit from.
|
||||
* @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
|
||||
* @return The new class's handle on success, or NULL otherwise.
|
||||
*
|
||||
* You should use #EO_DEFINE_CLASS. It'll provide thread safety and other
|
||||
* features easily.
|
||||
*
|
||||
* @see #EO_DEFINE_CLASS
|
||||
*/
|
||||
EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent, ...);
|
||||
|
||||
/**
|
||||
* @brief Sets the OP functions for a class.
|
||||
* @param klass the class to set the functions to.
|
||||
* @param func_descs a NULL terminated array of #Eo_Op_Func_Description
|
||||
*
|
||||
* Should be called from within the class constructor.
|
||||
*/
|
||||
EAPI void eo_class_funcs_set(Eo_Class *klass, const Eo_Op_Func_Description *func_descs);
|
||||
|
||||
/**
|
||||
* @brief Gets the name of the passed class.
|
||||
* @param klass the class to work on.
|
||||
* @return The class's name.
|
||||
*
|
||||
* @see eo_class_get()
|
||||
*/
|
||||
EAPI const char *eo_class_name_get(const Eo_Class *klass);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Init the eo subsystem
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* @see eo_shutfown()
|
||||
*/
|
||||
EAPI Eina_Bool eo_init(void);
|
||||
|
||||
/**
|
||||
* @brief Shutdown the eo subsystem
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* @see eo_init()
|
||||
*/
|
||||
EAPI Eina_Bool eo_shutdown(void);
|
||||
|
||||
/**
|
||||
* @def eo_do
|
||||
* A convenience wrapper around eo_do_internal()
|
||||
* @see eo_do_internal
|
||||
*/
|
||||
#define eo_do(obj, ...) eo_do_internal(obj, EINA_FALSE, __VA_ARGS__, EO_NOOP)
|
||||
|
||||
/**
|
||||
* @def eo_query
|
||||
* Same as #eo_do but only for const ops.
|
||||
* @see eo_do
|
||||
*/
|
||||
#define eo_query(obj, ...) eo_do_internal((Eo *) EO_TYPECHECK(const Eo *, obj), EINA_TRUE, __VA_ARGS__, EO_NOOP)
|
||||
|
||||
/**
|
||||
* @brief Issues ops on an object.
|
||||
* @param obj The object to work on
|
||||
* @param constant #EINA_TRUE if this call is on a constant object.
|
||||
* @param ... NULL terminated list of OPs and parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Use the helper macros, don't pass the parameters manually.
|
||||
* Use #eo_do instead of this function.
|
||||
*
|
||||
* @see #eo_do
|
||||
*/
|
||||
EAPI Eina_Bool eo_do_internal(Eo *obj, Eina_Bool constant, ...);
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Unlike eo_do() and eo_query(), this function only accepts one op.
|
||||
*
|
||||
* Use the helper macros, don't pass the parameters manually.
|
||||
*
|
||||
* Same as eo_do_super() just for const objects.
|
||||
*
|
||||
* @see #eo_query
|
||||
* @see eo_do_super()
|
||||
*/
|
||||
#define eo_query_super(obj, ...) eo_do_super_internal((Eo *) EO_TYPECHECK(const Eo *, obj), EINA_TRUE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Unlike eo_do() and eo_query(), this function only accepts one op.
|
||||
*
|
||||
* @see #eo_query
|
||||
* @see eo_query_super()
|
||||
*/
|
||||
#define eo_do_super(obj, ...) eo_do_super_internal((Eo *) EO_TYPECHECK(const Eo *, obj), EINA_FALSE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param constant #EINA_TRUE if this call is on a constant object.
|
||||
* @param op The wanted op.
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Don't use this function, use the wrapping macros instead.
|
||||
*
|
||||
* @see #eo_do
|
||||
* @see #eo_do_super
|
||||
* @see #eo_query_super
|
||||
*/
|
||||
EAPI Eina_Bool eo_do_super_internal(Eo *obj, Eina_Bool constant, Eo_Op op, ...);
|
||||
|
||||
/**
|
||||
* @brief Gets the class of the object.
|
||||
* @param obj The object to work on
|
||||
* @return The object's class.
|
||||
*
|
||||
* @see eo_class_name_get()
|
||||
*/
|
||||
EAPI const Eo_Class *eo_class_get(const Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Calls the super constructor of the object passed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eo_destructor_super()
|
||||
*/
|
||||
EAPI void eo_constructor_super(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Calls the super destructor of the object passed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eo_constructor_super()
|
||||
*/
|
||||
EAPI void eo_destructor_super(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Notify eo that there was an error when constructing the object.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* (Should only be called from within a constructor/destructor).
|
||||
*
|
||||
* @see eo_constructor_error_get()
|
||||
*/
|
||||
EAPI void eo_constructor_error_set(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Check if there was an error constructing obj
|
||||
* @param obj the object to work on.
|
||||
* @return #EINA_TRUE if there was an error.
|
||||
*
|
||||
* (Should only be called from within a constructor/destructor).
|
||||
*
|
||||
* @see eo_constructor_error_set()
|
||||
*/
|
||||
EAPI Eina_Bool eo_constructor_error_get(const Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Create a new object.
|
||||
* @param klass the class of the object to create.
|
||||
* @param parent the parent to set to the object.
|
||||
* @return An handle to the new object on success, NULL otherwise.
|
||||
*/
|
||||
EAPI Eo *eo_add(const Eo_Class *klass, Eo *parent);
|
||||
|
||||
/**
|
||||
* @brief Get the parent of an object
|
||||
* @param obj the object to get the parent of.
|
||||
* @return a pointer to the parent object.
|
||||
*/
|
||||
EAPI Eo *eo_parent_get(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the data of an object for a specific class.
|
||||
* @param obj the object to work on.
|
||||
* @param klass the klass associated with the data.
|
||||
* @return a pointer to the data.
|
||||
*/
|
||||
EAPI void *eo_data_get(const Eo *obj, const Eo_Class *klass);
|
||||
|
||||
/**
|
||||
* @brief Increment the object's reference count by 1.
|
||||
* @param obj the object to work on.
|
||||
* @return The object passed.
|
||||
*
|
||||
* It's very easy to get a refcount leak and start leaking memory because
|
||||
* of a forgotten unref or an extra ref. That is why there are eo_xref
|
||||
* and eo_xunref that will make debugging easier in such a case.
|
||||
* Therefor, these functions should only be used in small scopes, i.e at the
|
||||
* start of some section in which the object may get freed, or if you know
|
||||
* what you are doing.
|
||||
*
|
||||
* @see eo_unref()
|
||||
* @see eo_ref_get()
|
||||
*/
|
||||
EAPI Eo *eo_ref(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Decrement the object's reference count by 1 and free it if needed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eo_ref()
|
||||
* @see eo_ref_get()
|
||||
*/
|
||||
EAPI void eo_unref(Eo *obj);
|
||||
|
||||
/**
|
||||
* @brief Return the ref count of the object passed.
|
||||
* @param obj the object to work on.
|
||||
* @return the ref count of the object.
|
||||
*
|
||||
* @see eo_ref()
|
||||
* @see eo_unref()
|
||||
*/
|
||||
EAPI int eo_ref_get(const Eo *obj);
|
||||
|
||||
/**
|
||||
* @def eo_xref(obj, ref_obj)
|
||||
* Convenience macro around eo_xref()
|
||||
* @see eo_xref()
|
||||
*/
|
||||
#define eo_xref(obj, ref_obj) eo_xref_internal(obj, ref_obj, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* @brief Increment the object's reference count by 1 (and associate the ref with ref_obj)
|
||||
* @param obj the object to work on.
|
||||
* @param ref_obj the object that references obj.
|
||||
* @param file the call's filename.
|
||||
* @param line the call's line number.
|
||||
* @return The object passed (obj)
|
||||
*
|
||||
* People should not use this function, use #eo_xref instead.
|
||||
*
|
||||
* @see eo_xunref()
|
||||
*/
|
||||
EAPI Eo *eo_xref_internal(Eo *obj, const Eo *ref_obj, const char *file, int line);
|
||||
|
||||
/**
|
||||
* @brief Decrement the object's reference count by 1 and free it if needed. Will free the ref associated with ref_obj).
|
||||
* @param obj the object to work on.
|
||||
* @param ref_obj the object that references obj.
|
||||
*
|
||||
* This function only enforces the checks for object association. I.e don't rely
|
||||
* on it. If such enforces are compiled out, this function behaves the same as
|
||||
* eo_unref().
|
||||
*
|
||||
* @see eo_xref_internal()
|
||||
*/
|
||||
EAPI void eo_xunref(Eo *obj, const Eo *ref_obj);
|
||||
|
||||
/**
|
||||
* @brief Delete the object passed (disregarding ref count).
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eo_unref()
|
||||
*/
|
||||
EAPI void eo_del(Eo *obj);
|
||||
|
||||
/**
|
||||
* @addtogroup Eo_Composite_Objects Composite Objects.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Make an object a composite object of another.
|
||||
* @param obj the "parent" object.
|
||||
* @param comp_obj the object that will be used to composite obj.
|
||||
*
|
||||
* @see eo_composite_object_detach()
|
||||
* @see eo_composite_is()
|
||||
*/
|
||||
EAPI void eo_composite_object_attach(Eo *obj, Eo *comp_obj);
|
||||
|
||||
/**
|
||||
* @brief Detach a composite object from another object.
|
||||
* @param obj the "parent" object.
|
||||
* @param comp_obj the object attached to obj.
|
||||
*
|
||||
* @see eo_composite_object_attach()
|
||||
* @see eo_composite_is()
|
||||
*/
|
||||
EAPI void eo_composite_object_detach(Eo *obj, Eo *comp_obj);
|
||||
|
||||
/**
|
||||
* @brief Check if an object is a composite object.
|
||||
* @param comp_obj the object to be checked.
|
||||
* @return #EINA_TRUE if it is, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eo_composite_object_attach()
|
||||
* @see eo_composite_object_detach()
|
||||
*/
|
||||
EAPI Eina_Bool eo_composite_is(Eo *comp_obj);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eo_Events Eo's Event Handling
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EO_CALLBACK_PRIORITY_BEFORE
|
||||
* Slightly more prioritized than default.
|
||||
*/
|
||||
#define EO_CALLBACK_PRIORITY_BEFORE -100
|
||||
/**
|
||||
* @def EO_CALLBACK_PRIORITY_DEFAULT
|
||||
* Default callback priority level
|
||||
*/
|
||||
#define EO_CALLBACK_PRIORITY_DEFAULT 0
|
||||
/**
|
||||
* @def EO_CALLBACK_PRIORITY_AFTER
|
||||
* Slightly less prioritized than default.
|
||||
*/
|
||||
#define EO_CALLBACK_PRIORITY_AFTER 100
|
||||
|
||||
/**
|
||||
* @typedef Eo_Callback_Priority
|
||||
*
|
||||
* Callback priority value. Range is -32k - 32k. The lower the number, the
|
||||
* higher the priority.
|
||||
*
|
||||
* @see EO_CALLBACK_PRIORITY_AFTER
|
||||
* @see EO_CALLBACK_PRIORITY_BEFORE
|
||||
* @see EO_CALLBACK_PRIORITY_DEFAULT
|
||||
*/
|
||||
typedef short Eo_Callback_Priority;
|
||||
|
||||
/**
|
||||
* @def EO_CALLBACK_STOP
|
||||
* Stop calling callbacks for the even of which the callback was called for.
|
||||
* @see EO_CALLBACK_CONTINUE
|
||||
*/
|
||||
#define EO_CALLBACK_STOP EINA_FALSE
|
||||
|
||||
/**
|
||||
* @def EO_CALLBACK_CONTINUE
|
||||
* Continue calling callbacks for the even of which the callback was called for.
|
||||
* @see EO_CALLBACK_STOP
|
||||
*/
|
||||
#define EO_CALLBACK_CONTINUE EINA_TRUE
|
||||
|
||||
/**
|
||||
* @typedef Eo_Event_Cb
|
||||
*
|
||||
* An event callback prototype.
|
||||
*
|
||||
* @param data The user data registered with the callback.
|
||||
* @param obj The object which initiated the event.
|
||||
* @param desc The event's description.
|
||||
* @param event_info additional data passed with the event.
|
||||
* @return #EO_CALLBACK_STOP to stop calling additional callbacks for the event, #EO_CALLBACK_CONTINUE to continue.
|
||||
*/
|
||||
typedef Eina_Bool (*Eo_Event_Cb)(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
|
||||
|
||||
/**
|
||||
* @brief Add an event callback forwarder for an event and an object.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param new_obj The object to emit events from.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eo_event_callback_forwarder_del()
|
||||
*/
|
||||
EAPI Eina_Bool eo_event_callback_forwarder_add(Eo *obj, const Eo_Event_Description *desc, Eo *new_obj);
|
||||
|
||||
/**
|
||||
* @brief Remove an event callback forwarder for an event and an object.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param new_obj The object to emit events from.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eo_event_callback_forwarder_add()
|
||||
*/
|
||||
EAPI Eina_Bool eo_event_callback_forwarder_del(Eo *obj, const Eo_Event_Description *desc, Eo *new_obj);
|
||||
|
||||
/**
|
||||
* @def eo_event_callback_add(obj, desc, cb, data)
|
||||
* Add a callback for an event.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param cb the callback to call.
|
||||
* @param data additional data to pass to the callback.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* callbacks of the same priority are called in reverse order of creation.
|
||||
*
|
||||
* @see eo_event_callback_priority_add()
|
||||
*/
|
||||
#define eo_event_callback_add(obj, desc, cb, data) \
|
||||
eo_event_callback_priority_add(obj, desc, \
|
||||
EO_CALLBACK_PRIORITY_DEFAULT, cb, data)
|
||||
|
||||
/**
|
||||
* @brief Add a callback for an event with a specific priority.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param priority The priority of the callback.
|
||||
* @param cb the callback to call.
|
||||
* @param data additional data to pass to the callback.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* callbacks of the same priority are called in reverse order of creation.
|
||||
*
|
||||
* @see #eo_event_callback_add
|
||||
*/
|
||||
EAPI Eina_Bool eo_event_callback_priority_add(Eo *obj, const Eo_Event_Description *desc, Eo_Callback_Priority priority, Eo_Event_Cb cb, const void *data);
|
||||
|
||||
/**
|
||||
* @brief Del a callback for an event
|
||||
* @param obj The object to listen to delete from.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param func the callback to delete.
|
||||
* @return The additional data that was set to be passed to the callback.
|
||||
*
|
||||
* @see eo_event_callback_del()
|
||||
*/
|
||||
EAPI void *eo_event_callback_del_lazy(Eo *obj, const Eo_Event_Description *desc, Eo_Event_Cb func);
|
||||
|
||||
/**
|
||||
* @brief Del a callback with a specific data associated to it for an event.
|
||||
* @param obj The object to listen to delete from.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param func the callback to delete.
|
||||
* @param user_data The data to compare.
|
||||
* @return The additional data that was set to be passed to the callback.
|
||||
*
|
||||
* @see eo_event_callback_del_lazy()
|
||||
*/
|
||||
EAPI void *eo_event_callback_del(Eo *obj, const Eo_Event_Description *desc, Eo_Event_Cb func, const void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Call the callbacks for an event of an object.
|
||||
* @param obj The object to work on.
|
||||
* @param desc The description of the event to call.
|
||||
* @param event_info Extra event info to pass to the callbacks.
|
||||
* @return #EINA_FALSE if one of the callbacks aborted the callback calls or #EINA_TRUE otherwise.
|
||||
*/
|
||||
EAPI Eina_Bool eo_event_callback_call(Eo *obj, const Eo_Event_Description *desc, const void *event_info);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eo_Class_Base Eo's Base class.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EO_BASE_CLASS
|
||||
* The class type for the Eo base class.
|
||||
*/
|
||||
#define EO_BASE_CLASS eo_base_class_get()
|
||||
/**
|
||||
* @brief Use #EO_BASE_CLASS
|
||||
* @internal
|
||||
* */
|
||||
EAPI const Eo_Class *eo_base_class_get(void) EINA_CONST;
|
||||
|
||||
/**
|
||||
* @typedef eo_base_data_free_func
|
||||
* Data free func prototype.
|
||||
*/
|
||||
typedef void (*eo_base_data_free_func)(void *);
|
||||
|
||||
/**
|
||||
* @var EO_BASE_BASE_ID
|
||||
* #EO_BASE_CLASS 's base id.
|
||||
*/
|
||||
extern EAPI Eo_Op EO_BASE_BASE_ID;
|
||||
|
||||
enum {
|
||||
EO_BASE_SUB_ID_DATA_SET,
|
||||
EO_BASE_SUB_ID_DATA_GET,
|
||||
EO_BASE_SUB_ID_DATA_DEL,
|
||||
EO_BASE_SUB_ID_WREF_ADD,
|
||||
EO_BASE_SUB_ID_WREF_DEL,
|
||||
EO_BASE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @def EO_BASE_ID(sub_id)
|
||||
* Helper macro to get the full Op ID out of the sub_id for EO_BASE.
|
||||
* @param sub_id the sub id inside EO_BASE.
|
||||
*/
|
||||
#define EO_BASE_ID(sub_id) (EO_BASE_BASE_ID + sub_id)
|
||||
|
||||
/**
|
||||
* @def eo_base_data_set(key, data, free_func)
|
||||
* Set generic data to object.
|
||||
* @param[in] key the key associated with the data
|
||||
* @param[in] data the data to set.
|
||||
* @param[in] free_func the func to free data with (NULL means "do nothing").
|
||||
*
|
||||
* @see #eo_base_data_get
|
||||
* @see #eo_base_data_del
|
||||
*/
|
||||
#define eo_base_data_set(key, data, free_func) EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(const void *, data), EO_TYPECHECK(eo_base_data_free_func, free_func)
|
||||
|
||||
/**
|
||||
* @def eo_base_data_get(key, data)
|
||||
* Get generic data from object.
|
||||
* @param[in] key the key associated with the data
|
||||
* @param[out] data the data for the key
|
||||
*
|
||||
* @see #eo_base_data_set
|
||||
* @see #eo_base_data_del
|
||||
*/
|
||||
#define eo_base_data_get(key, data) EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), EO_TYPECHECK(const char *, key), EO_TYPECHECK(void **, data)
|
||||
|
||||
/**
|
||||
* @def eo_base_data_del(key)
|
||||
* Del generic data from object.
|
||||
* @param[in] key the key associated with the data
|
||||
*
|
||||
* @see #eo_base_data_set
|
||||
* @see #eo_base_data_get
|
||||
*/
|
||||
#define eo_base_data_del(key) EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), EO_TYPECHECK(const char *, key)
|
||||
|
||||
/**
|
||||
* @def eo_wref_add
|
||||
* @brief Add a new weak reference to obj.
|
||||
* @param wref The pointer to use for the weak ref.
|
||||
*
|
||||
* This function registers the object handle pointed by wref to obj so when
|
||||
* obj is deleted it'll be updated to NULL. This functions should be used
|
||||
* when you want to keep track of an object in a safe way, but you don't want
|
||||
* to prevent it from being freed.
|
||||
*
|
||||
* @see #eo_wref_del
|
||||
*/
|
||||
#define eo_wref_add(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), EO_TYPECHECK(Eo **, wref)
|
||||
|
||||
/**
|
||||
* @def eo_wref_del
|
||||
* @brief Delete the weak reference passed.
|
||||
* @param wref the weak reference to free.
|
||||
*
|
||||
* @see #eo_wref_add
|
||||
*/
|
||||
#define eo_wref_del(wref) EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), EO_TYPECHECK(Eo **, wref)
|
||||
|
||||
/**
|
||||
* @var _EO_EV_CALLBACK_ADD
|
||||
* see EO_EV_CALLBACK_ADD
|
||||
*/
|
||||
EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_ADD;
|
||||
|
||||
/**
|
||||
* @def EO_EV_CALLBACK_ADD
|
||||
* The event description (of type #Eo_Event_Description) for
|
||||
* The "Callback listener added" event.
|
||||
*/
|
||||
#define EO_EV_CALLBACK_ADD (&(_EO_EV_CALLBACK_ADD))
|
||||
|
||||
/**
|
||||
* @var _EO_EV_CALLBACK_DEL
|
||||
* see EO_EV_CALLBACK_DEL
|
||||
*/
|
||||
EAPI extern const Eo_Event_Description _EO_EV_CALLBACK_DEL;
|
||||
|
||||
/**
|
||||
* @def EO_EV_CALLBACK_DEL
|
||||
* The event description (of type #Eo_Event_Description) for
|
||||
* The "Callback listener deleted" event.
|
||||
*/
|
||||
#define EO_EV_CALLBACK_DEL (&(_EO_EV_CALLBACK_DEL))
|
||||
|
||||
/**
|
||||
* @var _EO_EV_FREE
|
||||
* see #EO_EV_FREE
|
||||
*/
|
||||
EAPI extern const Eo_Event_Description _EO_EV_FREE;
|
||||
|
||||
/**
|
||||
* @def EO_EV_FREE
|
||||
* Object is being freed.
|
||||
*/
|
||||
#define EO_EV_FREE (&(_EO_EV_FREE))
|
||||
|
||||
/**
|
||||
* @var _EO_EV_DEL
|
||||
* see #EO_EV_DEL
|
||||
*/
|
||||
EAPI extern const Eo_Event_Description _EO_EV_DEL;
|
||||
|
||||
/**
|
||||
* @def EO_EV_DEL
|
||||
* Object is being deleted.
|
||||
*/
|
||||
#define EO_EV_DEL (&(_EO_EV_DEL))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -1,969 +0,0 @@
|
|||
#ifndef EOBJ_H
|
||||
#define EOBJ_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <Eina.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_EOBJ_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif /* ! DLL_EXPORT */
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif /* ! EFL_EOBJ_BUILD */
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
/**
|
||||
* @var _eobj_class_creation_lock
|
||||
* This variable is used for locking purposes in the class_get function
|
||||
* defined in #EOBJ_DEFINE_CLASS.
|
||||
* This is just to work around the fact that we need to init locks before
|
||||
* using them.
|
||||
* Don't touch it if you don't know what you are doing.
|
||||
* @internal
|
||||
*/
|
||||
EAPI extern Eina_Lock _eobj_class_creation_lock;
|
||||
|
||||
/**
|
||||
* @defgroup Eobj Eobj Generic Object System
|
||||
*
|
||||
* The Eobj generic object system. It was designed to be the base object
|
||||
* system for the EFL.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EOBJ_TYPECHECK(type, x)
|
||||
*
|
||||
* Checks x is castable to type "type" and casts it to it.
|
||||
* @param type The C type to check against.
|
||||
* @param x the variable to test and cast.
|
||||
*/
|
||||
#define EOBJ_TYPECHECK(type, x) \
|
||||
({ \
|
||||
type __x; \
|
||||
__x = x; \
|
||||
(void) __x; \
|
||||
(type) x; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @typedef Eobj
|
||||
* The basic Object type.
|
||||
*/
|
||||
typedef struct _Eobj Eobj;
|
||||
/**
|
||||
* @typedef Eobj_Op
|
||||
* The Eobj operation type id.
|
||||
*/
|
||||
typedef unsigned int Eobj_Op;
|
||||
|
||||
/**
|
||||
* @def EOBJ_NOOP
|
||||
* A special #Eobj_Op meaning "No operation".
|
||||
*/
|
||||
#define EOBJ_NOOP ((Eobj_Op) 0)
|
||||
|
||||
/**
|
||||
* @typedef eobj_op_func_type
|
||||
* The type of the Op functions. This is the type of the functions used by
|
||||
* Eobj.
|
||||
*
|
||||
* @see eobj_op_func_type_const
|
||||
*/
|
||||
typedef void (*eobj_op_func_type)(Eobj *, void *class_data, va_list *list);
|
||||
|
||||
/**
|
||||
* @typedef eobj_op_func_type_const
|
||||
* The type of the const Op functions. This is the type of the functions used
|
||||
* by Eobj. This is the same as #eobj_op_func_type, except that this should
|
||||
* be used with functions that don't modify the data.
|
||||
*
|
||||
* @see eobj_op_func_type
|
||||
*/
|
||||
typedef void (*eobj_op_func_type_const)(const Eobj *, const void *class_data, va_list *list);
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Events Eobj's Event Handling
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct _Eobj_Event_Description
|
||||
* This struct holds the description of a specific event.
|
||||
*/
|
||||
struct _Eobj_Event_Description
|
||||
{
|
||||
const char *name; /**< name of the event. */
|
||||
const char *type; /**< describes the data passed in event_info */
|
||||
const char *doc; /**< Explanation about the event. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Event_Description
|
||||
* A convenience typedef for #_Eobj_Event_Description
|
||||
*/
|
||||
typedef struct _Eobj_Event_Description Eobj_Event_Description;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EVENT_DESCRIPTION(name, type, doc)
|
||||
* An helper macro to help populating #Eobj_Event_Description
|
||||
* @param name The name of the event.
|
||||
* @param type The type string of the event.
|
||||
* @param doc Additional doc for the event.
|
||||
* @see Eobj_Event_Description
|
||||
*/
|
||||
#define EOBJ_EVENT_DESCRIPTION(name, type, doc) { name, type, doc }
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Class Eobj Class
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Class
|
||||
* The basic Object class type.
|
||||
*/
|
||||
typedef struct _Eobj_Class Eobj_Class;
|
||||
|
||||
/**
|
||||
* @def EOBJ_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
|
||||
* A convenience macro to be used for creating the class_get function. This
|
||||
* macro is fairly simple but should still be used as it'll let us improve
|
||||
* things easily.
|
||||
* @param class_get_func_name the name of the wanted class_get function name.
|
||||
* @param class_desc the class description.
|
||||
* @param parent_class The parent class for the function. Look at eobj_class_new() for more information.
|
||||
* @param ... List of etxensions. Look at eobj_class_new() for more information.
|
||||
*
|
||||
* You must use this macro if you want thread safety in class creation.
|
||||
*/
|
||||
#define EOBJ_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
|
||||
EAPI const Eobj_Class * \
|
||||
class_get_func_name(void) \
|
||||
{ \
|
||||
static volatile char lk_init = 0; \
|
||||
static Eina_Lock _my_lock; \
|
||||
static const Eobj_Class * volatile _my_class = NULL; \
|
||||
if (EINA_LIKELY(!!_my_class)) return _my_class; \
|
||||
\
|
||||
eina_lock_take(&_eobj_class_creation_lock); \
|
||||
if (!lk_init) \
|
||||
eina_lock_new(&_my_lock); \
|
||||
if (lk_init < 2) eina_lock_take(&_my_lock); \
|
||||
if (!lk_init) \
|
||||
lk_init = 1; \
|
||||
else \
|
||||
{ \
|
||||
if (lk_init < 2) eina_lock_release(&_my_lock); \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
return _my_class; \
|
||||
} \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
_my_class = eobj_class_new(class_desc, parent_class, __VA_ARGS__); \
|
||||
eina_lock_release(&_my_lock); \
|
||||
\
|
||||
eina_lock_take(&_eobj_class_creation_lock); \
|
||||
eina_lock_free(&_my_lock); \
|
||||
lk_init = 2; \
|
||||
eina_lock_release(&_eobj_class_creation_lock); \
|
||||
return _my_class; \
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enum representing the possible types of an Eobj class.
|
||||
*/
|
||||
enum _Eobj_Class_Type
|
||||
{
|
||||
EOBJ_CLASS_TYPE_REGULAR = 0, /**< Regular class. */
|
||||
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT, /**< Regular non instant-able class. */
|
||||
EOBJ_CLASS_TYPE_INTERFACE, /**< Interface */
|
||||
EOBJ_CLASS_TYPE_MIXIN /**< Mixin */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Class_Type
|
||||
* A convenience typedef for #_Eobj_Class_Type.
|
||||
*/
|
||||
typedef enum _Eobj_Class_Type Eobj_Class_Type;
|
||||
|
||||
/**
|
||||
* @struct _Eobj_Op_Func_Description
|
||||
* Used to associate an Op with a func.
|
||||
* @see eobj_class_funcs_set
|
||||
*/
|
||||
struct _Eobj_Op_Func_Description
|
||||
{
|
||||
Eobj_Op op; /**< The op */
|
||||
eobj_op_func_type func; /**< The function to call for the op. */
|
||||
Eina_Bool constant; /**< #EINA_TRUE if this function is a const. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Op_Func_Description
|
||||
* A convenience typedef for #_Eobj_Op_Func_Description
|
||||
*/
|
||||
typedef struct _Eobj_Op_Func_Description Eobj_Op_Func_Description;
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_FUNC(op, func)
|
||||
* A convenience macro to be used when populating the #Eobj_Op_Func_Description
|
||||
* array.
|
||||
*
|
||||
* @see EOBJ_OP_FUNC_CONST
|
||||
*/
|
||||
#define EOBJ_OP_FUNC(op, func) { op, EOBJ_TYPECHECK(eobj_op_func_type, func), EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_FUNC_CONST(op, func)
|
||||
* A convenience macro to be used when populating the #Eobj_Op_Func_Description
|
||||
* array.
|
||||
* The same as #EOBJ_OP_FUNC but for const functions.
|
||||
*
|
||||
* @see EOBJ_OP_FUNC
|
||||
*/
|
||||
#define EOBJ_OP_FUNC_CONST(op, func) { op, (eobj_op_func_type) EOBJ_TYPECHECK(eobj_op_func_type_const, func), EINA_TRUE }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_FUNC_SENTINEL
|
||||
* A convenience macro to be used when populating the #Eobj_Op_Func_Description
|
||||
* array. It must appear at the end of the ARRAY.
|
||||
*/
|
||||
#define EOBJ_OP_FUNC_SENTINEL { 0, NULL, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @struct _Eobj_Op_Description
|
||||
* This struct holds the description of a specific op.
|
||||
*/
|
||||
struct _Eobj_Op_Description
|
||||
{
|
||||
Eobj_Op sub_op; /**< The sub_id of the op in it's class. */
|
||||
const char *name; /**< The name of the op. */
|
||||
const char *type; /**< descripbes the Op's function signature. */
|
||||
const char *doc; /**< Explanation about the Op. */
|
||||
Eina_Bool constant; /**< #EINA_TRUE if this op's implementation should not change the obj. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Op_Description
|
||||
* A convenience typedef for #_Eobj_Op_Description
|
||||
*/
|
||||
typedef struct _Eobj_Op_Description Eobj_Op_Description;
|
||||
|
||||
/**
|
||||
* @struct _Eobj_Class_Description
|
||||
* This struct holds the description of a class.
|
||||
* This description should be passed to eobj_class_new.
|
||||
* Please use the #EOBJ_CLASS_DESCRIPTION_OPS macro when populating it.
|
||||
*/
|
||||
struct _Eobj_Class_Description
|
||||
{
|
||||
const char *name; /**< The name of the class. */
|
||||
Eobj_Class_Type type; /**< The type of the class. */
|
||||
struct {
|
||||
Eobj_Op *base_op_id;
|
||||
const Eobj_Op_Description *descs;
|
||||
size_t count;
|
||||
} ops; /**< The ops description, should be filled using #EOBJ_CLASS_DESCRIPTION_OPS */
|
||||
const Eobj_Event_Description **events; /**< The event descriptions for this class. */
|
||||
size_t data_size; /**< The size of data (private + protected + public) this class needs per object. */
|
||||
void (*constructor)(Eobj *obj, void *class_data); /**< The constructor of the object. */
|
||||
void (*destructor)(Eobj *obj, void *class_data); /**< The destructor of the object. */
|
||||
void (*class_constructor)(Eobj_Class *klass); /**< The constructor of the class. */
|
||||
void (*class_destructor)(Eobj_Class *klass); /**< The destructor of the class. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Class_Description
|
||||
* A convenience typedef for #_Eobj_Class_Description
|
||||
*/
|
||||
typedef struct _Eobj_Class_Description Eobj_Class_Description;
|
||||
|
||||
/**
|
||||
* @def EOBJ_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count)
|
||||
* An helper macro to help populating #Eobj_Class_Description.
|
||||
* @param base_op_id A pointer to the base op id of the class.
|
||||
* @param op_descs the op descriptions array.
|
||||
* @param count the number of ops in the op descriptions array.
|
||||
*/
|
||||
#define EOBJ_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_DESCRIPTION(op, type, doc)
|
||||
* An helper macro to help populating #Eobj_Op_Description
|
||||
* @param sub_id The sub id of the op being described.
|
||||
* @param type The type string for the op.
|
||||
* @param doc Additional doc for the op.
|
||||
* @see Eobj_Op_Description
|
||||
* @see EOBJ_OP_DESCRIPTION_CONST
|
||||
* @see EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
*/
|
||||
#define EOBJ_OP_DESCRIPTION(sub_id, type, doc) { sub_id, #sub_id, type, doc, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_DESCRIPTION_CONST(op, type, doc)
|
||||
* An helper macro to help populating #Eobj_Op_Description
|
||||
* This macro is the same as EOBJ_OP_DESCRIPTION but indicates that the op's
|
||||
* implementation should not change the object.
|
||||
* @param sub_id The sub id of the op being described.
|
||||
* @param type The type string for the op.
|
||||
* @param doc Additional doc for the op.
|
||||
* @see Eobj_Op_Description
|
||||
* @see EOBJ_OP_DESCRIPTION
|
||||
* @see EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
*/
|
||||
#define EOBJ_OP_DESCRIPTION_CONST(sub_id, type, doc) { sub_id, #sub_id, type, doc, EINA_TRUE }
|
||||
|
||||
/**
|
||||
* @def EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
* An helper macro to help populating #Eobj_Op_Description
|
||||
* Should be placed at the end of the array.
|
||||
* @see Eobj_Op_Description
|
||||
* @see EOBJ_OP_DESCRIPTION
|
||||
*/
|
||||
#define EOBJ_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, NULL, EINA_FALSE }
|
||||
|
||||
/**
|
||||
* @brief Create a new class.
|
||||
* @param desc the class description to create the class with.
|
||||
* @param parent the class to inherit from.
|
||||
* @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
|
||||
* @return The new class's handle on success, or NULL otherwise.
|
||||
*
|
||||
* You should use #EOBJ_DEFINE_CLASS. It'll provide thread safety and other
|
||||
* features easily.
|
||||
*
|
||||
* @see #EOBJ_DEFINE_CLASS
|
||||
*/
|
||||
EAPI const Eobj_Class *eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...);
|
||||
|
||||
/**
|
||||
* @brief Sets the OP functions for a class.
|
||||
* @param klass the class to set the functions to.
|
||||
* @param func_descs a NULL terminated array of #Eobj_Op_Func_Description
|
||||
*
|
||||
* Should be called from within the class constructor.
|
||||
*/
|
||||
EAPI void eobj_class_funcs_set(Eobj_Class *klass, const Eobj_Op_Func_Description *func_descs);
|
||||
|
||||
/**
|
||||
* @brief Gets the name of the passed class.
|
||||
* @param klass the class to work on.
|
||||
* @return The class's name.
|
||||
*
|
||||
* @see eobj_class_get()
|
||||
*/
|
||||
EAPI const char *eobj_class_name_get(const Eobj_Class *klass);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Init the eobj subsystem
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* @see eobj_shutfown()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_init(void);
|
||||
|
||||
/**
|
||||
* @brief Shutdown the eobj subsystem
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* @see eobj_init()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_shutdown(void);
|
||||
|
||||
/**
|
||||
* @def eobj_do
|
||||
* A convenience wrapper around eobj_do_internal()
|
||||
* @see eobj_do_internal
|
||||
*/
|
||||
#define eobj_do(obj, ...) eobj_do_internal(obj, EINA_FALSE, __VA_ARGS__, EOBJ_NOOP)
|
||||
|
||||
/**
|
||||
* @def eobj_query
|
||||
* Same as #eobj_do but only for const ops.
|
||||
* @see eobj_do
|
||||
*/
|
||||
#define eobj_query(obj, ...) eobj_do_internal((Eobj *) EOBJ_TYPECHECK(const Eobj *, obj), EINA_TRUE, __VA_ARGS__, EOBJ_NOOP)
|
||||
|
||||
/**
|
||||
* @brief Issues ops on an object.
|
||||
* @param obj The object to work on
|
||||
* @param constant #EINA_TRUE if this call is on a constant object.
|
||||
* @param ... NULL terminated list of OPs and parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Use the helper macros, don't pass the parameters manually.
|
||||
* Use #eobj_do instead of this function.
|
||||
*
|
||||
* @see #eobj_do
|
||||
*/
|
||||
EAPI Eina_Bool eobj_do_internal(Eobj *obj, Eina_Bool constant, ...);
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Unlike eobj_do() and eobj_query(), this function only accepts one op.
|
||||
*
|
||||
* Use the helper macros, don't pass the parameters manually.
|
||||
*
|
||||
* Same as eobj_do_super() just for const objects.
|
||||
*
|
||||
* @see #eobj_query
|
||||
* @see eobj_do_super()
|
||||
*/
|
||||
#define eobj_query_super(obj, ...) eobj_do_super_internal((Eobj *) EOBJ_TYPECHECK(const Eobj *, obj), EINA_TRUE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Unlike eobj_do() and eobj_query(), this function only accepts one op.
|
||||
*
|
||||
* @see #eobj_query
|
||||
* @see eobj_query_super()
|
||||
*/
|
||||
#define eobj_do_super(obj, ...) eobj_do_super_internal((Eobj *) EOBJ_TYPECHECK(const Eobj *, obj), EINA_FALSE, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Calls the super function for the specific op.
|
||||
* @param obj The object to work on
|
||||
* @param constant #EINA_TRUE if this call is on a constant object.
|
||||
* @param op The wanted op.
|
||||
* @param ... list of parameters.
|
||||
* @return #EINA_TRUE on success.
|
||||
*
|
||||
* Don't use this function, use the wrapping macros instead.
|
||||
*
|
||||
* @see #eobj_do
|
||||
* @see #eobj_do_super
|
||||
* @see #eobj_query_super
|
||||
*/
|
||||
EAPI Eina_Bool eobj_do_super_internal(Eobj *obj, Eina_Bool constant, Eobj_Op op, ...);
|
||||
|
||||
/**
|
||||
* @brief Gets the class of the object.
|
||||
* @param obj The object to work on
|
||||
* @return The object's class.
|
||||
*
|
||||
* @see eobj_class_name_get()
|
||||
*/
|
||||
EAPI const Eobj_Class *eobj_class_get(const Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Calls the super constructor of the object passed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eobj_destructor_super()
|
||||
*/
|
||||
EAPI void eobj_constructor_super(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Calls the super destructor of the object passed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eobj_constructor_super()
|
||||
*/
|
||||
EAPI void eobj_destructor_super(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Notify eobj that there was an error when constructing the object.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* (Should only be called from within a constructor/destructor).
|
||||
*
|
||||
* @see eobj_constructor_error_get()
|
||||
*/
|
||||
EAPI void eobj_constructor_error_set(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Check if there was an error constructing obj
|
||||
* @param obj the object to work on.
|
||||
* @return #EINA_TRUE if there was an error.
|
||||
*
|
||||
* (Should only be called from within a constructor/destructor).
|
||||
*
|
||||
* @see eobj_constructor_error_set()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_constructor_error_get(const Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Create a new object.
|
||||
* @param klass the class of the object to create.
|
||||
* @param parent the parent to set to the object.
|
||||
* @return An handle to the new object on success, NULL otherwise.
|
||||
*/
|
||||
EAPI Eobj *eobj_add(const Eobj_Class *klass, Eobj *parent);
|
||||
|
||||
/**
|
||||
* @brief Get the parent of an object
|
||||
* @param obj the object to get the parent of.
|
||||
* @return a pointer to the parent object.
|
||||
*/
|
||||
EAPI Eobj *eobj_parent_get(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the data of an object for a specific class.
|
||||
* @param obj the object to work on.
|
||||
* @param klass the klass associated with the data.
|
||||
* @return a pointer to the data.
|
||||
*/
|
||||
EAPI void *eobj_data_get(const Eobj *obj, const Eobj_Class *klass);
|
||||
|
||||
/**
|
||||
* @brief Increment the object's reference count by 1.
|
||||
* @param obj the object to work on.
|
||||
* @return The object passed.
|
||||
*
|
||||
* It's very easy to get a refcount leak and start leaking memory because
|
||||
* of a forgotten unref or an extra ref. That is why there are eobj_xref
|
||||
* and eobj_xunref that will make debugging easier in such a case.
|
||||
* Therefor, these functions should only be used in small scopes, i.e at the
|
||||
* start of some section in which the object may get freed, or if you know
|
||||
* what you are doing.
|
||||
*
|
||||
* @see eobj_unref()
|
||||
* @see eobj_ref_get()
|
||||
*/
|
||||
EAPI Eobj *eobj_ref(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Decrement the object's reference count by 1 and free it if needed.
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eobj_ref()
|
||||
* @see eobj_ref_get()
|
||||
*/
|
||||
EAPI void eobj_unref(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @brief Return the ref count of the object passed.
|
||||
* @param obj the object to work on.
|
||||
* @return the ref count of the object.
|
||||
*
|
||||
* @see eobj_ref()
|
||||
* @see eobj_unref()
|
||||
*/
|
||||
EAPI int eobj_ref_get(const Eobj *obj);
|
||||
|
||||
/**
|
||||
* @def eobj_xref(obj, ref_obj)
|
||||
* Convenience macro around eobj_xref()
|
||||
* @see eobj_xref()
|
||||
*/
|
||||
#define eobj_xref(obj, ref_obj) eobj_xref_internal(obj, ref_obj, __FILE__, __LINE__)
|
||||
|
||||
/**
|
||||
* @brief Increment the object's reference count by 1 (and associate the ref with ref_obj)
|
||||
* @param obj the object to work on.
|
||||
* @param ref_obj the object that references obj.
|
||||
* @param file the call's filename.
|
||||
* @param line the call's line number.
|
||||
* @return The object passed (obj)
|
||||
*
|
||||
* People should not use this function, use #eobj_xref instead.
|
||||
*
|
||||
* @see eobj_xunref()
|
||||
*/
|
||||
EAPI Eobj *eobj_xref_internal(Eobj *obj, const Eobj *ref_obj, const char *file, int line);
|
||||
|
||||
/**
|
||||
* @brief Decrement the object's reference count by 1 and free it if needed. Will free the ref associated with ref_obj).
|
||||
* @param obj the object to work on.
|
||||
* @param ref_obj the object that references obj.
|
||||
*
|
||||
* This function only enforces the checks for object association. I.e don't rely
|
||||
* on it. If such enforces are compiled out, this function behaves the same as
|
||||
* eobj_unref().
|
||||
*
|
||||
* @see eobj_xref_internal()
|
||||
*/
|
||||
EAPI void eobj_xunref(Eobj *obj, const Eobj *ref_obj);
|
||||
|
||||
/**
|
||||
* @brief Delete the object passed (disregarding ref count).
|
||||
* @param obj the object to work on.
|
||||
*
|
||||
* @see eobj_unref()
|
||||
*/
|
||||
EAPI void eobj_del(Eobj *obj);
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Composite_Objects Composite Objects.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Make an object a composite object of another.
|
||||
* @param obj the "parent" object.
|
||||
* @param comp_obj the object that will be used to composite obj.
|
||||
*
|
||||
* @see eobj_composite_object_detach()
|
||||
* @see eobj_composite_is()
|
||||
*/
|
||||
EAPI void eobj_composite_object_attach(Eobj *obj, Eobj *comp_obj);
|
||||
|
||||
/**
|
||||
* @brief Detach a composite object from another object.
|
||||
* @param obj the "parent" object.
|
||||
* @param comp_obj the object attached to obj.
|
||||
*
|
||||
* @see eobj_composite_object_attach()
|
||||
* @see eobj_composite_is()
|
||||
*/
|
||||
EAPI void eobj_composite_object_detach(Eobj *obj, Eobj *comp_obj);
|
||||
|
||||
/**
|
||||
* @brief Check if an object is a composite object.
|
||||
* @param comp_obj the object to be checked.
|
||||
* @return #EINA_TRUE if it is, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eobj_composite_object_attach()
|
||||
* @see eobj_composite_object_detach()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_composite_is(Eobj *comp_obj);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Events Eobj's Event Handling
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EOBJ_CALLBACK_PRIORITY_BEFORE
|
||||
* Slightly more prioritized than default.
|
||||
*/
|
||||
#define EOBJ_CALLBACK_PRIORITY_BEFORE -100
|
||||
/**
|
||||
* @def EOBJ_CALLBACK_PRIORITY_DEFAULT
|
||||
* Default callback priority level
|
||||
*/
|
||||
#define EOBJ_CALLBACK_PRIORITY_DEFAULT 0
|
||||
/**
|
||||
* @def EOBJ_CALLBACK_PRIORITY_AFTER
|
||||
* Slightly less prioritized than default.
|
||||
*/
|
||||
#define EOBJ_CALLBACK_PRIORITY_AFTER 100
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Callback_Priority
|
||||
*
|
||||
* Callback priority value. Range is -32k - 32k. The lower the number, the
|
||||
* higher the priority.
|
||||
*
|
||||
* @see EOBJ_CALLBACK_PRIORITY_AFTER
|
||||
* @see EOBJ_CALLBACK_PRIORITY_BEFORE
|
||||
* @see EOBJ_CALLBACK_PRIORITY_DEFAULT
|
||||
*/
|
||||
typedef short Eobj_Callback_Priority;
|
||||
|
||||
/**
|
||||
* @def EOBJ_CALLBACK_STOP
|
||||
* Stop calling callbacks for the even of which the callback was called for.
|
||||
* @see EOBJ_CALLBACK_CONTINUE
|
||||
*/
|
||||
#define EOBJ_CALLBACK_STOP EINA_FALSE
|
||||
|
||||
/**
|
||||
* @def EOBJ_CALLBACK_CONTINUE
|
||||
* Continue calling callbacks for the even of which the callback was called for.
|
||||
* @see EOBJ_CALLBACK_STOP
|
||||
*/
|
||||
#define EOBJ_CALLBACK_CONTINUE EINA_TRUE
|
||||
|
||||
/**
|
||||
* @typedef Eobj_Event_Cb
|
||||
*
|
||||
* An event callback prototype.
|
||||
*
|
||||
* @param data The user data registered with the callback.
|
||||
* @param obj The object which initiated the event.
|
||||
* @param desc The event's description.
|
||||
* @param event_info additional data passed with the event.
|
||||
* @return #EOBJ_CALLBACK_STOP to stop calling additional callbacks for the event, #EOBJ_CALLBACK_CONTINUE to continue.
|
||||
*/
|
||||
typedef Eina_Bool (*Eobj_Event_Cb)(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info);
|
||||
|
||||
/**
|
||||
* @brief Add an event callback forwarder for an event and an object.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param new_obj The object to emit events from.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eobj_event_callback_forwarder_del()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_event_callback_forwarder_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
|
||||
|
||||
/**
|
||||
* @brief Remove an event callback forwarder for an event and an object.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param new_obj The object to emit events from.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* @see eobj_event_callback_forwarder_add()
|
||||
*/
|
||||
EAPI Eina_Bool eobj_event_callback_forwarder_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
|
||||
|
||||
/**
|
||||
* @def eobj_event_callback_add(obj, desc, cb, data)
|
||||
* Add a callback for an event.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param cb the callback to call.
|
||||
* @param data additional data to pass to the callback.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* callbacks of the same priority are called in reverse order of creation.
|
||||
*
|
||||
* @see eobj_event_callback_priority_add()
|
||||
*/
|
||||
#define eobj_event_callback_add(obj, desc, cb, data) \
|
||||
eobj_event_callback_priority_add(obj, desc, \
|
||||
EOBJ_CALLBACK_PRIORITY_DEFAULT, cb, data)
|
||||
|
||||
/**
|
||||
* @brief Add a callback for an event with a specific priority.
|
||||
* @param obj The object to listen to events on.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param priority The priority of the callback.
|
||||
* @param cb the callback to call.
|
||||
* @param data additional data to pass to the callback.
|
||||
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
|
||||
*
|
||||
* callbacks of the same priority are called in reverse order of creation.
|
||||
*
|
||||
* @see #eobj_event_callback_add
|
||||
*/
|
||||
EAPI Eina_Bool eobj_event_callback_priority_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Callback_Priority priority, Eobj_Event_Cb cb, const void *data);
|
||||
|
||||
/**
|
||||
* @brief Del a callback for an event
|
||||
* @param obj The object to listen to delete from.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param func the callback to delete.
|
||||
* @return The additional data that was set to be passed to the callback.
|
||||
*
|
||||
* @see eobj_event_callback_del()
|
||||
*/
|
||||
EAPI void *eobj_event_callback_del_lazy(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func);
|
||||
|
||||
/**
|
||||
* @brief Del a callback with a specific data associated to it for an event.
|
||||
* @param obj The object to listen to delete from.
|
||||
* @param desc The description of the event to listen to.
|
||||
* @param func the callback to delete.
|
||||
* @param user_data The data to compare.
|
||||
* @return The additional data that was set to be passed to the callback.
|
||||
*
|
||||
* @see eobj_event_callback_del_lazy()
|
||||
*/
|
||||
EAPI void *eobj_event_callback_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func, const void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Call the callbacks for an event of an object.
|
||||
* @param obj The object to work on.
|
||||
* @param desc The description of the event to call.
|
||||
* @param event_info Extra event info to pass to the callbacks.
|
||||
* @return #EINA_FALSE if one of the callbacks aborted the callback calls or #EINA_TRUE otherwise.
|
||||
*/
|
||||
EAPI Eina_Bool eobj_event_callback_call(Eobj *obj, const Eobj_Event_Description *desc, const void *event_info);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Class_Base Eobj's Base class.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def EOBJ_BASE_CLASS
|
||||
* The class type for the Eobj base class.
|
||||
*/
|
||||
#define EOBJ_BASE_CLASS eobj_base_class_get()
|
||||
/**
|
||||
* @brief Use #EOBJ_BASE_CLASS
|
||||
* @internal
|
||||
* */
|
||||
EAPI const Eobj_Class *eobj_base_class_get(void) EINA_CONST;
|
||||
|
||||
/**
|
||||
* @typedef eobj_base_data_free_func
|
||||
* Data free func prototype.
|
||||
*/
|
||||
typedef void (*eobj_base_data_free_func)(void *);
|
||||
|
||||
/**
|
||||
* @var EOBJ_BASE_BASE_ID
|
||||
* #EOBJ_BASE_CLASS 's base id.
|
||||
*/
|
||||
extern EAPI Eobj_Op EOBJ_BASE_BASE_ID;
|
||||
|
||||
enum {
|
||||
EOBJ_BASE_SUB_ID_DATA_SET,
|
||||
EOBJ_BASE_SUB_ID_DATA_GET,
|
||||
EOBJ_BASE_SUB_ID_DATA_DEL,
|
||||
EOBJ_BASE_SUB_ID_WREF_ADD,
|
||||
EOBJ_BASE_SUB_ID_WREF_DEL,
|
||||
EOBJ_BASE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @def EOBJ_BASE_ID(sub_id)
|
||||
* Helper macro to get the full Op ID out of the sub_id for EOBJ_BASE.
|
||||
* @param sub_id the sub id inside EOBJ_BASE.
|
||||
*/
|
||||
#define EOBJ_BASE_ID(sub_id) (EOBJ_BASE_BASE_ID + sub_id)
|
||||
|
||||
/**
|
||||
* @def eobj_base_data_set(key, data, free_func)
|
||||
* Set generic data to object.
|
||||
* @param[in] key the key associated with the data
|
||||
* @param[in] data the data to set.
|
||||
* @param[in] free_func the func to free data with (NULL means "do nothing").
|
||||
*
|
||||
* @see #eobj_base_data_get
|
||||
* @see #eobj_base_data_del
|
||||
*/
|
||||
#define eobj_base_data_set(key, data, free_func) EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_SET), EOBJ_TYPECHECK(const char *, key), EOBJ_TYPECHECK(const void *, data), EOBJ_TYPECHECK(eobj_base_data_free_func, free_func)
|
||||
|
||||
/**
|
||||
* @def eobj_base_data_get(key, data)
|
||||
* Get generic data from object.
|
||||
* @param[in] key the key associated with the data
|
||||
* @param[out] data the data for the key
|
||||
*
|
||||
* @see #eobj_base_data_set
|
||||
* @see #eobj_base_data_del
|
||||
*/
|
||||
#define eobj_base_data_get(key, data) EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_GET), EOBJ_TYPECHECK(const char *, key), EOBJ_TYPECHECK(void **, data)
|
||||
|
||||
/**
|
||||
* @def eobj_base_data_del(key)
|
||||
* Del generic data from object.
|
||||
* @param[in] key the key associated with the data
|
||||
*
|
||||
* @see #eobj_base_data_set
|
||||
* @see #eobj_base_data_get
|
||||
*/
|
||||
#define eobj_base_data_del(key) EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_DEL), EOBJ_TYPECHECK(const char *, key)
|
||||
|
||||
/**
|
||||
* @def eobj_wref_add
|
||||
* @brief Add a new weak reference to obj.
|
||||
* @param wref The pointer to use for the weak ref.
|
||||
*
|
||||
* This function registers the object handle pointed by wref to obj so when
|
||||
* obj is deleted it'll be updated to NULL. This functions should be used
|
||||
* when you want to keep track of an object in a safe way, but you don't want
|
||||
* to prevent it from being freed.
|
||||
*
|
||||
* @see #eobj_wref_del
|
||||
*/
|
||||
#define eobj_wref_add(wref) EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_WREF_ADD), EOBJ_TYPECHECK(Eobj **, wref)
|
||||
|
||||
/**
|
||||
* @def eobj_wref_del
|
||||
* @brief Delete the weak reference passed.
|
||||
* @param wref the weak reference to free.
|
||||
*
|
||||
* @see #eobj_wref_add
|
||||
*/
|
||||
#define eobj_wref_del(wref) EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_WREF_DEL), EOBJ_TYPECHECK(Eobj **, wref)
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_CALLBACK_ADD
|
||||
* see EOBJ_EV_CALLBACK_ADD
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_CALLBACK_ADD;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_CALLBACK_ADD
|
||||
* The event description (of type #Eobj_Event_Description) for
|
||||
* The "Callback listener added" event.
|
||||
*/
|
||||
#define EOBJ_EV_CALLBACK_ADD (&(_EOBJ_EV_CALLBACK_ADD))
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_CALLBACK_DEL
|
||||
* see EOBJ_EV_CALLBACK_DEL
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_CALLBACK_DEL;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_CALLBACK_DEL
|
||||
* The event description (of type #Eobj_Event_Description) for
|
||||
* The "Callback listener deleted" event.
|
||||
*/
|
||||
#define EOBJ_EV_CALLBACK_DEL (&(_EOBJ_EV_CALLBACK_DEL))
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_FREE
|
||||
* see #EOBJ_EV_FREE
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_FREE;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_FREE
|
||||
* Object is being freed.
|
||||
*/
|
||||
#define EOBJ_EV_FREE (&(_EOBJ_EV_FREE))
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_DEL
|
||||
* see #EOBJ_EV_DEL
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_DEL;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_DEL
|
||||
* Object is being deleted.
|
||||
*/
|
||||
#define EOBJ_EV_DEL (&(_EOBJ_EV_DEL))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,226 @@
|
|||
#include <Eina.h>
|
||||
|
||||
#include "Eo.h"
|
||||
#include "eo_private.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eo_Op EO_BASE_BASE_ID = EO_NOOP;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_Inlist *generic_data;
|
||||
} Private_Data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
EINA_INLIST;
|
||||
Eina_Stringshare *key;
|
||||
void *data;
|
||||
eo_base_data_free_func free_func;
|
||||
} Eo_Generic_Data_Node;
|
||||
|
||||
static void
|
||||
_eo_generic_data_node_free(Eo_Generic_Data_Node *node)
|
||||
{
|
||||
eina_stringshare_del(node->key);
|
||||
if (node->free_func)
|
||||
node->free_func(node->data);
|
||||
free(node);
|
||||
}
|
||||
|
||||
static void
|
||||
_eo_generic_data_del_all(Private_Data *pd)
|
||||
{
|
||||
Eina_Inlist *nnode;
|
||||
Eo_Generic_Data_Node *node = NULL;
|
||||
|
||||
EINA_INLIST_FOREACH_SAFE(pd->generic_data, nnode, node)
|
||||
{
|
||||
pd->generic_data = eina_inlist_remove(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
|
||||
_eo_generic_data_node_free(node);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_data_set(Eo *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
const void *data = va_arg(*list, const void *);
|
||||
eo_base_data_free_func free_func = va_arg(*list, eo_base_data_free_func);
|
||||
|
||||
Eo_Generic_Data_Node *node;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
eo_do(obj, eo_base_data_del(key));
|
||||
|
||||
node = malloc(sizeof(Eo_Generic_Data_Node));
|
||||
node->key = eina_stringshare_add(key);
|
||||
node->data = (void *) data;
|
||||
node->free_func = free_func;
|
||||
pd->generic_data = eina_inlist_prepend(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
}
|
||||
|
||||
static void
|
||||
_data_get(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
/* We don't really change it... */
|
||||
Private_Data *pd = (Private_Data *) class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
void **data = va_arg(*list, void **);
|
||||
Eo_Generic_Data_Node *node;
|
||||
|
||||
if (!data) return;
|
||||
*data = NULL;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
EINA_INLIST_FOREACH(pd->generic_data, node)
|
||||
{
|
||||
if (!strcmp(node->key, key))
|
||||
{
|
||||
pd->generic_data =
|
||||
eina_inlist_promote(pd->generic_data, EINA_INLIST_GET(node));
|
||||
*data = node->data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_data_del(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
|
||||
Eo_Generic_Data_Node *node;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
EINA_INLIST_FOREACH(pd->generic_data, node)
|
||||
{
|
||||
if (!strcmp(node->key, key))
|
||||
{
|
||||
pd->generic_data = eina_inlist_remove(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
_eo_generic_data_node_free(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Weak reference. */
|
||||
static Eina_Bool
|
||||
_eo_weak_ref_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eo **wref = data;
|
||||
*wref = NULL;
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_wref_add(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Eo **wref = va_arg(*list, Eo **);
|
||||
|
||||
*wref = (Eo *) obj;
|
||||
/* FIXME: The cast and the one in the next func are both bad and should be
|
||||
* fixed once the event callback functions are fixed. */
|
||||
eo_event_callback_add((Eo *) obj, EO_EV_DEL, _eo_weak_ref_cb, wref);
|
||||
}
|
||||
|
||||
static void
|
||||
_wref_del(const Eo *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Eo **wref = va_arg(*list, Eo **);
|
||||
if (*wref != obj)
|
||||
{
|
||||
ERR("Wref is a weak ref to %p, while this function was called on %p.",
|
||||
*wref, obj);
|
||||
return;
|
||||
}
|
||||
eo_event_callback_del((Eo *) obj, EO_EV_DEL, _eo_weak_ref_cb, wref);
|
||||
}
|
||||
|
||||
/* EOF Weak reference. */
|
||||
|
||||
|
||||
/* EO_BASE_CLASS stuff */
|
||||
#define MY_CLASS EO_BASE_CLASS
|
||||
|
||||
/* FIXME: Set proper type descriptions. */
|
||||
EAPI const Eo_Event_Description _EO_EV_CALLBACK_ADD =
|
||||
EO_EVENT_DESCRIPTION("callback,add", "?", "A callback was added.");
|
||||
EAPI const Eo_Event_Description _EO_EV_CALLBACK_DEL =
|
||||
EO_EVENT_DESCRIPTION("callback,del", "?", "A callback was deleted.");
|
||||
EAPI const Eo_Event_Description _EO_EV_FREE =
|
||||
EO_EVENT_DESCRIPTION("free", "", "Obj is being freed.");
|
||||
EAPI const Eo_Event_Description _EO_EV_DEL =
|
||||
EO_EVENT_DESCRIPTION("del", "", "Obj is being deleted.");
|
||||
|
||||
static void
|
||||
_constructor(Eo *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eo *obj, void *class_data)
|
||||
{
|
||||
DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS));
|
||||
|
||||
_eo_generic_data_del_all(class_data);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_SET), _data_set),
|
||||
EO_OP_FUNC_CONST(EO_BASE_ID(EO_BASE_SUB_ID_DATA_GET), _data_get),
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DATA_DEL), _data_del),
|
||||
EO_OP_FUNC_CONST(EO_BASE_ID(EO_BASE_SUB_ID_WREF_ADD), _wref_add),
|
||||
EO_OP_FUNC_CONST(EO_BASE_ID(EO_BASE_SUB_ID_WREF_DEL), _wref_del),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_SET, "?", "Set data for key."),
|
||||
EO_OP_DESCRIPTION_CONST(EO_BASE_SUB_ID_DATA_GET, "?", "Get data for key."),
|
||||
EO_OP_DESCRIPTION(EO_BASE_SUB_ID_DATA_DEL, "?", "Del key."),
|
||||
EO_OP_DESCRIPTION_CONST(EO_BASE_SUB_ID_WREF_ADD, "?", "Add a weak ref to the object."),
|
||||
EO_OP_DESCRIPTION_CONST(EO_BASE_SUB_ID_WREF_DEL, "?", "Delete the weak ref."),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Event_Description *event_desc[] = {
|
||||
EO_EV_CALLBACK_ADD,
|
||||
EO_EV_CALLBACK_DEL,
|
||||
EO_EV_FREE,
|
||||
EO_EV_DEL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Eo Base",
|
||||
EO_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EO_CLASS_DESCRIPTION_OPS(&EO_BASE_BASE_ID, op_desc, EO_BASE_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
_constructor,
|
||||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef _EO_PRIVATE_H
|
||||
#define _EO_PRIVATE_H
|
||||
|
||||
extern int _eo_log_dom;
|
||||
|
||||
#ifdef CRITICAL
|
||||
#undef CRITICAL
|
||||
#endif
|
||||
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eo_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef ERR
|
||||
#undef ERR
|
||||
#endif
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_eo_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef WRN
|
||||
#undef WRN
|
||||
#endif
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_eo_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef INF
|
||||
#undef INF
|
||||
#endif
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_eo_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef DBG
|
||||
#undef DBG
|
||||
#endif
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_eo_log_dom, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
#include <Eina.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "eobj_private.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
EAPI Eobj_Op EOBJ_BASE_BASE_ID = EOBJ_NOOP;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eina_Inlist *generic_data;
|
||||
} Private_Data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
EINA_INLIST;
|
||||
Eina_Stringshare *key;
|
||||
void *data;
|
||||
eobj_base_data_free_func free_func;
|
||||
} Eobj_Generic_Data_Node;
|
||||
|
||||
static void
|
||||
_eobj_generic_data_node_free(Eobj_Generic_Data_Node *node)
|
||||
{
|
||||
eina_stringshare_del(node->key);
|
||||
if (node->free_func)
|
||||
node->free_func(node->data);
|
||||
free(node);
|
||||
}
|
||||
|
||||
static void
|
||||
_eobj_generic_data_del_all(Private_Data *pd)
|
||||
{
|
||||
Eina_Inlist *nnode;
|
||||
Eobj_Generic_Data_Node *node = NULL;
|
||||
|
||||
EINA_INLIST_FOREACH_SAFE(pd->generic_data, nnode, node)
|
||||
{
|
||||
pd->generic_data = eina_inlist_remove(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
|
||||
_eobj_generic_data_node_free(node);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_data_set(Eobj *obj, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
const void *data = va_arg(*list, const void *);
|
||||
eobj_base_data_free_func free_func = va_arg(*list, eobj_base_data_free_func);
|
||||
|
||||
Eobj_Generic_Data_Node *node;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
eobj_do(obj, eobj_base_data_del(key));
|
||||
|
||||
node = malloc(sizeof(Eobj_Generic_Data_Node));
|
||||
node->key = eina_stringshare_add(key);
|
||||
node->data = (void *) data;
|
||||
node->free_func = free_func;
|
||||
pd->generic_data = eina_inlist_prepend(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
}
|
||||
|
||||
static void
|
||||
_data_get(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
/* We don't really change it... */
|
||||
Private_Data *pd = (Private_Data *) class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
void **data = va_arg(*list, void **);
|
||||
Eobj_Generic_Data_Node *node;
|
||||
|
||||
if (!data) return;
|
||||
*data = NULL;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
EINA_INLIST_FOREACH(pd->generic_data, node)
|
||||
{
|
||||
if (!strcmp(node->key, key))
|
||||
{
|
||||
pd->generic_data =
|
||||
eina_inlist_promote(pd->generic_data, EINA_INLIST_GET(node));
|
||||
*data = node->data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_data_del(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Private_Data *pd = class_data;
|
||||
const char *key = va_arg(*list, const char *);
|
||||
|
||||
Eobj_Generic_Data_Node *node;
|
||||
|
||||
if (!key) return;
|
||||
|
||||
EINA_INLIST_FOREACH(pd->generic_data, node)
|
||||
{
|
||||
if (!strcmp(node->key, key))
|
||||
{
|
||||
pd->generic_data = eina_inlist_remove(pd->generic_data,
|
||||
EINA_INLIST_GET(node));
|
||||
_eobj_generic_data_node_free(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Weak reference. */
|
||||
static Eina_Bool
|
||||
_eobj_weak_ref_cb(void *data, Eobj *obj EINA_UNUSED, const Eobj_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eobj **wref = data;
|
||||
*wref = NULL;
|
||||
|
||||
return EOBJ_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_wref_add(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Eobj **wref = va_arg(*list, Eobj **);
|
||||
|
||||
*wref = (Eobj *) obj;
|
||||
/* FIXME: The cast and the one in the next func are both bad and should be
|
||||
* fixed once the event callback functions are fixed. */
|
||||
eobj_event_callback_add((Eobj *) obj, EOBJ_EV_DEL, _eobj_weak_ref_cb, wref);
|
||||
}
|
||||
|
||||
static void
|
||||
_wref_del(const Eobj *obj, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Eobj **wref = va_arg(*list, Eobj **);
|
||||
if (*wref != obj)
|
||||
{
|
||||
ERR("Wref is a weak ref to %p, while this function was called on %p.",
|
||||
*wref, obj);
|
||||
return;
|
||||
}
|
||||
eobj_event_callback_del((Eobj *) obj, EOBJ_EV_DEL, _eobj_weak_ref_cb, wref);
|
||||
}
|
||||
|
||||
/* EOF Weak reference. */
|
||||
|
||||
|
||||
/* EOBJ_BASE_CLASS stuff */
|
||||
#define MY_CLASS EOBJ_BASE_CLASS
|
||||
|
||||
/* FIXME: Set proper type descriptions. */
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_CALLBACK_ADD =
|
||||
EOBJ_EVENT_DESCRIPTION("callback,add", "?", "A callback was added.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_CALLBACK_DEL =
|
||||
EOBJ_EVENT_DESCRIPTION("callback,del", "?", "A callback was deleted.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_FREE =
|
||||
EOBJ_EVENT_DESCRIPTION("free", "", "Obj is being freed.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_DEL =
|
||||
EOBJ_EVENT_DESCRIPTION("del", "", "Obj is being deleted.");
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
||||
{
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(MY_CLASS));
|
||||
}
|
||||
|
||||
static void
|
||||
_destructor(Eobj *obj, void *class_data)
|
||||
{
|
||||
DBG("%p - %s.", obj, eobj_class_name_get(MY_CLASS));
|
||||
|
||||
_eobj_generic_data_del_all(class_data);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_SET), _data_set),
|
||||
EOBJ_OP_FUNC_CONST(EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_GET), _data_get),
|
||||
EOBJ_OP_FUNC(EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_DATA_DEL), _data_del),
|
||||
EOBJ_OP_FUNC_CONST(EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_WREF_ADD), _wref_add),
|
||||
EOBJ_OP_FUNC_CONST(EOBJ_BASE_ID(EOBJ_BASE_SUB_ID_WREF_DEL), _wref_del),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(EOBJ_BASE_SUB_ID_DATA_SET, "?", "Set data for key."),
|
||||
EOBJ_OP_DESCRIPTION_CONST(EOBJ_BASE_SUB_ID_DATA_GET, "?", "Get data for key."),
|
||||
EOBJ_OP_DESCRIPTION(EOBJ_BASE_SUB_ID_DATA_DEL, "?", "Del key."),
|
||||
EOBJ_OP_DESCRIPTION_CONST(EOBJ_BASE_SUB_ID_WREF_ADD, "?", "Add a weak ref to the object."),
|
||||
EOBJ_OP_DESCRIPTION_CONST(EOBJ_BASE_SUB_ID_WREF_DEL, "?", "Delete the weak ref."),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Event_Description *event_desc[] = {
|
||||
EOBJ_EV_CALLBACK_ADD,
|
||||
EOBJ_EV_CALLBACK_DEL,
|
||||
EOBJ_EV_FREE,
|
||||
EOBJ_EV_DEL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Eobj Base",
|
||||
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&EOBJ_BASE_BASE_ID, op_desc, EOBJ_BASE_SUB_ID_LAST),
|
||||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
_constructor,
|
||||
_destructor,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(eobj_base_class_get, &class_desc, NULL, NULL)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef _EOBJ_PRIVATE_H
|
||||
#define _EOBJ_PRIVATE_H
|
||||
|
||||
extern int _eobj_log_dom;
|
||||
|
||||
#ifdef CRITICAL
|
||||
#undef CRITICAL
|
||||
#endif
|
||||
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eobj_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef ERR
|
||||
#undef ERR
|
||||
#endif
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_eobj_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef WRN
|
||||
#undef WRN
|
||||
#endif
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_eobj_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef INF
|
||||
#undef INF
|
||||
#endif
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_eobj_log_dom, __VA_ARGS__)
|
||||
|
||||
#ifdef DBG
|
||||
#undef DBG
|
||||
#endif
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_eobj_log_dom, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
if (CHECK_ENABLED)
|
||||
|
||||
LIST(APPEND EOBJ_SUITE_CC_SOURCES
|
||||
eobj_suite.c
|
||||
eobj_test_init.c
|
||||
eobj_test_general.c
|
||||
eobj_test_class_errors.c
|
||||
LIST(APPEND EO_SUITE_CC_SOURCES
|
||||
eo_suite.c
|
||||
eo_test_init.c
|
||||
eo_test_general.c
|
||||
eo_test_class_errors.c
|
||||
class_simple.c
|
||||
)
|
||||
|
||||
add_executable(eobj_suite ${EOBJ_SUITE_CC_SOURCES})
|
||||
add_executable(eo_suite ${EO_SUITE_CC_SOURCES})
|
||||
|
||||
include_directories(
|
||||
${EINA_INCLUDE_DIRS}
|
||||
|
@ -16,14 +16,14 @@ if (CHECK_ENABLED)
|
|||
${CHECK_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||
target_link_libraries(eobj_suite
|
||||
get_target_property(eo_LIB_FILE eo LOCATION)
|
||||
target_link_libraries(eo_suite
|
||||
${EINA_LIBRARIES}
|
||||
${EINA_LDFLAGS_OTHER}
|
||||
${eobj_LIB_FILE}
|
||||
${eo_LIB_FILE}
|
||||
${CHECK_LIBRARIES}
|
||||
)
|
||||
|
||||
add_test(eobj_suite eobj_suite)
|
||||
add_dependencies(check eobj_suite)
|
||||
add_test(eo_suite eo_suite)
|
||||
add_dependencies(check eo_suite)
|
||||
endif (CHECK_ENABLED)
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
#include "class_simple.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(MY_CLASS), a);
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
}
|
||||
|
||||
static void
|
||||
_a_print(const Eobj *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
_a_print(const Eo *obj EINA_UNUSED, const void *class_data, va_list *list)
|
||||
{
|
||||
const Simple_Public_Data *pd = class_data;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eobj_class_name_get(MY_CLASS), pd->a);
|
||||
printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
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_PRINT), _a_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_CONST(SIMPLE_SUB_ID_A_PRINT, "", "Print property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
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_PRINT, "", "Print property A"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Simple_Public_Data),
|
||||
NULL,
|
||||
|
@ -55,5 +55,5 @@ static const Eobj_Class_Description class_desc = {
|
|||
NULL
|
||||
};
|
||||
|
||||
EOBJ_DEFINE_CLASS(simple_class_get, &class_desc, EOBJ_BASE_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
|
@ -18,13 +18,13 @@ typedef struct
|
|||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
extern const Eo_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
const Eo_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,29 +5,29 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Eobj.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#include "eobj_suite.h"
|
||||
#include "eo_suite.h"
|
||||
|
||||
typedef struct _Eobj_Test_Case Eobj_Test_Case;
|
||||
typedef struct _Eo_Test_Case Eo_Test_Case;
|
||||
|
||||
struct _Eobj_Test_Case
|
||||
struct _Eo_Test_Case
|
||||
{
|
||||
const char *test_case;
|
||||
void (*build)(TCase *tc);
|
||||
};
|
||||
|
||||
static const Eobj_Test_Case etc[] = {
|
||||
{ "Eobj init", eobj_test_init },
|
||||
{ "Eobj general", eobj_test_general },
|
||||
{ "Eobj class errors", eobj_test_class_errors },
|
||||
static const Eo_Test_Case etc[] = {
|
||||
{ "Eo init", eo_test_init },
|
||||
{ "Eo general", eo_test_general },
|
||||
{ "Eo class errors", eo_test_class_errors },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
_list_tests(void)
|
||||
{
|
||||
const Eobj_Test_Case *itr;
|
||||
const Eo_Test_Case *itr;
|
||||
|
||||
itr = etc;
|
||||
fputs("Available Test Cases:\n", stderr);
|
||||
|
@ -47,13 +47,13 @@ _use_test(int argc, const char **argv, const char *test_case)
|
|||
}
|
||||
|
||||
static Suite *
|
||||
eobj_suite_build(int argc, const char **argv)
|
||||
eo_suite_build(int argc, const char **argv)
|
||||
{
|
||||
TCase *tc;
|
||||
Suite *s;
|
||||
int i;
|
||||
|
||||
s = suite_create("Eobj");
|
||||
s = suite_create("Eo");
|
||||
|
||||
for (i = 0; etc[i].test_case; ++i)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
s = eobj_suite_build(argc - 1, (const char **)argv + 1);
|
||||
s = eo_suite_build(argc - 1, (const char **)argv + 1);
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_ENV);
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _EO_SUITE_H
|
||||
#define _EO_SUITE_H
|
||||
|
||||
#include <check.h>
|
||||
|
||||
void eo_test_init(TCase *tc);
|
||||
void eo_test_general(TCase *tc);
|
||||
void eo_test_class_errors(TCase *tc);
|
||||
|
||||
|
||||
#endif /* _EO_SUITE_H */
|
|
@ -0,0 +1,362 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eo_suite.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#include "class_simple.h"
|
||||
|
||||
START_TEST(eo_incomplete_desc)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
const Eo_Class *klass;
|
||||
static Eo_Op TMP_BASE_ID = EO_NOOP;
|
||||
|
||||
enum {
|
||||
TEST_SUB_ID_FOO,
|
||||
TEST_SUB_ID_FOO2,
|
||||
TEST_SUB_ID_LAST
|
||||
};
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "i", "Foo"),
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "i", "Foo2"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Op_Description op_desc_wrong[] = {
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "i", "Foo2"),
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "i", "Foo"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
/* XXX: In real life this should be const, this is just for testing. */
|
||||
static Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.base_op_id = &TMP_BASE_ID;
|
||||
class_desc.ops.descs = NULL;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST + 1;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.count = 0;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST;
|
||||
class_desc.ops.descs = op_desc_wrong;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.name = NULL;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.name = "Simple";
|
||||
|
||||
|
||||
klass = eo_class_new(NULL, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
/* Should create a class. */
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
(void) klass;
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_inherit_errors)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
const Eo_Class *klass;
|
||||
const Eo_Class *klass_mixin;
|
||||
const Eo_Class *klass_simple;
|
||||
|
||||
static const Eo_Class_Description class_desc_simple = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin = {
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
"General",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
|
||||
fail_if(!klass_mixin);
|
||||
|
||||
klass_simple = eo_class_new(&class_desc_simple, NULL, NULL);
|
||||
fail_if(!klass_simple);
|
||||
|
||||
klass = eo_class_new(&class_desc, klass_simple, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.type = EO_CLASS_TYPE_REGULAR;
|
||||
|
||||
klass = eo_class_new(&class_desc, klass_mixin, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
(void) klass;
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_inconsistent_mro)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
const Eo_Class *klass;
|
||||
const Eo_Class *klass_mixin;
|
||||
const Eo_Class *klass_mixin2;
|
||||
const Eo_Class *klass_mixin3;
|
||||
|
||||
static const Eo_Class_Description class_desc_simple = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin = {
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin2 = {
|
||||
"Mixin2",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin3 = {
|
||||
"Mixin3",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
|
||||
fail_if(!klass_mixin);
|
||||
|
||||
klass_mixin2 = eo_class_new(&class_desc_mixin2, klass_mixin, NULL);
|
||||
fail_if(!klass_mixin2);
|
||||
|
||||
klass_mixin3 = eo_class_new(&class_desc_mixin3, klass_mixin, NULL);
|
||||
fail_if(!klass_mixin3);
|
||||
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void _stub_constructor(Eo *obj EINA_UNUSED, void *data EINA_UNUSED) {}
|
||||
static void _stub_class_constructor(Eo_Class *klass EINA_UNUSED) {}
|
||||
|
||||
START_TEST(eo_bad_interface)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
const Eo_Class *klass;
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
"Interface",
|
||||
EO_CLASS_TYPE_INTERFACE,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
10,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.data_size = 0;
|
||||
class_desc.constructor = _stub_constructor;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.constructor = NULL;
|
||||
class_desc.destructor = _stub_constructor;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.destructor = NULL;
|
||||
class_desc.class_constructor = _stub_class_constructor;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.class_constructor = NULL;
|
||||
class_desc.class_destructor = _stub_class_constructor;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.class_destructor = NULL;
|
||||
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static int _const_ops_counter = 0;
|
||||
|
||||
static void
|
||||
_const_ops_a_set(const Eo *obj EINA_UNUSED, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a = va_arg(*list, int);
|
||||
(void) a;
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eo_const_ops)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
const Eo_Class *klass;
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
_const_ops_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
eo_do(obj, simple_a_set(7), simple_a_print());
|
||||
fail_if(_const_ops_counter != 0);
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eo_test_class_errors(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_incomplete_desc);
|
||||
tcase_add_test(tc, eo_inherit_errors);
|
||||
tcase_add_test(tc, eo_inconsistent_mro);
|
||||
tcase_add_test(tc, eo_bad_interface);
|
||||
tcase_add_test(tc, eo_const_ops);
|
||||
}
|
|
@ -0,0 +1,327 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eo_suite.h"
|
||||
#include "Eo.h"
|
||||
|
||||
#include "class_simple.h"
|
||||
|
||||
START_TEST(eo_simple)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(EO_BASE_CLASS, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_refs)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj3 = eo_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_xref(obj, obj2);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
eo_xref(obj, obj3);
|
||||
fail_if(eo_ref_get(obj) != 3);
|
||||
|
||||
eo_xunref(obj, obj2);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
eo_xunref(obj, obj3);
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
#ifndef NDEBUG
|
||||
eo_xunref(obj, obj3);
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
eo_xref(obj, obj2);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_xunref(obj, obj3);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_xunref(obj, obj2);
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
#endif
|
||||
|
||||
eo_unref(obj);
|
||||
eo_unref(obj2);
|
||||
eo_unref(obj3);
|
||||
|
||||
/* Just check it doesn't seg atm. */
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
eo_ref(obj);
|
||||
eo_del(obj);
|
||||
eo_del(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_weak_reference)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *wref;
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
fail_if(!wref);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(!wref);
|
||||
|
||||
eo_del(obj);
|
||||
fail_if(wref);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
fail_if(EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_op_errors_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST), _a_set),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST + 1), _a_set),
|
||||
EO_OP_FUNC(0x0F010111, _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eo_op_errors)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
_op_errors_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
|
||||
/* Out of bounds op for a legal class. */
|
||||
fail_if(eo_do(obj, 0x00010111));
|
||||
|
||||
/* Ilegal class. */
|
||||
fail_if(eo_do(obj, 0x0F010111));
|
||||
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(eo_ref_get(obj) != 3);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!eo_do(obj, simple_a_print()));
|
||||
fail_if(!eo_query(obj, simple_a_print()));
|
||||
fail_if(eo_query(obj, simple_a_set(1)));
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_fake_free_func(void *data)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
int *a = data;
|
||||
++*a;
|
||||
}
|
||||
|
||||
START_TEST(eo_generic_data)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
void *data;
|
||||
|
||||
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eo_do(obj, eo_base_data_del("test1"));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
fail_if(data);
|
||||
|
||||
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
|
||||
eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
fail_if(2 != (int) data);
|
||||
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
fail_if(2 != (int) data);
|
||||
eo_do(obj, eo_base_data_del("test2"));
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
fail_if(data);
|
||||
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eo_do(obj, eo_base_data_del("test1"));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
fail_if(data);
|
||||
|
||||
int a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_get("test3", &data));
|
||||
fail_if(&a != data);
|
||||
eo_do(obj, eo_base_data_get("test3", NULL));
|
||||
eo_do(obj, eo_base_data_del("test3"));
|
||||
fail_if(a != 1);
|
||||
|
||||
a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func));
|
||||
fail_if(a != 1);
|
||||
a = 0;
|
||||
data = (void *) 123;
|
||||
eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_get(NULL, &data));
|
||||
fail_if(data);
|
||||
eo_do(obj, eo_base_data_del(NULL));
|
||||
|
||||
a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_set("test3", NULL, NULL));
|
||||
fail_if(a != 1);
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(a != 2);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_magic_checks)
|
||||
{
|
||||
char buf[sizeof(long)]; /* Just enough to hold eina magic + a bit more. */
|
||||
eo_init();
|
||||
|
||||
memset(buf, 1, sizeof(buf));
|
||||
Eo *obj = eo_add((Eo_Class *) buf, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, (Eo *) buf);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
|
||||
fail_if(eo_do((Eo *) buf, EO_NOOP));
|
||||
fail_if(eo_do_super((Eo *) buf, EO_NOOP));
|
||||
fail_if(eo_class_get((Eo *) buf));
|
||||
fail_if(eo_class_name_get((Eo_Class*) buf));
|
||||
eo_class_funcs_set((Eo_Class *) buf, NULL);
|
||||
|
||||
fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL);
|
||||
|
||||
eo_xref(obj, (Eo *) buf);
|
||||
eo_xunref(obj, (Eo *) buf);
|
||||
eo_xref((Eo *) buf, obj);
|
||||
eo_xunref((Eo *) buf, obj);
|
||||
|
||||
eo_ref((Eo *) buf);
|
||||
eo_unref((Eo *) buf);
|
||||
|
||||
fail_if(0 != eo_ref_get((Eo *) buf));
|
||||
|
||||
Eo *wref = NULL;
|
||||
eo_do((Eo *) buf, eo_wref_add(&wref));
|
||||
fail_if(wref);
|
||||
|
||||
eo_del((Eo *) buf);
|
||||
|
||||
fail_if(eo_parent_get((Eo *) buf));
|
||||
|
||||
eo_constructor_error_set((Eo *) buf);
|
||||
fail_if(!eo_constructor_error_get((Eo *) buf));
|
||||
|
||||
eo_constructor_super((Eo *) buf);
|
||||
eo_destructor_super((Eo *) buf);
|
||||
|
||||
fail_if(eo_data_get((Eo *) buf, SIMPLE_CLASS));
|
||||
|
||||
eo_composite_object_attach((Eo *) buf, obj);
|
||||
eo_composite_object_attach(obj, (Eo *) buf);
|
||||
eo_composite_object_detach((Eo *) buf, obj);
|
||||
eo_composite_object_detach(obj, (Eo *) buf);
|
||||
eo_composite_is((Eo *) buf);
|
||||
|
||||
fail_if(eo_event_callback_add((Eo *) buf, NULL, NULL, NULL));
|
||||
fail_if(eo_event_callback_del_lazy((Eo *) buf, NULL, NULL));
|
||||
fail_if(eo_event_callback_del((Eo *) buf, NULL, NULL, NULL));
|
||||
fail_if(eo_event_callback_call((Eo *) buf, NULL, NULL));
|
||||
|
||||
fail_if(eo_event_callback_forwarder_add((Eo *) buf, NULL, obj));
|
||||
fail_if(eo_event_callback_forwarder_add(obj, NULL, (Eo *) buf));
|
||||
fail_if(eo_event_callback_forwarder_del((Eo *) buf, NULL, obj));
|
||||
fail_if(eo_event_callback_forwarder_del(obj, NULL, (Eo *) buf));
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eo_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_generic_data);
|
||||
tcase_add_test(tc, eo_op_errors);
|
||||
tcase_add_test(tc, eo_simple);
|
||||
tcase_add_test(tc, eo_weak_reference);
|
||||
tcase_add_test(tc, eo_refs);
|
||||
tcase_add_test(tc, eo_magic_checks);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eo_suite.h"
|
||||
#include "Eo.h"
|
||||
|
||||
START_TEST(eo_simple)
|
||||
{
|
||||
fail_if(!eo_init()); /* one init by test suite */
|
||||
fail_if(eo_init() != 1);
|
||||
fail_if(eo_shutdown() != 1);
|
||||
fail_if(!eo_shutdown());
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eo_test_init(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_simple);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef _EOBJ_SUITE_H
|
||||
#define _EOBJ_SUITE_H
|
||||
|
||||
#include <check.h>
|
||||
|
||||
void eobj_test_init(TCase *tc);
|
||||
void eobj_test_general(TCase *tc);
|
||||
void eobj_test_class_errors(TCase *tc);
|
||||
|
||||
|
||||
#endif /* _EOBJ_SUITE_H */
|
|
@ -1,362 +0,0 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eobj_suite.h"
|
||||
#include "Eobj.h"
|
||||
|
||||
#include "class_simple.h"
|
||||
|
||||
START_TEST(eobj_incomplete_desc)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
const Eobj_Class *klass;
|
||||
static Eobj_Op TMP_BASE_ID = EOBJ_NOOP;
|
||||
|
||||
enum {
|
||||
TEST_SUB_ID_FOO,
|
||||
TEST_SUB_ID_FOO2,
|
||||
TEST_SUB_ID_LAST
|
||||
};
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(TEST_SUB_ID_FOO, "i", "Foo"),
|
||||
EOBJ_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "i", "Foo2"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Op_Description op_desc_wrong[] = {
|
||||
EOBJ_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "i", "Foo2"),
|
||||
EOBJ_OP_DESCRIPTION(TEST_SUB_ID_FOO, "i", "Foo"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
/* XXX: In real life this should be const, this is just for testing. */
|
||||
static Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.base_op_id = &TMP_BASE_ID;
|
||||
class_desc.ops.descs = NULL;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST + 1;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.count = 0;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST;
|
||||
class_desc.ops.descs = op_desc_wrong;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.name = NULL;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.name = "Simple";
|
||||
|
||||
|
||||
klass = eobj_class_new(NULL, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
/* Should create a class. */
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
(void) klass;
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eobj_inherit_errors)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
const Eobj_Class *klass;
|
||||
const Eobj_Class *klass_mixin;
|
||||
const Eobj_Class *klass_simple;
|
||||
|
||||
static const Eobj_Class_Description class_desc_simple = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc_mixin = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static Eobj_Class_Description class_desc = {
|
||||
"General",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass_mixin = eobj_class_new(&class_desc_mixin, NULL, NULL);
|
||||
fail_if(!klass_mixin);
|
||||
|
||||
klass_simple = eobj_class_new(&class_desc_simple, NULL, NULL);
|
||||
fail_if(!klass_simple);
|
||||
|
||||
klass = eobj_class_new(&class_desc, klass_simple, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.type = EOBJ_CLASS_TYPE_REGULAR;
|
||||
|
||||
klass = eobj_class_new(&class_desc, klass_mixin, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
(void) klass;
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eobj_inconsistent_mro)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
const Eobj_Class *klass;
|
||||
const Eobj_Class *klass_mixin;
|
||||
const Eobj_Class *klass_mixin2;
|
||||
const Eobj_Class *klass_mixin3;
|
||||
|
||||
static const Eobj_Class_Description class_desc_simple = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc_mixin = {
|
||||
"Mixin",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc_mixin2 = {
|
||||
"Mixin2",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc_mixin3 = {
|
||||
"Mixin3",
|
||||
EOBJ_CLASS_TYPE_MIXIN,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass_mixin = eobj_class_new(&class_desc_mixin, NULL, NULL);
|
||||
fail_if(!klass_mixin);
|
||||
|
||||
klass_mixin2 = eobj_class_new(&class_desc_mixin2, klass_mixin, NULL);
|
||||
fail_if(!klass_mixin2);
|
||||
|
||||
klass_mixin3 = eobj_class_new(&class_desc_mixin3, klass_mixin, NULL);
|
||||
fail_if(!klass_mixin3);
|
||||
|
||||
klass = eobj_class_new(&class_desc_simple, EOBJ_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
klass = eobj_class_new(&class_desc_simple, EOBJ_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
klass = eobj_class_new(&class_desc_simple, EOBJ_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void _stub_constructor(Eobj *obj EINA_UNUSED, void *data EINA_UNUSED) {}
|
||||
static void _stub_class_constructor(Eobj_Class *klass EINA_UNUSED) {}
|
||||
|
||||
START_TEST(eobj_bad_interface)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
const Eobj_Class *klass;
|
||||
|
||||
static Eobj_Class_Description class_desc = {
|
||||
"Interface",
|
||||
EOBJ_CLASS_TYPE_INTERFACE,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
10,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.data_size = 0;
|
||||
class_desc.constructor = _stub_constructor;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.constructor = NULL;
|
||||
class_desc.destructor = _stub_constructor;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.destructor = NULL;
|
||||
class_desc.class_constructor = _stub_class_constructor;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.class_constructor = NULL;
|
||||
class_desc.class_destructor = _stub_class_constructor;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
|
||||
class_desc.class_destructor = NULL;
|
||||
|
||||
klass = eobj_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static int _const_ops_counter = 0;
|
||||
|
||||
static void
|
||||
_const_ops_a_set(const Eobj *obj EINA_UNUSED, const void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a = va_arg(*list, int);
|
||||
(void) a;
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_a_print(Eobj *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_class_constructor(Eobj_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_CONST(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set),
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eobj_const_ops)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
const Eobj_Class *klass;
|
||||
|
||||
static Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
_const_ops_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
klass = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eobj *obj = eobj_add(klass, NULL);
|
||||
eobj_do(obj, simple_a_set(7), simple_a_print());
|
||||
fail_if(_const_ops_counter != 0);
|
||||
|
||||
eobj_unref(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eobj_test_class_errors(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eobj_incomplete_desc);
|
||||
tcase_add_test(tc, eobj_inherit_errors);
|
||||
tcase_add_test(tc, eobj_inconsistent_mro);
|
||||
tcase_add_test(tc, eobj_bad_interface);
|
||||
tcase_add_test(tc, eobj_const_ops);
|
||||
}
|
|
@ -1,327 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eobj_suite.h"
|
||||
#include "Eobj.h"
|
||||
|
||||
#include "class_simple.h"
|
||||
|
||||
START_TEST(eobj_simple)
|
||||
{
|
||||
eobj_init();
|
||||
Eobj *obj = eobj_add(EOBJ_BASE_CLASS, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eobj_refs)
|
||||
{
|
||||
eobj_init();
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Eobj *obj2 = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Eobj *obj3 = eobj_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eobj_xref(obj, obj2);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
eobj_xref(obj, obj3);
|
||||
fail_if(eobj_ref_get(obj) != 3);
|
||||
|
||||
eobj_xunref(obj, obj2);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
eobj_xunref(obj, obj3);
|
||||
fail_if(eobj_ref_get(obj) != 1);
|
||||
|
||||
#ifndef NDEBUG
|
||||
eobj_xunref(obj, obj3);
|
||||
fail_if(eobj_ref_get(obj) != 1);
|
||||
|
||||
eobj_xref(obj, obj2);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
|
||||
eobj_xunref(obj, obj3);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
|
||||
eobj_xunref(obj, obj2);
|
||||
fail_if(eobj_ref_get(obj) != 1);
|
||||
#endif
|
||||
|
||||
eobj_unref(obj);
|
||||
eobj_unref(obj2);
|
||||
eobj_unref(obj3);
|
||||
|
||||
/* Just check it doesn't seg atm. */
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
eobj_ref(obj);
|
||||
eobj_del(obj);
|
||||
eobj_del(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eobj_weak_reference)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
Eobj *wref;
|
||||
eobj_do(obj, eobj_wref_add(&wref));
|
||||
fail_if(!wref);
|
||||
|
||||
eobj_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
eobj_do(obj, eobj_wref_add(&wref));
|
||||
|
||||
eobj_ref(obj);
|
||||
fail_if(!wref);
|
||||
|
||||
eobj_del(obj);
|
||||
fail_if(wref);
|
||||
|
||||
eobj_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eobj_do(obj, eobj_wref_add(&wref));
|
||||
eobj_do(obj, eobj_wref_del(&wref));
|
||||
|
||||
eobj_unref(obj);
|
||||
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
fail_if(EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_op_errors_class_constructor(Eobj_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST), _a_set),
|
||||
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST + 1), _a_set),
|
||||
EOBJ_OP_FUNC(0x0F010111, _a_set),
|
||||
EOBJ_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eobj_op_errors)
|
||||
{
|
||||
eobj_init();
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
_op_errors_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Eobj_Class *klass = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eobj *obj = eobj_add(klass, NULL);
|
||||
|
||||
/* Out of bounds op for a legal class. */
|
||||
fail_if(eobj_do(obj, 0x00010111));
|
||||
|
||||
/* Ilegal class. */
|
||||
fail_if(eobj_do(obj, 0x0F010111));
|
||||
|
||||
fail_if(eobj_ref_get(obj) != 1);
|
||||
|
||||
eobj_ref(obj);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
|
||||
eobj_ref(obj);
|
||||
fail_if(eobj_ref_get(obj) != 3);
|
||||
|
||||
eobj_unref(obj);
|
||||
fail_if(eobj_ref_get(obj) != 2);
|
||||
|
||||
eobj_unref(obj);
|
||||
fail_if(eobj_ref_get(obj) != 1);
|
||||
|
||||
eobj_unref(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!eobj_do(obj, simple_a_print()));
|
||||
fail_if(!eobj_query(obj, simple_a_print()));
|
||||
fail_if(eobj_query(obj, simple_a_set(1)));
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_fake_free_func(void *data)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
int *a = data;
|
||||
++*a;
|
||||
}
|
||||
|
||||
START_TEST(eobj_generic_data)
|
||||
{
|
||||
eobj_init();
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
void *data;
|
||||
|
||||
eobj_do(obj, eobj_base_data_set("test1", (void *) 1, NULL));
|
||||
eobj_do(obj, eobj_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eobj_do(obj, eobj_base_data_del("test1"));
|
||||
eobj_do(obj, eobj_base_data_get("test1", &data));
|
||||
fail_if(data);
|
||||
|
||||
eobj_do(obj, eobj_base_data_set("test1", (void *) 1, NULL));
|
||||
eobj_do(obj, eobj_base_data_set("test2", (void *) 2, NULL));
|
||||
eobj_do(obj, eobj_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eobj_do(obj, eobj_base_data_get("test2", &data));
|
||||
fail_if(2 != (int) data);
|
||||
|
||||
eobj_do(obj, eobj_base_data_get("test2", &data));
|
||||
fail_if(2 != (int) data);
|
||||
eobj_do(obj, eobj_base_data_del("test2"));
|
||||
eobj_do(obj, eobj_base_data_get("test2", &data));
|
||||
fail_if(data);
|
||||
|
||||
eobj_do(obj, eobj_base_data_get("test1", &data));
|
||||
fail_if(1 != (int) data);
|
||||
eobj_do(obj, eobj_base_data_del("test1"));
|
||||
eobj_do(obj, eobj_base_data_get("test1", &data));
|
||||
fail_if(data);
|
||||
|
||||
int a = 0;
|
||||
eobj_do(obj, eobj_base_data_set("test3", &a, _fake_free_func));
|
||||
eobj_do(obj, eobj_base_data_get("test3", &data));
|
||||
fail_if(&a != data);
|
||||
eobj_do(obj, eobj_base_data_get("test3", NULL));
|
||||
eobj_do(obj, eobj_base_data_del("test3"));
|
||||
fail_if(a != 1);
|
||||
|
||||
a = 0;
|
||||
eobj_do(obj, eobj_base_data_set("test3", &a, _fake_free_func));
|
||||
eobj_do(obj, eobj_base_data_set("test3", NULL, _fake_free_func));
|
||||
fail_if(a != 1);
|
||||
a = 0;
|
||||
data = (void *) 123;
|
||||
eobj_do(obj, eobj_base_data_set(NULL, &a, _fake_free_func));
|
||||
eobj_do(obj, eobj_base_data_get(NULL, &data));
|
||||
fail_if(data);
|
||||
eobj_do(obj, eobj_base_data_del(NULL));
|
||||
|
||||
a = 0;
|
||||
eobj_do(obj, eobj_base_data_set("test3", &a, _fake_free_func));
|
||||
eobj_do(obj, eobj_base_data_set("test3", NULL, NULL));
|
||||
fail_if(a != 1);
|
||||
eobj_do(obj, eobj_base_data_set("test3", &a, _fake_free_func));
|
||||
|
||||
eobj_unref(obj);
|
||||
fail_if(a != 2);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eobj_magic_checks)
|
||||
{
|
||||
char buf[sizeof(long)]; /* Just enough to hold eina magic + a bit more. */
|
||||
eobj_init();
|
||||
|
||||
memset(buf, 1, sizeof(buf));
|
||||
Eobj *obj = eobj_add((Eobj_Class *) buf, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, (Eobj *) buf);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
|
||||
fail_if(eobj_do((Eobj *) buf, EOBJ_NOOP));
|
||||
fail_if(eobj_do_super((Eobj *) buf, EOBJ_NOOP));
|
||||
fail_if(eobj_class_get((Eobj *) buf));
|
||||
fail_if(eobj_class_name_get((Eobj_Class*) buf));
|
||||
eobj_class_funcs_set((Eobj_Class *) buf, NULL);
|
||||
|
||||
fail_if(eobj_class_new(NULL, (Eobj_Class *) buf), NULL);
|
||||
|
||||
eobj_xref(obj, (Eobj *) buf);
|
||||
eobj_xunref(obj, (Eobj *) buf);
|
||||
eobj_xref((Eobj *) buf, obj);
|
||||
eobj_xunref((Eobj *) buf, obj);
|
||||
|
||||
eobj_ref((Eobj *) buf);
|
||||
eobj_unref((Eobj *) buf);
|
||||
|
||||
fail_if(0 != eobj_ref_get((Eobj *) buf));
|
||||
|
||||
Eobj *wref = NULL;
|
||||
eobj_do((Eobj *) buf, eobj_wref_add(&wref));
|
||||
fail_if(wref);
|
||||
|
||||
eobj_del((Eobj *) buf);
|
||||
|
||||
fail_if(eobj_parent_get((Eobj *) buf));
|
||||
|
||||
eobj_constructor_error_set((Eobj *) buf);
|
||||
fail_if(!eobj_constructor_error_get((Eobj *) buf));
|
||||
|
||||
eobj_constructor_super((Eobj *) buf);
|
||||
eobj_destructor_super((Eobj *) buf);
|
||||
|
||||
fail_if(eobj_data_get((Eobj *) buf, SIMPLE_CLASS));
|
||||
|
||||
eobj_composite_object_attach((Eobj *) buf, obj);
|
||||
eobj_composite_object_attach(obj, (Eobj *) buf);
|
||||
eobj_composite_object_detach((Eobj *) buf, obj);
|
||||
eobj_composite_object_detach(obj, (Eobj *) buf);
|
||||
eobj_composite_is((Eobj *) buf);
|
||||
|
||||
fail_if(eobj_event_callback_add((Eobj *) buf, NULL, NULL, NULL));
|
||||
fail_if(eobj_event_callback_del_lazy((Eobj *) buf, NULL, NULL));
|
||||
fail_if(eobj_event_callback_del((Eobj *) buf, NULL, NULL, NULL));
|
||||
fail_if(eobj_event_callback_call((Eobj *) buf, NULL, NULL));
|
||||
|
||||
fail_if(eobj_event_callback_forwarder_add((Eobj *) buf, NULL, obj));
|
||||
fail_if(eobj_event_callback_forwarder_add(obj, NULL, (Eobj *) buf));
|
||||
fail_if(eobj_event_callback_forwarder_del((Eobj *) buf, NULL, obj));
|
||||
fail_if(eobj_event_callback_forwarder_del(obj, NULL, (Eobj *) buf));
|
||||
|
||||
eobj_unref(obj);
|
||||
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eobj_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eobj_generic_data);
|
||||
tcase_add_test(tc, eobj_op_errors);
|
||||
tcase_add_test(tc, eobj_simple);
|
||||
tcase_add_test(tc, eobj_weak_reference);
|
||||
tcase_add_test(tc, eobj_refs);
|
||||
tcase_add_test(tc, eobj_magic_checks);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "eobj_suite.h"
|
||||
#include "Eobj.h"
|
||||
|
||||
START_TEST(eobj_simple)
|
||||
{
|
||||
fail_if(!eobj_init()); /* one init by test suite */
|
||||
fail_if(eobj_init() != 1);
|
||||
fail_if(eobj_shutdown() != 1);
|
||||
fail_if(!eobj_shutdown());
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eobj_test_init(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eobj_simple);
|
||||
}
|
Loading…
Reference in New Issue