jackdanielz pushed a commit to branch efl-1.14.

http://git.enlightenment.org/core/efl.git/commit/?id=6c5d0b6f6be1937b2d00d30e19cac05fb0e7740f

commit 6c5d0b6f6be1937b2d00d30e19cac05fb0e7740f
Author: Daniel Zaoui <daniel.za...@samsung.com>
Date:   Wed May 6 20:41:59 2015 +0300

    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
---
 src/bin/eolian/types_generator.c    | 19 +++++++++++--------
 src/tests/eolian/data/typedef.eo    | 17 +++++++++++++++++
 src/tests/eolian/data/typedef_ref.c | 16 ++++++++++++++++
 3 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index 6f11be5..15bf535 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -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:
diff --git a/src/tests/eolian/data/typedef.eo b/src/tests/eolian/data/typedef.eo
index 4044740..906ebe4 100644
--- a/src/tests/eolian/data/typedef.eo
+++ b/src/tests/eolian/data/typedef.eo
@@ -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 {
diff --git a/src/tests/eolian/data/typedef_ref.c 
b/src/tests/eolian/data/typedef_ref.c
index a47b9c1..791d221 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;
 
 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()

-- 


Reply via email to