summaryrefslogtreecommitdiff
path: root/src/tests/eolian_cxx/callback.c
blob: a6e7ce1ebda5afbbd5b355bc8e5ce4571768e1c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>

#include <Eo.h>
#include <Ecore.h>

#include "callback.eo.h"

struct _Callback_Data
{
  int callbacks;
};
typedef struct _Callback_Data Callback_Data;

#define MY_CLASS CALLBACK_CLASS

static Eina_Bool _callback_callback_added(void* data EINA_UNUSED, Eo_Event const* event)
{
  Callback_Data* pd = event->event_info;
  ++pd->callbacks;
  eo_event_callback_call(event->obj, CALLBACK_EVENT_CALL_ON_ADD, &pd->callbacks);
  return EINA_TRUE;
}

static Eo *_callback_eo_base_constructor(Eo *obj, Callback_Data *pd EINA_UNUSED)
{
  pd->callbacks = 0;
  obj = eo_constructor(eo_super(obj, MY_CLASS));

  eo_event_callback_priority_add(obj, EO_BASE_EVENT_CALLBACK_ADD, EO_CALLBACK_PRIORITY_DEFAULT
                                 , &_callback_callback_added, pd);

  return obj;
}

static void _callback_onecallback(Eo *obj EINA_UNUSED, Callback_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data)
{
  cb(data);
}

static void _callback_twocallback(Eo *obj EINA_UNUSED, Callback_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data
                                  , Ecore_Cb  cb2 EINA_UNUSED)
{
  cb(data);
}

static void _callback_test_global_callbacks(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED
                                            , Ecore_Cb cb, void *data)
{
  cb(data);
}

#include "callback.eo.c"