2012-09-07 14:56:44 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-08 06:21:23 -07:00
|
|
|
#define EO_BASE_BETA
|
2015-05-06 09:05:38 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
#include "Eo.h"
|
2012-09-25 23:56:52 -07:00
|
|
|
#include "composite_objects_simple.h"
|
|
|
|
#include "composite_objects_comp.h"
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2012-04-12 04:20:26 -07:00
|
|
|
#include "../eunit_tests.h"
|
|
|
|
|
2012-04-12 03:48:08 -07:00
|
|
|
static int cb_called = EINA_FALSE;
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-05-01 00:40:14 -07:00
|
|
|
_a_changed_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
|
2012-04-12 03:48:08 -07:00
|
|
|
{
|
|
|
|
(void) desc;
|
|
|
|
(void) obj;
|
|
|
|
int new_a = *((int *) event_info);
|
|
|
|
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
|
|
|
|
|
|
|
|
cb_called = EINA_TRUE;
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
return EO_CALLBACK_CONTINUE;
|
2012-04-12 03:48:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
Eo: Remove GCCism and make it more portable.
This affects eo_do() and eo_add() that used to use the ({}) GCCism.
Following a discussion with Peter de Ridder after my talk at FOSDEM,
we've decided to reopen the GCCism (works with other gcc compatible
compilers like clang and intelc) discussion, and after a bit of back and
forth it was decided to make things more portable, at the cost of ease
of use.
For example:
if (eo_do(obj, visible_get()))
is no longer allowed, the portable alternative
Eina_Bool tmp;
if (eo_do_ret(obj, tmp, visible_get()))
is to be used instead.
However:
eo_do(obj, a = a_get(), b = b_get(), bool_set(!bool_get))
are still allowed and OK.
eo_do(obj, if (a_get()) return;);
is no longer allowed, but:
eo_do(obj, if (a_get()) something());
is still allowed.
For clarity, this commit only incorporates the Eo changes, and not the
EFL changes to make the efl conform with this change.
Thanks again to Peter de Ridder for triggering this important discussion
which led to this change.
2015-02-23 08:06:40 -08:00
|
|
|
Eina_Bool tmp;
|
2012-04-12 03:48:08 -07:00
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_init();
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2014-04-02 01:46:34 -07:00
|
|
|
Eo *obj = eo_add(COMP_CLASS, NULL);
|
|
|
|
eo_do(obj, eo_event_callback_add(EV_A_CHANGED, _a_changed_cb, NULL));
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2014-02-18 06:33:24 -08:00
|
|
|
fail_if(!eo_isa(obj, COMP_CLASS));
|
|
|
|
fail_if(!eo_isa(obj, SIMPLE_CLASS));
|
|
|
|
|
2013-12-30 13:16:55 -08:00
|
|
|
int a = 0;
|
2014-10-28 09:19:30 -07:00
|
|
|
cb_called = EINA_FALSE;
|
2014-04-02 01:46:34 -07:00
|
|
|
eo_do(obj, simple_a_set(1));
|
2012-04-12 04:20:26 -07:00
|
|
|
fail_if(!cb_called);
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2014-10-28 09:19:30 -07:00
|
|
|
/* Test functions from all across the chain. */
|
|
|
|
cb_called = EINA_FALSE;
|
|
|
|
eo_do(obj, simple_a_set1(1));
|
|
|
|
fail_if(!cb_called);
|
|
|
|
cb_called = EINA_FALSE;
|
|
|
|
eo_do(obj, simple_a_set15(1));
|
|
|
|
fail_if(!cb_called);
|
|
|
|
cb_called = EINA_FALSE;
|
|
|
|
eo_do(obj, simple_a_set32(1));
|
|
|
|
fail_if(!cb_called);
|
|
|
|
|
2014-04-02 01:46:34 -07:00
|
|
|
eo_do(obj, a = simple_a_get());
|
2012-04-12 04:20:26 -07:00
|
|
|
fail_if(a != 1);
|
|
|
|
|
2012-04-12 07:37:57 -07:00
|
|
|
/* disable the callback forwarder, and fail if it's still called. */
|
2013-12-30 13:16:55 -08:00
|
|
|
Eo *simple = NULL;
|
2014-04-02 03:42:00 -07:00
|
|
|
eo_do(obj, simple = eo_key_data_get("simple-obj"));
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_ref(simple);
|
2014-04-02 01:46:34 -07:00
|
|
|
eo_do(simple, eo_event_callback_forwarder_del(EV_A_CHANGED, obj));
|
2012-04-12 07:37:57 -07:00
|
|
|
|
|
|
|
cb_called = EINA_FALSE;
|
2014-04-02 01:46:34 -07:00
|
|
|
eo_do(obj, simple_a_set(2));
|
2012-04-12 07:37:57 -07:00
|
|
|
fail_if(cb_called);
|
|
|
|
|
Eo: Remove GCCism and make it more portable.
This affects eo_do() and eo_add() that used to use the ({}) GCCism.
Following a discussion with Peter de Ridder after my talk at FOSDEM,
we've decided to reopen the GCCism (works with other gcc compatible
compilers like clang and intelc) discussion, and after a bit of back and
forth it was decided to make things more portable, at the cost of ease
of use.
For example:
if (eo_do(obj, visible_get()))
is no longer allowed, the portable alternative
Eina_Bool tmp;
if (eo_do_ret(obj, tmp, visible_get()))
is to be used instead.
However:
eo_do(obj, a = a_get(), b = b_get(), bool_set(!bool_get))
are still allowed and OK.
eo_do(obj, if (a_get()) return;);
is no longer allowed, but:
eo_do(obj, if (a_get()) something());
is still allowed.
For clarity, this commit only incorporates the Eo changes, and not the
EFL changes to make the efl conform with this change.
Thanks again to Peter de Ridder for triggering this important discussion
which led to this change.
2015-02-23 08:06:40 -08:00
|
|
|
fail_if(!eo_do_ret(simple, tmp,eo_composite_part_is()));
|
|
|
|
fail_if(!eo_do_ret(obj, tmp,eo_composite_detach(simple)));
|
|
|
|
fail_if(eo_do_ret(obj, tmp,eo_composite_detach(simple)));
|
|
|
|
fail_if(eo_do_ret(simple, tmp,eo_composite_part_is()));
|
|
|
|
fail_if(!eo_do_ret(obj, tmp,eo_composite_attach(simple)));
|
|
|
|
fail_if(!eo_do_ret(simple, tmp,eo_composite_part_is()));
|
|
|
|
fail_if(eo_do_ret(obj, tmp,eo_composite_attach(simple)));
|
2014-10-21 04:37:00 -07:00
|
|
|
|
Eo: Remove GCCism and make it more portable.
This affects eo_do() and eo_add() that used to use the ({}) GCCism.
Following a discussion with Peter de Ridder after my talk at FOSDEM,
we've decided to reopen the GCCism (works with other gcc compatible
compilers like clang and intelc) discussion, and after a bit of back and
forth it was decided to make things more portable, at the cost of ease
of use.
For example:
if (eo_do(obj, visible_get()))
is no longer allowed, the portable alternative
Eina_Bool tmp;
if (eo_do_ret(obj, tmp, visible_get()))
is to be used instead.
However:
eo_do(obj, a = a_get(), b = b_get(), bool_set(!bool_get))
are still allowed and OK.
eo_do(obj, if (a_get()) return;);
is no longer allowed, but:
eo_do(obj, if (a_get()) something());
is still allowed.
For clarity, this commit only incorporates the Eo changes, and not the
EFL changes to make the efl conform with this change.
Thanks again to Peter de Ridder for triggering this important discussion
which led to this change.
2015-02-23 08:06:40 -08:00
|
|
|
fail_if(eo_do_ret(simple, tmp,eo_composite_attach(obj)));
|
2012-04-12 07:37:57 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_unref(simple);
|
|
|
|
eo_unref(obj);
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_shutdown();
|
2012-04-12 03:48:08 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|