aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/eolian/database_event_api.c
blob: 2c0647d5c98fd040449c659cb159ac04e8fe6e35 (plain) (blame)
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
82
83
84
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <Eina.h>
#include "eolian_database.h"

EAPI const Eolian_Type *
eolian_event_type_get(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL);
   if (event->type && (event->type->type == EOLIAN_TYPE_VOID))
     return NULL;
   return event->type;
}

EAPI const Eolian_Class *
eolian_event_class_get(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL);
   return event->klass;
}

EAPI const Eolian_Documentation *
eolian_event_documentation_get(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL);
   return event->doc;
}

EAPI Eolian_Object_Scope
eolian_event_scope_get(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, EOLIAN_SCOPE_UNKNOWN);
   return event->scope;
}

EAPI Eina_Bool
eolian_event_is_hot(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, EINA_FALSE);
   return event->is_hot;
}

EAPI Eina_Bool
eolian_event_is_restart(const Eolian_Event *event)
{
   EINA_SAFETY_ON_NULL_RETURN_VAL(event, EINA_FALSE);
   return event->is_restart;
}

EAPI Eina_Stringshare *
eolian_event_c_macro_get(const Eolian_Event *event)
{
    char  buf[512];
    char *tmp = buf;
    const char *pfx = event->klass->ev_prefix;
    if (!pfx) pfx = event->klass->c_prefix;
    if (!pfx) pfx = event->klass->base.name;
    snprintf(buf, sizeof(buf), "%s_EVENT_%s", pfx, event->base.name);
    eina_str_toupper(&tmp);
    while ((tmp = strpbrk(tmp, ".,"))) *tmp = '_';
    return eina_stringshare_add(buf);
}

EAPI const Eolian_Event *
eolian_class_event_by_name_get(const Eolian_Class *klass, const char *event_name)
{
   Eina_List *itr;
   Eolian_Event *event = NULL;
   if (!klass) return NULL;
   Eina_Stringshare *shr_ev = eina_stringshare_add(event_name);

   EINA_LIST_FOREACH(klass->events, itr, event)
        {
           if (event->base.name == shr_ev)
              goto end;
        }

   event = NULL;
end:
   eina_stringshare_del(shr_ev);
   return event;
}