forked from enlightenment/efl
Eolian/Generator: fix enums generation
Typedef word was not generated for enums. Camel case was not respected for type definition. Tests have been updated to check enums generation. @fix T2400
This commit is contained in:
parent
2c5ec0b132
commit
b0da753aaa
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <Eina.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "Eolian.h"
|
||||
#include "types_generator.h"
|
||||
|
@ -22,7 +23,11 @@ _concat_name(const Eolian_Type *tp)
|
|||
name = eolian_type_name_get(tp);
|
||||
if (name) eina_strbuf_append_printf(buf, "%s", name);
|
||||
if (eina_strbuf_length_get(buf))
|
||||
str = eina_strbuf_string_steal(buf);
|
||||
{
|
||||
char *tmp = str = eina_strbuf_string_steal(buf);
|
||||
*tmp = toupper(*tmp);
|
||||
while (*tmp) if (*tmp++ == '_' && *tmp) *tmp = toupper(*tmp);
|
||||
}
|
||||
eina_strbuf_free(buf);
|
||||
return str;
|
||||
}
|
||||
|
@ -118,14 +123,11 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef, Eina_Bool full)
|
|||
break;
|
||||
}
|
||||
char *pre = NULL;
|
||||
eina_strbuf_append_printf(buf, "enum %s {\n", name);
|
||||
eina_strbuf_append_printf(buf, "typedef enum\n{\n");
|
||||
if (eolian_type_enum_legacy_prefix_get(tp))
|
||||
{
|
||||
pre = strdup(eolian_type_enum_legacy_prefix_get(tp));
|
||||
free(name);
|
||||
}
|
||||
pre = strdup(eolian_type_enum_legacy_prefix_get(tp));
|
||||
else
|
||||
pre = name;
|
||||
pre = strdup(name);
|
||||
eina_str_toupper(&pre);
|
||||
Eina_Iterator *members = eolian_type_enum_fields_get(tp);
|
||||
Eina_Bool next = eina_iterator_next(members, (void**)&member);
|
||||
|
@ -162,10 +164,11 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef, Eina_Bool full)
|
|||
if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);
|
||||
eina_strbuf_append(buf, "\n");
|
||||
}
|
||||
eina_strbuf_append_printf(buf, "} %s", name);
|
||||
eina_strbuf_free(membuf);
|
||||
free(name);
|
||||
free(pre);
|
||||
eina_iterator_free(members);
|
||||
eina_strbuf_append(buf, "}");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
type Evas.Coord: int; /* Simple type definition */
|
||||
type List_Objects: own(list<Eo *>*); /* A little more complex */
|
||||
|
||||
enum Enum.Bar
|
||||
{
|
||||
legacy: bar;
|
||||
first_item = 0,
|
||||
second_item,
|
||||
last_item
|
||||
}
|
||||
|
||||
enum Elm.Object.Select_mode
|
||||
{
|
||||
default = 0,
|
||||
always,
|
||||
none,
|
||||
display_only,
|
||||
max
|
||||
}
|
||||
|
||||
class Typedef {
|
||||
methods {
|
||||
foo {
|
||||
|
|
|
@ -15,6 +15,22 @@ typedef int Evas_Coord;
|
|||
|
||||
typedef Eina_List *List_Objects;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BAR_FIRST_ITEM = 0,
|
||||
BAR_SECOND_ITEM,
|
||||
BAR_LAST_ITEM
|
||||
} Enum_Bar;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ELM_OBJECT_SELECT_MODE_DEFAULT = 0,
|
||||
ELM_OBJECT_SELECT_MODE_ALWAYS,
|
||||
ELM_OBJECT_SELECT_MODE_NONE,
|
||||
ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY,
|
||||
ELM_OBJECT_SELECT_MODE_MAX
|
||||
} Elm_Object_Select_Mode;
|
||||
|
||||
|
||||
#endif
|
||||
#define TYPEDEF_CLASS typedef_class_get()
|
||||
|
|
Loading…
Reference in New Issue