From: Enlightenment S. <no-...@en...> - 2012-04-12 15:27:33
|
Log: Eobj: Added more function override tests. Author: tasn Date: 2012-04-12 08:27:22 -0700 (Thu, 12 Apr 2012) New Revision: 70151 Trac: http://trac.enlightenment.org/e/changeset/70151 Modified: trunk/PROTO/eobj/examples/function_overrides/inherit.c trunk/PROTO/eobj/examples/function_overrides/inherit2.c trunk/PROTO/eobj/examples/function_overrides/inherit2.h trunk/PROTO/eobj/examples/function_overrides/inherit3.c trunk/PROTO/eobj/examples/function_overrides/main.c Modified: trunk/PROTO/eobj/examples/function_overrides/inherit.c =================================================================== --- trunk/PROTO/eobj/examples/function_overrides/inherit.c 2012-04-12 15:27:18 UTC (rev 70150) +++ trunk/PROTO/eobj/examples/function_overrides/inherit.c 2012-04-12 15:27:22 UTC (rev 70151) @@ -3,8 +3,6 @@ #include "inherit.h" -EAPI Eobj_Op INHERIT_BASE_ID = 0; - static Eobj_Class *_my_class = NULL; const Eobj_Class * Modified: trunk/PROTO/eobj/examples/function_overrides/inherit2.c =================================================================== --- trunk/PROTO/eobj/examples/function_overrides/inherit2.c 2012-04-12 15:27:18 UTC (rev 70150) +++ trunk/PROTO/eobj/examples/function_overrides/inherit2.c 2012-04-12 15:27:22 UTC (rev 70151) @@ -6,6 +6,8 @@ #include "config.h" +#include "../eunit_tests.h" + EAPI Eobj_Op INHERIT2_BASE_ID = 0; static Eobj_Class *_my_class = NULL; @@ -21,10 +23,25 @@ } static void +_print(Eobj *obj, void *class_data __UNUSED__, va_list *list __UNUSED__) +{ + printf("Hey\n"); + fail_if(eobj_super_do(obj, INHERIT2_PRINT())); +} + +static void +_print2(Eobj *obj __UNUSED__, void *class_data __UNUSED__, va_list *list __UNUSED__) +{ + printf("Hey2\n"); +} + +static void _class_constructor(Eobj_Class *klass) { const Eobj_Op_Func_Description func_desc[] = { EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set), + EOBJ_OP_FUNC_DESCRIPTION(INHERIT2_ID(INHERIT2_SUB_ID_PRINT), _print), + EOBJ_OP_FUNC_DESCRIPTION(INHERIT2_ID(INHERIT2_SUB_ID_PRINT2), _print2), EOBJ_OP_FUNC_DESCRIPTION_SENTINEL }; @@ -36,10 +53,16 @@ { if (_my_class) return _my_class; + 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 Eobj_Class_Description class_desc = { "Inherit2", EOBJ_CLASS_TYPE_REGULAR, - EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), + EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT2_BASE_ID, op_desc, INHERIT2_SUB_ID_LAST), NULL, 0, NULL, Modified: trunk/PROTO/eobj/examples/function_overrides/inherit2.h =================================================================== --- trunk/PROTO/eobj/examples/function_overrides/inherit2.h 2012-04-12 15:27:18 UTC (rev 70150) +++ trunk/PROTO/eobj/examples/function_overrides/inherit2.h 2012-04-12 15:27:22 UTC (rev 70151) @@ -3,6 +3,19 @@ #include "Eobj.h" +extern EAPI Eobj_Op INHERIT2_BASE_ID; + +enum { + INHERIT2_SUB_ID_PRINT, + INHERIT2_SUB_ID_PRINT2, + INHERIT2_SUB_ID_LAST +}; + +#define INHERIT2_ID(sub_id) (INHERIT2_BASE_ID + sub_id) + +#define INHERIT2_PRINT() INHERIT2_ID(INHERIT2_SUB_ID_PRINT) +#define INHERIT2_PRINT2() INHERIT2_ID(INHERIT2_SUB_ID_PRINT2) + #define INHERIT2_CLASS inherit2_class_get() const Eobj_Class *inherit2_class_get(void) EINA_CONST; Modified: trunk/PROTO/eobj/examples/function_overrides/inherit3.c =================================================================== --- trunk/PROTO/eobj/examples/function_overrides/inherit3.c 2012-04-12 15:27:18 UTC (rev 70150) +++ trunk/PROTO/eobj/examples/function_overrides/inherit3.c 2012-04-12 15:27:22 UTC (rev 70151) @@ -6,8 +6,6 @@ #include "config.h" -EAPI Eobj_Op INHERIT3_BASE_ID = 0; - static Eobj_Class *_my_class = NULL; static void Modified: trunk/PROTO/eobj/examples/function_overrides/main.c =================================================================== --- trunk/PROTO/eobj/examples/function_overrides/main.c 2012-04-12 15:27:18 UTC (rev 70150) +++ trunk/PROTO/eobj/examples/function_overrides/main.c 2012-04-12 15:27:22 UTC (rev 70151) @@ -29,6 +29,14 @@ eobj_unref(obj); + obj = eobj_add(INHERIT2_CLASS, NULL); + eobj_do(obj, INHERIT2_PRINT()); + eobj_unref(obj); + + obj = eobj_add(SIMPLE_CLASS, NULL); + fail_if(eobj_do(obj, INHERIT2_PRINT2())); + eobj_unref(obj); + eobj_shutdown(); return 0; } |