From 92da64a532f8c1746d7bd06b66b7ff4409c2ff8c Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Tue, 24 Sep 2019 17:06:24 +0200 Subject: [PATCH] eolian: remove support for globals This was meant to happen but did not previously happen. It is not ideal to do it now but better do it while we still can. In short, this removes one half of the variables API (keeps constants as they are) and repurposes the API to be only for constants. This is also better for consistency to match errors. --- src/bin/eolian/docs.c | 9 +- src/bin/eolian/types.c | 93 +++-------- .../eolian_mono/eolian/mono/documentation.hh | 17 +- .../eolian/mono/variable_definition.hh | 2 +- src/bin/eolian_mono/eolian_mono.cc | 4 +- src/bindings/luajit/eolian.lua | 70 ++------- src/lib/eolian/Eolian.h | 146 +++++------------- src/lib/eolian/database_check.c | 8 +- src/lib/eolian/database_expr.c | 2 +- src/lib/eolian/database_validate.c | 16 +- src/lib/eolian/database_var.c | 24 +-- src/lib/eolian/database_var_api.c | 15 +- src/lib/eolian/eo_lexer.c | 4 +- src/lib/eolian/eo_lexer.h | 14 +- src/lib/eolian/eo_parser.c | 36 ++--- src/lib/eolian/eolian_database.c | 43 +----- src/lib/eolian/eolian_database.h | 9 +- src/lib/eolian_cxx/grammar/klass_def.hpp | 45 ++---- src/scripts/pyolian/eolian.py | 43 ++---- src/scripts/pyolian/eolian_lib.py | 44 ++---- src/scripts/pyolian/generator.py | 3 +- src/scripts/pyolian/test_eolian.py | 34 +--- src/tests/eolian/eolian_parsing.c | 26 ++-- 23 files changed, 193 insertions(+), 514 deletions(-) diff --git a/src/bin/eolian/docs.c b/src/bin/eolian/docs.c index e9af2e867f..6b016eb4ee 100644 --- a/src/bin/eolian/docs.c +++ b/src/bin/eolian/docs.c @@ -27,13 +27,8 @@ _generate_ref(const Eolian_State *state, const char *refn, Eina_Strbuf *wbuf) char *n = strdup(eolian_object_name_get(decl)); char *p = n; while ((p = strchr(p, '.'))) *p = '_'; - if (eolian_object_type_get(decl) == EOLIAN_OBJECT_VARIABLE) - { - const Eolian_Variable *v = (const Eolian_Variable *)decl; - /* constants are emitted as macros */ - if (eolian_variable_type_get(v) == EOLIAN_VAR_CONSTANT) - eina_str_toupper(&n); - } + if (eolian_object_type_get(decl) == EOLIAN_OBJECT_CONSTANT) + eina_str_toupper(&n); eina_strbuf_append(wbuf, n); free(n); return; diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c index 75426f1220..96232833cd 100644 --- a/src/bin/eolian/types.c +++ b/src/bin/eolian/types.c @@ -168,12 +168,12 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp, } static Eina_Strbuf * -_var_generate(const Eolian_State *state, const Eolian_Variable *vr) +_const_generate(const Eolian_State *state, const Eolian_Constant *vr) { - char *fn = strdup(eolian_variable_name_get(vr)); + char *fn = strdup(eolian_constant_name_get(vr)); char *p = strrchr(fn, '.'); if (p) *p = '\0'; - Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_variable_documentation_get(vr), + Eina_Strbuf *buf = eo_gen_docs_full_gen(state, eolian_constant_documentation_get(vr), fn, 0); if (p) { @@ -184,31 +184,23 @@ _var_generate(const Eolian_State *state, const Eolian_Variable *vr) eina_str_toupper(&fn); if (!buf) buf = eina_strbuf_new(); else eina_strbuf_append_char(buf, '\n'); - const Eolian_Type *vt = eolian_variable_base_type_get(vr); - if (eolian_variable_type_get(vr) == EOLIAN_VAR_CONSTANT) - { - /* we generate a define macro here, as it's a constant */ - eina_strbuf_prepend_printf(buf, "#ifndef %s\n", fn); - eina_strbuf_append_printf(buf, "#define %s ", fn); - const Eolian_Expression *vv = eolian_variable_value_get(vr); - Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL); - Eina_Stringshare *lit = eolian_expression_value_to_literal(&val); - eina_strbuf_append(buf, lit); - Eina_Stringshare *exp = eolian_expression_serialize(vv); - if (exp && strcmp(lit, exp)) - eina_strbuf_append_printf(buf, " /* %s */", exp); - eina_stringshare_del(lit); - eina_stringshare_del(exp); - eina_strbuf_append(buf, "\n#endif"); - } - else - { - Eina_Stringshare *ct = eolian_type_c_type_get(vt); - eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn); - eina_stringshare_del(ct); - } + + /* we generate a define macro here, as it's a constant */ + eina_strbuf_prepend_printf(buf, "#ifndef %s\n", fn); + eina_strbuf_append_printf(buf, "#define %s ", fn); + const Eolian_Expression *vv = eolian_constant_value_get(vr); + Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL); + Eina_Stringshare *lit = eolian_expression_value_to_literal(&val); + eina_strbuf_append(buf, lit); + Eina_Stringshare *exp = eolian_expression_serialize(vv); + if (exp && strcmp(lit, exp)) + eina_strbuf_append_printf(buf, " /* %s */", exp); + eina_stringshare_del(lit); + eina_stringshare_del(exp); + eina_strbuf_append(buf, "\n#endif"); + free(fn); - if (eolian_variable_is_beta(vr)) + if (eolian_constant_is_beta(vr)) { eina_strbuf_prepend(buf, "#ifdef EFL_BETA_API_SUPPORT\n"); eina_strbuf_append(buf, "\n#endif /* EFL_BETA_API_SUPPORT */"); @@ -259,13 +251,13 @@ void eo_gen_types_header_gen(const Eolian_State *state, { Eolian_Object_Type dt = eolian_object_type_get(decl); - if (dt == EOLIAN_OBJECT_VARIABLE) + if (dt == EOLIAN_OBJECT_CONSTANT) { - const Eolian_Variable *vr = (const Eolian_Variable *)decl; - if (!vr || eolian_variable_is_extern(vr)) + const Eolian_Constant *vr = (const Eolian_Constant *)decl; + if (!vr || eolian_constant_is_extern(vr)) continue; - Eina_Strbuf *vbuf = _var_generate(state, vr); + Eina_Strbuf *vbuf = _const_generate(state, vr); if (vbuf) { eina_strbuf_append(buf, eina_strbuf_string_get(vbuf)); @@ -375,43 +367,6 @@ _source_gen_error(Eina_Strbuf *buf, const Eolian_Error *err) eina_strbuf_append(buf, " return err;\n}\n\n"); } -static void -_source_gen_var(Eina_Strbuf *buf, const Eolian_Variable *vr) -{ - if (eolian_variable_is_extern(vr)) - return; - - if (eolian_variable_type_get(vr) == EOLIAN_VAR_CONSTANT) - return; - - const Eolian_Expression *vv = eolian_variable_value_get(vr); - if (!vv) - return; - - char *fn = strdup(eolian_variable_name_get(vr)); - for (char *p = strchr(fn, '.'); p; p = strchr(p, '.')) - *p = '_'; - eina_str_toupper(&fn); - - const Eolian_Type *vt = eolian_variable_base_type_get(vr); - Eina_Stringshare *ct = eolian_type_c_type_get(vt); - eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn); - eina_stringshare_del(ct); - free(fn); - - Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL); - Eina_Stringshare *lit = eolian_expression_value_to_literal(&val); - eina_strbuf_append(buf, lit); - eina_strbuf_append_char(buf, ';'); - Eina_Stringshare *exp = eolian_expression_serialize(vv); - if (exp && strcmp(lit, exp)) - eina_strbuf_append_printf(buf, " /* %s */", exp); - eina_stringshare_del(lit); - eina_stringshare_del(exp); - - eina_strbuf_append(buf, "\n"); -} - void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf) { const Eolian_Object *decl; @@ -421,8 +376,6 @@ void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf) if (dt == EOLIAN_OBJECT_ERROR) _source_gen_error(buf, (const Eolian_Error *)decl); - else if (dt == EOLIAN_OBJECT_VARIABLE) - _source_gen_var(buf, (const Eolian_Variable *)decl); } eina_iterator_free(itr); } diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh index 234ce49430..a7821c5e5d 100644 --- a/src/bin/eolian_mono/eolian/mono/documentation.hh +++ b/src/bin/eolian_mono/eolian/mono/documentation.hh @@ -187,17 +187,12 @@ struct documentation_generator ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail); is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2); break; - case ::EOLIAN_OBJECT_VARIABLE: - if (::eolian_variable_type_get((::Eolian_Variable *)data) == ::EOLIAN_VAR_CONSTANT) - { - auto names = utils::split(name_helpers::managed_namespace(::eolian_object_name_get(data)), '.'); - names.pop_back(); // Remove var name - ref = name_helpers::join_namespaces(names, '.'); - ref += "Constants."; - ref += name_helpers::managed_name(::eolian_object_short_name_get(data)); - } - // Otherwise, do nothing and no tag will be generated. Because, who would - // reference a global (non-constant) variable in the docs? + case ::EOLIAN_OBJECT_CONSTANT: + auto names = utils::split(name_helpers::managed_namespace(::eolian_object_name_get(data)), '.'); + names.pop_back(); // Remove var name + ref = name_helpers::join_namespaces(names, '.'); + ref += "Constants."; + ref += name_helpers::managed_name(::eolian_object_short_name_get(data)); break; case ::EOLIAN_OBJECT_UNKNOWN: // If the reference cannot be resolved, just return an empty string and diff --git a/src/bin/eolian_mono/eolian/mono/variable_definition.hh b/src/bin/eolian_mono/eolian/mono/variable_definition.hh index fdc5219794..c34a18cc7f 100644 --- a/src/bin/eolian_mono/eolian/mono/variable_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/variable_definition.hh @@ -28,7 +28,7 @@ namespace eolian_mono { struct constant_definition_generator { template - bool generate(OutputIterator sink, attributes::variable_def constant, Context const& context) const + bool generate(OutputIterator sink, attributes::constant_def constant, Context const& context) const { // Open partial class if (!name_helpers::open_namespaces(sink, constant.namespaces, context)) diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc index 42f8034a03..83379b28cb 100644 --- a/src/bin/eolian_mono/eolian_mono.cc +++ b/src/bin/eolian_mono/eolian_mono.cc @@ -177,10 +177,10 @@ run(options_type const& opts) // Constants { auto var_cxt = context_add_tag(class_context{class_context::variables}, context); - for (efl::eina::iterator var_iterator( ::eolian_state_constants_by_file_get(opts.state, basename_input.c_str())) + for (efl::eina::iterator var_iterator( ::eolian_state_constants_by_file_get(opts.state, basename_input.c_str())) , var_last; var_iterator != var_last; ++var_iterator) { - efl::eolian::grammar::attributes::variable_def var(&*var_iterator, opts.unit); + efl::eolian::grammar::attributes::constant_def var(&*var_iterator, opts.unit); if (!eolian_mono::constant_definition.generate(iterator, var, var_cxt)) { throw std::runtime_error("Failed to generate enum"); diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index 7fec606c10..bd3b20601b 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -25,7 +25,7 @@ ffi.cdef [[ typedef struct _Eolian_Constructor Eolian_Constructor; typedef struct _Eolian_Event Eolian_Event; typedef struct _Eolian_Expression Eolian_Expression; - typedef struct _Eolian_Variable Eolian_Variable; + typedef struct _Eolian_Constant Eolian_Constant; typedef struct _Eolian_Error Eolian_Error; typedef struct _Eolian_Struct_Type_Field Eolian_Struct_Type_Field; typedef struct _Eolian_Enum_Type_Field Eolian_Enum_Type_Field; @@ -43,7 +43,7 @@ ffi.cdef [[ EOLIAN_OBJECT_STRUCT_FIELD, EOLIAN_OBJECT_ENUM_FIELD, EOLIAN_OBJECT_TYPE, - EOLIAN_OBJECT_VARIABLE, + EOLIAN_OBJECT_CONSTANT, EOLIAN_OBJECT_EXPRESSION, EOLIAN_OBJECT_FUNCTION, EOLIAN_OBJECT_FUNCTION_PARAMETER, @@ -207,12 +207,6 @@ ffi.cdef [[ | EOLIAN_MASK_NULL } Eolian_Expression_Mask; - typedef enum { - EOLIAN_VAR_UNKNOWN = 0, - EOLIAN_VAR_CONSTANT, - EOLIAN_VAR_GLOBAL - } Eolian_Variable_Type; - typedef union { char c; Eina_Bool b; @@ -325,11 +319,9 @@ ffi.cdef [[ Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit); const Eolian_Class *eolian_unit_class_by_name_get(const Eolian_Unit *unit, const char *class_name); Eina_Iterator *eolian_unit_classes_get(const Eolian_Unit *unit); - const Eolian_Variable *eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name); - const Eolian_Variable *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); + const Eolian_Constant *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); const Eolian_Error *eolian_unit_error_by_name_get(const Eolian_Unit *unit, const char *name); Eina_Iterator *eolian_unit_constants_get(const Eolian_Unit *unit); - Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit); Eina_Iterator *eolian_unit_errors_get(const Eolian_Unit *unit); const Eolian_Typedecl *eolian_unit_alias_by_name_get(const Eolian_Unit *unit, const char *name); const Eolian_Typedecl *eolian_unit_struct_by_name_get(const Eolian_Unit *unit, const char *name); @@ -339,7 +331,6 @@ ffi.cdef [[ Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit); Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name); const Eolian_Class *eolian_state_class_by_file_get(const Eolian_State *state, const char *file_name); - Eina_Iterator *eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name); Eina_Iterator *eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name); Eina_Iterator *eolian_state_errors_by_file_get(const Eolian_State *state, const char *file_name); Eina_Iterator *eolian_state_aliases_by_file_get(const Eolian_State *state, const char *file_name); @@ -462,11 +453,10 @@ ffi.cdef [[ Eolian_Unary_Operator eolian_expression_unary_operator_get(const Eolian_Expression *expr); const Eolian_Expression *eolian_expression_unary_expression_get(const Eolian_Expression *expr); Eolian_Value_t eolian_expression_value_get(const Eolian_Expression *expr); - Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var); - const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var); - const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var); - const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var); - Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var); + const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var); + const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var); + const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var); + Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var); const char *eolian_documentation_summary_get(const Eolian_Documentation *doc); const char *eolian_documentation_description_get(const Eolian_Documentation *doc); const char *eolian_documentation_since_get(const Eolian_Documentation *doc); @@ -522,7 +512,7 @@ M.object_type = { STRUCT_FIELD = 3, ENUM_FIELD = 4, TYPE = 5, - VARIABLE = 6, + CONSTANT = 6, EXPRESSION = 7, FUNCTION = 8, FUNCTION_PARAMETER = 9, @@ -674,12 +664,6 @@ local unit_idx, wrap_unit = gen_wrap { eolian.eolian_unit_classes_get(cast_unit(self))) end, - global_by_name_get = function(self, name) - local v = eolian.eolian_unit_global_by_name_get(cast_unit(self), name) - if v == nil then return nil end - return v - end, - constant_by_name_get = function(self, name) local v = eolian.eolian_unit_constant_by_name_get(cast_unit(self), name) if v == nil then return nil end @@ -693,15 +677,10 @@ local unit_idx, wrap_unit = gen_wrap { end, constants_get = function(self) - return Ptr_Iterator("const Eolian_Variable *", + return Ptr_Iterator("const Eolian_Constant *", eolian.eolian_unit_constants_get(cast_unit(self))) end, - globals_get = function(self) - return Ptr_Iterator("const Eolian_Variable *", - eolian.eolian_unit_globals_get(cast_unit(self))) - end, - errors_get = function(self) return Ptr_Iterator("const Eolian_Error *", eolian.eolian_unit_errors_get(cast_unit(self))) @@ -860,13 +839,8 @@ ffi.metatype("Eolian_State", { return v end, - globals_by_file_get = function(unit, fname) - return Ptr_Iterator("const Eolian_Variable*", - eolian.eolian_state_globals_by_file_get(self, fname)) - end, - constants_by_file_get = function(unit, fname) - return Ptr_Iterator("const Eolian_Variable*", + return Ptr_Iterator("const Eolian_Constant*", eolian.eolian_state_constants_by_file_get(self, fname)) end, @@ -1606,12 +1580,6 @@ emask.NUMBER = bit.bor(emask.INT , emask.FLOAT) emask.ALL = bit.bor(emask.NUMBER, emask.BOOL, emask.STRING, emask.CHAR, emask.NULL) -M.variable_type = { - UNKNOWN = 0, - CONSTANT = 1, - GLOBAL = 2 -} - local value_con = { [etype.INT ] = function(v) return tonumber(v.value.i ) end, [etype.UINT ] = function(v) return tonumber(v.value.u ) end, @@ -1737,32 +1705,28 @@ M.Expression = ffi.metatype("Eolian_Expression", { } }) -M.Variable = ffi.metatype("Eolian_Variable", { +M.Constant = ffi.metatype("Eolian_Constant", { __index = wrap_object { - type_get = function(self) - return tonumber(eolian.eolian_variable_type_get(self)) - end, - documentation_get = function(self) - local v = eolian.eolian_variable_documentation_get(self) + local v = eolian.eolian_constant_documentation_get(self) if v == nil then return nil end return v end, base_type_get = function(self) - local v = eolian.eolian_variable_base_type_get(self) + local v = eolian.eolian_constant_base_type_get(self) if v == nil then return nil end return v end, value_get = function(self) - local v = eolian.eolian_variable_value_get(self) + local v = eolian.eolian_constant_value_get(self) if v == nil then return nil end return v end, is_extern = function(self) - return eolian.eolian_variable_is_extern(self) ~= 0 + return eolian.eolian_constant_is_extern(self) ~= 0 end } }) @@ -1890,8 +1854,8 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", { elseif tp == reft.ENUM_FIELD then return tp, ffi.cast("const Eolian_Typedecl *", stor[0]), ffi.cast("const Eolian_Enum_Type_Field *", stor[1]) - elseif tp == reft.VARIABLE then - return tp, ffi.cast("const Eolian_Variable *", stor[0]) + elseif tp == reft.CONSTANT then + return tp, ffi.cast("const Eolian_Constant *", stor[0]) else return reft.UNKNOWN end diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index ed6444ce73..b0d7a4e9ce 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -164,11 +164,11 @@ typedef struct _Eolian_Event Eolian_Event; */ typedef struct _Eolian_Expression Eolian_Expression; -/* Variable information +/* Constant information * * @ingroup Eolian */ -typedef struct _Eolian_Variable Eolian_Variable; +typedef struct _Eolian_Constant Eolian_Constant; /* Error information * @@ -220,7 +220,7 @@ typedef enum EOLIAN_OBJECT_STRUCT_FIELD, EOLIAN_OBJECT_ENUM_FIELD, EOLIAN_OBJECT_TYPE, - EOLIAN_OBJECT_VARIABLE, + EOLIAN_OBJECT_CONSTANT, EOLIAN_OBJECT_EXPRESSION, EOLIAN_OBJECT_FUNCTION, EOLIAN_OBJECT_FUNCTION_PARAMETER, @@ -388,13 +388,6 @@ typedef enum | EOLIAN_MASK_NULL } Eolian_Expression_Mask; -typedef enum -{ - EOLIAN_VAR_UNKNOWN = 0, - EOLIAN_VAR_CONSTANT, - EOLIAN_VAR_GLOBAL -} Eolian_Variable_Type; - typedef union { char c; @@ -699,7 +692,7 @@ EAPI const char *eolian_object_name_get(const Eolian_Object *obj); * This is the full name, but for C. It is typically derived from the * regular full name, with namespaces flattened to underscores, but * some things may be explicitly renamed. Only classes, types (both - * declarations and instances) and variables have C names, as others + * declarations and instances) and constants have C names, as others * are never referred to by name directly in C. * * @see eolian_object_unit_get @@ -1018,7 +1011,7 @@ EAPI unsigned short eolian_unit_version_get(const Eolian_Unit *unit); * @brief Get an object in a unit by name. * * Only objects declared directly within the file can be retrieved, i.e. - * classes, typedecls and variables. + * classes, typedecls and constants. * * @param[in] unit The unit. * @param[in] name The fully namespaced object name. @@ -1032,7 +1025,7 @@ EAPI const Eolian_Object *eolian_unit_object_by_name_get(const Eolian_Unit *unit * * The order is not necessarily the declaration order. Only objects declared * directly within the file can be retrieved, i.e. classes, typedecls and - * variables. + * constants. * * @param[in] unit The unit. * @@ -1060,24 +1053,14 @@ EAPI const Eolian_Class *eolian_unit_class_by_name_get(const Eolian_Unit *unit, EAPI Eina_Iterator *eolian_unit_classes_get(const Eolian_Unit *unit); /* - * @brief Get a global variable in a unit by name. + * @brief Get a constant in a unit by name. * * @param[in] unit The unit. - * @param[in] name the name of the variable + * @param[in] name the name of the constant * * @ingroup Eolian */ -EAPI const Eolian_Variable *eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name); - -/* - * @brief Get a constant variable in a unit by name. - * - * @param[in] unit The unit. - * @param[in] name the name of the variable - * - * @ingroup Eolian - */ -EAPI const Eolian_Variable *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); +EAPI const Eolian_Constant *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); /* * @brief Get an error declaration in a unit by name. @@ -1090,7 +1073,7 @@ EAPI const Eolian_Variable *eolian_unit_constant_by_name_get(const Eolian_Unit * EAPI const Eolian_Error *eolian_unit_error_by_name_get(const Eolian_Unit *unit, const char *name); /* - * @brief Get an iterator to all constant variables in the Eolian database. + * @brief Get an iterator to all constants in the Eolian database. * * @return the iterator or NULL * @@ -1100,17 +1083,6 @@ EAPI const Eolian_Error *eolian_unit_error_by_name_get(const Eolian_Unit *unit, */ EAPI Eina_Iterator *eolian_unit_constants_get(const Eolian_Unit *unit); -/* - * @brief Get an iterator to all global variables in the Eolian database. - * - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit); - /* * @brief Get an iterator to all error declarations in the Eolian database. * @@ -1203,7 +1175,7 @@ eolian_state_object_by_name_get(const Eolian_State *state, const char *name) * * The list follows declaration order in the file. Only objects declared * directly within the file can be retrieved, i.e. classes, typedecls and - * variables. + * constants. * * @param[in] state The state. * @param[in] file_name The file name. @@ -1261,19 +1233,6 @@ eolian_state_classes_get(const Eolian_State *state) return eolian_unit_classes_get(EOLIAN_UNIT(state)); } -/* - * @brief A helper function to get a global in a state by name. - * - * @see eolian_unit_global_by_name_get - * - * @ingroup Eolian - */ -static inline const Eolian_Variable * -eolian_state_global_by_name_get(const Eolian_State *state, const char *name) -{ - return eolian_unit_global_by_name_get(EOLIAN_UNIT(state), name); -} - /* * @brief A helper function to get a constant in a state by name. * @@ -1281,7 +1240,7 @@ eolian_state_global_by_name_get(const Eolian_State *state, const char *name) * * @ingroup Eolian */ -static inline const Eolian_Variable * +static inline const Eolian_Constant * eolian_state_constant_by_name_get(const Eolian_State *state, const char *name) { return eolian_unit_constant_by_name_get(EOLIAN_UNIT(state), name); @@ -1301,19 +1260,7 @@ eolian_state_error_by_name_get(const Eolian_State *state, const char *name) } /* - * @brief Get an iterator to all global variables contained in a file. - * - * @param[in] state The state. - * @param[in] file_name The file name. - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name); - -/* - * @brief Get an iterator to all constant variables contained in a file. + * @brief Get an iterator to all constants contained in a file. * * @param[in] state The state. * @param[in] file_name The file name. @@ -1338,19 +1285,6 @@ EAPI Eina_Iterator *eolian_state_constants_by_file_get(const Eolian_State *state */ EAPI Eina_Iterator *eolian_state_errors_by_file_get(const Eolian_State *state, const char *file_name); -/* - * @brief A helper function to get all globals in a state. - * - * @see eolian_unit_globals_get - * - * @ingroup Eolian - */ -static inline Eina_Iterator * -eolian_state_globals_get(const Eolian_State *state) -{ - return eolian_unit_globals_get(EOLIAN_UNIT(state)); -} - /* * @brief A helper function to get all constants in a state. * @@ -3182,116 +3116,106 @@ EAPI const Eolian_Expression *eolian_expression_unary_expression_get(const Eolia EAPI Eolian_Value eolian_expression_value_get(const Eolian_Expression *expr); /* - * @brief Get the type of a variable (global, constant) + * @brief Get the documentation of a constant. * - * @param[in] var the variable. - * @return an Eolian_Type_Type. - * - * @ingroup Eolian - */ -EAPI Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var); - -/* - * @brief Get the documentation of a variable. - * - * @param[in] var the variable. + * @param[in] var the constant. * @return the documentation or NULL. * * @ingroup Eolian */ -EAPI const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var); +EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var); /* - * @brief Get the base type of a variable. + * @brief Get the base type of a constant. * - * @param[in] var the variable. + * @param[in] var the constant. * @return the base type or NULL. * * @ingroup Eolian */ -EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var); +EAPI const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var); /* - * @brief Get the value of a variable. + * @brief Get the value of a constant. * - * @param[in] var the variable. + * @param[in] var the constant. * @return the value or NULL. * * @ingroup Eolian */ -EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var); +EAPI const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var); /* - * @brief A helper function to get the full name of a variable. + * @brief A helper function to get the full name of a constant. * * @see eolian_object_name_get * * @ingroup Eolian */ static inline const char * -eolian_variable_name_get(const Eolian_Variable *tp) +eolian_constant_name_get(const Eolian_Constant *tp) { return eolian_object_name_get(EOLIAN_OBJECT(tp)); } /* - * @brief A helper function to get the C name of a variable. + * @brief A helper function to get the C name of a constant. * * @see eolian_object_c_name_get * * @ingroup Eolian */ static inline const char * -eolian_variable_c_name_get(const Eolian_Variable *tp) +eolian_constant_c_name_get(const Eolian_Constant *tp) { return eolian_object_c_name_get(EOLIAN_OBJECT(tp)); } /* - * @brief A helper function to get the short name of a variable. + * @brief A helper function to get the short name of a constant. * * @see eolian_object_short_name_get * * @ingroup Eolian */ static inline const char * -eolian_variable_short_name_get(const Eolian_Variable *tp) +eolian_constant_short_name_get(const Eolian_Constant *tp) { return eolian_object_short_name_get(EOLIAN_OBJECT(tp)); } /* - * @brief A helper function to get the namespaces of a variable. + * @brief A helper function to get the namespaces of a constant. * * @see eolian_object_namespaces_get * * @ingroup Eolian */ static inline Eina_Iterator * -eolian_variable_namespaces_get(const Eolian_Variable *tp) +eolian_constant_namespaces_get(const Eolian_Constant *tp) { return eolian_object_namespaces_get(EOLIAN_OBJECT(tp)); } /* - * @brief Check if a variable is extern. + * @brief Check if a constant is extern. * - * @param[in] var the variable. + * @param[in] var the constant. * @return EINA_TRUE if it's extern, EINA_FALSE otherwise. * * @ingroup Eolian */ -EAPI Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var); +EAPI Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var); /* - * @brief Get whether a variable is beta. + * @brief Get whether a constant is beta. * * @see eolian_object_is_beta * * @ingroup Eolian */ static inline Eina_Bool -eolian_variable_is_beta(const Eolian_Variable *var) +eolian_constant_is_beta(const Eolian_Constant *var) { return eolian_object_is_beta(EOLIAN_OBJECT(var)); } diff --git a/src/lib/eolian/database_check.c b/src/lib/eolian/database_check.c index 4e448cea7a..0626512076 100644 --- a/src/lib/eolian/database_check.c +++ b/src/lib/eolian/database_check.c @@ -47,7 +47,7 @@ _check_expr_cb(const Eolian_Object *obj, void *data) switch (obj->type) { case EOLIAN_OBJECT_TYPEDECL: - case EOLIAN_OBJECT_VARIABLE: + case EOLIAN_OBJECT_CONSTANT: _add_dep(depset, obj->unit); default: break; @@ -195,7 +195,7 @@ _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash) } static void -_check_variable(const Eolian_Variable *v, Eina_Hash *depset, Eina_Hash *chash) +_check_constant(const Eolian_Constant *v, Eina_Hash *depset, Eina_Hash *chash) { if (_check_cycle(chash, &v->base)) return; @@ -230,8 +230,8 @@ _check_unit(const Eolian_Unit *unit) case EOLIAN_OBJECT_TYPEDECL: _check_typedecl((const Eolian_Typedecl *)obj, depset, chash); break; - case EOLIAN_OBJECT_VARIABLE: - _check_variable((const Eolian_Variable *)obj, depset, chash); + case EOLIAN_OBJECT_CONSTANT: + _check_constant((const Eolian_Constant *)obj, depset, chash); break; default: continue; diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c index c2b6030db1..978f281a8f 100644 --- a/src/lib/eolian/database_expr.c +++ b/src/lib/eolian/database_expr.c @@ -512,7 +512,7 @@ eval_exp(const Eolian_Unit *unit, Eolian_Expression *expr, return eval_exp(NULL, expr->expr, mask, out, cb, data); } - const Eolian_Variable *var = eolian_unit_constant_by_name_get + const Eolian_Constant *var = eolian_unit_constant_by_name_get (unit, expr->value.s); Eolian_Expression *exp = NULL; diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c index d0bf40d17a..87d51ac2e1 100644 --- a/src/lib/eolian/database_validate.c +++ b/src/lib/eolian/database_validate.c @@ -1488,7 +1488,7 @@ _validate_class(Validate_State *vals, Eolian_Class *cl, } static Eina_Bool -_validate_variable(Validate_State *vals, Eolian_Variable *var) +_validate_constant(Validate_State *vals, Eolian_Constant *var) { if (var->base.validated) return EINA_TRUE; @@ -1498,7 +1498,7 @@ _validate_variable(Validate_State *vals, Eolian_Variable *var) if (!_validate_type(vals, var->base_type)) return _reset_stable(vals, was_stable, EINA_FALSE); - if (var->value && !_validate_expr(var->value, var->base_type, 0, EINA_FALSE)) + if (!_validate_expr(var->value, var->base_type, 0, EINA_FALSE)) return _reset_stable(vals, was_stable, EINA_FALSE); if (!_validate_doc(var->doc)) @@ -1516,10 +1516,10 @@ _typedecl_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, } static Eina_Bool -_var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, - Eolian_Variable *var, Cb_Ret *sc) +_constant_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, + Eolian_Constant *var, Cb_Ret *sc) { - return (sc->succ = _validate_variable(sc->vals, var)); + return (sc->succ = _validate_constant(sc->vals, var)); } Eina_Bool @@ -1597,11 +1597,7 @@ database_validate(const Eolian_Unit *src) if (!rt.succ) return EINA_FALSE; - eina_hash_foreach(src->globals, (Eina_Hash_Foreach)_var_map_cb, &rt); - if (!rt.succ) - return EINA_FALSE; - - eina_hash_foreach(src->constants, (Eina_Hash_Foreach)_var_map_cb, &rt); + eina_hash_foreach(src->constants, (Eina_Hash_Foreach)_constant_map_cb, &rt); if (!rt.succ) return EINA_FALSE; diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c index 5029e52068..a714bd6344 100644 --- a/src/lib/eolian/database_var.c +++ b/src/lib/eolian/database_var.c @@ -6,7 +6,7 @@ #include "eo_lexer.h" void -database_var_del(Eolian_Variable *var) +database_constant_del(Eolian_Constant *var) { if (!var || eolian_object_unref(&var->base)) return; eina_stringshare_del(var->base.file); @@ -19,29 +19,11 @@ database_var_del(Eolian_Variable *var) free(var); } -static void -database_var_global_add(Eolian_Unit *unit, Eolian_Variable *var) -{ - EOLIAN_OBJECT_ADD(unit, var->base.name, var, globals); - eina_hash_set(unit->state->staging.globals_f, var->base.file, eina_list_append - ((Eina_List*)eina_hash_find(unit->state->staging.globals_f, var->base.file), var)); -} - -static void -database_var_constant_add(Eolian_Unit *unit, Eolian_Variable *var) +void +database_constant_add(Eolian_Unit *unit, Eolian_Constant *var) { EOLIAN_OBJECT_ADD(unit, var->base.name, var, constants); eina_hash_set(unit->state->staging.constants_f, var->base.file, eina_list_append ((Eina_List*)eina_hash_find(unit->state->staging.constants_f, var->base.file), var)); database_object_add(unit, &var->base); } - -void -database_var_add(Eolian_Unit *unit, Eolian_Variable *var) -{ - if (var->type == EOLIAN_VAR_GLOBAL) - database_var_global_add(unit, var); - else - database_var_constant_add(unit, var); - database_object_add(unit, &var->base); -} diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c index 099237a8ba..260baa638f 100644 --- a/src/lib/eolian/database_var_api.c +++ b/src/lib/eolian/database_var_api.c @@ -5,36 +5,29 @@ #include #include "eolian_database.h" -EAPI Eolian_Variable_Type -eolian_variable_type_get(const Eolian_Variable *var) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(var, EOLIAN_VAR_UNKNOWN); - return var->type; -} - EAPI const Eolian_Documentation * -eolian_variable_documentation_get(const Eolian_Variable *var) +eolian_constant_documentation_get(const Eolian_Constant *var) { EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL); return var->doc; } EAPI const Eolian_Type * -eolian_variable_base_type_get(const Eolian_Variable *var) +eolian_constant_base_type_get(const Eolian_Constant *var) { EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL); return var->base_type; } EAPI const Eolian_Expression * -eolian_variable_value_get(const Eolian_Variable *var) +eolian_constant_value_get(const Eolian_Constant *var) { EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL); return var->value; } EAPI Eina_Bool -eolian_variable_is_extern(const Eolian_Variable *var) +eolian_constant_is_extern(const Eolian_Constant *var) { EINA_SAFETY_ON_NULL_RETURN_VAL(var, EINA_FALSE); return var->is_extern; diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 809e7fae5d..165c8340f2 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -1056,8 +1056,8 @@ _node_free(Eolian_Object *obj) case EOLIAN_OBJECT_TYPE: database_type_del((Eolian_Type *)obj); break; - case EOLIAN_OBJECT_VARIABLE: - database_var_del((Eolian_Variable *)obj); + case EOLIAN_OBJECT_CONSTANT: + database_constant_del((Eolian_Constant *)obj); break; case EOLIAN_OBJECT_EXPRESSION: database_expr_del((Eolian_Expression *)obj); diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h index 3b2bf734ac..706acb028e 100644 --- a/src/lib/eolian/eo_lexer.h +++ b/src/lib/eolian/eo_lexer.h @@ -31,7 +31,7 @@ enum Tokens KW(data), KW(destructor), KW(error), KW(event_prefix), KW(events), KW(extends), \ KW(free), KW(get), KW(implements), KW(import), KW(interface), \ KW(keys), KW(legacy), KW(methods), KW(mixin), KW(params), \ - KW(parse), KW(parts), KW(ptr), KW(set), KW(type), KW(values), KW(var), KW(requires), \ + KW(parse), KW(parts), KW(ptr), KW(set), KW(type), KW(values), KW(requires), \ \ KWAT(auto), KWAT(beta), KWAT(by_ref), KWAT(c_name), KWAT(const), \ KWAT(empty), KWAT(extern), KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), \ @@ -264,16 +264,16 @@ eo_lexer_typedecl_release(Eo_Lexer *ls, Eolian_Typedecl *tp) return (Eolian_Typedecl *)eo_lexer_node_release(ls, (Eolian_Object *)tp); } -static inline Eolian_Variable * -eo_lexer_variable_new(Eo_Lexer *ls) +static inline Eolian_Constant * +eo_lexer_constant_new(Eo_Lexer *ls) { - return (Eolian_Variable *)eo_lexer_node_new(ls, sizeof(Eolian_Variable)); + return (Eolian_Constant *)eo_lexer_node_new(ls, sizeof(Eolian_Constant)); } -static inline Eolian_Variable * -eo_lexer_variable_release(Eo_Lexer *ls, Eolian_Variable *var) +static inline Eolian_Constant * +eo_lexer_constant_release(Eo_Lexer *ls, Eolian_Constant *var) { - return (Eolian_Variable *)eo_lexer_node_release(ls, (Eolian_Object *)var); + return (Eolian_Constant *)eo_lexer_node_release(ls, (Eolian_Object *)var); } static inline Eolian_Expression * diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 879cc0af3a..faaaf4fb3d 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -125,7 +125,7 @@ _eolian_decl_get(Eo_Lexer *ls, const char *name) obj = eina_hash_find(ls->state->staging.unit.objects, name); if (obj && ((obj->type == EOLIAN_OBJECT_CLASS) || (obj->type == EOLIAN_OBJECT_TYPEDECL) || - (obj->type == EOLIAN_OBJECT_VARIABLE))) + (obj->type == EOLIAN_OBJECT_CONSTANT))) return obj; return NULL; @@ -152,8 +152,8 @@ _eolian_decl_name_get(Eolian_Object *obj) break; } goto end; - case EOLIAN_OBJECT_VARIABLE: - return "variable"; + case EOLIAN_OBJECT_CONSTANT: + return "constant"; default: break; } @@ -879,10 +879,10 @@ tags_done: return def; } -static Eolian_Variable * -parse_variable(Eo_Lexer *ls, Eina_Bool global) +static Eolian_Constant * +parse_constant(Eo_Lexer *ls) { - Eolian_Variable *def = eo_lexer_variable_new(ls); + Eolian_Constant *def = eo_lexer_constant_new(ls); Eina_Strbuf *buf; eo_lexer_get(ls); Eina_Stringshare *cname = NULL; @@ -908,11 +908,10 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global) goto tags_done; } tags_done: - def->type = global ? EOLIAN_VAR_GLOBAL : EOLIAN_VAR_CONSTANT; buf = eina_strbuf_new(); eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf); eo_lexer_context_push(ls); - FILL_BASE(def->base, ls, ls->line_number, ls->column, VARIABLE); + FILL_BASE(def->base, ls, ls->line_number, ls->column, CONSTANT); parse_name(ls, buf); def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf)); if (cname) @@ -932,17 +931,12 @@ tags_done: check_next(ls, ':'); def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE)); /* 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); - def->value = parse_expr(ls); - ls->expr_mode = EINA_FALSE; - eo_lexer_expr_release_ref(ls, def->value); - } + check(ls, '='); + ls->expr_mode = EINA_TRUE; + eo_lexer_get(ls); + def->value = parse_expr(ls); + ls->expr_mode = EINA_FALSE; + eo_lexer_expr_release_ref(ls, def->value); check_next(ls, ';'); FILL_DOC(ls, def, doc); eo_lexer_dtor_pop(ls); @@ -2401,10 +2395,8 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot) break; } case KW_const: - case KW_var: { - database_var_add(ls->unit, eo_lexer_variable_release(ls, - parse_variable(ls, ls->t.kw == KW_var))); + database_constant_add(ls->unit, eo_lexer_constant_release(ls, parse_constant(ls))); break; } case KW_error: diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index cef722dd95..09eb904992 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -491,7 +491,7 @@ database_doc_token_ref_resolve(const Eolian_Doc_Token *tok, { case EOLIAN_OBJECT_CLASS: case EOLIAN_OBJECT_TYPEDECL: - case EOLIAN_OBJECT_VARIABLE: + case EOLIAN_OBJECT_CONSTANT: case EOLIAN_OBJECT_ERROR: /* we only allow certain types to be referenced */ return tp; @@ -589,8 +589,7 @@ database_unit_init(Eolian_State *state, Eolian_Unit *unit, const char *file) unit->children = eina_hash_stringshared_new(NULL); unit->classes = eina_hash_stringshared_new(EINA_FREE_CB(database_class_del)); - unit->globals = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); - unit->constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); + unit->constants = eina_hash_stringshared_new(EINA_FREE_CB(database_constant_del)); unit->errors = eina_hash_stringshared_new(EINA_FREE_CB(database_error_del)); unit->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); unit->structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); @@ -607,7 +606,6 @@ _unit_contents_del(Eolian_Unit *unit) eina_stringshare_del(unit->file); eina_hash_free(unit->children); eina_hash_free(unit->classes); - eina_hash_free(unit->globals); eina_hash_free(unit->constants); eina_hash_free(unit->errors); eina_hash_free(unit->aliases); @@ -660,7 +658,6 @@ _state_area_init(Eolian_State *state, Eolian_State_Area *a) a->aliases_f = eina_hash_stringshared_new(NULL); a->structs_f = eina_hash_stringshared_new(NULL); a->enums_f = eina_hash_stringshared_new(NULL); - a->globals_f = eina_hash_stringshared_new(NULL); a->constants_f = eina_hash_stringshared_new(NULL); a->errors_f = eina_hash_stringshared_new(NULL); a->objects_f = eina_hash_stringshared_new(NULL); @@ -687,7 +684,6 @@ _state_area_contents_del(Eolian_State_Area *a) _hashlist_free(a->aliases_f); _hashlist_free(a->structs_f); _hashlist_free(a->enums_f); - _hashlist_free(a->globals_f); _hashlist_free(a->constants_f); _hashlist_free(a->errors_f); _hashlist_free(a->objects_f); @@ -906,7 +902,6 @@ _state_clean(Eolian_State *state) Eolian_Unit *stu = &st->unit; eina_hash_free_buckets(stu->classes); - eina_hash_free_buckets(stu->globals); eina_hash_free_buckets(stu->constants); eina_hash_free_buckets(stu->aliases); eina_hash_free_buckets(stu->structs); @@ -921,7 +916,6 @@ _state_clean(Eolian_State *state) _hashlist_free_buckets(st->aliases_f); _hashlist_free_buckets(st->structs_f); _hashlist_free_buckets(st->enums_f); - _hashlist_free_buckets(st->globals_f); _hashlist_free_buckets(st->constants_f); _hashlist_free_buckets(st->objects_f); } @@ -1010,7 +1004,6 @@ static void _merge_unit(Eolian_Unit *dest, Eolian_Unit *src) { eina_hash_foreach(src->classes, _merge_unit_cb, dest->classes); - eina_hash_foreach(src->globals, _merge_unit_cb, dest->globals); eina_hash_foreach(src->constants, _merge_unit_cb, dest->constants); eina_hash_foreach(src->aliases, _merge_unit_cb, dest->aliases); eina_hash_foreach(src->structs, _merge_unit_cb, dest->structs); @@ -1073,7 +1066,6 @@ _merge_staging(Eolian_State *state) EOLIAN_STAGING_MERGE_LIST(aliases); EOLIAN_STAGING_MERGE_LIST(structs); EOLIAN_STAGING_MERGE_LIST(enums); - EOLIAN_STAGING_MERGE_LIST(globals); EOLIAN_STAGING_MERGE_LIST(constants); EOLIAN_STAGING_MERGE_LIST(objects); @@ -1248,17 +1240,6 @@ eolian_state_class_by_file_get(const Eolian_State *state, const char *file_name) return cl; } -EAPI Eina_Iterator * -eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name) -{ - if (!state) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(file_name); - Eina_List *l = eina_hash_find(state->main.globals_f, shr); - eina_stringshare_del(shr); - if (!l) return NULL; - return eina_list_iterator_new(l); -} - EAPI Eina_Iterator * eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name) { @@ -1383,22 +1364,12 @@ eolian_unit_classes_get(const Eolian_Unit *unit) return (unit ? eina_hash_iterator_data_new(unit->classes) : NULL); } -EAPI const Eolian_Variable * -eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Variable *v = eina_hash_find(unit->globals, shr); - eina_stringshare_del(shr); - return v; -} - -EAPI const Eolian_Variable * +EAPI const Eolian_Constant * eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name) { if (!unit) return NULL; Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Variable *v = eina_hash_find(unit->constants, shr); + Eolian_Constant *v = eina_hash_find(unit->constants, shr); eina_stringshare_del(shr); return v; } @@ -1419,12 +1390,6 @@ eolian_unit_constants_get(const Eolian_Unit *unit) return (unit ? eina_hash_iterator_data_new(unit->constants) : NULL); } -EAPI Eina_Iterator * -eolian_unit_globals_get(const Eolian_Unit *unit) -{ - return (unit ? eina_hash_iterator_data_new(unit->globals) : NULL); -} - EAPI Eina_Iterator * eolian_unit_errors_get(const Eolian_Unit *unit) { diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index ab49424cad..3cbf4fbeea 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -39,7 +39,6 @@ struct _Eolian_Unit Eolian_State *state; Eina_Hash *children; Eina_Hash *classes; - Eina_Hash *globals; Eina_Hash *constants; Eina_Hash *errors; Eina_Hash *aliases; @@ -59,7 +58,6 @@ typedef struct _Eolian_State_Area Eina_Hash *aliases_f; Eina_Hash *structs_f; Eina_Hash *enums_f; - Eina_Hash *globals_f; Eina_Hash *constants_f; Eina_Hash *errors_f; Eina_Hash *objects_f; @@ -394,10 +392,9 @@ struct _Eolian_Expression Eina_Bool weak_rhs :1; }; -struct _Eolian_Variable +struct _Eolian_Constant { Eolian_Object base; - Eolian_Variable_Type type; Eolian_Type *base_type; Eolian_Expression *value; Eolian_Documentation *doc; @@ -449,8 +446,8 @@ void database_expr_print(Eolian_Expression *expr); /* variables */ -void database_var_del(Eolian_Variable *var); -void database_var_add(Eolian_Unit *unit, Eolian_Variable *var); +void database_constant_del(Eolian_Constant *var); +void database_constant_add(Eolian_Unit *unit, Eolian_Constant *var); /* classes */ void database_class_del(Eolian_Class *cl); diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index a7a01cc243..ce3053331c 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp @@ -113,13 +113,6 @@ inline typedecl_type typedecl_type_get(Eolian_Typedecl const* decl) } } -enum class variable_type -{ - unknown, - constant, - global -}; - struct type_def; bool operator==(type_def const& lhs, type_def const& rhs); @@ -1070,63 +1063,57 @@ struct property_def } }; -struct variable_def +struct constant_def { std::string name; std::string full_name; type_def base_type; documentation_def documentation; - variable_type type; std::vector namespaces; Eolian_Value expression_value; bool is_extern : 1; - friend inline bool operator==(variable_def const& lhs, variable_def const& rhs) + friend inline bool operator==(constant_def const& lhs, constant_def const& rhs) { return lhs.name == rhs.name && lhs.full_name == rhs.full_name && lhs.base_type == rhs.base_type && lhs.documentation == rhs.documentation - && lhs.type == rhs.type && lhs.namespaces == rhs.namespaces && lhs.expression_value.type == rhs.expression_value.type && lhs.expression_value.value.ll == rhs.expression_value.value.ll && lhs.is_extern == rhs.is_extern; } - friend inline bool operator!=(variable_def const& lhs, variable_def const& rhs) + friend inline bool operator!=(constant_def const& lhs, constant_def const& rhs) { return !(lhs == rhs); } - variable_def() = default; - variable_def(Eolian_Variable const* variable, Eolian_Unit const* unit) - : name(::eolian_variable_short_name_get(variable)) - , full_name(::eolian_variable_name_get(variable)) - , base_type(::eolian_variable_base_type_get(variable) + constant_def() = default; + constant_def(Eolian_Constant const* constant, Eolian_Unit const* unit) + : name(::eolian_constant_short_name_get(constant)) + , full_name(::eolian_constant_name_get(constant)) + , base_type(::eolian_constant_base_type_get(constant) , unit - , ::eolian_type_c_type_get(eolian_variable_base_type_get(variable)) + , ::eolian_type_c_type_get(eolian_constant_base_type_get(constant)) , value_ownership::unmoved , is_by::value) - , documentation(::eolian_variable_documentation_get(variable)) - , type(static_cast(::eolian_variable_type_get(variable))) + , documentation(::eolian_constant_documentation_get(constant)) , expression_value() - , is_extern(::eolian_variable_is_extern(variable)) + , is_extern(::eolian_constant_is_extern(constant)) { - for(efl::eina::iterator namespace_iterator( ::eolian_variable_namespaces_get(variable)) + for(efl::eina::iterator namespace_iterator( ::eolian_constant_namespaces_get(constant)) , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) { this->namespaces.push_back((&*namespace_iterator)); } - if (this->type == variable_type::constant) - { - auto expr = ::eolian_variable_value_get(variable); - if (!expr) - throw std::runtime_error("Could not get constant variable value expression"); + auto expr = ::eolian_constant_value_get(constant); + if (!expr) + throw std::runtime_error("Could not get constant variable value expression"); - this->expression_value = ::eolian_expression_eval(expr, ::EOLIAN_MASK_ALL); - } + this->expression_value = ::eolian_expression_eval(expr, ::EOLIAN_MASK_ALL); } }; diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index c76bc49e72..6d800cdd82 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -173,11 +173,6 @@ class Eolian_Expression_Mask(IntEnum): NUMBER = INT | FLOAT ALL = NUMBER | BOOL | STRING | CHAR | NULL -class Eolian_Variable_Type(IntEnum): - UNKNOWN = 0 - CONSTANT = 1 - GLOBAL = 2 - class Eolian_Binary_Operator(IntEnum): INVALID = 0 ADD = 1 # + int, float @@ -350,19 +345,11 @@ class Eolian_Unit(EolianBaseObject): @property def constants(self): - return Iterator(Variable, lib.eolian_unit_constants_get(self)) + return Iterator(Constant, lib.eolian_unit_constants_get(self)) def constant_by_name_get(self, name): c_var = lib.eolian_unit_constant_by_name_get(self, _str_to_bytes(name)) - return Variable(c_var) if c_var else None - - @property - def globals(self): - return Iterator(Variable, lib.eolian_unit_globals_get(self)) - - def global_by_name_get(self, name): - c_var = lib.eolian_unit_global_by_name_get(self, _str_to_bytes(name)) - return Variable(c_var) if c_var else None + return Constant(c_var) if c_var else None @property def enums(self): @@ -472,13 +459,9 @@ class Eolian_State(Eolian_Unit): return Class(c_cls) if c_cls else None def constants_by_file_get(self, file_name): - return Iterator(Variable, + return Iterator(Constant, lib.eolian_state_constants_by_file_get(self, _str_to_bytes(file_name))) - def globals_by_file_get(self, file_name): - return Iterator(Variable, - lib.eolian_state_globals_by_file_get(self, _str_to_bytes(file_name))) - def aliases_by_file_get(self, file_name): return Iterator(Typedecl, lib.eolian_state_aliases_by_file_get(self, _str_to_bytes(file_name))) @@ -1238,31 +1221,27 @@ class Expression(Object): return Expression(c_expr) if c_expr is not None else None -class Variable(Object): +class Constant(Object): def __repr__(self): - return "".format(self) - - @cached_property - def type(self): - return Eolian_Variable_Type(lib.eolian_variable_type_get(self)) + return "".format(self) @cached_property def value(self): - c_expr = lib.eolian_variable_value_get(self) + c_expr = lib.eolian_constant_value_get(self) return Expression(c_expr) if c_expr else None @cached_property def base_type(self): - c_type = lib.eolian_variable_base_type_get(self) + c_type = lib.eolian_constant_base_type_get(self) return Type(c_type) if c_type else None @cached_property def is_extern(self): - return bool(lib.eolian_variable_is_extern(self)) + return bool(lib.eolian_constant_is_extern(self)) @cached_property def documentation(self): - c_doc = lib.eolian_variable_documentation_get(self) + c_doc = lib.eolian_constant_documentation_get(self) return Documentation(c_doc) if c_doc else None @@ -1380,7 +1359,7 @@ class _Eolian_Object_Type(IntEnum): STRUCT_FIELD = 3 ENUM_FIELD = 4 TYPE = 5 - VARIABLE = 6 + CONSTANT = 6 EXPRESSION = 7 FUNCTION = 8 FUNCTION_PARAMETER = 9 @@ -1397,7 +1376,7 @@ _eolian_type_class_mapping = { _Eolian_Object_Type.STRUCT_FIELD: Struct_Type_Field, _Eolian_Object_Type.ENUM_FIELD: Enum_Type_Field, _Eolian_Object_Type.TYPE: Type, - _Eolian_Object_Type.VARIABLE: Variable, + _Eolian_Object_Type.CONSTANT: Constant, _Eolian_Object_Type.EXPRESSION: Expression, _Eolian_Object_Type.FUNCTION: Function, _Eolian_Object_Type.FUNCTION_PARAMETER: Function_Parameter, diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index b9ee5d39a1..3a745edf31 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -108,10 +108,6 @@ lib.eolian_state_objects_by_file_get.restype = c_void_p lib.eolian_state_class_by_file_get.argtypes = (c_void_p, c_char_p) lib.eolian_state_class_by_file_get.restype = c_void_p -# EAPI Eina_Iterator *eolian_state_globals_by_file_get(const Eolian_State *state, const char *file_name); -lib.eolian_state_globals_by_file_get.argtypes = (c_void_p, c_char_p) -lib.eolian_state_globals_by_file_get.restype = c_void_p - # EAPI Eina_Iterator *eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name); lib.eolian_state_constants_by_file_get.argtypes = (c_void_p, c_char_p) lib.eolian_state_constants_by_file_get.restype = c_void_p @@ -182,11 +178,7 @@ lib.eolian_unit_structs_get.restype = c_void_p lib.eolian_unit_enums_get.argtypes = (c_void_p,) lib.eolian_unit_enums_get.restype = c_void_p -# EAPI const Eolian_Variable *eolian_unit_global_by_name_get(const Eolian_Unit *unit, const char *name); -lib.eolian_unit_global_by_name_get.argtypes = (c_void_p, c_char_p) -lib.eolian_unit_global_by_name_get.restype = c_void_p - -# EAPI const Eolian_Variable *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); +# EAPI const Eolian_Constant *eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name); lib.eolian_unit_constant_by_name_get.argtypes = (c_void_p, c_char_p) lib.eolian_unit_constant_by_name_get.restype = c_void_p @@ -194,10 +186,6 @@ lib.eolian_unit_constant_by_name_get.restype = c_void_p lib.eolian_unit_constants_get.argtypes = (c_void_p,) lib.eolian_unit_constants_get.restype = c_void_p -# EAPI Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit); -lib.eolian_unit_globals_get.argtypes = (c_void_p,) -lib.eolian_unit_globals_get.restype = c_void_p - ### Eolian_Object ########################################################### # EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj); @@ -637,27 +625,23 @@ lib.eolian_expression_unary_operator_get.restype = c_int lib.eolian_expression_unary_expression_get.argtypes = (c_void_p,) lib.eolian_expression_unary_expression_get.restype = c_void_p -### Eolian_Variable ######################################################### +### Eolian_Constant ######################################################### -# EAPI Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var); -lib.eolian_variable_type_get.argtypes = (c_void_p,) -lib.eolian_variable_type_get.restype = c_int +# EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var); +lib.eolian_constant_documentation_get.argtypes = (c_void_p,) +lib.eolian_constant_documentation_get.restype = c_void_p -# EAPI const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var); -lib.eolian_variable_documentation_get.argtypes = (c_void_p,) -lib.eolian_variable_documentation_get.restype = c_void_p +# EAPI const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var); +lib.eolian_constant_base_type_get.argtypes = (c_void_p,) +lib.eolian_constant_base_type_get.restype = c_void_p -# EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var); -lib.eolian_variable_base_type_get.argtypes = (c_void_p,) -lib.eolian_variable_base_type_get.restype = c_void_p +# EAPI const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var); +lib.eolian_constant_value_get.argtypes = (c_void_p,) +lib.eolian_constant_value_get.restype = c_void_p -# EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var); -lib.eolian_variable_value_get.argtypes = (c_void_p,) -lib.eolian_variable_value_get.restype = c_void_p - -# EAPI Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var); -lib.eolian_variable_is_extern.argtypes = (c_void_p,) -lib.eolian_variable_is_extern.restype = c_bool +# EAPI Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var); +lib.eolian_constant_is_extern.argtypes = (c_void_p,) +lib.eolian_constant_is_extern.restype = c_bool ### Eolian_Documentation #################################################### diff --git a/src/scripts/pyolian/generator.py b/src/scripts/pyolian/generator.py index cd4d105858..a86e03240c 100755 --- a/src/scripts/pyolian/generator.py +++ b/src/scripts/pyolian/generator.py @@ -125,7 +125,7 @@ class Template(pyratemp.Template): 'Enum_Type_Field': eolian.Enum_Type_Field, 'Struct_Type_Field': eolian.Struct_Type_Field, 'Expression': eolian.Expression, - 'Variable': eolian.Variable, + 'Constant': eolian.Constant, 'Documentation': eolian.Documentation, 'Documentation_Token': eolian.Documentation_Token, # Eolian Enums @@ -139,7 +139,6 @@ class Template(pyratemp.Template): 'Eolian_C_Type_Type': eolian.Eolian_C_Type_Type, 'Eolian_Expression_Type': eolian.Eolian_Expression_Type, 'Eolian_Expression_Mask': eolian.Eolian_Expression_Mask, - 'Eolian_Variable_Type': eolian.Eolian_Variable_Type, 'Eolian_Binary_Operator': eolian.Eolian_Binary_Operator, 'Eolian_Unary_Operator': eolian.Eolian_Unary_Operator, 'Eolian_Doc_Token_Type': eolian.Eolian_Doc_Token_Type, diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index 36c19ea1ae..280d4c187c 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py @@ -180,22 +180,14 @@ class TestEolianUnit(unittest.TestCase): all_count += 1 self.assertGreater(all_count, 10) - def test_variable_listing(self): + def test_constant_listing(self): l = list(eolian_db.constants) self.assertGreater(len(l), 2) - self.assertIsInstance(l[0], eolian.Variable) - - l = list(eolian_db.globals) - self.assertGreater(len(l), 20) - self.assertIsInstance(l[0], eolian.Variable) + self.assertIsInstance(l[0], eolian.Constant) l = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo')) self.assertGreater(len(l), 1) - self.assertIsInstance(l[0], eolian.Variable) - - l = list(eolian_db.globals_by_file_get('efl_net_http_types.eot')) - self.assertGreater(len(l), 10) - self.assertIsInstance(l[0], eolian.Variable) + self.assertIsInstance(l[0], eolian.Constant) def test_class_listing(self): all_count = 0 @@ -473,26 +465,12 @@ class TestEolianDocumentation(unittest.TestCase): self.assertEqual(doc.since, '1.22') -class TestEolianVariable(unittest.TestCase): - def test_variable_global(self): - var = eolian_db.global_by_name_get('Efl.Net.Http.Error.BAD_CONTENT_ENCODING') - self.assertIsInstance(var, eolian.Variable) - self.assertEqual(var.name, 'Efl.Net.Http.Error.BAD_CONTENT_ENCODING') - self.assertEqual(var.short_name, 'BAD_CONTENT_ENCODING') - self.assertEqual(var.type, eolian.Eolian_Variable_Type.GLOBAL) - self.assertEqual(var.file, 'efl_net_http_types.eot') - self.assertFalse(var.is_extern) - self.assertEqual(list(var.namespaces), ['Efl','Net','Http','Error']) - self.assertIsInstance(var.documentation, eolian.Documentation) - self.assertIsInstance(var.base_type, eolian.Type) - self.assertIsNone(var.value) # TODO is None correct here? no value? - - def test_variable_constant(self): +class TestEolianConstant(unittest.TestCase): + def test_constant(self): var = eolian_db.constant_by_name_get('Efl.Gfx.Hint_Expand') - self.assertIsInstance(var, eolian.Variable) + self.assertIsInstance(var, eolian.Constant) self.assertEqual(var.name, 'Efl.Gfx.Hint_Expand') self.assertEqual(var.short_name, 'Hint_Expand') - self.assertEqual(var.type, eolian.Eolian_Variable_Type.CONSTANT) self.assertEqual(var.file, 'efl_gfx_hint.eo') self.assertFalse(var.is_extern) self.assertEqual(list(var.namespaces), ['Efl','Gfx']) diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 1a8f9eebcd..a6a6d744b4 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -765,7 +765,7 @@ EFL_END_TEST EFL_START_TEST(eolian_var) { - const Eolian_Variable *var = NULL; + const Eolian_Constant *var = NULL; const Eolian_Expression *exp = NULL; const Eolian_Type *type = NULL; const Eolian_Class *class; @@ -785,12 +785,11 @@ EFL_START_TEST(eolian_var) /* regular constant */ fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Foo"))); - fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); - fail_if(eolian_variable_is_extern(var)); - fail_if(!(type = eolian_variable_base_type_get(var))); + fail_if(eolian_constant_is_extern(var)); + fail_if(!(type = eolian_constant_base_type_get(var))); fail_if(!(name = eolian_type_short_name_get(type))); fail_if(strcmp(name, "int")); - fail_if(!(exp = eolian_variable_value_get(var))); + fail_if(!(exp = eolian_constant_value_get(var))); v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); fail_if(v.type != EOLIAN_EXPR_INT); fail_if(v.value.i != 5); @@ -849,7 +848,7 @@ EFL_END_TEST EFL_START_TEST(eolian_enum) { const Eolian_Enum_Type_Field *field = NULL; - const Eolian_Variable *var = NULL; + const Eolian_Constant *var = NULL; const Eolian_Typedecl *tdl = NULL; const Eolian_Type *type = NULL; const Eolian_Class *class; @@ -914,19 +913,16 @@ EFL_START_TEST(eolian_enum) eina_stringshare_del(cname); fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Bah"))); - fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); - fail_if(eolian_variable_is_extern(var)); - fail_if(!(type = eolian_variable_base_type_get(var))); + fail_if(!(type = eolian_constant_base_type_get(var))); fail_if(!(name = eolian_type_short_name_get(type))); fail_if(strcmp(name, "Baz")); - fail_if(!(exp = eolian_variable_value_get(var))); + fail_if(!(exp = eolian_constant_value_get(var))); v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); fail_if(v.type != EOLIAN_EXPR_INT); fail_if(v.value.i != (1 << 0)); fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Pants"))); - fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT); - fail_if(!(exp = eolian_variable_value_get(var))); + fail_if(!(exp = eolian_constant_value_get(var))); v = eolian_expression_eval(exp, EOLIAN_MASK_ALL); fail_if(v.type != EOLIAN_EXPR_INT); fail_if(v.value.i != 5); @@ -1032,7 +1028,7 @@ EFL_START_TEST(eolian_docs) const Eolian_Typedecl *tdl; const Eolian_Class *class; const Eolian_Event *event; - const Eolian_Variable *var; + const Eolian_Constant *var; const Eolian_Function *fid; const Eolian_Documentation *doc; const Eolian_Function_Parameter *par; @@ -1101,7 +1097,7 @@ EFL_START_TEST(eolian_docs) fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF); txt = eolian_doc_token_text_get(&tok); fail_if(strcmp(txt, "pants")); - fail_if(eolian_doc_token_ref_resolve(&tok, eos, NULL, NULL) != EOLIAN_OBJECT_VARIABLE); + fail_if(eolian_doc_token_ref_resolve(&tok, eos, NULL, NULL) != EOLIAN_OBJECT_CONSTANT); free(txt); tdoc = eolian_documentation_tokenize(tdoc, &tok); fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT); @@ -1181,7 +1177,7 @@ EFL_START_TEST(eolian_docs) "2.0")); fail_if(!(var = eolian_unit_constant_by_name_get(unit, "pants"))); - fail_if(!(doc = eolian_variable_documentation_get(var))); + fail_if(!(doc = eolian_constant_documentation_get(var))); fail_if(strcmp(eolian_documentation_summary_get(doc), "Docs for var.")); fail_if(eolian_documentation_description_get(doc));