forked from enlightenment/efl
Eo: Added a non-default constructor test.
SVN revision: 75616
This commit is contained in:
parent
b6c1892463
commit
41c490609c
|
@ -59,6 +59,16 @@ main(int argc, char *argv[])
|
||||||
obj = eo_add(SIMPLE7_CLASS, NULL);
|
obj = eo_add(SIMPLE7_CLASS, NULL);
|
||||||
fail_if(obj);
|
fail_if(obj);
|
||||||
|
|
||||||
|
my_init_count = 0;
|
||||||
|
obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7));
|
||||||
|
fail_if(!obj);
|
||||||
|
|
||||||
|
fail_if(my_init_count != 2);
|
||||||
|
eo_do(obj, simple_a_get(&a));
|
||||||
|
fail_if(a != 7);
|
||||||
|
|
||||||
|
eo_unref(obj);
|
||||||
|
|
||||||
eo_shutdown();
|
eo_shutdown();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,21 @@ _GET_SET_FUNC(b)
|
||||||
|
|
||||||
extern int my_init_count;
|
extern int my_init_count;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_simple_constructor(Eo *obj, void *class_data, va_list *list)
|
||||||
|
{
|
||||||
|
Private_Data *pd = class_data;
|
||||||
|
int a;
|
||||||
|
a = va_arg(*list, int);
|
||||||
|
|
||||||
|
eo_do_super(obj, eo_constructor());
|
||||||
|
|
||||||
|
pd->a = a;
|
||||||
|
printf("%s %d\n", __func__, pd->a);
|
||||||
|
|
||||||
|
my_init_count++;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
_constructor(Eo *obj, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +78,7 @@ _class_constructor(Eo_Class *klass)
|
||||||
const Eo_Op_Func_Description func_desc[] = {
|
const Eo_Op_Func_Description func_desc[] = {
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
|
||||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
|
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
|
||||||
|
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), _simple_constructor),
|
||||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
||||||
|
@ -82,6 +98,7 @@ _class_destructor(Eo_Class *klass EINA_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Eo_Op_Description op_desc[] = {
|
static const Eo_Op_Description op_desc[] = {
|
||||||
|
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_CONSTRUCTOR, "Construct and set A."),
|
||||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
|
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
|
||||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
|
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "Get property A"),
|
||||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
|
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "Set property B"),
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
SIMPLE_SUB_ID_CONSTRUCTOR,
|
||||||
SIMPLE_SUB_ID_A_SET,
|
SIMPLE_SUB_ID_A_SET,
|
||||||
SIMPLE_SUB_ID_A_GET,
|
SIMPLE_SUB_ID_A_GET,
|
||||||
SIMPLE_SUB_ID_B_SET,
|
SIMPLE_SUB_ID_B_SET,
|
||||||
|
@ -15,6 +16,7 @@ enum {
|
||||||
|
|
||||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define simple_constructor(a) SIMPLE_ID(SIMPLE_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(int, a)
|
||||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_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)
|
#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_set(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EO_TYPECHECK(int, b)
|
||||||
|
|
Loading…
Reference in New Issue