q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8c9fa54be4074d4d7a0237194ecfe5c343876ade

commit 8c9fa54be4074d4d7a0237194ecfe5c343876ade
Author: Daniel Kolesa <[email protected]>
Date:   Wed Oct 19 15:24:26 2016 +0200

    eolian: fix the nonsensical semantics for variables
    
    Both variables and constants can have extern on them (it means the same 
thing
    as in types, they won't get generated in C). This is different from the 
previous
    semantics which only allowed extern on globals, which makes no sense.
    
    Both globals and constants are allowed to have a value (previously only
    constants were); constants are required to have a value. Globals having
    a value is just a convenience for initialization during source generation.
    This is unlike the previous behavior, where the value was optional for both
    globals and constants and only allowed when not marked extern, which makes
    no sense either.
    
    Obivously, even when globals have a value, they're not allowed to be used
    in expressions, as they cannot be evaluated at compile time (they're 
mutable).
---
 src/lib/eolian/eo_parser.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 1fc4b97..1bc0f09 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1006,19 +1006,15 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
 {
    Eolian_Declaration *decl;
    Eolian_Variable *def = calloc(1, sizeof(Eolian_Variable));
-   Eina_Bool has_extern = EINA_FALSE;
    Eina_Strbuf *buf;
    ls->tmp.var = def;
    eo_lexer_get(ls);
    if (ls->t.kw == KW_at_extern)
      {
-        if (!global)
-          eo_lexer_syntax_error(ls, "extern constant");
-        has_extern = EINA_TRUE;
+        def->is_extern = EINA_TRUE;
         eo_lexer_get(ls);
      }
    def->type = global ? EOLIAN_VAR_GLOBAL : EOLIAN_VAR_CONSTANT;
-   def->is_extern = has_extern;
    buf = push_strbuf(ls);
    eo_lexer_context_push(ls);
    FILL_BASE(def->base, ls, ls->line_number, ls->column);
@@ -1035,7 +1031,11 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
    check_next(ls, ':');
    def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
    pop_type(ls);
-   if ((ls->t.token == '=') && !has_extern)
+   /* constants are required to have a value */
+   if (!global)
+     check(ls, '=');
+   /* globals can optionally have a value */
+   if (ls->t.token == '=')
      {
         ls->expr_mode = EINA_TRUE;
         eo_lexer_get(ls);

-- 


Reply via email to