From 12fa5f534972b8fe4b3548af7a1e0ff9b7f46bbf Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 18 May 2015 16:37:42 +0100 Subject: [PATCH] eolian: fix eolian_type_enum_field_c_name_get for namespaced enums --- src/lib/eolian/database_type_api.c | 3 ++- src/tests/eolian/data/enum.eo | 4 ++++ src/tests/eolian/eolian_parsing.c | 11 +++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 0799fce..29f8233 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -160,7 +160,7 @@ eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl) { Eina_Stringshare *ret; Eina_Strbuf *buf; - char *bufp; + char *bufp, *p; EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL); buf = eina_strbuf_new(); if (fl->base_enum->legacy) @@ -172,6 +172,7 @@ eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl) bufp = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); eina_str_toupper(&bufp); + while ((p = strchr(bufp, '.'))) *p = '_'; ret = eina_stringshare_add(bufp); free(bufp); return ret; diff --git a/src/tests/eolian/data/enum.eo b/src/tests/eolian/data/enum.eo index 4843356..3901943 100644 --- a/src/tests/eolian/data/enum.eo +++ b/src/tests/eolian/data/enum.eo @@ -16,6 +16,10 @@ enum Baz { flag3 = 1 << 2 } +enum Name.Spaced { + pants +} + const Bah: Baz = Baz.flag1; enum Value { diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index f7c827b..41c4152 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -895,16 +895,19 @@ START_TEST(eolian_enum) fail_if(v.type != EOLIAN_EXPR_INT); fail_if(v.value.i != (1 << 1)); - cname = eolian_type_enum_field_c_name_get(field); - fail_if(strcmp(cname, "BAZ_FLAG2")); - eina_stringshare_del(cname); - fail_if(!(field = eolian_type_enum_field_get(type, "flag3"))); fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE))); v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); fail_if(v.type != EOLIAN_EXPR_INT); fail_if(v.value.i != (1 << 2)); + fail_if(!(type = eolian_type_enum_get_by_name("Name.Spaced"))); + fail_if(!(field = eolian_type_enum_field_get(type, "pants"))); + + cname = eolian_type_enum_field_c_name_get(field); + fail_if(strcmp(cname, "NAME_SPACED_PANTS")); + eina_stringshare_del(cname); + fail_if(!(var = eolian_variable_constant_get_by_name("Bah"))); fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); fail_if(eolian_variable_is_extern(var)); -- 2.7.4