summaryrefslogtreecommitdiff
path: root/src/bin
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/bin
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/bin')
-rw-r--r--src/bin/eolian/types_generator.c19
1 files changed, 11 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: