diff options
author | Daniel Kolesa <d.kolesa@samsung.com> | 2014-08-07 16:29:03 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2014-08-11 13:34:54 +0100 |
commit | 491223c3345a25979ebb33a208ad88c03b193f8c (patch) | |
tree | 6ed5f5acd10938500ea81e82d563a89ebe3bacbe | |
parent | c981a3b2ce57919b8b55072c424ee7d280f13ec1 (diff) | |
download | efl-491223c3345a25979ebb33a208ad88c03b193f8c.tar.gz |
eolian: eolian_type_name_get now returns the eo name, not c name
so instead of "unsigned int" you get "uint". This is important for handling of
expressions and cross-language interoperability. You can use c_type_get on the
base type to get the C name. Also, append the appropriate suffix to number literals
when calling eolian_expression_value_to_literal.
-rw-r--r-- | src/lib/eolian/database_expr.c | 4 | ||||
-rw-r--r-- | src/lib/eolian/database_expr_api.c | 31 | ||||
-rw-r--r-- | src/lib/eolian/database_type.c | 7 | ||||
-rw-r--r-- | src/lib/eolian/eo_parser.c | 2 |
4 files changed, 37 insertions, 7 deletions
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c index 7f9aac44a2..0a75eda1aa 100644 --- a/src/lib/eolian/database_expr.c +++ b/src/lib/eolian/database_expr.c @@ -28,8 +28,8 @@ mask_to_str(int mask, char *buf) APPEND_TP("integer") else if (mask & EOLIAN_MASK_SINT) APPEND_TP("signed integer") - else if (mask & EOLIAN_MASK_SINT) - APPEND_TP("signed integer") + else if (mask & EOLIAN_MASK_UINT) + APPEND_TP("unsigned integer") if (mask & EOLIAN_MASK_FLOAT) APPEND_TP("float") diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c index 9258d62691..aee655e022 100644 --- a/src/lib/eolian/database_expr_api.c +++ b/src/lib/eolian/database_expr_api.c @@ -116,6 +116,30 @@ _append_char_escaped(Eina_Strbuf *buf, char c) } } +static const char * +_get_literal_suffix(Eolian_Expression_Type etp) +{ + switch (etp) + { + case EOLIAN_EXPR_UINT: + return "U"; + case EOLIAN_EXPR_LONG: + return "L"; + case EOLIAN_EXPR_ULONG: + return "UL"; + case EOLIAN_EXPR_LLONG: + return "LL"; + case EOLIAN_EXPR_ULLONG: + return "ULL"; + case EOLIAN_EXPR_FLOAT: + return "f"; + case EOLIAN_EXPR_LDOUBLE: + return "L"; + default: + return ""; + } +} + EAPI Eina_Stringshare * eolian_expression_value_to_literal(const Eina_Value *v, Eolian_Expression_Type etp) @@ -167,9 +191,14 @@ eolian_expression_value_to_literal(const Eina_Value *v, case EOLIAN_EXPR_DOUBLE: case EOLIAN_EXPR_LDOUBLE: { + const char *ret; char *str = eina_value_to_string(v); - const char *ret = eina_stringshare_add(str); + Eina_Strbuf *buf = eina_strbuf_new(); + eina_strbuf_append(buf, str); free(str); + eina_strbuf_append(buf, _get_literal_suffix(etp)); + ret = eina_stringshare_add(eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); return ret; } default: diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index 50fb63a6d1..2c0347bc5b 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -1,6 +1,5 @@ #include <Eina.h> -#include "eolian_database.h" -#include "eo_definitions.h" +#include "eo_lexer.h" void database_type_del(Eolian_Type *tp) @@ -165,7 +164,9 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) eina_strbuf_append(buf, sp); eina_strbuf_append_char(buf, '_'); } - eina_strbuf_append(buf, tp->name); + int kw = eo_lexer_keyword_str_to_id(tp->name); + if (kw) eina_strbuf_append(buf, eo_lexer_get_c_type(kw)); + else eina_strbuf_append(buf, tp->name); } else if (tp->type == EOLIAN_TYPE_REGULAR_STRUCT) { diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 0bd515a996..63013f0357 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -697,7 +697,7 @@ parse_type_struct_void(Eo_Lexer *ls, Eina_Bool allow_struct) ctype = eo_lexer_get_c_type(ls->t.kw); if (ctype) { - _fill_type_name(def, eina_stringshare_add(ctype)); + _fill_type_name(def, eina_stringshare_add(ls->t.value.s)); eo_lexer_get(ls); } else |