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;
}
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)
{
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 */");
{
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));
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;
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);
}
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 <see> 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
struct constant_definition_generator
{
template<typename OutputIterator, typename Context>
- 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))
// Constants
{
auto var_cxt = context_add_tag(class_context{class_context::variables}, context);
- for (efl::eina::iterator<const Eolian_Variable> var_iterator( ::eolian_state_constants_by_file_get(opts.state, basename_input.c_str()))
+ for (efl::eina::iterator<const Eolian_Constant> 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");
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;
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,
| 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;
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);
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);
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);
STRUCT_FIELD = 3,
ENUM_FIELD = 4,
TYPE = 5,
- VARIABLE = 6,
+ CONSTANT = 6,
EXPRESSION = 7,
FUNCTION = 8,
FUNCTION_PARAMETER = 9,
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
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)))
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,
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,
}
})
-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
}
})
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
*/
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
*
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,
| 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;
* 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
* @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.
*
* 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.
*
EAPI Eina_Iterator *eolian_unit_classes_get(const Eolian_Unit *unit);
/*
- * @brief Get a global 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_global_by_name_get(const Eolian_Unit *unit, const char *name);
-
-/*
- * @brief Get a constant 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_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.
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
*
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.
*
* @return the iterator or NULL
*
* 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.
}
/*
- * @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.
*
* @see eolian_unit_constant_by_name_get
*
* @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);
}
/*
- * @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.
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.
*
* @see eolian_unit_constants_get
EAPI Eolian_Value eolian_expression_value_get(const Eolian_Expression *expr);
/*
- * @brief Get the type of a variable (global, 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.
+ * @brief Get the documentation of a constant.
*
- * @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));
}
switch (obj->type)
{
case EOLIAN_OBJECT_TYPEDECL:
- case EOLIAN_OBJECT_VARIABLE:
+ case EOLIAN_OBJECT_CONSTANT:
_add_dep(depset, obj->unit);
default:
break;
}
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;
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;
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;
}
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;
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))
}
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
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;
#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);
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);
-}
#include <Eina.h>
#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;
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);
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), \
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 *
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;
break;
}
goto end;
- case EOLIAN_OBJECT_VARIABLE:
- return "variable";
+ case EOLIAN_OBJECT_CONSTANT:
+ return "constant";
default:
break;
}
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;
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)
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);
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:
{
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;
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));
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);
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);
_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);
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);
_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);
}
_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);
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);
}
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)
{
if (!state) return NULL;
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;
}
}
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)
{
return (unit ? eina_hash_iterator_data_new(unit->errors) : NULL);
Eolian_State *state;
Eina_Hash *children;
Eina_Hash *classes;
- Eina_Hash *globals;
Eina_Hash *constants;
Eina_Hash *errors;
Eina_Hash *aliases;
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;
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;
/* 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);
}
}
-enum class variable_type
-{
- unknown,
- constant,
- global
-};
-
struct type_def;
bool operator==(type_def const& lhs, type_def const& rhs);
}
};
-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<std::string> 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<variable_type>(::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<const char> namespace_iterator( ::eolian_variable_namespaces_get(variable))
+ for(efl::eina::iterator<const char> 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);
}
};
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
@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):
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)))
return Expression(c_expr) if c_expr is not None else None
-class Variable(Object):
+class Constant(Object):
def __repr__(self):
- return "<eolian.Variable '{0.name}', type={0.type!s}, file={0.file}>".format(self)
-
- @cached_property
- def type(self):
- return Eolian_Variable_Type(lib.eolian_variable_type_get(self))
+ return "<eolian.Constant '{0.name}', type={0.type!s}, file={0.file}>".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
STRUCT_FIELD = 3
ENUM_FIELD = 4
TYPE = 5
- VARIABLE = 6
+ CONSTANT = 6
EXPRESSION = 7
FUNCTION = 8
FUNCTION_PARAMETER = 9
_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,
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
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
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);
lib.eolian_expression_unary_expression_get.argtypes = (c_void_p,)
lib.eolian_expression_unary_expression_get.restype = c_void_p
-### Eolian_Variable #########################################################
-
-# 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
+### Eolian_Constant #########################################################
-# 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_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_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_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_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 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 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 ####################################################
'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
'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,
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
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'])
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;
/* 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);
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;
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);
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;
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);
"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));