2012-04-10 02:12:46 -07:00
|
|
|
#include "Eobj.h"
|
2012-04-05 08:31:15 -07:00
|
|
|
#include "simple.h"
|
|
|
|
|
2012-04-12 06:52:13 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-04-05 08:31:15 -07:00
|
|
|
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2012-04-12 05:42:33 -07:00
|
|
|
Simple_Public_Data pub;
|
2012-04-05 08:31:15 -07:00
|
|
|
int a;
|
|
|
|
} Private_Data;
|
|
|
|
|
|
|
|
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
|
|
|
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
|
|
|
|
2012-04-17 03:27:25 -07:00
|
|
|
static const Eobj_Class *_my_class = NULL;
|
2012-04-05 08:31:15 -07:00
|
|
|
|
|
|
|
static void
|
2012-04-12 06:52:13 -07:00
|
|
|
_a_set(Eobj *obj, void *class_data, va_list *list)
|
2012-04-05 08:31:15 -07:00
|
|
|
{
|
2012-04-12 06:52:13 -07:00
|
|
|
Private_Data *pd = class_data;
|
2012-04-05 08:31:15 -07:00
|
|
|
int a;
|
|
|
|
a = va_arg(*list, int);
|
|
|
|
pd->a = a;
|
|
|
|
printf("%s %d\n", __func__, pd->a);
|
|
|
|
|
|
|
|
eobj_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)
|
|
|
|
{
|
2012-04-12 05:42:33 -07:00
|
|
|
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
2012-04-05 08:31:15 -07:00
|
|
|
const Eobj_Event_Description *cb_desc = event_info;
|
|
|
|
(void) data;
|
|
|
|
(void) desc;
|
|
|
|
|
|
|
|
if (cb_desc != SIG_A_CHANGED)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
2012-04-12 05:42:33 -07:00
|
|
|
pd->cb_count++;
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-04-12 05:42:33 -07:00
|
|
|
printf("Added SIG_A_CHANGED callback to %p. Count: %d\n", obj, pd->cb_count);
|
2012-04-05 08:31:15 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
|
|
|
{
|
2012-04-12 05:42:33 -07:00
|
|
|
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
2012-04-05 08:31:15 -07:00
|
|
|
const Eobj_Event_Description *cb_desc = event_info;
|
|
|
|
(void) data;
|
|
|
|
(void) desc;
|
|
|
|
|
|
|
|
if (cb_desc != SIG_A_CHANGED)
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
2012-04-12 05:42:33 -07:00
|
|
|
pd->cb_count--;
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-04-12 05:42:33 -07:00
|
|
|
printf("Removed SIG_A_CHANGED callback from %p. Count: %d\n", obj, pd->cb_count);
|
2012-04-05 08:31:15 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-19 04:30:17 -07:00
|
|
|
_constructor(Eobj *obj, void *class_data EINA_UNUSED)
|
2012-04-05 08:31:15 -07:00
|
|
|
{
|
|
|
|
eobj_constructor_super(obj);
|
|
|
|
|
2012-04-16 07:22:08 -07:00
|
|
|
eobj_event_callback_add(obj, EOBJ_EV_CALLBACK_ADD, _cb_added, NULL);
|
|
|
|
eobj_event_callback_add(obj, EOBJ_EV_CALLBACK_DEL, _cb_deled, NULL);
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-04-17 05:49:53 -07:00
|
|
|
eobj_do(obj, EOBJ_BASE_DATA_SET("cb_count", (intptr_t) 0, NULL));
|
2012-04-05 08:31:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_class_constructor(Eobj_Class *klass)
|
|
|
|
{
|
|
|
|
const Eobj_Op_Func_Description func_desc[] = {
|
2012-04-16 05:36:34 -07:00
|
|
|
EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
|
|
|
EOBJ_OP_FUNC_SENTINEL
|
2012-04-05 08:31:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
eobj_class_funcs_set(klass, func_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Eobj_Class *
|
|
|
|
simple_class_get(void)
|
|
|
|
{
|
|
|
|
if (_my_class) return _my_class;
|
|
|
|
|
|
|
|
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 Eobj_Event_Description *event_desc[] = {
|
|
|
|
SIG_A_CHANGED,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Eobj_Class_Description class_desc = {
|
|
|
|
"Simple",
|
|
|
|
EOBJ_CLASS_TYPE_REGULAR,
|
|
|
|
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
|
|
|
event_desc,
|
|
|
|
sizeof(Private_Data),
|
|
|
|
_constructor,
|
2012-04-12 06:52:13 -07:00
|
|
|
NULL,
|
2012-04-05 08:31:15 -07:00
|
|
|
_class_constructor,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-04-17 07:01:09 -07:00
|
|
|
return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS, NULL);
|
2012-04-05 08:31:15 -07:00
|
|
|
}
|