summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-06-19 11:22:35 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-06-19 16:04:08 +0100
commit07dcaadb97622849d608042ea26b3f76e7a422b6 (patch)
treeae267b23d46b8abc62d64b56cdfa4e42c74c8e1f
parentb39b37d732bcb153cc1fd4b33e24e3adc510dff4 (diff)
downloadefl-07dcaadb97622849d608042ea26b3f76e7a422b6.tar.gz
eolian: simpler type parsing
-rw-r--r--src/lib/eolian/eo_parser.c62
1 files changed, 18 insertions, 44 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 19ebc4ad58..48076a779b 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -135,6 +135,15 @@ parse_type(Eo_Lexer *ls, Eina_Inlist *types, Eina_Strbuf *sbuf)
Eina_Bool is_own = EINA_FALSE;
Eina_Strbuf *buf = sbuf ? sbuf : push_strbuf(ls);
+#define CHECK_KW(kwname, cond) \
+ if ((cond) && (ls->t.kw == KW_##kwname)) \
+ { \
+ if (need_space) eina_strbuf_append_char(buf, ' '); \
+ eina_strbuf_append(buf, #kwname); \
+ eo_lexer_get(ls); \
+ need_space = EINA_TRUE; \
+ }
+
if (ls->t.kw == KW_at_own)
{
if (sbuf) eina_strbuf_append(buf, "@own ");
@@ -142,42 +151,13 @@ parse_type(Eo_Lexer *ls, Eina_Inlist *types, Eina_Strbuf *sbuf)
eo_lexer_get(ls);
}
- if (ls->t.kw == KW_const)
- {
- eina_strbuf_append(buf, "const");
- eo_lexer_get(ls);
- need_space = EINA_TRUE;
- }
+ CHECK_KW(const, EINA_TRUE)
- if (ls->t.kw == KW_unsigned)
- {
- if (need_space) eina_strbuf_append_char(buf, ' ');
- eina_strbuf_append(buf, "unsigned");
- eo_lexer_get(ls);
- need_space = EINA_TRUE;
- }
- else if (ls->t.kw == KW_signed)
- {
- if (need_space) eina_strbuf_append_char(buf, ' ');
- eina_strbuf_append(buf, "signed");
- eo_lexer_get(ls);
- need_space = EINA_TRUE;
- }
- else if (ls->t.kw == KW_struct)
- {
- if (need_space) eina_strbuf_append_char(buf, ' ');
- eina_strbuf_append(buf, "struct");
- eo_lexer_get(ls);
- need_space = EINA_TRUE;
- }
+ CHECK_KW(unsigned, EINA_TRUE)
+ else CHECK_KW(signed, EINA_TRUE)
+ else CHECK_KW(struct, EINA_TRUE)
- if (!has_struct && ls->t.kw == KW_const)
- {
- if (need_space) eina_strbuf_append_char(buf, ' ');
- eina_strbuf_append(buf, "const");
- eo_lexer_get(ls);
- need_space = EINA_TRUE;
- }
+ CHECK_KW(const, !has_struct)
check(ls, TOK_VALUE);
if (need_space) eina_strbuf_append_char(buf, ' ');
@@ -185,11 +165,7 @@ parse_type(Eo_Lexer *ls, Eina_Inlist *types, Eina_Strbuf *sbuf)
eo_lexer_get(ls);
need_space = EINA_TRUE;
- if (ls->t.kw == KW_const)
- {
- eina_strbuf_append(buf, " const");
- eo_lexer_get(ls);
- }
+ CHECK_KW(const, EINA_TRUE)
if (ls->t.token == '*')
{
@@ -198,14 +174,12 @@ parse_type(Eo_Lexer *ls, Eina_Inlist *types, Eina_Strbuf *sbuf)
{
eina_strbuf_append_char(buf, '*');
eo_lexer_get(ls);
- if (ls->t.kw == KW_const)
- {
- eina_strbuf_append(buf, " const");
- eo_lexer_get(ls);
- }
+ CHECK_KW(const, EINA_TRUE)
}
}
+#undef CHECK_KW
+
if (!sbuf)
{
types = database_type_append(types, eina_strbuf_string_get(buf), is_own);