eolian: parsing of @nullable and @optional args on func params
authorDaniel Kolesa <d.kolesa@samsung.com>
Thu, 12 Feb 2015 11:14:45 +0000 (11:14 +0000)
committerDaniel Kolesa <d.kolesa@samsung.com>
Thu, 12 Feb 2015 11:14:45 +0000 (11:14 +0000)
src/lib/eolian/eo_lexer.h
src/lib/eolian/eo_parser.c

index eb1ca9777673a01b3a054240ca06294bdccc7f49..5203045be64878cb47b94cfb400a3b1ac810c1d4 100644 (file)
@@ -31,8 +31,8 @@ enum Tokens
     KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \
     KWAT(c_only), KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), \
     KWAT(empty), KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \
-    KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), KWAT(virtual), \
-    KWAT(warn_unused), \
+    KWAT(nullable), KWAT(optional), KWAT(out), KWAT(private), KWAT(protected), \
+    KWAT(virtual), KWAT(warn_unused), \
     \
     KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
     KW(long), KW(ulong), KW(llong), KW(ullong), \
index f01fe836051a42f2d097725164c6628a8294b8ea..07e37541d558b7c82671d6508f21bbf791a39e7b 100644 (file)
@@ -1073,6 +1073,8 @@ static void
 parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
             Eina_Bool is_vals)
 {
+   Eina_Bool has_nonull   = EINA_FALSE, has_optional = EINA_FALSE,
+             has_nullable = EINA_FALSE;
    Eolian_Function_Parameter *par = calloc(1, sizeof(Eolian_Function_Parameter));
    par->base.file = eina_stringshare_ref(ls->filename);
    par->base.line = ls->line_number;
@@ -1130,6 +1132,29 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
              eo_lexer_get(ls);
           }
      }
+   for (;;) switch (ls->t.kw)
+     {
+      case KW_at_nonull:
+        if (has_nullable)
+          eo_lexer_syntax_error(ls, "both nullable and nonull specified");
+        CASE_LOCK(ls, nonull, "nonull qualifier")
+        par->nonull = EINA_TRUE;
+        eo_lexer_get(ls);
+        break;
+      case KW_at_optional:
+        CASE_LOCK(ls, optional, "optional qualifier");
+        eo_lexer_get(ls);
+        break;
+      case KW_at_nullable:
+        if (has_nullable)
+          eo_lexer_syntax_error(ls, "both nullable and nonull specified");
+        CASE_LOCK(ls, nullable, "c_only qualifier");
+        eo_lexer_get(ls);
+        break;
+      default:
+        goto end;
+     }
+end:
    if (ls->t.kw == KW_at_nonull)
      {
         par->nonull = EINA_TRUE;