forked from enlightenment/efl
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.
This commit is contained in:
parent
eab668bb0f
commit
788386c86c
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue