eolian: builtin support for event callback signature

This commit is contained in:
Daniel Kolesa 2016-03-14 17:16:41 +00:00
parent fbd9defdd4
commit 22875f066c
5 changed files with 29 additions and 7 deletions

View File

@ -195,21 +195,35 @@ _etype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name)
}
static void
_atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
_append_name(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
{
Eina_Strbuf *fulln = eina_strbuf_new();
Eina_List *l;
const char *sp;
eina_strbuf_append(buf, "typedef ");
EINA_LIST_FOREACH(tp->namespaces, l, sp)
{
eina_strbuf_append(fulln, sp);
eina_strbuf_append_char(fulln, '_');
eina_strbuf_append(buf, sp);
eina_strbuf_append_char(buf, '_');
}
eina_strbuf_append(fulln, tp->name);
eina_strbuf_append(buf, tp->name);
}
static void
_atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
{
eina_strbuf_append(buf, "typedef ");
if (tp->base_type->type == EOLIAN_TYPE_REGULAR &&
!strcmp(tp->base_type->name, "__builtin_event_cb"))
{
eina_strbuf_append(buf, "Eina_Bool (*");
_append_name(tp, buf);
eina_strbuf_append(buf, ")(void *data, const Eo_Event *event)");
return;
}
Eina_Strbuf *fulln = eina_strbuf_new();
_append_name(tp, fulln);
database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln));
eina_strbuf_free(fulln);
}

View File

@ -8,6 +8,8 @@ type @extern Evas.Pants: float; /* not generated */
type Undef: __undefined_type; /* not generated */
type Event: __builtin_event_cb; /* specially generated */
enum Enum.Bar
{
legacy: bar;

View File

@ -19,6 +19,8 @@ typedef Evas_Coord Evas_Coord2;
typedef Evas_Coord2 Evas_Coord3;
typedef Eina_Bool (*Event)(void *data, const Eo_Event *event);
typedef enum
{
BAR_FIRST_ITEM = 0,

View File

@ -11,5 +11,7 @@ typedef Evas_Coord Evas_Coord2;
typedef Evas_Coord2 Evas_Coord3;
typedef Eina_Bool (*Event)(void *data, const Eo_Event *event);
#endif

View File

@ -418,6 +418,8 @@ START_TEST(eolian_typedef)
fail_if(!eina_iterator_next(iter, (void**)&tdl));
/* not generated undefined type, skip */
fail_if(!eina_iterator_next(iter, (void**)&tdl));
/* event type, tested by generation tests */
fail_if(!eina_iterator_next(iter, (void**)&tdl));
fail_if(eina_iterator_next(iter, (void**)&tdl));
eolian_shutdown();