From eab6f009e25a34492e0fd69a283d135df7a60d25 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 1 Nov 2017 12:00:14 +0100 Subject: [PATCH] eolian: add @cref as alternative to @in This is a "pass by reference to const" equivalent. There is no explicit pointer and currently it's the same as ptr(const(x)) on the type. However, it is also usable on properties. --- src/lib/eolian/eo_lexer.h | 5 +++-- src/lib/eolian/eo_parser.c | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index 9168ad9..18d6f7e 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -29,10 +29,11 @@ enum Tokens KW(get), KW(implements), KW(import), KW(interface), KW(keys), KW(legacy), \ KW(legacy_prefix), KW(methods), KW(mixin), KW(params), KW(parts), KW(ptr), \ KW(set), KW(type), KW(values), KW(var), KWAT(auto), KWAT(beta), \ - KWAT(class), KWAT(const), KWAT(empty), KWAT(extern), \ + KWAT(class), KWAT(const), KWAT(cref), KWAT(empty), KWAT(extern), \ KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), KWAT(nonull), KWAT(nullable), \ KWAT(optional), KWAT(out), KWAT(owned), KWAT(private), KWAT(property), \ - KWAT(protected), KWAT(restart), KWAT(pure_virtual), KWAT(warn_unused), \ + KWAT(protected), KWAT(restart), KWAT(pure_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), \ diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 2250dda..0ec492b 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -969,11 +969,12 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout, { Eina_Bool has_nonull = EINA_FALSE, has_optional = EINA_FALSE, has_nullable = EINA_FALSE, has_owned = EINA_FALSE; + Eina_Bool cref = (ls->t.kw == KW_at_cref); Eolian_Function_Parameter *par = calloc(1, sizeof(Eolian_Function_Parameter)); par->param_dir = EOLIAN_IN_PARAM; FILL_BASE(par->base, ls, ls->line_number, ls->column); *params = eina_list_append(*params, par); - if (allow_inout && ls->t.kw == KW_at_in) + if (cref || (allow_inout && (ls->t.kw == KW_at_in))) { par->param_dir = EOLIAN_IN_PARAM; eo_lexer_get(ls); @@ -1008,6 +1009,11 @@ parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout, pop_expr(ls); check_match(ls, ')', '(', line, col); } + if (cref) + { + par->type->is_const = EINA_TRUE; + par->type->is_ptr = EINA_TRUE; + } for (;;) switch (ls->t.kw) { case KW_at_nonull: -- 2.7.4