summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_event_message.c
blob: 768e3779b7bc05240858543205e412c10bdf0638 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Ecore.h>

#include "ecore_private.h"

#define MY_CLASS ECORE_EVENT_MESSAGE_CLASS

//////////////////////////////////////////////////////////////////////////

typedef struct _Ecore_Event_Message_Data Ecore_Event_Message_Data;

struct _Ecore_Event_Message_Data
{
   int type;
   void *ev;
   Ecore_End_Cb free_func;
   void *data;
};

//////////////////////////////////////////////////////////////////////////

EOLIAN static void
_ecore_event_message_data_set(Eo *obj EINA_UNUSED, Ecore_Event_Message_Data *pd, int type, void *data, void *free_func, void *free_data)
{
   pd->type = type;
   pd->ev = data;
   pd->free_func = free_func;
   pd->data = free_data;
}

EOLIAN static void
_ecore_event_message_data_get(const Eo *obj EINA_UNUSED, Ecore_Event_Message_Data *pd, int *type, void **data, void **free_func, void **free_data)
{
   if (type) *type = pd->type;
   if (data) *data = pd->ev;
   if (free_func) *free_func = pd->free_func;
   if (free_data) *free_data = pd->data;
}

EOLIAN static void
_ecore_event_message_data_steal(Eo *obj EINA_UNUSED, Ecore_Event_Message_Data *pd, int *type, void **data, void **free_func, void **free_data)
{
   if (type) *type = pd->type;
   if (data) *data = pd->ev;
   if (free_func) *free_func = pd->free_func;
   if (free_data) *free_data = pd->data;
   pd->type = -1;
   pd->ev = NULL;
   pd->free_func = NULL;
   pd->data = NULL;
}

EOLIAN static Efl_Object *
_ecore_event_message_efl_object_constructor(Eo *obj, Ecore_Event_Message_Data *pd EINA_UNUSED)
{
   obj = efl_constructor(efl_super(obj, MY_CLASS));
   pd->type = -1;
   return obj;
}

EOLIAN static void
_ecore_event_message_efl_object_destructor(Eo *obj EINA_UNUSED, Ecore_Event_Message_Data *pd EINA_UNUSED)
{
   if (pd->ev)
     {
        Ecore_End_Cb fn_free = pd->free_func;
        void *ev = pd->ev;

        pd->ev = NULL;
        if (fn_free) fn_free(pd->data, ev);
        else free(ev);
     }
   efl_destructor(efl_super(obj, MY_CLASS));
}

//////////////////////////////////////////////////////////////////////////

#include "ecore_event_message.eo.c"