From 49aebd063e9a9bebac9ff5d7a9e3ecf7a70712cd Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 3 Dec 2014 14:59:24 +0000 Subject: [PATCH] eolian: add eolian_function_is_c_only This function allows us to mark functions that are not bindable. Also remove some obsolete code. --- src/lib/eolian/Eolian.h | 10 +++++ src/lib/eolian/database_function_api.c | 7 ++++ src/lib/eolian/eo_lexer.h | 4 +- src/lib/eolian/eo_parser.c | 77 +++++++++++++++------------------- src/lib/eolian/eolian_database.h | 1 + 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 42e41c7..9464cdf 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -874,6 +874,16 @@ EAPI Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id); /* + * @brief Get whether a function is C only (i.e. not bindable). + * + * @param[in] function_id Id of the function + * @return EINA_TRUE and EINA_FALSE respectively + * + * @ingroup Eolian + */ +EAPI Eina_Bool eolian_function_is_c_only(const Eolian_Function *function_id); + +/* * @brief Indicates if a function is a constructing function of a given class. * * @param[in] klass the class diff --git a/src/lib/eolian/database_function_api.c b/src/lib/eolian/database_function_api.c index 000dda6..266ae54 100644 --- a/src/lib/eolian/database_function_api.c +++ b/src/lib/eolian/database_function_api.c @@ -249,3 +249,10 @@ eolian_function_object_is_const(const Eolian_Function *fid) EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); return fid->obj_is_const; } + +EAPI Eina_Bool +eolian_function_is_c_only(const Eolian_Function *fid) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE); + return fid->is_c_only; +} diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index 120e97a..eb1ca97 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -29,8 +29,8 @@ enum Tokens KW(get), KW(implements), KW(interface), KW(keys), KW(legacy), \ KW(legacy_prefix), KW(methods), KW(mixin), KW(own), KW(params), \ KW(properties), KW(set), KW(type), KW(values), KW(var), KWAT(auto), \ - KWAT(class), KWAT(const), KWAT(const_get), KWAT(const_set), KWAT(empty), \ - KWAT(extern), KWAT(free), KWAT(in), KWAT(inout), KWAT(nonull), \ + 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), \ \ diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 0d45bd0..9673c03 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1276,7 +1276,8 @@ parse_property(Eo_Lexer *ls) Eolian_Function *prop = NULL; Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE, has_keys = EINA_FALSE, has_values = EINA_FALSE, - has_protected = EINA_FALSE, has_class = EINA_FALSE; + has_protected = EINA_FALSE, has_class = EINA_FALSE, + has_c_only = EINA_FALSE; prop = calloc(1, sizeof(Eolian_Function)); prop->klass = ls->tmp.kls; prop->type = EOLIAN_UNRESOLVED; @@ -1299,6 +1300,11 @@ parse_property(Eo_Lexer *ls) prop->is_class = EINA_TRUE; eo_lexer_get(ls); break; + case KW_at_c_only: + CASE_LOCK(ls, c_only, "c_only qualifier"); + prop->is_c_only = EINA_TRUE; + eo_lexer_get(ls); + break; default: goto body; } @@ -1340,14 +1346,14 @@ end: } static void -parse_method(Eo_Lexer *ls, Eina_Bool ctor) +parse_method(Eo_Lexer *ls) { int line, col; Eolian_Function *meth = NULL; Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE, has_return = EINA_FALSE, has_legacy = EINA_FALSE, has_protected = EINA_FALSE, has_class = EINA_FALSE, - has_eo = EINA_FALSE; + has_eo = EINA_FALSE, has_c_only = EINA_FALSE; meth = calloc(1, sizeof(Eolian_Function)); meth->klass = ls->tmp.kls; meth->type = EOLIAN_METHOD; @@ -1355,48 +1361,33 @@ parse_method(Eo_Lexer *ls, Eina_Bool ctor) meth->base.line = ls->line_number; meth->base.column = ls->column; ls->tmp.kls->methods = eina_list_append(ls->tmp.kls->methods, meth); - if (ctor) + check(ls, TOK_VALUE); + meth->name = eina_stringshare_ref(ls->t.value.s); + eo_lexer_get(ls); + for (;;) switch (ls->t.kw) { - if (ls->t.token != TOK_VALUE) - eo_lexer_syntax_error(ls, "expected method name"); - meth->name = eina_stringshare_ref(ls->t.value.s); + case KW_at_protected: + CASE_LOCK(ls, protected, "protected qualifier") + meth->scope = EOLIAN_SCOPE_PROTECTED; eo_lexer_get(ls); - for (;;) switch (ls->t.kw) - { - case KW_at_protected: - CASE_LOCK(ls, protected, "protected qualifier") - meth->scope = EOLIAN_SCOPE_PROTECTED; - eo_lexer_get(ls); - break; - default: - goto body; - } - } - else - { - check(ls, TOK_VALUE); - meth->name = eina_stringshare_ref(ls->t.value.s); + break; + case KW_at_const: + CASE_LOCK(ls, const, "const qualifier") + meth->obj_is_const = EINA_TRUE; eo_lexer_get(ls); - for (;;) switch (ls->t.kw) - { - case KW_at_protected: - CASE_LOCK(ls, protected, "protected qualifier") - meth->scope = EOLIAN_SCOPE_PROTECTED; - eo_lexer_get(ls); - break; - case KW_at_const: - CASE_LOCK(ls, const, "const qualifier") - meth->obj_is_const = EINA_TRUE; - eo_lexer_get(ls); - break; - case KW_at_class: - CASE_LOCK(ls, class, "class qualifier"); - meth->is_class = EINA_TRUE; - eo_lexer_get(ls); - break; - default: - goto body; - } + break; + case KW_at_class: + CASE_LOCK(ls, class, "class qualifier"); + meth->is_class = EINA_TRUE; + eo_lexer_get(ls); + break; + case KW_at_c_only: + CASE_LOCK(ls, c_only, "c_only qualifier"); + meth->is_c_only = EINA_TRUE; + eo_lexer_get(ls); + break; + default: + goto body; } body: line = ls->line_number; @@ -1671,7 +1662,7 @@ parse_methods(Eo_Lexer *ls) line = ls->line_number, col = ls->column; check_next(ls, '{'); while (ls->t.token != '}') - parse_method(ls, EINA_FALSE); + parse_method(ls); check_match(ls, '}', '{', line, col); } diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index e011e11..b12e05a 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -118,6 +118,7 @@ struct _Eolian_Function Eina_Bool get_only_legacy: 1; Eina_Bool set_only_legacy: 1; Eina_Bool is_class :1; + Eina_Bool is_c_only :1; Eina_List *ctor_of; Eolian_Class *klass; }; -- 2.7.4