summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2015-05-06 20:41:59 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-05-07 09:57:23 +0300
commitb0da753aaaee885b4bee15e2729076fb2ee152f1 (patch)
treec27619d7a659fcbdb308fcdf6fea64b6e3a6617c /src
parent2c5ec0b132222131306514d578b6f604c00b61b1 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/eolian/types_generator.c19
-rw-r--r--src/tests/eolian/data/typedef.eo17
-rw-r--r--src/tests/eolian/data/typedef_ref.c16
3 files changed, 44 insertions, 8 deletions
diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index 6f11be5edc..15bf535061 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -4,6 +4,7 @@
4 4
5#include <Eina.h> 5#include <Eina.h>
6#include <string.h> 6#include <string.h>
7#include <ctype.h>
7 8
8#include "Eolian.h" 9#include "Eolian.h"
9#include "types_generator.h" 10#include "types_generator.h"
@@ -22,7 +23,11 @@ _concat_name(const Eolian_Type *tp)
22 name = eolian_type_name_get(tp); 23 name = eolian_type_name_get(tp);
23 if (name) eina_strbuf_append_printf(buf, "%s", name); 24 if (name) eina_strbuf_append_printf(buf, "%s", name);
24 if (eina_strbuf_length_get(buf)) 25 if (eina_strbuf_length_get(buf))
25 str = eina_strbuf_string_steal(buf); 26 {
27 char *tmp = str = eina_strbuf_string_steal(buf);
28 *tmp = toupper(*tmp);
29 while (*tmp) if (*tmp++ == '_' && *tmp) *tmp = toupper(*tmp);
30 }
26 eina_strbuf_free(buf); 31 eina_strbuf_free(buf);
27 return str; 32 return str;
28} 33}
@@ -118,14 +123,11 @@ _type_generate(const Eolian_Type *tp, Eina_Bool in_typedef, Eina_Bool full)
118 break; 123 break;
119 } 124 }
120 char *pre = NULL; 125 char *pre = NULL;
121 eina_strbuf_append_printf(buf, "enum %s {\n", name); 126 eina_strbuf_append_printf(buf, "typedef enum\n{\n");
122 if (eolian_type_enum_legacy_prefix_get(tp)) 127 if (eolian_type_enum_legacy_prefix_get(tp))
123 { 128 pre = strdup(eolian_type_enum_legacy_prefix_get(tp));
124 pre = strdup(eolian_type_enum_legacy_prefix_get(tp));
125 free(name);
126 }
127 else 129 else
128 pre = name; 130 pre = strdup(name);
129 eina_str_toupper(&pre); 131 eina_str_toupper(&pre);
130 Eina_Iterator *members = eolian_type_enum_fields_get(tp); 132 Eina_Iterator *members = eolian_type_enum_fields_get(tp);
131 Eina_Bool next = eina_iterator_next(members, (void**)&member); 133 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)
162 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc); 164 if (desc) eina_strbuf_append_printf(buf, " /** %s */", desc);
163 eina_strbuf_append(buf, "\n"); 165 eina_strbuf_append(buf, "\n");
164 } 166 }
167 eina_strbuf_append_printf(buf, "} %s", name);
165 eina_strbuf_free(membuf); 168 eina_strbuf_free(membuf);
169 free(name);
166 free(pre); 170 free(pre);
167 eina_iterator_free(members); 171 eina_iterator_free(members);
168 eina_strbuf_append(buf, "}");
169 break; 172 break;
170 } 173 }
171 default: 174 default:
diff --git a/src/tests/eolian/data/typedef.eo b/src/tests/eolian/data/typedef.eo
index 4044740c34..906ebe4daa 100644
--- a/src/tests/eolian/data/typedef.eo
+++ b/src/tests/eolian/data/typedef.eo
@@ -1,6 +1,23 @@
1type Evas.Coord: int; /* Simple type definition */ 1type Evas.Coord: int; /* Simple type definition */
2type List_Objects: own(list<Eo *>*); /* A little more complex */ 2type List_Objects: own(list<Eo *>*); /* A little more complex */
3 3
4enum Enum.Bar
5{
6 legacy: bar;
7 first_item = 0,
8 second_item,
9 last_item
10}
11
12enum Elm.Object.Select_mode
13{
14 default = 0,
15 always,
16 none,
17 display_only,
18 max
19}
20
4class Typedef { 21class Typedef {
5 methods { 22 methods {
6 foo { 23 foo {
diff --git a/src/tests/eolian/data/typedef_ref.c b/src/tests/eolian/data/typedef_ref.c
index a47b9c1143..791d221cba 100644
--- a/src/tests/eolian/data/typedef_ref.c
+++ b/src/tests/eolian/data/typedef_ref.c
@@ -15,6 +15,22 @@ typedef int Evas_Coord;
15 15
16typedef Eina_List *List_Objects; 16typedef Eina_List *List_Objects;
17 17
18typedef enum
19{
20 BAR_FIRST_ITEM = 0,
21 BAR_SECOND_ITEM,
22 BAR_LAST_ITEM
23} Enum_Bar;
24
25typedef enum
26{
27 ELM_OBJECT_SELECT_MODE_DEFAULT = 0,
28 ELM_OBJECT_SELECT_MODE_ALWAYS,
29 ELM_OBJECT_SELECT_MODE_NONE,
30 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY,
31 ELM_OBJECT_SELECT_MODE_MAX
32} Elm_Object_Select_Mode;
33
18 34
19#endif 35#endif
20#define TYPEDEF_CLASS typedef_class_get() 36#define TYPEDEF_CLASS typedef_class_get()