forked from enlightenment/efl
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.
This commit is contained in:
parent
553ce69bad
commit
92da64a532
|
@ -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 *n = strdup(eolian_object_name_get(decl));
|
||||||
char *p = n;
|
char *p = n;
|
||||||
while ((p = strchr(p, '.'))) *p = '_';
|
while ((p = strchr(p, '.'))) *p = '_';
|
||||||
if (eolian_object_type_get(decl) == EOLIAN_OBJECT_VARIABLE)
|
if (eolian_object_type_get(decl) == EOLIAN_OBJECT_CONSTANT)
|
||||||
{
|
eina_str_toupper(&n);
|
||||||
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);
|
|
||||||
}
|
|
||||||
eina_strbuf_append(wbuf, n);
|
eina_strbuf_append(wbuf, n);
|
||||||
free(n);
|
free(n);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -168,12 +168,12 @@ _type_generate(const Eolian_State *state, const Eolian_Typedecl *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Strbuf *
|
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, '.');
|
char *p = strrchr(fn, '.');
|
||||||
if (p) *p = '\0';
|
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);
|
fn, 0);
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
|
@ -184,31 +184,23 @@ _var_generate(const Eolian_State *state, const Eolian_Variable *vr)
|
||||||
eina_str_toupper(&fn);
|
eina_str_toupper(&fn);
|
||||||
if (!buf) buf = eina_strbuf_new();
|
if (!buf) buf = eina_strbuf_new();
|
||||||
else eina_strbuf_append_char(buf, '\n');
|
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);
|
||||||
/* we generate a define macro here, as it's a constant */
|
eina_strbuf_append_printf(buf, "#define %s ", fn);
|
||||||
eina_strbuf_prepend_printf(buf, "#ifndef %s\n", fn);
|
const Eolian_Expression *vv = eolian_constant_value_get(vr);
|
||||||
eina_strbuf_append_printf(buf, "#define %s ", fn);
|
Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL);
|
||||||
const Eolian_Expression *vv = eolian_variable_value_get(vr);
|
Eina_Stringshare *lit = eolian_expression_value_to_literal(&val);
|
||||||
Eolian_Value val = eolian_expression_eval(vv, EOLIAN_MASK_ALL);
|
eina_strbuf_append(buf, lit);
|
||||||
Eina_Stringshare *lit = eolian_expression_value_to_literal(&val);
|
Eina_Stringshare *exp = eolian_expression_serialize(vv);
|
||||||
eina_strbuf_append(buf, lit);
|
if (exp && strcmp(lit, exp))
|
||||||
Eina_Stringshare *exp = eolian_expression_serialize(vv);
|
eina_strbuf_append_printf(buf, " /* %s */", exp);
|
||||||
if (exp && strcmp(lit, exp))
|
eina_stringshare_del(lit);
|
||||||
eina_strbuf_append_printf(buf, " /* %s */", exp);
|
eina_stringshare_del(exp);
|
||||||
eina_stringshare_del(lit);
|
eina_strbuf_append(buf, "\n#endif");
|
||||||
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);
|
|
||||||
}
|
|
||||||
free(fn);
|
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_prepend(buf, "#ifdef EFL_BETA_API_SUPPORT\n");
|
||||||
eina_strbuf_append(buf, "\n#endif /* EFL_BETA_API_SUPPORT */");
|
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);
|
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;
|
const Eolian_Constant *vr = (const Eolian_Constant *)decl;
|
||||||
if (!vr || eolian_variable_is_extern(vr))
|
if (!vr || eolian_constant_is_extern(vr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Eina_Strbuf *vbuf = _var_generate(state, vr);
|
Eina_Strbuf *vbuf = _const_generate(state, vr);
|
||||||
if (vbuf)
|
if (vbuf)
|
||||||
{
|
{
|
||||||
eina_strbuf_append(buf, eina_strbuf_string_get(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");
|
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)
|
void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf)
|
||||||
{
|
{
|
||||||
const Eolian_Object *decl;
|
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)
|
if (dt == EOLIAN_OBJECT_ERROR)
|
||||||
_source_gen_error(buf, (const Eolian_Error *)decl);
|
_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);
|
eina_iterator_free(itr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,17 +187,12 @@ struct documentation_generator
|
||||||
ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail);
|
ref += function_conversion(data, (const ::Eolian_Function *)data2, name_tail);
|
||||||
is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2);
|
is_beta = eolian_object_is_beta(data) || eolian_object_is_beta(data2);
|
||||||
break;
|
break;
|
||||||
case ::EOLIAN_OBJECT_VARIABLE:
|
case ::EOLIAN_OBJECT_CONSTANT:
|
||||||
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
|
||||||
auto names = utils::split(name_helpers::managed_namespace(::eolian_object_name_get(data)), '.');
|
ref = name_helpers::join_namespaces(names, '.');
|
||||||
names.pop_back(); // Remove var name
|
ref += "Constants.";
|
||||||
ref = name_helpers::join_namespaces(names, '.');
|
ref += name_helpers::managed_name(::eolian_object_short_name_get(data));
|
||||||
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?
|
|
||||||
break;
|
break;
|
||||||
case ::EOLIAN_OBJECT_UNKNOWN:
|
case ::EOLIAN_OBJECT_UNKNOWN:
|
||||||
// If the reference cannot be resolved, just return an empty string and
|
// If the reference cannot be resolved, just return an empty string and
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace eolian_mono {
|
||||||
struct constant_definition_generator
|
struct constant_definition_generator
|
||||||
{
|
{
|
||||||
template<typename OutputIterator, typename Context>
|
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
|
// Open partial class
|
||||||
if (!name_helpers::open_namespaces(sink, constant.namespaces, context))
|
if (!name_helpers::open_namespaces(sink, constant.namespaces, context))
|
||||||
|
|
|
@ -177,10 +177,10 @@ run(options_type const& opts)
|
||||||
// Constants
|
// Constants
|
||||||
{
|
{
|
||||||
auto var_cxt = context_add_tag(class_context{class_context::variables}, context);
|
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)
|
, 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))
|
if (!eolian_mono::constant_definition.generate(iterator, var, var_cxt))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Failed to generate enum");
|
throw std::runtime_error("Failed to generate enum");
|
||||||
|
|
|
@ -25,7 +25,7 @@ ffi.cdef [[
|
||||||
typedef struct _Eolian_Constructor Eolian_Constructor;
|
typedef struct _Eolian_Constructor Eolian_Constructor;
|
||||||
typedef struct _Eolian_Event Eolian_Event;
|
typedef struct _Eolian_Event Eolian_Event;
|
||||||
typedef struct _Eolian_Expression Eolian_Expression;
|
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_Error Eolian_Error;
|
||||||
typedef struct _Eolian_Struct_Type_Field Eolian_Struct_Type_Field;
|
typedef struct _Eolian_Struct_Type_Field Eolian_Struct_Type_Field;
|
||||||
typedef struct _Eolian_Enum_Type_Field Eolian_Enum_Type_Field;
|
typedef struct _Eolian_Enum_Type_Field Eolian_Enum_Type_Field;
|
||||||
|
@ -43,7 +43,7 @@ ffi.cdef [[
|
||||||
EOLIAN_OBJECT_STRUCT_FIELD,
|
EOLIAN_OBJECT_STRUCT_FIELD,
|
||||||
EOLIAN_OBJECT_ENUM_FIELD,
|
EOLIAN_OBJECT_ENUM_FIELD,
|
||||||
EOLIAN_OBJECT_TYPE,
|
EOLIAN_OBJECT_TYPE,
|
||||||
EOLIAN_OBJECT_VARIABLE,
|
EOLIAN_OBJECT_CONSTANT,
|
||||||
EOLIAN_OBJECT_EXPRESSION,
|
EOLIAN_OBJECT_EXPRESSION,
|
||||||
EOLIAN_OBJECT_FUNCTION,
|
EOLIAN_OBJECT_FUNCTION,
|
||||||
EOLIAN_OBJECT_FUNCTION_PARAMETER,
|
EOLIAN_OBJECT_FUNCTION_PARAMETER,
|
||||||
|
@ -207,12 +207,6 @@ ffi.cdef [[
|
||||||
| EOLIAN_MASK_NULL
|
| EOLIAN_MASK_NULL
|
||||||
} Eolian_Expression_Mask;
|
} Eolian_Expression_Mask;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
EOLIAN_VAR_UNKNOWN = 0,
|
|
||||||
EOLIAN_VAR_CONSTANT,
|
|
||||||
EOLIAN_VAR_GLOBAL
|
|
||||||
} Eolian_Variable_Type;
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
char c;
|
char c;
|
||||||
Eina_Bool b;
|
Eina_Bool b;
|
||||||
|
@ -325,11 +319,9 @@ ffi.cdef [[
|
||||||
Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit);
|
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);
|
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);
|
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_Constant *eolian_unit_constant_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_Error *eolian_unit_error_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_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);
|
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_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);
|
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_unit_enums_get(const Eolian_Unit *unit);
|
||||||
Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name);
|
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);
|
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_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_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);
|
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);
|
Eolian_Unary_Operator eolian_expression_unary_operator_get(const Eolian_Expression *expr);
|
||||||
const Eolian_Expression *eolian_expression_unary_expression_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_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_constant_documentation_get(const Eolian_Constant *var);
|
||||||
const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var);
|
const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var);
|
||||||
const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var);
|
const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var);
|
||||||
const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var);
|
Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var);
|
||||||
Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var);
|
|
||||||
const char *eolian_documentation_summary_get(const Eolian_Documentation *doc);
|
const char *eolian_documentation_summary_get(const Eolian_Documentation *doc);
|
||||||
const char *eolian_documentation_description_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);
|
const char *eolian_documentation_since_get(const Eolian_Documentation *doc);
|
||||||
|
@ -522,7 +512,7 @@ M.object_type = {
|
||||||
STRUCT_FIELD = 3,
|
STRUCT_FIELD = 3,
|
||||||
ENUM_FIELD = 4,
|
ENUM_FIELD = 4,
|
||||||
TYPE = 5,
|
TYPE = 5,
|
||||||
VARIABLE = 6,
|
CONSTANT = 6,
|
||||||
EXPRESSION = 7,
|
EXPRESSION = 7,
|
||||||
FUNCTION = 8,
|
FUNCTION = 8,
|
||||||
FUNCTION_PARAMETER = 9,
|
FUNCTION_PARAMETER = 9,
|
||||||
|
@ -674,12 +664,6 @@ local unit_idx, wrap_unit = gen_wrap {
|
||||||
eolian.eolian_unit_classes_get(cast_unit(self)))
|
eolian.eolian_unit_classes_get(cast_unit(self)))
|
||||||
end,
|
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)
|
constant_by_name_get = function(self, name)
|
||||||
local v = eolian.eolian_unit_constant_by_name_get(cast_unit(self), name)
|
local v = eolian.eolian_unit_constant_by_name_get(cast_unit(self), name)
|
||||||
if v == nil then return nil end
|
if v == nil then return nil end
|
||||||
|
@ -693,15 +677,10 @@ local unit_idx, wrap_unit = gen_wrap {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
constants_get = function(self)
|
constants_get = function(self)
|
||||||
return Ptr_Iterator("const Eolian_Variable *",
|
return Ptr_Iterator("const Eolian_Constant *",
|
||||||
eolian.eolian_unit_constants_get(cast_unit(self)))
|
eolian.eolian_unit_constants_get(cast_unit(self)))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
globals_get = function(self)
|
|
||||||
return Ptr_Iterator("const Eolian_Variable *",
|
|
||||||
eolian.eolian_unit_globals_get(cast_unit(self)))
|
|
||||||
end,
|
|
||||||
|
|
||||||
errors_get = function(self)
|
errors_get = function(self)
|
||||||
return Ptr_Iterator("const Eolian_Error *",
|
return Ptr_Iterator("const Eolian_Error *",
|
||||||
eolian.eolian_unit_errors_get(cast_unit(self)))
|
eolian.eolian_unit_errors_get(cast_unit(self)))
|
||||||
|
@ -860,13 +839,8 @@ ffi.metatype("Eolian_State", {
|
||||||
return v
|
return v
|
||||||
end,
|
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)
|
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))
|
eolian.eolian_state_constants_by_file_get(self, fname))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -1606,12 +1580,6 @@ emask.NUMBER = bit.bor(emask.INT , emask.FLOAT)
|
||||||
emask.ALL = bit.bor(emask.NUMBER, emask.BOOL,
|
emask.ALL = bit.bor(emask.NUMBER, emask.BOOL,
|
||||||
emask.STRING, emask.CHAR, emask.NULL)
|
emask.STRING, emask.CHAR, emask.NULL)
|
||||||
|
|
||||||
M.variable_type = {
|
|
||||||
UNKNOWN = 0,
|
|
||||||
CONSTANT = 1,
|
|
||||||
GLOBAL = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
local value_con = {
|
local value_con = {
|
||||||
[etype.INT ] = function(v) return tonumber(v.value.i ) end,
|
[etype.INT ] = function(v) return tonumber(v.value.i ) end,
|
||||||
[etype.UINT ] = function(v) return tonumber(v.value.u ) 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 {
|
__index = wrap_object {
|
||||||
type_get = function(self)
|
|
||||||
return tonumber(eolian.eolian_variable_type_get(self))
|
|
||||||
end,
|
|
||||||
|
|
||||||
documentation_get = function(self)
|
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
|
if v == nil then return nil end
|
||||||
return v
|
return v
|
||||||
end,
|
end,
|
||||||
|
|
||||||
base_type_get = function(self)
|
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
|
if v == nil then return nil end
|
||||||
return v
|
return v
|
||||||
end,
|
end,
|
||||||
|
|
||||||
value_get = function(self)
|
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
|
if v == nil then return nil end
|
||||||
return v
|
return v
|
||||||
end,
|
end,
|
||||||
|
|
||||||
is_extern = function(self)
|
is_extern = function(self)
|
||||||
return eolian.eolian_variable_is_extern(self) ~= 0
|
return eolian.eolian_constant_is_extern(self) ~= 0
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1890,8 +1854,8 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", {
|
||||||
elseif tp == reft.ENUM_FIELD then
|
elseif tp == reft.ENUM_FIELD then
|
||||||
return tp, ffi.cast("const Eolian_Typedecl *", stor[0]),
|
return tp, ffi.cast("const Eolian_Typedecl *", stor[0]),
|
||||||
ffi.cast("const Eolian_Enum_Type_Field *", stor[1])
|
ffi.cast("const Eolian_Enum_Type_Field *", stor[1])
|
||||||
elseif tp == reft.VARIABLE then
|
elseif tp == reft.CONSTANT then
|
||||||
return tp, ffi.cast("const Eolian_Variable *", stor[0])
|
return tp, ffi.cast("const Eolian_Constant *", stor[0])
|
||||||
else
|
else
|
||||||
return reft.UNKNOWN
|
return reft.UNKNOWN
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,11 +164,11 @@ typedef struct _Eolian_Event Eolian_Event;
|
||||||
*/
|
*/
|
||||||
typedef struct _Eolian_Expression Eolian_Expression;
|
typedef struct _Eolian_Expression Eolian_Expression;
|
||||||
|
|
||||||
/* Variable information
|
/* Constant information
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
typedef struct _Eolian_Variable Eolian_Variable;
|
typedef struct _Eolian_Constant Eolian_Constant;
|
||||||
|
|
||||||
/* Error information
|
/* Error information
|
||||||
*
|
*
|
||||||
|
@ -220,7 +220,7 @@ typedef enum
|
||||||
EOLIAN_OBJECT_STRUCT_FIELD,
|
EOLIAN_OBJECT_STRUCT_FIELD,
|
||||||
EOLIAN_OBJECT_ENUM_FIELD,
|
EOLIAN_OBJECT_ENUM_FIELD,
|
||||||
EOLIAN_OBJECT_TYPE,
|
EOLIAN_OBJECT_TYPE,
|
||||||
EOLIAN_OBJECT_VARIABLE,
|
EOLIAN_OBJECT_CONSTANT,
|
||||||
EOLIAN_OBJECT_EXPRESSION,
|
EOLIAN_OBJECT_EXPRESSION,
|
||||||
EOLIAN_OBJECT_FUNCTION,
|
EOLIAN_OBJECT_FUNCTION,
|
||||||
EOLIAN_OBJECT_FUNCTION_PARAMETER,
|
EOLIAN_OBJECT_FUNCTION_PARAMETER,
|
||||||
|
@ -388,13 +388,6 @@ typedef enum
|
||||||
| EOLIAN_MASK_NULL
|
| EOLIAN_MASK_NULL
|
||||||
} Eolian_Expression_Mask;
|
} Eolian_Expression_Mask;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
EOLIAN_VAR_UNKNOWN = 0,
|
|
||||||
EOLIAN_VAR_CONSTANT,
|
|
||||||
EOLIAN_VAR_GLOBAL
|
|
||||||
} Eolian_Variable_Type;
|
|
||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
char c;
|
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
|
* This is the full name, but for C. It is typically derived from the
|
||||||
* regular full name, with namespaces flattened to underscores, but
|
* regular full name, with namespaces flattened to underscores, but
|
||||||
* some things may be explicitly renamed. Only classes, types (both
|
* 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.
|
* are never referred to by name directly in C.
|
||||||
*
|
*
|
||||||
* @see eolian_object_unit_get
|
* @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.
|
* @brief Get an object in a unit by name.
|
||||||
*
|
*
|
||||||
* Only objects declared directly within the file can be retrieved, i.e.
|
* 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] unit The unit.
|
||||||
* @param[in] name The fully namespaced object name.
|
* @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
|
* The order is not necessarily the declaration order. Only objects declared
|
||||||
* directly within the file can be retrieved, i.e. classes, typedecls and
|
* directly within the file can be retrieved, i.e. classes, typedecls and
|
||||||
* variables.
|
* constants.
|
||||||
*
|
*
|
||||||
* @param[in] unit The unit.
|
* @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);
|
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] unit The unit.
|
||||||
* @param[in] name the name of the variable
|
* @param[in] name the name of the constant
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
EAPI const Eolian_Variable *eolian_unit_global_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 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);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get an error declaration in a unit by 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);
|
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
|
* @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);
|
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.
|
* @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
|
* The list follows declaration order in the file. Only objects declared
|
||||||
* directly within the file can be retrieved, i.e. classes, typedecls and
|
* directly within the file can be retrieved, i.e. classes, typedecls and
|
||||||
* variables.
|
* constants.
|
||||||
*
|
*
|
||||||
* @param[in] state The state.
|
* @param[in] state The state.
|
||||||
* @param[in] file_name The file name.
|
* @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));
|
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.
|
* @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
|
* @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)
|
eolian_state_constant_by_name_get(const Eolian_State *state, const char *name)
|
||||||
{
|
{
|
||||||
return eolian_unit_constant_by_name_get(EOLIAN_UNIT(state), 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.
|
* @brief Get an iterator to all constants 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.
|
|
||||||
*
|
*
|
||||||
* @param[in] state The state.
|
* @param[in] state The state.
|
||||||
* @param[in] file_name The file name.
|
* @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);
|
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.
|
* @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);
|
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.
|
* @param[in] var the constant.
|
||||||
* @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.
|
|
||||||
* @return the documentation or NULL.
|
* @return the documentation or NULL.
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @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.
|
* @return the base type or NULL.
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @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.
|
* @return the value or NULL.
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @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
|
* @see eolian_object_name_get
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
static inline const char *
|
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));
|
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
|
* @see eolian_object_c_name_get
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
static inline const char *
|
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));
|
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
|
* @see eolian_object_short_name_get
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
static inline const char *
|
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));
|
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
|
* @see eolian_object_namespaces_get
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
static inline Eina_Iterator *
|
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));
|
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.
|
* @return EINA_TRUE if it's extern, EINA_FALSE otherwise.
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @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
|
* @see eolian_object_is_beta
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool
|
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));
|
return eolian_object_is_beta(EOLIAN_OBJECT(var));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ _check_expr_cb(const Eolian_Object *obj, void *data)
|
||||||
switch (obj->type)
|
switch (obj->type)
|
||||||
{
|
{
|
||||||
case EOLIAN_OBJECT_TYPEDECL:
|
case EOLIAN_OBJECT_TYPEDECL:
|
||||||
case EOLIAN_OBJECT_VARIABLE:
|
case EOLIAN_OBJECT_CONSTANT:
|
||||||
_add_dep(depset, obj->unit);
|
_add_dep(depset, obj->unit);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -195,7 +195,7 @@ _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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))
|
if (_check_cycle(chash, &v->base))
|
||||||
return;
|
return;
|
||||||
|
@ -230,8 +230,8 @@ _check_unit(const Eolian_Unit *unit)
|
||||||
case EOLIAN_OBJECT_TYPEDECL:
|
case EOLIAN_OBJECT_TYPEDECL:
|
||||||
_check_typedecl((const Eolian_Typedecl *)obj, depset, chash);
|
_check_typedecl((const Eolian_Typedecl *)obj, depset, chash);
|
||||||
break;
|
break;
|
||||||
case EOLIAN_OBJECT_VARIABLE:
|
case EOLIAN_OBJECT_CONSTANT:
|
||||||
_check_variable((const Eolian_Variable *)obj, depset, chash);
|
_check_constant((const Eolian_Constant *)obj, depset, chash);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -512,7 +512,7 @@ eval_exp(const Eolian_Unit *unit, Eolian_Expression *expr,
|
||||||
return eval_exp(NULL, expr->expr, mask, out, cb, data);
|
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);
|
(unit, expr->value.s);
|
||||||
Eolian_Expression *exp = NULL;
|
Eolian_Expression *exp = NULL;
|
||||||
|
|
||||||
|
|
|
@ -1488,7 +1488,7 @@ _validate_class(Validate_State *vals, Eolian_Class *cl,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_validate_variable(Validate_State *vals, Eolian_Variable *var)
|
_validate_constant(Validate_State *vals, Eolian_Constant *var)
|
||||||
{
|
{
|
||||||
if (var->base.validated)
|
if (var->base.validated)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
@ -1498,7 +1498,7 @@ _validate_variable(Validate_State *vals, Eolian_Variable *var)
|
||||||
if (!_validate_type(vals, var->base_type))
|
if (!_validate_type(vals, var->base_type))
|
||||||
return _reset_stable(vals, was_stable, EINA_FALSE);
|
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);
|
return _reset_stable(vals, was_stable, EINA_FALSE);
|
||||||
|
|
||||||
if (!_validate_doc(var->doc))
|
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
|
static Eina_Bool
|
||||||
_var_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
_constant_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
|
||||||
Eolian_Variable *var, Cb_Ret *sc)
|
Eolian_Constant *var, Cb_Ret *sc)
|
||||||
{
|
{
|
||||||
return (sc->succ = _validate_variable(sc->vals, var));
|
return (sc->succ = _validate_constant(sc->vals, var));
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
|
@ -1597,11 +1597,7 @@ database_validate(const Eolian_Unit *src)
|
||||||
if (!rt.succ)
|
if (!rt.succ)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
eina_hash_foreach(src->globals, (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;
|
|
||||||
|
|
||||||
eina_hash_foreach(src->constants, (Eina_Hash_Foreach)_var_map_cb, &rt);
|
|
||||||
if (!rt.succ)
|
if (!rt.succ)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "eo_lexer.h"
|
#include "eo_lexer.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
database_var_del(Eolian_Variable *var)
|
database_constant_del(Eolian_Constant *var)
|
||||||
{
|
{
|
||||||
if (!var || eolian_object_unref(&var->base)) return;
|
if (!var || eolian_object_unref(&var->base)) return;
|
||||||
eina_stringshare_del(var->base.file);
|
eina_stringshare_del(var->base.file);
|
||||||
|
@ -19,29 +19,11 @@ database_var_del(Eolian_Variable *var)
|
||||||
free(var);
|
free(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
database_var_global_add(Eolian_Unit *unit, Eolian_Variable *var)
|
database_constant_add(Eolian_Unit *unit, Eolian_Constant *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)
|
|
||||||
{
|
{
|
||||||
EOLIAN_OBJECT_ADD(unit, var->base.name, var, constants);
|
EOLIAN_OBJECT_ADD(unit, var->base.name, var, constants);
|
||||||
eina_hash_set(unit->state->staging.constants_f, var->base.file, eina_list_append
|
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));
|
((Eina_List*)eina_hash_find(unit->state->staging.constants_f, var->base.file), var));
|
||||||
database_object_add(unit, &var->base);
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,36 +5,29 @@
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
#include "eolian_database.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 *
|
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);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL);
|
||||||
return var->doc;
|
return var->doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const Eolian_Type *
|
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);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL);
|
||||||
return var->base_type;
|
return var->base_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const Eolian_Expression *
|
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);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(var, NULL);
|
||||||
return var->value;
|
return var->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
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);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(var, EINA_FALSE);
|
||||||
return var->is_extern;
|
return var->is_extern;
|
||||||
|
|
|
@ -1056,8 +1056,8 @@ _node_free(Eolian_Object *obj)
|
||||||
case EOLIAN_OBJECT_TYPE:
|
case EOLIAN_OBJECT_TYPE:
|
||||||
database_type_del((Eolian_Type *)obj);
|
database_type_del((Eolian_Type *)obj);
|
||||||
break;
|
break;
|
||||||
case EOLIAN_OBJECT_VARIABLE:
|
case EOLIAN_OBJECT_CONSTANT:
|
||||||
database_var_del((Eolian_Variable *)obj);
|
database_constant_del((Eolian_Constant *)obj);
|
||||||
break;
|
break;
|
||||||
case EOLIAN_OBJECT_EXPRESSION:
|
case EOLIAN_OBJECT_EXPRESSION:
|
||||||
database_expr_del((Eolian_Expression *)obj);
|
database_expr_del((Eolian_Expression *)obj);
|
||||||
|
|
|
@ -31,7 +31,7 @@ enum Tokens
|
||||||
KW(data), KW(destructor), KW(error), KW(event_prefix), KW(events), KW(extends), \
|
KW(data), KW(destructor), KW(error), KW(event_prefix), KW(events), KW(extends), \
|
||||||
KW(free), KW(get), KW(implements), KW(import), KW(interface), \
|
KW(free), KW(get), KW(implements), KW(import), KW(interface), \
|
||||||
KW(keys), KW(legacy), KW(methods), KW(mixin), KW(params), \
|
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(auto), KWAT(beta), KWAT(by_ref), KWAT(c_name), KWAT(const), \
|
||||||
KWAT(empty), KWAT(extern), KWAT(free), KWAT(hot), KWAT(in), KWAT(inout), \
|
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);
|
return (Eolian_Typedecl *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Eolian_Variable *
|
static inline Eolian_Constant *
|
||||||
eo_lexer_variable_new(Eo_Lexer *ls)
|
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 *
|
static inline Eolian_Constant *
|
||||||
eo_lexer_variable_release(Eo_Lexer *ls, Eolian_Variable *var)
|
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 *
|
static inline Eolian_Expression *
|
||||||
|
|
|
@ -125,7 +125,7 @@ _eolian_decl_get(Eo_Lexer *ls, const char *name)
|
||||||
obj = eina_hash_find(ls->state->staging.unit.objects, name);
|
obj = eina_hash_find(ls->state->staging.unit.objects, name);
|
||||||
if (obj && ((obj->type == EOLIAN_OBJECT_CLASS) ||
|
if (obj && ((obj->type == EOLIAN_OBJECT_CLASS) ||
|
||||||
(obj->type == EOLIAN_OBJECT_TYPEDECL) ||
|
(obj->type == EOLIAN_OBJECT_TYPEDECL) ||
|
||||||
(obj->type == EOLIAN_OBJECT_VARIABLE)))
|
(obj->type == EOLIAN_OBJECT_CONSTANT)))
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -152,8 +152,8 @@ _eolian_decl_name_get(Eolian_Object *obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
case EOLIAN_OBJECT_VARIABLE:
|
case EOLIAN_OBJECT_CONSTANT:
|
||||||
return "variable";
|
return "constant";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -879,10 +879,10 @@ tags_done:
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eolian_Variable *
|
static Eolian_Constant *
|
||||||
parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
parse_constant(Eo_Lexer *ls)
|
||||||
{
|
{
|
||||||
Eolian_Variable *def = eo_lexer_variable_new(ls);
|
Eolian_Constant *def = eo_lexer_constant_new(ls);
|
||||||
Eina_Strbuf *buf;
|
Eina_Strbuf *buf;
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
Eina_Stringshare *cname = NULL;
|
Eina_Stringshare *cname = NULL;
|
||||||
|
@ -908,11 +908,10 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
||||||
goto tags_done;
|
goto tags_done;
|
||||||
}
|
}
|
||||||
tags_done:
|
tags_done:
|
||||||
def->type = global ? EOLIAN_VAR_GLOBAL : EOLIAN_VAR_CONSTANT;
|
|
||||||
buf = eina_strbuf_new();
|
buf = eina_strbuf_new();
|
||||||
eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
|
eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
|
||||||
eo_lexer_context_push(ls);
|
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);
|
parse_name(ls, buf);
|
||||||
def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
def->base.name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
||||||
if (cname)
|
if (cname)
|
||||||
|
@ -932,17 +931,12 @@ tags_done:
|
||||||
check_next(ls, ':');
|
check_next(ls, ':');
|
||||||
def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
|
def->base_type = eo_lexer_type_release(ls, parse_type(ls, EINA_TRUE));
|
||||||
/* constants are required to have a value */
|
/* constants are required to have a value */
|
||||||
if (!global)
|
check(ls, '=');
|
||||||
check(ls, '=');
|
ls->expr_mode = EINA_TRUE;
|
||||||
/* globals can optionally have a value */
|
eo_lexer_get(ls);
|
||||||
if (ls->t.token == '=')
|
def->value = parse_expr(ls);
|
||||||
{
|
ls->expr_mode = EINA_FALSE;
|
||||||
ls->expr_mode = EINA_TRUE;
|
eo_lexer_expr_release_ref(ls, def->value);
|
||||||
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, ';');
|
check_next(ls, ';');
|
||||||
FILL_DOC(ls, def, doc);
|
FILL_DOC(ls, def, doc);
|
||||||
eo_lexer_dtor_pop(ls);
|
eo_lexer_dtor_pop(ls);
|
||||||
|
@ -2401,10 +2395,8 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KW_const:
|
case KW_const:
|
||||||
case KW_var:
|
|
||||||
{
|
{
|
||||||
database_var_add(ls->unit, eo_lexer_variable_release(ls,
|
database_constant_add(ls->unit, eo_lexer_constant_release(ls, parse_constant(ls)));
|
||||||
parse_variable(ls, ls->t.kw == KW_var)));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KW_error:
|
case KW_error:
|
||||||
|
|
|
@ -491,7 +491,7 @@ database_doc_token_ref_resolve(const Eolian_Doc_Token *tok,
|
||||||
{
|
{
|
||||||
case EOLIAN_OBJECT_CLASS:
|
case EOLIAN_OBJECT_CLASS:
|
||||||
case EOLIAN_OBJECT_TYPEDECL:
|
case EOLIAN_OBJECT_TYPEDECL:
|
||||||
case EOLIAN_OBJECT_VARIABLE:
|
case EOLIAN_OBJECT_CONSTANT:
|
||||||
case EOLIAN_OBJECT_ERROR:
|
case EOLIAN_OBJECT_ERROR:
|
||||||
/* we only allow certain types to be referenced */
|
/* we only allow certain types to be referenced */
|
||||||
return tp;
|
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->children = eina_hash_stringshared_new(NULL);
|
||||||
unit->classes = eina_hash_stringshared_new(EINA_FREE_CB(database_class_del));
|
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_constant_del));
|
||||||
unit->constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
|
|
||||||
unit->errors = eina_hash_stringshared_new(EINA_FREE_CB(database_error_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->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
|
||||||
unit->structs = 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_stringshare_del(unit->file);
|
||||||
eina_hash_free(unit->children);
|
eina_hash_free(unit->children);
|
||||||
eina_hash_free(unit->classes);
|
eina_hash_free(unit->classes);
|
||||||
eina_hash_free(unit->globals);
|
|
||||||
eina_hash_free(unit->constants);
|
eina_hash_free(unit->constants);
|
||||||
eina_hash_free(unit->errors);
|
eina_hash_free(unit->errors);
|
||||||
eina_hash_free(unit->aliases);
|
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->aliases_f = eina_hash_stringshared_new(NULL);
|
||||||
a->structs_f = eina_hash_stringshared_new(NULL);
|
a->structs_f = eina_hash_stringshared_new(NULL);
|
||||||
a->enums_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->constants_f = eina_hash_stringshared_new(NULL);
|
||||||
a->errors_f = eina_hash_stringshared_new(NULL);
|
a->errors_f = eina_hash_stringshared_new(NULL);
|
||||||
a->objects_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->aliases_f);
|
||||||
_hashlist_free(a->structs_f);
|
_hashlist_free(a->structs_f);
|
||||||
_hashlist_free(a->enums_f);
|
_hashlist_free(a->enums_f);
|
||||||
_hashlist_free(a->globals_f);
|
|
||||||
_hashlist_free(a->constants_f);
|
_hashlist_free(a->constants_f);
|
||||||
_hashlist_free(a->errors_f);
|
_hashlist_free(a->errors_f);
|
||||||
_hashlist_free(a->objects_f);
|
_hashlist_free(a->objects_f);
|
||||||
|
@ -906,7 +902,6 @@ _state_clean(Eolian_State *state)
|
||||||
|
|
||||||
Eolian_Unit *stu = &st->unit;
|
Eolian_Unit *stu = &st->unit;
|
||||||
eina_hash_free_buckets(stu->classes);
|
eina_hash_free_buckets(stu->classes);
|
||||||
eina_hash_free_buckets(stu->globals);
|
|
||||||
eina_hash_free_buckets(stu->constants);
|
eina_hash_free_buckets(stu->constants);
|
||||||
eina_hash_free_buckets(stu->aliases);
|
eina_hash_free_buckets(stu->aliases);
|
||||||
eina_hash_free_buckets(stu->structs);
|
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->aliases_f);
|
||||||
_hashlist_free_buckets(st->structs_f);
|
_hashlist_free_buckets(st->structs_f);
|
||||||
_hashlist_free_buckets(st->enums_f);
|
_hashlist_free_buckets(st->enums_f);
|
||||||
_hashlist_free_buckets(st->globals_f);
|
|
||||||
_hashlist_free_buckets(st->constants_f);
|
_hashlist_free_buckets(st->constants_f);
|
||||||
_hashlist_free_buckets(st->objects_f);
|
_hashlist_free_buckets(st->objects_f);
|
||||||
}
|
}
|
||||||
|
@ -1010,7 +1004,6 @@ static void
|
||||||
_merge_unit(Eolian_Unit *dest, Eolian_Unit *src)
|
_merge_unit(Eolian_Unit *dest, Eolian_Unit *src)
|
||||||
{
|
{
|
||||||
eina_hash_foreach(src->classes, _merge_unit_cb, dest->classes);
|
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->constants, _merge_unit_cb, dest->constants);
|
||||||
eina_hash_foreach(src->aliases, _merge_unit_cb, dest->aliases);
|
eina_hash_foreach(src->aliases, _merge_unit_cb, dest->aliases);
|
||||||
eina_hash_foreach(src->structs, _merge_unit_cb, dest->structs);
|
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(aliases);
|
||||||
EOLIAN_STAGING_MERGE_LIST(structs);
|
EOLIAN_STAGING_MERGE_LIST(structs);
|
||||||
EOLIAN_STAGING_MERGE_LIST(enums);
|
EOLIAN_STAGING_MERGE_LIST(enums);
|
||||||
EOLIAN_STAGING_MERGE_LIST(globals);
|
|
||||||
EOLIAN_STAGING_MERGE_LIST(constants);
|
EOLIAN_STAGING_MERGE_LIST(constants);
|
||||||
EOLIAN_STAGING_MERGE_LIST(objects);
|
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;
|
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 *
|
EAPI Eina_Iterator *
|
||||||
eolian_state_constants_by_file_get(const Eolian_State *state, const char *file_name)
|
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);
|
return (unit ? eina_hash_iterator_data_new(unit->classes) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const Eolian_Variable *
|
EAPI const Eolian_Constant *
|
||||||
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 *
|
|
||||||
eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name)
|
eolian_unit_constant_by_name_get(const Eolian_Unit *unit, const char *name)
|
||||||
{
|
{
|
||||||
if (!unit) return NULL;
|
if (!unit) return NULL;
|
||||||
Eina_Stringshare *shr = eina_stringshare_add(name);
|
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);
|
eina_stringshare_del(shr);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -1419,12 +1390,6 @@ eolian_unit_constants_get(const Eolian_Unit *unit)
|
||||||
return (unit ? eina_hash_iterator_data_new(unit->constants) : NULL);
|
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 *
|
EAPI Eina_Iterator *
|
||||||
eolian_unit_errors_get(const Eolian_Unit *unit)
|
eolian_unit_errors_get(const Eolian_Unit *unit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,6 @@ struct _Eolian_Unit
|
||||||
Eolian_State *state;
|
Eolian_State *state;
|
||||||
Eina_Hash *children;
|
Eina_Hash *children;
|
||||||
Eina_Hash *classes;
|
Eina_Hash *classes;
|
||||||
Eina_Hash *globals;
|
|
||||||
Eina_Hash *constants;
|
Eina_Hash *constants;
|
||||||
Eina_Hash *errors;
|
Eina_Hash *errors;
|
||||||
Eina_Hash *aliases;
|
Eina_Hash *aliases;
|
||||||
|
@ -59,7 +58,6 @@ typedef struct _Eolian_State_Area
|
||||||
Eina_Hash *aliases_f;
|
Eina_Hash *aliases_f;
|
||||||
Eina_Hash *structs_f;
|
Eina_Hash *structs_f;
|
||||||
Eina_Hash *enums_f;
|
Eina_Hash *enums_f;
|
||||||
Eina_Hash *globals_f;
|
|
||||||
Eina_Hash *constants_f;
|
Eina_Hash *constants_f;
|
||||||
Eina_Hash *errors_f;
|
Eina_Hash *errors_f;
|
||||||
Eina_Hash *objects_f;
|
Eina_Hash *objects_f;
|
||||||
|
@ -394,10 +392,9 @@ struct _Eolian_Expression
|
||||||
Eina_Bool weak_rhs :1;
|
Eina_Bool weak_rhs :1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Eolian_Variable
|
struct _Eolian_Constant
|
||||||
{
|
{
|
||||||
Eolian_Object base;
|
Eolian_Object base;
|
||||||
Eolian_Variable_Type type;
|
|
||||||
Eolian_Type *base_type;
|
Eolian_Type *base_type;
|
||||||
Eolian_Expression *value;
|
Eolian_Expression *value;
|
||||||
Eolian_Documentation *doc;
|
Eolian_Documentation *doc;
|
||||||
|
@ -449,8 +446,8 @@ void database_expr_print(Eolian_Expression *expr);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
|
|
||||||
void database_var_del(Eolian_Variable *var);
|
void database_constant_del(Eolian_Constant *var);
|
||||||
void database_var_add(Eolian_Unit *unit, Eolian_Variable *var);
|
void database_constant_add(Eolian_Unit *unit, Eolian_Constant *var);
|
||||||
|
|
||||||
/* classes */
|
/* classes */
|
||||||
void database_class_del(Eolian_Class *cl);
|
void database_class_del(Eolian_Class *cl);
|
||||||
|
|
|
@ -113,13 +113,6 @@ inline typedecl_type typedecl_type_get(Eolian_Typedecl const* decl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class variable_type
|
|
||||||
{
|
|
||||||
unknown,
|
|
||||||
constant,
|
|
||||||
global
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct type_def;
|
struct type_def;
|
||||||
bool operator==(type_def const& lhs, type_def const& rhs);
|
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 name;
|
||||||
std::string full_name;
|
std::string full_name;
|
||||||
type_def base_type;
|
type_def base_type;
|
||||||
documentation_def documentation;
|
documentation_def documentation;
|
||||||
variable_type type;
|
|
||||||
std::vector<std::string> namespaces;
|
std::vector<std::string> namespaces;
|
||||||
Eolian_Value expression_value;
|
Eolian_Value expression_value;
|
||||||
bool is_extern : 1;
|
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
|
return lhs.name == rhs.name
|
||||||
&& lhs.full_name == rhs.full_name
|
&& lhs.full_name == rhs.full_name
|
||||||
&& lhs.base_type == rhs.base_type
|
&& lhs.base_type == rhs.base_type
|
||||||
&& lhs.documentation == rhs.documentation
|
&& lhs.documentation == rhs.documentation
|
||||||
&& lhs.type == rhs.type
|
|
||||||
&& lhs.namespaces == rhs.namespaces
|
&& lhs.namespaces == rhs.namespaces
|
||||||
&& lhs.expression_value.type == rhs.expression_value.type
|
&& lhs.expression_value.type == rhs.expression_value.type
|
||||||
&& lhs.expression_value.value.ll == rhs.expression_value.value.ll
|
&& lhs.expression_value.value.ll == rhs.expression_value.value.ll
|
||||||
&& lhs.is_extern == rhs.is_extern;
|
&& 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);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
variable_def() = default;
|
constant_def() = default;
|
||||||
variable_def(Eolian_Variable const* variable, Eolian_Unit const* unit)
|
constant_def(Eolian_Constant const* constant, Eolian_Unit const* unit)
|
||||||
: name(::eolian_variable_short_name_get(variable))
|
: name(::eolian_constant_short_name_get(constant))
|
||||||
, full_name(::eolian_variable_name_get(variable))
|
, full_name(::eolian_constant_name_get(constant))
|
||||||
, base_type(::eolian_variable_base_type_get(variable)
|
, base_type(::eolian_constant_base_type_get(constant)
|
||||||
, unit
|
, 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
|
, value_ownership::unmoved
|
||||||
, is_by::value)
|
, is_by::value)
|
||||||
, documentation(::eolian_variable_documentation_get(variable))
|
, documentation(::eolian_constant_documentation_get(constant))
|
||||||
, type(static_cast<variable_type>(::eolian_variable_type_get(variable)))
|
|
||||||
, expression_value()
|
, 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)
|
, namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
|
||||||
{
|
{
|
||||||
this->namespaces.push_back((&*namespace_iterator));
|
this->namespaces.push_back((&*namespace_iterator));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->type == variable_type::constant)
|
auto expr = ::eolian_constant_value_get(constant);
|
||||||
{
|
if (!expr)
|
||||||
auto expr = ::eolian_variable_value_get(variable);
|
throw std::runtime_error("Could not get constant variable value expression");
|
||||||
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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,6 @@ class Eolian_Expression_Mask(IntEnum):
|
||||||
NUMBER = INT | FLOAT
|
NUMBER = INT | FLOAT
|
||||||
ALL = NUMBER | BOOL | STRING | CHAR | NULL
|
ALL = NUMBER | BOOL | STRING | CHAR | NULL
|
||||||
|
|
||||||
class Eolian_Variable_Type(IntEnum):
|
|
||||||
UNKNOWN = 0
|
|
||||||
CONSTANT = 1
|
|
||||||
GLOBAL = 2
|
|
||||||
|
|
||||||
class Eolian_Binary_Operator(IntEnum):
|
class Eolian_Binary_Operator(IntEnum):
|
||||||
INVALID = 0
|
INVALID = 0
|
||||||
ADD = 1 # + int, float
|
ADD = 1 # + int, float
|
||||||
|
@ -350,19 +345,11 @@ class Eolian_Unit(EolianBaseObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def constants(self):
|
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):
|
def constant_by_name_get(self, name):
|
||||||
c_var = lib.eolian_unit_constant_by_name_get(self, _str_to_bytes(name))
|
c_var = lib.eolian_unit_constant_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 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enums(self):
|
def enums(self):
|
||||||
|
@ -472,13 +459,9 @@ class Eolian_State(Eolian_Unit):
|
||||||
return Class(c_cls) if c_cls else None
|
return Class(c_cls) if c_cls else None
|
||||||
|
|
||||||
def constants_by_file_get(self, file_name):
|
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)))
|
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):
|
def aliases_by_file_get(self, file_name):
|
||||||
return Iterator(Typedecl,
|
return Iterator(Typedecl,
|
||||||
lib.eolian_state_aliases_by_file_get(self, _str_to_bytes(file_name)))
|
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
|
return Expression(c_expr) if c_expr is not None else None
|
||||||
|
|
||||||
|
|
||||||
class Variable(Object):
|
class Constant(Object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<eolian.Variable '{0.name}', type={0.type!s}, file={0.file}>".format(self)
|
return "<eolian.Constant '{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))
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def value(self):
|
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
|
return Expression(c_expr) if c_expr else None
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def base_type(self):
|
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
|
return Type(c_type) if c_type else None
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def is_extern(self):
|
def is_extern(self):
|
||||||
return bool(lib.eolian_variable_is_extern(self))
|
return bool(lib.eolian_constant_is_extern(self))
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def documentation(self):
|
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
|
return Documentation(c_doc) if c_doc else None
|
||||||
|
|
||||||
|
|
||||||
|
@ -1380,7 +1359,7 @@ class _Eolian_Object_Type(IntEnum):
|
||||||
STRUCT_FIELD = 3
|
STRUCT_FIELD = 3
|
||||||
ENUM_FIELD = 4
|
ENUM_FIELD = 4
|
||||||
TYPE = 5
|
TYPE = 5
|
||||||
VARIABLE = 6
|
CONSTANT = 6
|
||||||
EXPRESSION = 7
|
EXPRESSION = 7
|
||||||
FUNCTION = 8
|
FUNCTION = 8
|
||||||
FUNCTION_PARAMETER = 9
|
FUNCTION_PARAMETER = 9
|
||||||
|
@ -1397,7 +1376,7 @@ _eolian_type_class_mapping = {
|
||||||
_Eolian_Object_Type.STRUCT_FIELD: Struct_Type_Field,
|
_Eolian_Object_Type.STRUCT_FIELD: Struct_Type_Field,
|
||||||
_Eolian_Object_Type.ENUM_FIELD: Enum_Type_Field,
|
_Eolian_Object_Type.ENUM_FIELD: Enum_Type_Field,
|
||||||
_Eolian_Object_Type.TYPE: Type,
|
_Eolian_Object_Type.TYPE: Type,
|
||||||
_Eolian_Object_Type.VARIABLE: Variable,
|
_Eolian_Object_Type.CONSTANT: Constant,
|
||||||
_Eolian_Object_Type.EXPRESSION: Expression,
|
_Eolian_Object_Type.EXPRESSION: Expression,
|
||||||
_Eolian_Object_Type.FUNCTION: Function,
|
_Eolian_Object_Type.FUNCTION: Function,
|
||||||
_Eolian_Object_Type.FUNCTION_PARAMETER: Function_Parameter,
|
_Eolian_Object_Type.FUNCTION_PARAMETER: Function_Parameter,
|
||||||
|
|
|
@ -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.argtypes = (c_void_p, c_char_p)
|
||||||
lib.eolian_state_class_by_file_get.restype = c_void_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);
|
# 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.argtypes = (c_void_p, c_char_p)
|
||||||
lib.eolian_state_constants_by_file_get.restype = c_void_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.argtypes = (c_void_p,)
|
||||||
lib.eolian_unit_enums_get.restype = 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);
|
# EAPI const Eolian_Constant *eolian_unit_constant_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);
|
|
||||||
lib.eolian_unit_constant_by_name_get.argtypes = (c_void_p, c_char_p)
|
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_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.argtypes = (c_void_p,)
|
||||||
lib.eolian_unit_constants_get.restype = 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 ###########################################################
|
### Eolian_Object ###########################################################
|
||||||
|
|
||||||
# EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj);
|
# 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.argtypes = (c_void_p,)
|
||||||
lib.eolian_expression_unary_expression_get.restype = 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);
|
# EAPI const Eolian_Documentation *eolian_constant_documentation_get(const Eolian_Constant *var);
|
||||||
lib.eolian_variable_type_get.argtypes = (c_void_p,)
|
lib.eolian_constant_documentation_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_variable_type_get.restype = c_int
|
lib.eolian_constant_documentation_get.restype = c_void_p
|
||||||
|
|
||||||
# EAPI const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var);
|
# EAPI const Eolian_Type *eolian_constant_base_type_get(const Eolian_Constant *var);
|
||||||
lib.eolian_variable_documentation_get.argtypes = (c_void_p,)
|
lib.eolian_constant_base_type_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_variable_documentation_get.restype = 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);
|
# EAPI const Eolian_Expression *eolian_constant_value_get(const Eolian_Constant *var);
|
||||||
lib.eolian_variable_base_type_get.argtypes = (c_void_p,)
|
lib.eolian_constant_value_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_variable_base_type_get.restype = c_void_p
|
lib.eolian_constant_value_get.restype = c_void_p
|
||||||
|
|
||||||
# EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var);
|
# EAPI Eina_Bool eolian_constant_is_extern(const Eolian_Constant *var);
|
||||||
lib.eolian_variable_value_get.argtypes = (c_void_p,)
|
lib.eolian_constant_is_extern.argtypes = (c_void_p,)
|
||||||
lib.eolian_variable_value_get.restype = c_void_p
|
lib.eolian_constant_is_extern.restype = c_bool
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
### Eolian_Documentation ####################################################
|
### Eolian_Documentation ####################################################
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Template(pyratemp.Template):
|
||||||
'Enum_Type_Field': eolian.Enum_Type_Field,
|
'Enum_Type_Field': eolian.Enum_Type_Field,
|
||||||
'Struct_Type_Field': eolian.Struct_Type_Field,
|
'Struct_Type_Field': eolian.Struct_Type_Field,
|
||||||
'Expression': eolian.Expression,
|
'Expression': eolian.Expression,
|
||||||
'Variable': eolian.Variable,
|
'Constant': eolian.Constant,
|
||||||
'Documentation': eolian.Documentation,
|
'Documentation': eolian.Documentation,
|
||||||
'Documentation_Token': eolian.Documentation_Token,
|
'Documentation_Token': eolian.Documentation_Token,
|
||||||
# Eolian Enums
|
# Eolian Enums
|
||||||
|
@ -139,7 +139,6 @@ class Template(pyratemp.Template):
|
||||||
'Eolian_C_Type_Type': eolian.Eolian_C_Type_Type,
|
'Eolian_C_Type_Type': eolian.Eolian_C_Type_Type,
|
||||||
'Eolian_Expression_Type': eolian.Eolian_Expression_Type,
|
'Eolian_Expression_Type': eolian.Eolian_Expression_Type,
|
||||||
'Eolian_Expression_Mask': eolian.Eolian_Expression_Mask,
|
'Eolian_Expression_Mask': eolian.Eolian_Expression_Mask,
|
||||||
'Eolian_Variable_Type': eolian.Eolian_Variable_Type,
|
|
||||||
'Eolian_Binary_Operator': eolian.Eolian_Binary_Operator,
|
'Eolian_Binary_Operator': eolian.Eolian_Binary_Operator,
|
||||||
'Eolian_Unary_Operator': eolian.Eolian_Unary_Operator,
|
'Eolian_Unary_Operator': eolian.Eolian_Unary_Operator,
|
||||||
'Eolian_Doc_Token_Type': eolian.Eolian_Doc_Token_Type,
|
'Eolian_Doc_Token_Type': eolian.Eolian_Doc_Token_Type,
|
||||||
|
|
|
@ -180,22 +180,14 @@ class TestEolianUnit(unittest.TestCase):
|
||||||
all_count += 1
|
all_count += 1
|
||||||
self.assertGreater(all_count, 10)
|
self.assertGreater(all_count, 10)
|
||||||
|
|
||||||
def test_variable_listing(self):
|
def test_constant_listing(self):
|
||||||
l = list(eolian_db.constants)
|
l = list(eolian_db.constants)
|
||||||
self.assertGreater(len(l), 2)
|
self.assertGreater(len(l), 2)
|
||||||
self.assertIsInstance(l[0], eolian.Variable)
|
self.assertIsInstance(l[0], eolian.Constant)
|
||||||
|
|
||||||
l = list(eolian_db.globals)
|
|
||||||
self.assertGreater(len(l), 20)
|
|
||||||
self.assertIsInstance(l[0], eolian.Variable)
|
|
||||||
|
|
||||||
l = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo'))
|
l = list(eolian_db.constants_by_file_get('efl_gfx_stack.eo'))
|
||||||
self.assertGreater(len(l), 1)
|
self.assertGreater(len(l), 1)
|
||||||
self.assertIsInstance(l[0], eolian.Variable)
|
self.assertIsInstance(l[0], eolian.Constant)
|
||||||
|
|
||||||
l = list(eolian_db.globals_by_file_get('efl_net_http_types.eot'))
|
|
||||||
self.assertGreater(len(l), 10)
|
|
||||||
self.assertIsInstance(l[0], eolian.Variable)
|
|
||||||
|
|
||||||
def test_class_listing(self):
|
def test_class_listing(self):
|
||||||
all_count = 0
|
all_count = 0
|
||||||
|
@ -473,26 +465,12 @@ class TestEolianDocumentation(unittest.TestCase):
|
||||||
self.assertEqual(doc.since, '1.22')
|
self.assertEqual(doc.since, '1.22')
|
||||||
|
|
||||||
|
|
||||||
class TestEolianVariable(unittest.TestCase):
|
class TestEolianConstant(unittest.TestCase):
|
||||||
def test_variable_global(self):
|
def test_constant(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):
|
|
||||||
var = eolian_db.constant_by_name_get('Efl.Gfx.Hint_Expand')
|
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.name, 'Efl.Gfx.Hint_Expand')
|
||||||
self.assertEqual(var.short_name, '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.assertEqual(var.file, 'efl_gfx_hint.eo')
|
||||||
self.assertFalse(var.is_extern)
|
self.assertFalse(var.is_extern)
|
||||||
self.assertEqual(list(var.namespaces), ['Efl','Gfx'])
|
self.assertEqual(list(var.namespaces), ['Efl','Gfx'])
|
||||||
|
|
|
@ -765,7 +765,7 @@ EFL_END_TEST
|
||||||
|
|
||||||
EFL_START_TEST(eolian_var)
|
EFL_START_TEST(eolian_var)
|
||||||
{
|
{
|
||||||
const Eolian_Variable *var = NULL;
|
const Eolian_Constant *var = NULL;
|
||||||
const Eolian_Expression *exp = NULL;
|
const Eolian_Expression *exp = NULL;
|
||||||
const Eolian_Type *type = NULL;
|
const Eolian_Type *type = NULL;
|
||||||
const Eolian_Class *class;
|
const Eolian_Class *class;
|
||||||
|
@ -785,12 +785,11 @@ EFL_START_TEST(eolian_var)
|
||||||
|
|
||||||
/* regular constant */
|
/* regular constant */
|
||||||
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Foo")));
|
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Foo")));
|
||||||
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
|
fail_if(eolian_constant_is_extern(var));
|
||||||
fail_if(eolian_variable_is_extern(var));
|
fail_if(!(type = eolian_constant_base_type_get(var)));
|
||||||
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
||||||
fail_if(!(name = eolian_type_short_name_get(type)));
|
fail_if(!(name = eolian_type_short_name_get(type)));
|
||||||
fail_if(strcmp(name, "int"));
|
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);
|
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||||
fail_if(v.type != EOLIAN_EXPR_INT);
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
||||||
fail_if(v.value.i != 5);
|
fail_if(v.value.i != 5);
|
||||||
|
@ -849,7 +848,7 @@ EFL_END_TEST
|
||||||
EFL_START_TEST(eolian_enum)
|
EFL_START_TEST(eolian_enum)
|
||||||
{
|
{
|
||||||
const Eolian_Enum_Type_Field *field = NULL;
|
const Eolian_Enum_Type_Field *field = NULL;
|
||||||
const Eolian_Variable *var = NULL;
|
const Eolian_Constant *var = NULL;
|
||||||
const Eolian_Typedecl *tdl = NULL;
|
const Eolian_Typedecl *tdl = NULL;
|
||||||
const Eolian_Type *type = NULL;
|
const Eolian_Type *type = NULL;
|
||||||
const Eolian_Class *class;
|
const Eolian_Class *class;
|
||||||
|
@ -914,19 +913,16 @@ EFL_START_TEST(eolian_enum)
|
||||||
eina_stringshare_del(cname);
|
eina_stringshare_del(cname);
|
||||||
|
|
||||||
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Bah")));
|
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Bah")));
|
||||||
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
|
fail_if(!(type = eolian_constant_base_type_get(var)));
|
||||||
fail_if(eolian_variable_is_extern(var));
|
|
||||||
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
||||||
fail_if(!(name = eolian_type_short_name_get(type)));
|
fail_if(!(name = eolian_type_short_name_get(type)));
|
||||||
fail_if(strcmp(name, "Baz"));
|
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);
|
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||||
fail_if(v.type != EOLIAN_EXPR_INT);
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
||||||
fail_if(v.value.i != (1 << 0));
|
fail_if(v.value.i != (1 << 0));
|
||||||
|
|
||||||
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "Pants")));
|
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_constant_value_get(var)));
|
||||||
fail_if(!(exp = eolian_variable_value_get(var)));
|
|
||||||
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
|
||||||
fail_if(v.type != EOLIAN_EXPR_INT);
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
||||||
fail_if(v.value.i != 5);
|
fail_if(v.value.i != 5);
|
||||||
|
@ -1032,7 +1028,7 @@ EFL_START_TEST(eolian_docs)
|
||||||
const Eolian_Typedecl *tdl;
|
const Eolian_Typedecl *tdl;
|
||||||
const Eolian_Class *class;
|
const Eolian_Class *class;
|
||||||
const Eolian_Event *event;
|
const Eolian_Event *event;
|
||||||
const Eolian_Variable *var;
|
const Eolian_Constant *var;
|
||||||
const Eolian_Function *fid;
|
const Eolian_Function *fid;
|
||||||
const Eolian_Documentation *doc;
|
const Eolian_Documentation *doc;
|
||||||
const Eolian_Function_Parameter *par;
|
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);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
||||||
txt = eolian_doc_token_text_get(&tok);
|
txt = eolian_doc_token_text_get(&tok);
|
||||||
fail_if(strcmp(txt, "pants"));
|
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);
|
free(txt);
|
||||||
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
||||||
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
||||||
|
@ -1181,7 +1177,7 @@ EFL_START_TEST(eolian_docs)
|
||||||
"2.0"));
|
"2.0"));
|
||||||
|
|
||||||
fail_if(!(var = eolian_unit_constant_by_name_get(unit, "pants")));
|
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),
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
||||||
"Docs for var."));
|
"Docs for var."));
|
||||||
fail_if(eolian_documentation_description_get(doc));
|
fail_if(eolian_documentation_description_get(doc));
|
||||||
|
|
Loading…
Reference in New Issue