summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-03-03 19:01:02 +0000
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-03-03 19:01:02 +0000
commit0c545b88ba69e7f66e927b1f7318cdb156b07d79 (patch)
tree2c4a0b078cc15199545f107cb6adf039ef6d7cc8
parent54f954c2ee6f75bb3fcbc71e78b7e8526df93918 (diff)
parentf57d4b9a3c769d077cf68a46a3d564b38cc04fa7 (diff)
downloadefl-0c545b88ba69e7f66e927b1f7318cdb156b07d79.tar.gz
eolian: new type system API
The Eolian type system API has been overhauled to properly separate declarations (i.e. struct/enum/alias declarations) and usage. This should simplify writing generators (as it makes it clear what is what) as well as make it easier to maintain. @feature
-rw-r--r--src/bin/eolian/docs_generator.c10
-rw-r--r--src/bin/eolian/types_generator.c54
-rw-r--r--src/bin/eolian_cxx/type_lookup.hh2
-rw-r--r--src/bindings/luajit/eolian.lua261
-rw-r--r--src/lib/eolian/Eolian.h319
-rw-r--r--src/lib/eolian/database_expr.c22
-rw-r--r--src/lib/eolian/database_expr_api.c13
-rw-r--r--src/lib/eolian/database_type.c223
-rw-r--r--src/lib/eolian/database_type_api.c193
-rw-r--r--src/lib/eolian/database_validate.c82
-rw-r--r--src/lib/eolian/eo_lexer.c9
-rw-r--r--src/lib/eolian/eo_lexer.h1
-rw-r--r--src/lib/eolian/eo_parser.c42
-rw-r--r--src/lib/eolian/eolian_database.c10
-rw-r--r--src/lib/eolian/eolian_database.h27
-rw-r--r--src/tests/eolian/eolian_parsing.c258
16 files changed, 900 insertions, 626 deletions
diff --git a/src/bin/eolian/docs_generator.c b/src/bin/eolian/docs_generator.c
index eb008bd30e..886bf9e185 100644
--- a/src/bin/eolian/docs_generator.c
+++ b/src/bin/eolian/docs_generator.c
@@ -42,10 +42,10 @@ _generate_ref(const char *refn, Eina_Strbuf *wbuf, Eina_Bool use_legacy)
Eina_Stringshare *bname = eina_stringshare_add_length(refn, sfx - refn);
- const Eolian_Type *tp = eolian_type_struct_get_by_name(bname);
+ const Eolian_Typedecl *tp = eolian_typedecl_struct_get_by_name(bname);
if (tp)
{
- if (!eolian_type_struct_field_get(tp, sfx + 1))
+ if (!eolian_typedecl_struct_field_get(tp, sfx + 1))
{
eina_stringshare_del(bname);
goto noref;
@@ -56,17 +56,17 @@ _generate_ref(const char *refn, Eina_Strbuf *wbuf, Eina_Bool use_legacy)
return;
}
- tp = eolian_type_enum_get_by_name(bname);
+ tp = eolian_typedecl_enum_get_by_name(bname);
if (tp)
{
- const Eolian_Enum_Type_Field *efl = eolian_type_enum_field_get(tp, sfx + 1);
+ const Eolian_Enum_Type_Field *efl = eolian_typedecl_enum_field_get(tp, sfx + 1);
if (!efl)
{
eina_stringshare_del(bname);
goto noref;
}
_generate_ref(bname, wbuf, use_legacy);
- Eina_Stringshare *str = eolian_type_enum_field_c_name_get(efl);
+ Eina_Stringshare *str = eolian_typedecl_enum_field_c_name_get(efl);
eina_strbuf_append_char(wbuf, '.');
eina_strbuf_append(wbuf, str);
eina_stringshare_del(str);
diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c
index 32864fded7..adea8196c2 100644
--- a/src/bin/eolian/types_generator.c
+++ b/src/bin/eolian/types_generator.c
@@ -12,16 +12,16 @@
#include "common_funcs.h"
static char *
-_concat_name(const Eolian_Type *tp)
+_concat_name(const Eolian_Typedecl *tp)
{
const char *name;
char *str = NULL;
Eina_Strbuf *buf = eina_strbuf_new();
- Eina_Iterator *itr = eolian_type_namespaces_get(tp);
+ Eina_Iterator *itr = eolian_typedecl_namespaces_get(tp);
EINA_ITERATOR_FOREACH(itr, name)
if (name) eina_strbuf_append_printf(buf, "%s_", name);
eina_iterator_free(itr);
- name = eolian_type_name_get(tp);
+ name = eolian_typedecl_name_get(tp);
if (name) eina_strbuf_append_printf(buf, "%s", name);
if (eina_strbuf_length_get(buf))
{
@@ -34,51 +34,51 @@ _concat_name(const Eolian_Type *tp)
}
static Eina_Strbuf *
-_type_generate(const Eolian_Type *tp, Eina_Bool full, Eina_Bool use_legacy)
+_type_generate(const Eolian_Typedecl *tp, Eina_Bool full, Eina_Bool use_legacy)
{
- char *grp = strdup(eolian_type_full_name_get(tp));
+ char *grp = strdup(eolian_typedecl_full_name_get(tp));
char *p = strrchr(grp, '.');
if (p) *p = '\0';
- Eina_Strbuf *buf = docs_generate_full(eolian_type_documentation_get(tp),
+ Eina_Strbuf *buf = docs_generate_full(eolian_typedecl_documentation_get(tp),
grp, 0, use_legacy);
free(grp);
if (!buf) buf = eina_strbuf_new();
else eina_strbuf_append_char(buf, '\n');
- Eolian_Type_Type tp_type = eolian_type_type_get(tp);
+ Eolian_Typedecl_Type tp_type = eolian_typedecl_type_get(tp);
switch(tp_type)
{
- case EOLIAN_TYPE_ALIAS:
+ case EOLIAN_TYPEDECL_ALIAS:
{
char *name = _concat_name(tp);
Eina_Stringshare *c_type = eolian_type_c_type_named_get(
- eolian_type_base_type_get(tp), name);
+ eolian_typedecl_base_type_get(tp), name);
eina_strbuf_append_printf(buf, "typedef %s", c_type);
eina_stringshare_del(c_type);
free(name);
break;
}
- case EOLIAN_TYPE_STRUCT:
- case EOLIAN_TYPE_STRUCT_OPAQUE:
+ case EOLIAN_TYPEDECL_STRUCT:
+ case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
{
const Eolian_Struct_Type_Field *member;
char *name = _concat_name(tp);
- if (tp_type == EOLIAN_TYPE_STRUCT_OPAQUE || !full)
+ if (tp_type == EOLIAN_TYPEDECL_STRUCT_OPAQUE || !full)
{
eina_strbuf_append_printf(buf, "typedef struct _%s %s", name, name);
free(name);
break;
}
eina_strbuf_append_printf(buf, "typedef struct _%s\n{\n", name);
- Eina_Iterator *members = eolian_type_struct_fields_get(tp);
+ Eina_Iterator *members = eolian_typedecl_struct_fields_get(tp);
EINA_ITERATOR_FOREACH(members, member)
{
- const Eolian_Type *type = eolian_type_struct_field_type_get(member);
+ const Eolian_Type *type = eolian_typedecl_struct_field_type_get(member);
Eina_Stringshare *c_type = eolian_type_c_type_get(type);
eina_strbuf_append_printf(buf, " %s%s%s;",
c_type, strchr(c_type, '*')?"":" ",
- eolian_type_struct_field_name_get(member));
+ eolian_typedecl_struct_field_name_get(member));
const Eolian_Documentation *fdoc
- = eolian_type_struct_field_documentation_get(member);
+ = eolian_typedecl_struct_field_documentation_get(member);
if (fdoc)
{
const char *nl = strrchr(eina_strbuf_string_get(buf), '\n');
@@ -98,7 +98,7 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full, Eina_Bool use_legacy)
free(name);
break;
}
- case EOLIAN_TYPE_ENUM:
+ case EOLIAN_TYPEDECL_ENUM:
{
const Eolian_Enum_Type_Field *member;
char *name;
@@ -107,18 +107,18 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full, Eina_Bool use_legacy)
name = _concat_name(tp);
char *pre = NULL;
eina_strbuf_append_printf(buf, "typedef enum\n{\n");
- if (eolian_type_enum_legacy_prefix_get(tp))
- pre = strdup(eolian_type_enum_legacy_prefix_get(tp));
+ if (eolian_typedecl_enum_legacy_prefix_get(tp))
+ pre = strdup(eolian_typedecl_enum_legacy_prefix_get(tp));
else
pre = strdup(name);
eina_str_toupper(&pre);
- Eina_Iterator *members = eolian_type_enum_fields_get(tp);
+ Eina_Iterator *members = eolian_typedecl_enum_fields_get(tp);
Eina_Bool next = eina_iterator_next(members, (void**)&member);
Eina_Strbuf *membuf = eina_strbuf_new();
while (next)
{
- const Eolian_Expression *value = eolian_type_enum_field_value_get(member, EINA_FALSE);
- char *memb_u = strdup(eolian_type_enum_field_name_get(member));
+ const Eolian_Expression *value = eolian_typedecl_enum_field_value_get(member, EINA_FALSE);
+ char *memb_u = strdup(eolian_typedecl_enum_field_name_get(member));
eina_str_toupper(&memb_u);
eina_strbuf_reset(membuf);
eina_strbuf_append(membuf, pre);
@@ -141,7 +141,7 @@ _type_generate(const Eolian_Type *tp, Eina_Bool full, Eina_Bool use_legacy)
eina_stringshare_del(lit);
}
const Eolian_Documentation *fdoc
- = eolian_type_enum_field_documentation_get(member);
+ = eolian_typedecl_enum_field_documentation_get(member);
next = eina_iterator_next(members, (void**)&member);
if (next)
eina_strbuf_append(buf, ",");
@@ -191,13 +191,13 @@ types_header_generate(const char *eo_filename, Eina_Strbuf *buf, Eina_Bool full,
if (dt == EOLIAN_DECL_ENUM && !full)
continue;
- const Eolian_Type *tp = eolian_declaration_data_type_get(decl);
- if (!tp || eolian_type_is_extern(tp))
+ const Eolian_Typedecl *tp = eolian_declaration_data_type_get(decl);
+ if (!tp || eolian_typedecl_is_extern(tp))
continue;
- if (eolian_type_type_get(tp) == EOLIAN_TYPE_ALIAS)
+ if (eolian_typedecl_type_get(tp) == EOLIAN_TYPEDECL_ALIAS)
{
- const Eolian_Type *btp = eolian_type_base_type_get(tp);
+ const Eolian_Type *btp = eolian_typedecl_base_type_get(tp);
if (eolian_type_type_get(btp) == EOLIAN_TYPE_UNDEFINED)
continue;
}
diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh
index 38b683d468..7f73a5edda 100644
--- a/src/bin/eolian_cxx/type_lookup.hh
+++ b/src/bin/eolian_cxx/type_lookup.hh
@@ -49,7 +49,7 @@ type_from_eolian(Eolian_Type const& type)
efl::eolian::eolian_type x;
Eolian_Type_Type tpt = ::eolian_type_type_get(&type);
- if (tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_ALIAS || tpt == EOLIAN_TYPE_REGULAR)
+ if (tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_REGULAR)
{
Eolian_Type const* base_type = ::eolian_type_base_type_get(&type);
if (base_type && ::eolian_type_type_get(base_type) == EOLIAN_TYPE_CLASS)
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 3192703f7e..af36a20c2e 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -15,6 +15,7 @@ ffi.cdef [[
typedef struct _Eolian_Class Eolian_Class;
typedef struct _Eolian_Function Eolian_Function;
typedef struct _Eolian_Type Eolian_Type;
+ typedef struct _Eolian_Typedecl Eolian_Typedecl;
typedef struct _Eolian_Function_Parameter Eolian_Function_Parameter;
typedef struct _Eolian_Implement Eolian_Implement;
typedef struct _Eolian_Constructor Eolian_Constructor;
@@ -29,7 +30,7 @@ ffi.cdef [[
typedef enum
{
- EOLIAN_UNRESOLVED,
+ EOLIAN_UNRESOLVED = 0,
EOLIAN_PROPERTY,
EOLIAN_PROP_SET,
EOLIAN_PROP_GET,
@@ -38,14 +39,14 @@ ffi.cdef [[
typedef enum
{
- EOLIAN_IN_PARAM,
+ EOLIAN_IN_PARAM = 0,
EOLIAN_OUT_PARAM,
EOLIAN_INOUT_PARAM
} Eolian_Parameter_Dir;
typedef enum
{
- EOLIAN_CLASS_UNKNOWN_TYPE,
+ EOLIAN_CLASS_UNKNOWN_TYPE = 0,
EOLIAN_CLASS_REGULAR,
EOLIAN_CLASS_ABSTRACT,
EOLIAN_CLASS_MIXIN,
@@ -54,10 +55,18 @@ ffi.cdef [[
typedef enum
{
- EOLIAN_SCOPE_PUBLIC,
+ EOLIAN_SCOPE_PUBLIC = 0,
EOLIAN_SCOPE_PROTECTED
} Eolian_Object_Scope;
+ typedef enum {
+ EOLIAN_TYPEDECL_UNKNOWN = 0,
+ EOLIAN_TYPEDECL_STRUCT,
+ EOLIAN_TYPEDECL_STRUCT_OPAQUE,
+ EOLIAN_TYPEDECL_ENUM,
+ EOLIAN_TYPEDECL_ALIAS
+ } Eolian_Typedecl_Type;
+
typedef enum
{
EOLIAN_TYPE_UNKNOWN_TYPE,
@@ -232,7 +241,6 @@ ffi.cdef [[
const Eolian_Documentation *eolian_function_return_documentation_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id);
- Eina_Bool eolian_type_is_extern(const Eolian_Type *tp);
const char *eolian_implement_full_name_get(const Eolian_Implement *impl);
const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
@@ -258,40 +266,63 @@ ffi.cdef [[
Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass);
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
- const Eolian_Type *eolian_type_alias_get_by_name(const char *name);
- const Eolian_Type *eolian_type_struct_get_by_name(const char *name);
- const Eolian_Type *eolian_type_enum_get_by_name(const char *name);
- Eina_Iterator *eolian_type_aliases_get_by_file(const char *fname);
- Eina_Iterator *eolian_type_structs_get_by_file(const char *fname);
- Eina_Iterator *eolian_type_enums_get_by_file(const char *fname);
+ const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const char *name);
+ const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const char *name);
+ const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const char *name);
+ Eina_Iterator *eolian_typedecl_aliases_get_by_file(const char *fname);
+ Eina_Iterator *eolian_typedecl_structs_get_by_file(const char *fname);
+ Eina_Iterator *eolian_typedecl_enums_get_by_file(const char *fname);
Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
- Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp);
+ Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp);
- Eina_Iterator *eolian_type_struct_fields_get(const Eolian_Type *tp);
- const Eolian_Struct_Type_Field *eolian_type_struct_field_get(const Eolian_Type *tp, const char *field);
- const char *eolian_type_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
- const Eolian_Documentation *eolian_type_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
- const Eolian_Type *eolian_type_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
- Eina_Iterator *eolian_type_enum_fields_get(const Eolian_Type *tp);
- const Eolian_Enum_Type_Field *eolian_type_enum_field_get(const Eolian_Type *tp, const char *field);
- const char *eolian_type_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
- const Eolian_Documentation *eolian_type_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl);
- const Eolian_Expression *eolian_type_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
- const char *eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp);
- const Eolian_Documentation *eolian_type_documentation_get(const Eolian_Type *tp);
+ Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp);
+ const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field);
+ const char *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
+ const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
+ const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
+ Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
+ const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
+ const char *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
+ const char *eolian_typedecl_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl);
+ const Eolian_Documentation *eolian_typedecl_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl);
+ const Eolian_Expression *eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
+
+ const char *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
+ const Eolian_Documentation *eolian_typedecl_documentation_get(const Eolian_Typedecl *tp);
const char *eolian_type_file_get(const Eolian_Type *tp);
- const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp);
+ const char *eolian_typedecl_file_get(const Eolian_Typedecl *tp);
+
const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
+ const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp);
+ const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Type *tp);
+
const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
+ const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp);
+
const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp);
Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
+
+ Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
+
const char *eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name);
+ const char *eolian_typedecl_c_type_named_get(const Eolian_Typedecl *tp, const char *name);
+
const char *eolian_type_c_type_get(const Eolian_Type *tp);
+ const char *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
+
const char *eolian_type_name_get(const Eolian_Type *tp);
+ const char *eolian_typedecl_name_get(const Eolian_Typedecl *tp);
+
const char *eolian_type_full_name_get(const Eolian_Type *tp);
+ const char *eolian_typedecl_full_name_get(const Eolian_Typedecl *tp);
+
Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp);
+ Eina_Iterator *eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp);
+
const char *eolian_type_free_func_get(const Eolian_Type *tp);
+ const char *eolian_typedecl_free_func_get(const Eolian_Typedecl *tp);
+
Eolian_Value_t eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m);
Eolian_Value_t eolian_expression_eval_type(const Eolian_Expression *expr, const Eolian_Type *type);
const char *eolian_expression_value_to_literal(const Eolian_Value *v);
@@ -416,36 +447,44 @@ M.declaration_type = {
}
M.type_type = {
- UNKNOWN = 0,
- VOID = 1,
- REGULAR = 2,
- COMPLEX = 3,
- POINTER = 4,
- FUNCTION = 5,
- STRUCT = 6,
- STRUCT_OPAQUE = 7,
- ENUM = 8,
- ALIAS = 9,
- CLASS = 10,
- UNDEFINED = 11
+ UNKNOWN = 0,
+ VOID = 1,
+ REGULAR = 2,
+ COMPLEX = 3,
+ POINTER = 4,
+ FUNCTION = 5,
+ STRUCT = 6,
+ STRUCT_OPAQUE = 7,
+ ENUM = 8,
+ ALIAS = 9,
+ CLASS = 10,
+ UNDEFINED = 11
+}
+
+M.typedecl_type = {
+ UNKNOWN = 0,
+ STRUCT = 1,
+ STRUCT_OPAQUE = 2,
+ ENUM = 3,
+ ALIAS = 4
}
ffi.metatype("Eolian_Struct_Type_Field", {
__index = {
name_get = function(self)
- local v = eolian.eolian_type_struct_field_name_get(self)
+ local v = eolian.eolian_typedecl_struct_field_name_get(self)
if v == nil then return nil end
return ffi.string(v)
end,
documentation_get = function(self)
- local v = eolian.eolian_type_struct_field_documentation_get(self)
+ local v = eolian.eolian_typedecl_struct_field_documentation_get(self)
if v == nil then return nil end
return v
end,
type_get = function(self)
- local v = eolian.eolian_type_struct_field_type_get(self)
+ local v = eolian.eolian_typedecl_struct_field_type_get(self)
if v == nil then return nil end
return v
end
@@ -455,93 +494,159 @@ ffi.metatype("Eolian_Struct_Type_Field", {
ffi.metatype("Eolian_Enum_Type_Field", {
__index = {
name_get = function(self)
- local v = eolian.eolian_type_enum_field_name_get(self)
+ local v = eolian.eolian_typedecl_enum_field_name_get(self)
if v == nil then return nil end
return ffi.string(v)
end,
+ c_name_get = function(self)
+ local v = eolian.eolian_typedecl_enum_field_c_name_get(self)
+ if v == nil then return nil end
+ return ffi_stringshare(v)
+ end,
+
documentation_get = function(self)
- local v = eolian.eolian_type_enum_field_documentation_get(self)
+ local v = eolian.eolian_typedecl_enum_field_documentation_get(self)
if v == nil then return nil end
return v
end,
value_get = function(self, force)
- local v = eolian.eolian_type_enum_field_value_get(self, force and 1 or 0)
+ local v = eolian.eolian_typedecl_enum_field_value_get(self, force and 1 or 0)
if v == nil then return nil end
return v
end
}
})
-M.Type = ffi.metatype("Eolian_Type", {
+M.Typedecl = ffi.metatype("Eolian_Typedecl", {
__index = {
type_get = function(self)
- return tonumber(eolian.eolian_type_type_get(self))
- end,
-
- arguments_get = function(self)
- return Ptr_Iterator("const Eolian_Type*",
- eolian.eolian_type_arguments_get(self))
- end,
-
- subtypes_get = function(self)
- return Ptr_Iterator("const Eolian_Type*",
- eolian.eolian_type_subtypes_get(self))
+ return tonumber(eolian.eolian_typedecl_type_get(self))
end,
struct_fields_get = function(self)
return Ptr_Iterator("const Eolian_Struct_Type_Field*",
- eolian.eolian_type_struct_fields_get(self))
+ eolian.eolian_typedecl_struct_fields_get(self))
end,
struct_field_get = function(self, name)
- local v = eolian.eolian_type_struct_field_get(self, name)
+ local v = eolian.eolian_typedecl_struct_field_get(self, name)
if v == nil then return nil end
return v
end,
enum_fields_get = function(self)
return Ptr_Iterator("const Eolian_Enum_Type_Field*",
- eolian.eolian_type_enum_fields_get(self))
+ eolian.eolian_typedecl_enum_fields_get(self))
end,
enum_field_get = function(self, field)
- local v = eolian.eolian_type_enum_field_get(self, field)
+ local v = eolian.eolian_typedecl_enum_field_get(self, field)
if v == nil then return nil end
return v
end,
enum_legacy_prefix_get = function(self)
- local v = eolian.eolian_type_enum_legacy_prefix_get(self)
+ local v = eolian.eolian_typedecl_enum_legacy_prefix_get(self)
if v == nil then return nil end
return ffi.string(v)
end,
documentation_get = function(self, name)
- local v = eolian.eolian_type_documentation_get(self)
+ local v = eolian.eolian_typedecl_documentation_get(self)
if v == nil then return nil end
return v
end,
file_get = function(self, name)
- local v = eolian.eolian_type_file_get(self)
+ local v = eolian.eolian_typedecl_file_get(self)
if v == nil then return nil end
return ffi.string(v)
end,
- return_type_get = function(self)
- local v = eolian.eolian_type_return_type_get(self)
+ base_type_get = function(self)
+ local v = eolian.eolian_typedecl_base_type_get(self)
+ if v == nil then return nil end
+ return v
+ end,
+
+ aliased_base_get = function(self)
+ local v = eolian.eolian_typedecl_aliased_byse_get(self)
if v == nil then return nil end
return v
end,
+ is_extern = function(self)
+ return eolian.eolian_typedecl_is_extern(self) ~= 0
+ end,
+
+ c_type_named_get = function(self, name)
+ local v = eolian.eolian_typedecl_c_type_named_get(self, name)
+ if v == nil then return nil end
+ return ffi_stringshare(v)
+ end,
+
+ c_type_get = function(self)
+ local v = eolian.eolian_typedecl_c_type_get(self)
+ if v == nil then return nil end
+ return ffi_stringshare(v)
+ end,
+
+ name_get = function(self)
+ local v = eolian.eolian_typedecl_name_get(self)
+ if v == nil then return nil end
+ return ffi.string(v)
+ end,
+
+ full_name_get = function(self)
+ local v = eolian.eolian_typedecl_full_name_get(self)
+ if v == nil then return nil end
+ return ffi.string(v)
+ end,
+
+ namespaces_get = function(self)
+ return iterator.String_Iterator(
+ eolian.eolian_typedecl_namespaces_get(self))
+ end,
+
+ free_func_get = function(self)
+ local v = eolian.eolian_typedecl_free_func_get(self)
+ if v == nil then return nil end
+ return ffi.string(v)
+ end
+ }
+})
+
+M.Type = ffi.metatype("Eolian_Type", {
+ __index = {
+ type_get = function(self)
+ return tonumber(eolian.eolian_type_type_get(self))
+ end,
+
+ subtypes_get = function(self)
+ return Ptr_Iterator("const Eolian_Type*",
+ eolian.eolian_type_subtypes_get(self))
+ end,
+
+ file_get = function(self, name)
+ local v = eolian.eolian_type_file_get(self)
+ if v == nil then return nil end
+ return ffi.string(v)
+ end,
+
base_type_get = function(self)
local v = eolian.eolian_type_base_type_get(self)
if v == nil then return nil end
return v
end,
+ typedecl_get = function(self)
+ local v = eolian.eolian_type_typedecl_get(self)
+ if v == nil then return nil end
+ return v
+ end,
+
aliased_base_get = function(self)
local v = eolian.eolian_type_aliased_byse_get(self)
if v == nil then return nil end
@@ -562,10 +667,6 @@ M.Type = ffi.metatype("Eolian_Type", {
return eolian.eolian_type_is_const(self) ~= 0
end,
- is_extern = function(self)
- return eolian.eolian_type_is_extern(self) ~= 0
- end,
-
c_type_named_get = function(self, name)
local v = eolian.eolian_type_c_type_named_get(self, name)
if v == nil then return nil end
@@ -1002,36 +1103,36 @@ M.Class = ffi.metatype("Eolian_Class", {
}
})
-M.type_alias_get_by_name = function(name)
- local v = eolian.eolian_type_alias_get_by_name(name)
+M.typedecl_alias_get_by_name = function(name)
+ local v = eolian.eolian_typedecl_alias_get_by_name(name)
if v == nil then return nil end
return v
end
-M.type_struct_get_by_name = function(name)
- local v = eolian.eolian_type_struct_get_by_name(name)
+M.typedecl_struct_get_by_name = function(name)
+ local v = eolian.eolian_typedecl_struct_get_by_name(name)
if v == nil then return nil end
return v
end
-M.type_enum_get_by_name = function(name)
- local v = eolian.eolian_type_enum_get_by_name(name)
+M.typedecl_enum_get_by_name = function(name)
+ local v = eolian.eolian_typedecl_enum_get_by_name(name)
if v == nil then return nil end
return v
end
-M.type_aliases_get_by_file = function(fname)
- return Ptr_Iterator("const Eolian_Type*",
+M.typedecl_aliases_get_by_file = function(fname)
+ return Ptr_Iterator("const Eolian_Typedecl *",
eolian.eolian_type_aliases_get_by_file(self))
end
-M.type_structs_get_by_file = function(fname)
- return Ptr_Iterator("const Eolian_Type*",
+M.typedecl_structs_get_by_file = function(fname)
+ return Ptr_Iterator("const Eolian_Typedecl *",
eolian.eolian_type_structs_get_by_file(self))
end
-M.type_enums_get_by_file = function(fname)
- return Ptr_Iterator("const Eolian_Type*",
+M.typedecl_enums_get_by_file = function(fname)
+ return Ptr_Iterator("const Eolian_Typedecl *",
eolian.eolian_type_enums_get_by_file(self))
end
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index a5748eb09e..70c5a1c194 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -105,6 +105,12 @@ typedef struct _Eolian_Function Eolian_Function;
*/
typedef struct _Eolian_Type Eolian_Type;
+/* Type declaration.
+ *
+ * @ingroup Eolian
+ */
+typedef struct _Eolian_Typedecl Eolian_Typedecl;
+
/* Class function parameter information
*
* @ingroup Eolian
@@ -167,7 +173,7 @@ typedef struct _Eolian_Documentation Eolian_Documentation;
typedef enum
{
- EOLIAN_UNRESOLVED,
+ EOLIAN_UNRESOLVED = 0,
EOLIAN_PROPERTY,
EOLIAN_PROP_SET,
EOLIAN_PROP_GET,
@@ -176,14 +182,14 @@ typedef enum
typedef enum
{
- EOLIAN_IN_PARAM,
+ EOLIAN_IN_PARAM = 0,
EOLIAN_OUT_PARAM,
EOLIAN_INOUT_PARAM
} Eolian_Parameter_Dir;
typedef enum
{
- EOLIAN_CLASS_UNKNOWN_TYPE,
+ EOLIAN_CLASS_UNKNOWN_TYPE = 0,
EOLIAN_CLASS_REGULAR,
EOLIAN_CLASS_ABSTRACT,
EOLIAN_CLASS_MIXIN,
@@ -192,22 +198,27 @@ typedef enum
typedef enum
{
- EOLIAN_SCOPE_PUBLIC,
+ EOLIAN_SCOPE_PUBLIC = 0,
EOLIAN_SCOPE_PRIVATE,
EOLIAN_SCOPE_PROTECTED
} Eolian_Object_Scope;
typedef enum
{
- EOLIAN_TYPE_UNKNOWN_TYPE,
+ EOLIAN_TYPEDECL_UNKNOWN = 0,
+ EOLIAN_TYPEDECL_STRUCT,
+ EOLIAN_TYPEDECL_STRUCT_OPAQUE,
+ EOLIAN_TYPEDECL_ENUM,
+ EOLIAN_TYPEDECL_ALIAS
+} Eolian_Typedecl_Type;
+
+typedef enum
+{
+ EOLIAN_TYPE_UNKNOWN_TYPE = 0,
EOLIAN_TYPE_VOID,
EOLIAN_TYPE_REGULAR,
EOLIAN_TYPE_COMPLEX,
EOLIAN_TYPE_POINTER,
- EOLIAN_TYPE_STRUCT,
- EOLIAN_TYPE_STRUCT_OPAQUE,
- EOLIAN_TYPE_ENUM,
- EOLIAN_TYPE_ALIAS,
EOLIAN_TYPE_CLASS,
EOLIAN_TYPE_UNDEFINED
} Eolian_Type_Type;
@@ -1253,34 +1264,34 @@ EAPI Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
/*
- * @brief Get an alias type by name. Supports namespaces.
+ * @brief Get an alias type declaration by name. Supports namespaces.
*
* @param[in] name the name of the alias
* @return the alias type or NULL
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_type_alias_get_by_name(const char *name);
+EAPI const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const char *name);
/*
- * @brief Get a struct by name. Supports namespaces.
+ * @brief Get a struct declaration by name. Supports namespaces.
*
* @param[in] name the name of the struct
* @return the struct or NULL
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_type_struct_get_by_name(const char *name);
+EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const char *name);
/*
- * @brief Get an enum by name. Supports namespaces.
+ * @brief Get an enum declaration by name. Supports namespaces.
*
* @param[in] name the name of the struct
* @return the struct or NULL
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_type_enum_get_by_name(const char *name);
+EAPI const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const char *name);
/*
* @brief Get an iterator to all aliases contained in a file.
@@ -1292,7 +1303,7 @@ EAPI const Eolian_Type *eolian_type_enum_get_by_name(const char *name);
*
* @ingroup Eolian
*/
-EAPI Eina_Iterator *eolian_type_aliases_get_by_file(const char *fname);
+EAPI Eina_Iterator *eolian_typedecl_aliases_get_by_file(const char *fname);
/*
* @brief Get an iterator to all named structs contained in a file.
@@ -1304,7 +1315,7 @@ EAPI Eina_Iterator *eolian_type_aliases_get_by_file(const char *fname);
*
* @ingroup Eolian
*/
-EAPI Eina_Iterator *eolian_type_structs_get_by_file(const char *fname);
+EAPI Eina_Iterator *eolian_typedecl_structs_get_by_file(const char *fname);
/*
* @brief Get an iterator to all enums contained in a file.
@@ -1316,49 +1327,39 @@ EAPI Eina_Iterator *eolian_type_structs_get_by_file(const char *fname);
*
* @ingroup Eolian
*/
-EAPI Eina_Iterator *eolian_type_enums_get_by_file(const char *fname);
+EAPI Eina_Iterator *eolian_typedecl_enums_get_by_file(const char *fname);
/*
- * @brief Get the type of a type (regular, function, pointer)
+ * @brief Get the type of a type declaration.
*
- * @param[in] tp the type.
- * @return an Eolian_Type_Type.
+ * @param[in] tp the type declaration.
+ * @return an Eolian_Typedecl_Type.
*
* @ingroup Eolian
*/
-EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
-
-/*
- * @brief Get an iterator to all subtypes of a type.
- *
- * @param[in] tp the type.
- * @return the iterator when @c tp is a complex type.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp);
+EAPI Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
/*
* @brief Get an iterator to all fields of a struct type.
*
- * @param[in] tp the type.
- * @return the iterator when @c tp is EOLIAN_TYPE_STRUCT, NULL otherwise.
+ * @param[in] tp the type declaration.
+ * @return the iterator when @c tp is EOLIAN_TYPEDECL_STRUCT, NULL otherwise.
*
* @ingroup Eolian
*/
-EAPI Eina_Iterator *eolian_type_struct_fields_get(const Eolian_Type *tp);
+EAPI Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp);
/*
* @brief Get a field of a struct type.
*
- * @param[in] tp the type.
+ * @param[in] tp the type declaration.
* @param[in] field the field name.
- * @return the field when @c tp is EOLIAN_TYPE_STRUCT, @c field is not NULL
+ * @return the field when @c tp is EOLIAN_TYPEDECL_STRUCT, @c field is not NULL
* and the field exists, NULL otherwise.
*
* @ingroup Eolian
*/
-EAPI const Eolian_Struct_Type_Field *eolian_type_struct_field_get(const Eolian_Type *tp, const char *field);
+EAPI const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field);
/*
* @brief Get the name of a field of a struct type.
@@ -1368,7 +1369,7 @@ EAPI const Eolian_Struct_Type_Field *eolian_type_struct_field_get(const Eolian_T
*
* @ingroup Eolian
*/
-EAPI Eina_Stringshare *eolian_type_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
+EAPI Eina_Stringshare *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get the documentation of a field of a struct type.
@@ -1378,7 +1379,7 @@ EAPI Eina_Stringshare *eolian_type_struct_field_name_get(const Eolian_Struct_Typ
*
* @ingroup Eolian
*/
-EAPI const Eolian_Documentation *eolian_type_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
+EAPI const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get the type of a field of a struct type.
@@ -1388,24 +1389,24 @@ EAPI const Eolian_Documentation *eolian_type_struct_field_documentation_get(cons
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_type_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
+EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
/*
* @brief Get an iterator to all fields of an enum type.
*
- * @param[in] tp the type.
- * @return the iterator when @c tp is EOLIAN_TYPE_ENUM, NULL otherwise.
+ * @param[in] tp the type declaration.
+ * @return the iterator when @c tp is EOLIAN_TYPEDECL_ENUM, NULL otherwise.
*
* @ingroup Eolian
*/
-EAPI Eina_Iterator *eolian_type_enum_fields_get(const Eolian_Type *tp);
+EAPI Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
/*
* @brief Get a field of an enum type.
*
- * @param[in] tp the type.
+ * @param[in] tp the type declaration.
* @param[in] field the field name.
- * @return the field when @c tp is EOLIAN_TYPE_ENUM, @c field is not NULL,
+ * @return the field when @c tp is EOLIAN_TYPEDECL_ENUM, @c field is not NULL,
* field exists and has a value set, NULL otherwise.
*
* Keep in mind that this can return NULL for an existing field, particularly
@@ -1413,7 +1414,7 @@ EAPI Eina_Iterator *eolian_type_enum_fields_get(const Eolian_Type *tp);
*
* @ingroup Eolian
*/
-EAPI const Eolian_Enum_Type_Field *eolian_type_enum_field_get(const Eolian_Type *tp, const char *field);
+EAPI const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
/*
* @brief Get the name of a field of an enum type.
@@ -1423,7 +1424,7 @@ EAPI const Eolian_Enum_Type_Field *eolian_type_enum_field_get(const Eolian_Type
*
* @ingroup Eolian
*/
-EAPI Eina_Stringshare *eolian_type_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
+EAPI Eina_Stringshare *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
/*
* @brief Get the C name of a field of an enum type.
@@ -1435,7 +1436,7 @@ EAPI Eina_Stringshare *eolian_type_enum_field_name_get(const Eolian_Enum_Type_Fi
*
* @ingroup Eolian
*/
-EAPI Eina_Stringshare *eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl);
+EAPI Eina_Stringshare *eolian_typedecl_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl);
/*
* @brief Get the documentation of a field of an enum type.
@@ -1445,7 +1446,7 @@ EAPI Eina_Stringshare *eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_
*
* @ingroup Eolian
*/
-EAPI const Eolian_Documentation *eolian_type_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl);
+EAPI const Eolian_Documentation *eolian_typedecl_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl);
/*
* @brief Get the value of a field of an enum type.
@@ -1460,32 +1461,170 @@ EAPI const Eolian_Documentation *eolian_type_enum_field_documentation_get(const
*
* @ingroup Eolian
*/
-EAPI const Eolian_Expression *eolian_type_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
+EAPI const Eolian_Expression *eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
/*
* @brief Get the legacy prefix of enum field names. When not specified,
* enum name is used.
*
- * @param[in] tp the type.
+ * @param[in] tp the type declaration.
* @return the legacy prefix or NULL.
*
* @ingroup Eolian
*/
-EAPI Eina_Stringshare *eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp);
+EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
/*
* @brief Get the documentation of a struct/alias type.
*
- * @param[in] tp the type.
+ * @param[in] tp the type declaration.
* @return the documentation when @c tp is EOLIAN_TYPE_STRUCT or
* EOLIAN_TYPE_STRUCT_OPAQUE, NULL otherwise.
*
* @ingroup Eolian
*/
-EAPI const Eolian_Documentation *eolian_type_documentation_get(const Eolian_Type *tp);
+EAPI const Eolian_Documentation *eolian_typedecl_documentation_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the filename of a type declaration.
+ *
+ * @param[in] tp the type declaration.
+ * @return the filename.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_file_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the base type of an alias declaration.
+ *
+ * @param[in] tp the type declaration.
+ * @return the base type when @c tp is an alias, NULL otherwise.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the lowest base type of an alias stack.
+ *
+ * If the given typedecl is an alias, it returns the result of
+ * eolian_type_aliased_base_get on its base type. Otherwise this returns NULL.
+ *
+ * @param[in] tp the type declaration.
+ * @return the lowest alias base or the given type.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Check if a struct or alias type declaration is extern.
+ *
+ * @param[in] tp the type declaration.
+ * @return EINA_TRUE if it's extern, EINA_FALSE otherwise.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the full C type name of the given type declaration with a name.
+ *
+ * @param[in] tp the type declaration.
+ * @param[in] name the name.
+ * @return The C type name assuming @c tp is not NULL.
+ *
+ * Name is ignored for alias types and they're turned into C typedefs.
+ *
+ * Keep in mind that if @c name is NULL, the name won't be included.
+ * Also, you're responsible for deleting the stringshare.
+ *
+ * @see eolian_typedecl_c_type_get
+ * @see eolian_type_c_type_named_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_c_type_named_get(const Eolian_Typedecl *tp, const char *name);
+
+/*
+ * @brief Get the full C type name of the given type without a name.
+ *
+ * @param[in] tp the type declaration.
+ * @return The C type name assuming @c tp is not NULL.
+ *
+ * This behaves exactly like eolian_typedecl_c_type_named_get when name is NULL.
+ *
+ * @see eolian_typedecl_c_type_named_get
+ * @see eolian_type_c_type_get
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
/*
- * @brief Get the filename of a struct/alias type.
+ * @brief Get the name of the given type declaration. Keep in mind that the
+ * name doesn't include namespaces.
+ *
+ * @param[in] tp the type declaration.
+ * @return the name.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the full (namespaced) name of a type declaration.
+ *
+ * @param[in] tp the type declaration.
+ * @return the name.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_full_name_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get an iterator to the list of namespaces of the given type decl.
+ *
+ * @param[in] tp the type declaration.
+ * @return the iterator.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the name of the function used to free this type declaration.
+ *
+ * @param[in] tp the type declaration.
+ * @return the free func name.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Stringshare *eolian_typedecl_free_func_get(const Eolian_Typedecl *tp);
+
+/*
+ * @brief Get the type of a type.
+ *
+ * @param[in] tp the type.
+ * @return an Eolian_Type_Type.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
+
+/*
+ * @brief Get an iterator to all subtypes of a type.
+ *
+ * @param[in] tp the type.
+ * @return the iterator when @c tp is a complex type.
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp);
+
+/*
+ * @brief Get the filename of a type.
*
* @param[in] tp the type.
* @return the filename.
@@ -1495,27 +1634,35 @@ EAPI const Eolian_Documentation *eolian_type_documentation_get(const Eolian_Type
EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
/*
- * @brief Get the base type of a pointer, alias or regular type.
- *
- * For pointers and aliases, it's a simple lookup. For regular types, it
- * tries to look up alias, struct and enum in that order.
+ * @brief Get the base type of a pointer type.
*
* @param[in] tp the type.
- * @return the base type when @c tp is a pointer or alias, NULL otherwise.
+ * @return the base type when @c tp is a pointer, NULL otherwise.
*
* @ingroup Eolian
*/
EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
/*
+ * @brief Get the declaration a regular type points to.
+ *
+ * This tries to look up alias, struct and enum in that order.
+ *
+ * @param[in] tp the type.
+ * @return the pointed to type decalration or NULL.
+ *
+ * @ingroup Eolian
+ */
+EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Type *tp);
+
+/*
* @brief Get the lowest base type of an alias stack.
*
- * If the given type is an alias, it returns the result of a recursive call
- * to this function on its base type. If it's a regular type, it first tries
- * to retrieve its base using eolian_type_base_type_get and if the retrieved
- * base is an alias, returns a recursive call of this function on it. Otherwise
- * it returns the given type. This is useful in order to retrieve what an
- * aliased type actually is while still having convenience.
+ * If this is a regular type, it first tries to retrieve its base declaration
+ * using eolian_type_typedecl_get and if the retrieved base is an alias, returns
+ * a call of eolian_typedecl_aliased_base_get function on it. Otherwise it
+ * returns the given type. This is useful in order to retrieve what an aliased
+ * type actually is while still having convenience.
*
* @param[in] tp the type.
* @return the lowest alias base or the given type.
@@ -1557,32 +1704,17 @@ EAPI Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
/*
- * @brief Check if a struct or alias type is extern.
- *
- * @param[in] tp the type.
- * @return EINA_TRUE if it's extern, EINA_FALSE otherwise.
- *
- * @ingroup Eolian
- */
-EAPI Eina_Bool eolian_type_is_extern(const Eolian_Type *tp);
-
-/*
* @brief Get the full C type name of the given type with a name.
*
* @param[in] tp the type.
* @param[in] name the name.
* @return The C type name assuming @c tp is not NULL.
*
- * Providing the name is useful for function types, as in C a function
- * pointer type alone is not valid syntax. For non-function types, the
- * name is simply appended to the type (with a space). C type names do
- * not include subtypes as C doesn't support them. Name is ignored for
- * alias types. Alias types are turned into C typedefs.
- *
* Keep in mind that if @c name is NULL, the name won't be included.
* Also, you're responsible for deleting the stringshare.
*
* @see eolian_type_c_type_get
+ * @see eolian_typedecl_c_type_named_get
*
* @ingroup Eolian
*/
@@ -1595,11 +1727,9 @@ EAPI Eina_Stringshare *eolian_type_c_type_named_get(const Eolian_Type *tp, const
* @return The C type name assuming @c tp is not NULL.
*
* This behaves exactly like eolian_type_c_type_named_get when name is NULL.
- * Keep in mind that this is not useful for function types as a function
- * pointer type in C cannot be used without a name.
- * Also, you're responsible for deleting the stringshare.
*
* @see eolian_type_c_type_named_get
+ * @see eolian_typedecl_c_type_get
*
* @ingroup Eolian
*/
@@ -1607,10 +1737,8 @@ EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
/*
* @brief Get the name of the given type. For regular or complex types, this
- * is for example "int". For EOLIAN_TYPE_STRUCT, EOLIAN_TYPE_STRUCT_OPAQUE and
- * EOLIAN_TYPE_ALIAS, this is the name of the alias or of the struct. For
- * EOLIAN_TYPE_CLASS, this can be "Button". Keep in mind that the name doesn't
- * include namespaces for structs and aliases.
+ * is for example "int". For EOLIAN_TYPE_CLASS, this can be "Button". Keep in
+ * mind that the name doesn't include namespaces.
*
* @param[in] tp the type.
* @return the name.
@@ -1620,8 +1748,7 @@ EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp);
/*
- * @brief Get the full (namespaced) name of a function. Only works on named
- * types (not pointers, not functions, not void).
+ * @brief Get the full (namespaced) name of a type.
*
* @param[in] tp the type.
* @return the name.
@@ -1631,8 +1758,7 @@ EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp);
EAPI Eina_Stringshare *eolian_type_full_name_get(const Eolian_Type *tp);
/*
- * @brief Get an iterator to the list of namespaces of the given type. Only
- * works on named types (not pointers, not functions, not void).
+ * @brief Get an iterator to the list of namespaces of the given type.
*
* @param[in] tp the type.
* @return the iterator.
@@ -1648,8 +1774,7 @@ EAPI Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp);
* @return the free func name.
*
* For pointer types, this returns name of the func used to free the pointer.
- * For struct and alias types, this returns name of the func used to free a
- * pointer to that type. For other types, this returns NULL.
+ * For other types, this returns NULL.
*
* @ingroup Eolian
*/
@@ -2004,7 +2129,7 @@ EAPI const Eolian_Class *eolian_declaration_class_get(const Eolian_Declaration *
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_declaration_data_type_get(const Eolian_Declaration *decl);
+EAPI const Eolian_Typedecl *eolian_declaration_data_type_get(const Eolian_Declaration *decl);
/*
* @brief Get the variable of a variable (constant, global) declaration.
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index 0076f7ca27..862c30bd71 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -497,7 +497,7 @@ eval_exp(const Eolian_Expression *expr, Eolian_Expression_Mask mask,
if (!var)
{
- const Eolian_Type *etp;
+ const Eolian_Typedecl *etpd;
const Eolian_Enum_Type_Field *fl;
/* try aliases, hoping it'll be enum */
@@ -510,20 +510,24 @@ eval_exp(const Eolian_Expression *expr, Eolian_Expression_Mask mask,
if (!(mask & EOLIAN_MASK_INT))
return expr_type_error(expr, EOLIAN_MASK_INT, mask);
- etp = eolian_type_alias_get_by_name(fulln);
- while (etp && (etp->type == EOLIAN_TYPE_ALIAS
- || etp->type == EOLIAN_TYPE_REGULAR))
- etp = eolian_type_base_type_get(etp);
+ etpd = eolian_typedecl_alias_get_by_name(fulln);
+ while (etpd && etpd->type == EOLIAN_TYPEDECL_ALIAS)
+ {
+ const Eolian_Type *etp = eolian_typedecl_base_type_get(etpd);
+ if (!etp || etp->type != EOLIAN_TYPE_REGULAR)
+ break;
+ etpd = eolian_type_typedecl_get(etp);
+ }
- if (!etp) etp = eolian_type_enum_get_by_name(fulln);
- if (!etp || etp->type != EOLIAN_TYPE_ENUM)
+ if (!etpd) etpd = eolian_typedecl_enum_get_by_name(fulln);
+ if (!etpd || etpd->type != EOLIAN_TYPEDECL_ENUM)
{
free(fulln);
return expr_error(expr, "undefined variable");
}
- fl = eolian_type_enum_field_get(etp, memb);
- if (fl) exp = eolian_type_enum_field_value_get(fl, EINA_TRUE);
+ fl = eolian_typedecl_enum_field_get(etpd, memb);
+ if (fl) exp = eolian_typedecl_enum_field_value_get(fl, EINA_TRUE);
free(fulln);
if (!exp)
diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index eb0d119d68..81d4200a31 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -23,8 +23,6 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
return err;
switch (type->type)
{
- case EOLIAN_TYPE_ALIAS:
- return _eval_type(expr, eolian_type_base_type_get(type));
case EOLIAN_TYPE_POINTER:
{
int mask = EOLIAN_MASK_NULL;
@@ -36,15 +34,18 @@ _eval_type(const Eolian_Expression *expr, const Eolian_Type *type)
}
case EOLIAN_TYPE_CLASS:
return database_expr_eval(expr, EOLIAN_MASK_NULL);
- case EOLIAN_TYPE_ENUM:
- return database_expr_eval(expr, EOLIAN_MASK_INT);
case EOLIAN_TYPE_REGULAR:
{
int kw = eo_lexer_keyword_str_to_id(type->name);
if (!kw || kw < KW_byte || kw >= KW_void)
{
- const Eolian_Type *base = eolian_type_base_type_get(type);
- if (base) return _eval_type(expr, base);
+ const Eolian_Typedecl *base = eolian_type_typedecl_get(type);
+ if (!base)
+ return err;
+ if (base->type == EOLIAN_TYPEDECL_ALIAS)
+ return _eval_type(expr, eolian_typedecl_base_type_get(base));
+ else if (base->type == EOLIAN_TYPEDECL_ENUM)
+ return database_expr_eval(expr, EOLIAN_MASK_INT);
return err;
}
switch (kw)
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 787cc3d6d3..ec3b9a8303 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -14,39 +14,36 @@ database_type_del(Eolian_Type *tp)
if (tp->base.file) eina_stringshare_del(tp->base.file);
if (tp->subtypes) EINA_LIST_FREE(tp->subtypes, stp)
database_type_del(stp);
- if (tp->base_type)
- database_type_del(tp->base_type);
+ database_type_del(tp->base_type);
if (tp->name) eina_stringshare_del(tp->name);
if (tp->full_name) eina_stringshare_del(tp->full_name);
- if (tp->fields) eina_hash_free(tp->fields);
- if (tp->field_list) eina_list_free(tp->field_list);
if (tp->namespaces) EINA_LIST_FREE(tp->namespaces, sp)
eina_stringshare_del(sp);
- if (tp->legacy) eina_stringshare_del(tp->legacy);
if (tp->freefunc) eina_stringshare_del(tp->freefunc);
- database_doc_del(tp->doc);
free(tp);
}
void
-database_typedef_del(Eolian_Type *tp)
+database_typedecl_del(Eolian_Typedecl *tp)
{
if (!tp) return;
- Eolian_Type *btp = tp->base_type;
- /* prevent deletion of named structs/enums as they're deleted later on */
- if (btp)
- {
- if (btp->type == EOLIAN_TYPE_ENUM)
- tp->base_type = NULL;
- else if ((btp->type == EOLIAN_TYPE_STRUCT
- || btp->type == EOLIAN_TYPE_STRUCT_OPAQUE) && btp->name)
- tp->base_type = NULL;
- }
- database_type_del(tp);
+ const char *sp;
+ if (tp->base.file) eina_stringshare_del(tp->base.file);
+ database_type_del(tp->base_type);
+ if (tp->name) eina_stringshare_del(tp->name);
+ if (tp->full_name) eina_stringshare_del(tp->full_name);
+ if (tp->fields) eina_hash_free(tp->fields);
+ if (tp->field_list) eina_list_free(tp->field_list);
+ if (tp->namespaces) EINA_LIST_FREE(tp->namespaces, sp)
+ eina_stringshare_del(sp);
+ if (tp->legacy) eina_stringshare_del(tp->legacy);
+ if (tp->freefunc) eina_stringshare_del(tp->freefunc);
+ database_doc_del(tp->doc);
+ free(tp);
}
void
-database_type_add(Eolian_Type *def)
+database_type_add(Eolian_Typedecl *def)
{
eina_hash_set(_aliases, def->full_name, def);
eina_hash_set(_aliasesf, def->base.file, eina_list_append
@@ -55,7 +52,7 @@ database_type_add(Eolian_Type *def)
}
void
-database_struct_add(Eolian_Type *tp)
+database_struct_add(Eolian_Typedecl *tp)
{
eina_hash_set(_structs, tp->full_name, tp);
eina_hash_set(_structsf, tp->base.file, eina_list_append
@@ -64,7 +61,7 @@ database_struct_add(Eolian_Type *tp)
}
void
-database_enum_add(Eolian_Type *tp)
+database_enum_add(Eolian_Typedecl *tp)
{
eina_hash_set(_enums, tp->full_name, tp);
eina_hash_set(_enumsf, tp->base.file, eina_list_append
@@ -72,8 +69,55 @@ database_enum_add(Eolian_Type *tp)
database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
}
+void
+database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
+{
+ if ((tp->type == EOLIAN_TYPE_REGULAR
+ || tp->type == EOLIAN_TYPE_COMPLEX
+ || tp->type == EOLIAN_TYPE_VOID
+ || tp->type == EOLIAN_TYPE_CLASS)
+ && tp->is_const)
+ {
+ eina_strbuf_append(buf, "const ");
+ }
+ if (tp->type == EOLIAN_TYPE_REGULAR
+ || tp->type == EOLIAN_TYPE_COMPLEX
+ || tp->type == EOLIAN_TYPE_CLASS)
+ {
+ Eina_List *l;
+ const char *sp;
+ EINA_LIST_FOREACH(tp->namespaces, l, sp)
+ {
+ eina_strbuf_append(buf, sp);
+ eina_strbuf_append_char(buf, '_');
+ }
+ int kw = eo_lexer_keyword_str_to_id(tp->name);
+ if (kw && eo_lexer_is_type_keyword(kw))
+ eina_strbuf_append(buf, eo_lexer_get_c_type(kw));
+ else
+ eina_strbuf_append(buf, tp->name);
+ }
+ else if (tp->type == EOLIAN_TYPE_VOID)
+ eina_strbuf_append(buf, "void");
+ else
+ {
+ Eolian_Type *btp = tp->base_type;
+ database_type_to_str(tp->base_type, buf, NULL);
+ if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const)
+ eina_strbuf_append_char(buf, ' ');
+ eina_strbuf_append_char(buf, '*');
+ if (tp->is_const) eina_strbuf_append(buf, " const");
+ }
+ if (name)
+ {
+ if (tp->type != EOLIAN_TYPE_POINTER)
+ eina_strbuf_append_char(buf, ' ');
+ eina_strbuf_append(buf, name);
+ }
+}
+
static void
-_stype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
+_stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name)
{
Eolian_Struct_Type_Field *sf;
Eina_List *l;
@@ -90,7 +134,7 @@ _stype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
eina_strbuf_append(buf, tp->name);
eina_strbuf_append_char(buf, ' ');
}
- if (tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
+ if (tp->type == EOLIAN_TYPEDECL_STRUCT_OPAQUE)
goto append_name;
eina_strbuf_append(buf, "{ ");
EINA_LIST_FOREACH(tp->field_list, l, sf)
@@ -108,7 +152,7 @@ append_name:
}
static void
-_etype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
+_etype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name)
{
Eolian_Enum_Type_Field *ef;
Eina_List *l;
@@ -151,7 +195,7 @@ _etype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
}
static void
-_atype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf)
+_atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
{
Eina_Strbuf *fulln = eina_strbuf_new();
Eina_List *l;
@@ -171,144 +215,29 @@ _atype_to_str(const Eolian_Type *tp, Eina_Strbuf *buf)
}
void
-database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name)
+database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name)
{
- if (tp->type == EOLIAN_TYPE_ALIAS)
+ if (tp->type == EOLIAN_TYPEDECL_ALIAS)
{
_atype_to_str(tp, buf);
return;
}
- else if (tp->type == EOLIAN_TYPE_STRUCT
- || tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
+ else if (tp->type == EOLIAN_TYPEDECL_STRUCT
+ || tp->type == EOLIAN_TYPEDECL_STRUCT_OPAQUE)
{
_stype_to_str(tp, buf, name);
return;
}
- else if (tp->type == EOLIAN_TYPE_ENUM)
+ else if (tp->type == EOLIAN_TYPEDECL_ENUM)
{
_etype_to_str(tp, buf, name);
return;
}
- if ((tp->type == EOLIAN_TYPE_REGULAR
- || tp->type == EOLIAN_TYPE_COMPLEX
- || tp->type == EOLIAN_TYPE_VOID
- || tp->type == EOLIAN_TYPE_CLASS)
- && tp->is_const)
- {
- eina_strbuf_append(buf, "const ");
- }
- if (tp->type == EOLIAN_TYPE_REGULAR
- || tp->type == EOLIAN_TYPE_COMPLEX
- || tp->type == EOLIAN_TYPE_CLASS)
- {
- Eina_List *l;
- const char *sp;
- EINA_LIST_FOREACH(tp->namespaces, l, sp)
- {
- eina_strbuf_append(buf, sp);
- eina_strbuf_append_char(buf, '_');
- }
- int kw = eo_lexer_keyword_str_to_id(tp->name);
- if (kw && eo_lexer_is_type_keyword(kw))
- eina_strbuf_append(buf, eo_lexer_get_c_type(kw));
- else
- eina_strbuf_append(buf, tp->name);
- }
- else if (tp->type == EOLIAN_TYPE_VOID)
- eina_strbuf_append(buf, "void");
else
- {
- Eolian_Type *btp = tp->base_type;
- database_type_to_str(tp->base_type, buf, NULL);
- if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const)
- eina_strbuf_append_char(buf, ' ');
- eina_strbuf_append_char(buf, '*');
- if (tp->is_const) eina_strbuf_append(buf, " const");
- }
+ return;
if (name)
{
- if (tp->type != EOLIAN_TYPE_POINTER)
- eina_strbuf_append_char(buf, ' ');
+ eina_strbuf_append_char(buf, ' ');
eina_strbuf_append(buf, name);
}
}
-
-static void
-_typedef_print(Eolian_Type *tp)
-{
- printf("type %s: ", tp->full_name);
- database_type_print(tp->base_type);
-}
-
-void
-database_expr_print(Eolian_Expression *exp)
-{
- Eolian_Value val = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
- const char *ret = eolian_expression_value_to_literal(&val);
- printf("%s", ret);
- eina_stringshare_del(ret);
-}
-
-void
-database_type_print(Eolian_Type *tp)
-{
- if (tp->type == EOLIAN_TYPE_ALIAS)
- {
- _typedef_print(tp);
- return;
- }
- if (tp->is_own)
- printf("own(");
- if (tp->is_const)
- printf("const(");
- if (tp->type == EOLIAN_TYPE_REGULAR || tp->type == EOLIAN_TYPE_COMPLEX
- || tp->type == EOLIAN_TYPE_CLASS)
- printf("%s", tp->full_name);
- else if (tp->type == EOLIAN_TYPE_VOID)
- printf("void");
- else if (tp->type == EOLIAN_TYPE_STRUCT_OPAQUE)
- printf("struct %s", tp->full_name);
- else if (tp->type == EOLIAN_TYPE_POINTER)
- {
- database_type_print(tp->base_type);
- putchar('*');
- }
- else if (tp->type == EOLIAN_TYPE_STRUCT)
- {
- Eolian_Struct_Type_Field *sf;
- Eina_List *m;
- printf("struct ");
- if (tp->full_name) printf("%s ", tp->full_name);
- printf("{ ");
- EINA_LIST_FOREACH(tp->field_list, m, sf)
- {
- printf("%s: ", sf->name);
- database_type_print(sf->type);
- printf("; ");
- }
- printf("}");
- }
- else if (tp->type == EOLIAN_TYPE_ENUM)
- {
- Eolian_Enum_Type_Field *ef;
- Eina_List *m;
- printf("enum %s ", tp->full_name);
- printf("{ ");
- EINA_LIST_FOREACH(tp->field_list, m, ef)
- {
- printf("%s", ef->name);
- if (ef->value)
- {
- printf(" = ");
- database_expr_print(ef->value);
- }
- if (m != eina_list_last(tp->field_list))
- printf(", ");
- }
- printf(" }");
- }
- if (tp->is_own)
- putchar(')');
- if (tp->is_const)
- putchar(')');
-}
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 392d40a64b..763112ea06 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -6,38 +6,41 @@
#include "eolian_database.h"
#include "eo_lexer.h"
-EAPI const Eolian_Type *
-eolian_type_alias_get_by_name(const char *name)
+EAPI const Eolian_Typedecl *
+eolian_typedecl_alias_get_by_name(const char *name)
{
if (!_aliases) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Type *tp = eina_hash_find(_aliases, shr);
+ Eolian_Typedecl *tp = eina_hash_find(_aliases, shr);
eina_stringshare_del(shr);
+ if (!tp) return NULL;
return tp;
}
-EAPI const Eolian_Type *
-eolian_type_struct_get_by_name(const char *name)
+EAPI const Eolian_Typedecl *
+eolian_typedecl_struct_get_by_name(const char *name)
{
if (!_structs) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Type *tp = eina_hash_find(_structs, shr);
+ Eolian_Typedecl *tp = eina_hash_find(_structs, shr);
eina_stringshare_del(shr);
+ if (!tp) return NULL;
return tp;
}
-EAPI const Eolian_Type *
-eolian_type_enum_get_by_name(const char *name)
+EAPI const Eolian_Typedecl *
+eolian_typedecl_enum_get_by_name(const char *name)
{
if (!_enums) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- Eolian_Type *tp = eina_hash_find(_enums, shr);
+ Eolian_Typedecl *tp = eina_hash_find(_enums, shr);
eina_stringshare_del(shr);
+ if (!tp) return NULL;
return tp;
}
EAPI Eina_Iterator *
-eolian_type_aliases_get_by_file(const char *fname)
+eolian_typedecl_aliases_get_by_file(const char *fname)
{
if (!_aliasesf) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
@@ -48,7 +51,7 @@ eolian_type_aliases_get_by_file(const char *fname)
}
EAPI Eina_Iterator *
-eolian_type_structs_get_by_file(const char *fname)
+eolian_typedecl_structs_get_by_file(const char *fname)
{
if (!_structsf) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
@@ -59,9 +62,9 @@ eolian_type_structs_get_by_file(const char *fname)
}
EAPI Eina_Iterator *
-eolian_type_enums_get_by_file(const char *fname)
+eolian_typedecl_enums_get_by_file(const char *fname)
{
- if (!_structsf) return NULL;
+ if (!_enumsf) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
Eina_List *l = eina_hash_find(_enumsf, shr);
eina_stringshare_del(shr);
@@ -76,6 +79,13 @@ eolian_type_type_get(const Eolian_Type *tp)
return tp->type;
}
+EAPI Eolian_Typedecl_Type
+eolian_typedecl_type_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EOLIAN_TYPEDECL_UNKNOWN);
+ return tp->type;
+}
+
EAPI Eina_Iterator *
eolian_type_subtypes_get(const Eolian_Type *tp)
{
@@ -88,21 +98,21 @@ eolian_type_subtypes_get(const Eolian_Type *tp)
}
EAPI Eina_Iterator *
-eolian_type_struct_fields_get(const Eolian_Type *tp)
+eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
- if (tp->type != EOLIAN_TYPE_STRUCT)
+ if (tp->type != EOLIAN_TYPEDECL_STRUCT)
return NULL;
return eina_list_iterator_new(tp->field_list);
}
EAPI const Eolian_Struct_Type_Field *
-eolian_type_struct_field_get(const Eolian_Type *tp, const char *field)
+eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field)
{
Eolian_Struct_Type_Field *sf = NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
- if (tp->type != EOLIAN_TYPE_STRUCT)
+ if (tp->type != EOLIAN_TYPEDECL_STRUCT)
return NULL;
sf = eina_hash_find(tp->fields, field);
if (!sf) return NULL;
@@ -110,42 +120,42 @@ eolian_type_struct_field_get(const Eolian_Type *tp, const char *field)
}
EAPI Eina_Stringshare *
-eolian_type_struct_field_name_get(const Eolian_Struct_Type_Field *fl)
+eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
return fl->name;
}
EAPI const Eolian_Documentation *
-eolian_type_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl)
+eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
return fl->doc;
}
EAPI const Eolian_Type *
-eolian_type_struct_field_type_get(const Eolian_Struct_Type_Field *fl)
+eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
return fl->type;
}
EAPI Eina_Iterator *
-eolian_type_enum_fields_get(const Eolian_Type *tp)
+eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
- if (tp->type != EOLIAN_TYPE_ENUM)
+ if (tp->type != EOLIAN_TYPEDECL_ENUM)
return NULL;
return eina_list_iterator_new(tp->field_list);
}
EAPI const Eolian_Enum_Type_Field *
-eolian_type_enum_field_get(const Eolian_Type *tp, const char *field)
+eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field)
{
Eolian_Enum_Type_Field *ef = NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL);
- if (tp->type != EOLIAN_TYPE_ENUM)
+ if (tp->type != EOLIAN_TYPEDECL_ENUM)
return NULL;
ef = eina_hash_find(tp->fields, field);
if (!ef) return NULL;
@@ -153,14 +163,14 @@ eolian_type_enum_field_get(const Eolian_Type *tp, const char *field)
}
EAPI Eina_Stringshare *
-eolian_type_enum_field_name_get(const Eolian_Enum_Type_Field *fl)
+eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
return fl->name;
}
EAPI Eina_Stringshare *
-eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl)
+eolian_typedecl_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl)
{
Eina_Stringshare *ret;
Eina_Strbuf *buf;
@@ -183,14 +193,14 @@ eolian_type_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl)
}
EAPI const Eolian_Documentation *
-eolian_type_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl)
+eolian_typedecl_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
return fl->doc;
}
EAPI const Eolian_Expression *
-eolian_type_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force)
+eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL);
if (!force && !fl->is_public_value) return NULL;
@@ -198,16 +208,16 @@ eolian_type_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool for
}
EAPI Eina_Stringshare *
-eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp)
+eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
- if (tp->type != EOLIAN_TYPE_ENUM)
+ if (tp->type != EOLIAN_TYPEDECL_ENUM)
return NULL;
return tp->legacy;
}
EAPI const Eolian_Documentation *
-eolian_type_documentation_get(const Eolian_Type *tp)
+eolian_typedecl_documentation_get(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->doc;
@@ -220,48 +230,63 @@ eolian_type_file_get(const Eolian_Type *tp)
return tp->base.file;
}
+EAPI Eina_Stringshare *
+eolian_typedecl_file_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ return tp->base.file;
+}
+
EAPI const Eolian_Type *
eolian_type_base_type_get(const Eolian_Type *tp)
{
- Eolian_Type_Type tpt;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
- tpt = eolian_type_type_get(tp);
- if ((tpt != EOLIAN_TYPE_POINTER) && (tpt != EOLIAN_TYPE_ALIAS) &&
- (tpt != EOLIAN_TYPE_REGULAR))
+ return tp->base_type;
+}
+
+EAPI const Eolian_Typedecl *
+eolian_type_typedecl_get(const Eolian_Type *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ if (eolian_type_type_get(tp) != EOLIAN_TYPE_REGULAR)
return NULL;
- if (tpt == EOLIAN_TYPE_REGULAR)
+ /* try looking up if it belongs to a struct, enum or an alias... otherwise
+ * return NULL, but first check for builtins
+ */
+ int kw = eo_lexer_keyword_str_to_id(tp->full_name);
+ if (!kw || kw < KW_byte || kw >= KW_true)
{
- /* for regular types, try looking up if it belongs to a struct,
- * enum or an alias... otherwise return NULL
- * but first check for builtins
- */
- int kw = eo_lexer_keyword_str_to_id(tp->full_name);
- if (!kw || kw < KW_byte || kw >= KW_true)
- {
- Eolian_Declaration *decl = eina_hash_find(_decls, tp->full_name);
- if (decl && decl->type != EOLIAN_DECL_CLASS
- && decl->type != EOLIAN_DECL_VAR)
- return decl->data;
- }
- return NULL;
+ Eolian_Declaration *decl = eina_hash_find(_decls, tp->full_name);
+ if (decl && decl->type != EOLIAN_DECL_CLASS
+ && decl->type != EOLIAN_DECL_VAR)
+ return decl->data;
}
+ return NULL;
+}
+
+EAPI const Eolian_Type *
+eolian_typedecl_base_type_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->base_type;
}
EAPI const Eolian_Type *
eolian_type_aliased_base_get(const Eolian_Type *tp)
{
- if (!tp)
- return NULL;
- if (eolian_type_type_get(tp) == EOLIAN_TYPE_REGULAR)
- {
- const Eolian_Type *btp = eolian_type_base_type_get(tp);
- if (btp && (eolian_type_type_get(btp) == EOLIAN_TYPE_ALIAS))
- return eolian_type_aliased_base_get(btp);
- return tp;
- }
- else if (eolian_type_type_get(tp) != EOLIAN_TYPE_ALIAS)
+ if (!tp || tp->type != EOLIAN_TYPE_REGULAR)
return tp;
+ const Eolian_Typedecl *btp = eolian_type_typedecl_get(tp);
+ if (btp && (btp->type == EOLIAN_TYPEDECL_ALIAS))
+ return eolian_typedecl_aliased_base_get(btp);
+ return tp;
+}
+
+EAPI const Eolian_Type *
+eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp)
+{
+ if (!tp || tp->type != EOLIAN_TYPEDECL_ALIAS)
+ return NULL;
return eolian_type_aliased_base_get(tp->base_type);
}
@@ -289,7 +314,7 @@ eolian_type_is_const(const Eolian_Type *tp)
}
EAPI Eina_Bool
-eolian_type_is_extern(const Eolian_Type *tp)
+eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE);
return tp->is_extern;
@@ -309,12 +334,31 @@ eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name)
}
EAPI Eina_Stringshare *
+eolian_typedecl_c_type_named_get(const Eolian_Typedecl *tp, const char *name)
+{
+ Eina_Stringshare *ret;
+ Eina_Strbuf *buf;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ buf = eina_strbuf_new();
+ database_typedecl_to_str(tp, buf, name);
+ ret = eina_stringshare_add(eina_strbuf_string_get(buf));
+ eina_strbuf_free(buf);
+ return ret;
+}
+
+EAPI Eina_Stringshare *
eolian_type_c_type_get(const Eolian_Type *tp)
{
return eolian_type_c_type_named_get(tp, NULL);
}
EAPI Eina_Stringshare *
+eolian_typedecl_c_type_get(const Eolian_Typedecl *tp)
+{
+ return eolian_typedecl_c_type_named_get(tp, NULL);
+}
+
+EAPI Eina_Stringshare *
eolian_type_name_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
@@ -322,12 +366,26 @@ eolian_type_name_get(const Eolian_Type *tp)
}
EAPI Eina_Stringshare *
+eolian_typedecl_name_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ return tp->name;
+}
+
+EAPI Eina_Stringshare *
eolian_type_full_name_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->full_name;
}
+EAPI Eina_Stringshare *
+eolian_typedecl_full_name_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ return tp->full_name;
+}
+
EAPI Eina_Iterator *
eolian_type_namespaces_get(const Eolian_Type *tp)
{
@@ -336,9 +394,24 @@ eolian_type_namespaces_get(const Eolian_Type *tp)
return eina_list_iterator_new(tp->namespaces);
}
+EAPI Eina_Iterator *
+eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ if (!tp->namespaces) return NULL;
+ return eina_list_iterator_new(tp->namespaces);
+}
+
EAPI Eina_Stringshare *
eolian_type_free_func_get(const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
return tp->freefunc;
}
+
+EAPI Eina_Stringshare *
+eolian_typedecl_free_func_get(const Eolian_Typedecl *tp)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
+ return tp->freefunc;
+}
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 2a44a3d3dd..8ce37a172f 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -27,20 +27,20 @@ _validate_ref(const Validator *vs EINA_UNUSED, const char *ref,
Eina_Stringshare *base = eina_stringshare_add_length(ref, suffix - ref);
- const Eolian_Type *tp = eolian_type_struct_get_by_name(base);
- if (tp)
+ const Eolian_Typedecl *tpd = eolian_typedecl_struct_get_by_name(base);
+ if (tpd)
{
eina_stringshare_del(base);
- if (!eolian_type_struct_field_get(tp, suffix + 1))
+ if (!eolian_typedecl_struct_field_get(tpd, suffix + 1))
goto failed;
return EINA_TRUE;
}
- tp = eolian_type_enum_get_by_name(base);
- if (tp)
+ tpd = eolian_typedecl_enum_get_by_name(base);
+ if (tpd)
{
eina_stringshare_del(base);
- if (!eolian_type_enum_field_get(tp, suffix + 1))
+ if (!eolian_typedecl_enum_field_get(tpd, suffix + 1))
goto failed;
return EINA_TRUE;
}
@@ -189,55 +189,67 @@ _type_error(const Validator *vs, const Eolian_Type *tp, const char *msg)
}
static Eina_Bool
-_validate_type(const Validator *vs, const Eolian_Type *tp)
+_validate_typedecl(const Validator *vs, const Eolian_Typedecl *tp)
{
if (!_validate_doc(vs, tp->doc))
return EINA_FALSE;
switch (tp->type)
{
+ case EOLIAN_TYPEDECL_ALIAS:
+ return _validate_type(vs, tp->base_type);
+ case EOLIAN_TYPEDECL_STRUCT:
+ {
+ Val_Success succ;
+ succ.vs = vs;
+ succ.success = EINA_TRUE;
+ eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
+ return succ.success;
+ }
+ case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
+ return EINA_TRUE;
+ case EOLIAN_TYPEDECL_ENUM:
+ {
+ Val_Success succ;
+ succ.vs = vs;
+ succ.success = EINA_TRUE;
+ eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
+ return succ.success;
+ }
+ default:
+ return EINA_FALSE;
+ }
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_validate_type(const Validator *vs, const Eolian_Type *tp)
+{
+ switch (tp->type)
+ {
case EOLIAN_TYPE_VOID:
case EOLIAN_TYPE_UNDEFINED:
case EOLIAN_TYPE_COMPLEX:
return EINA_TRUE;
case EOLIAN_TYPE_REGULAR:
{
- const Eolian_Type *tpp;
+ const Eolian_Typedecl *tpp;
/* builtins */
int id = eo_lexer_keyword_str_to_id(tp->full_name);
if (id)
return eo_lexer_is_type_keyword(id);
/* user defined */
- tpp = eolian_type_base_type_get(tp);
+ tpp = eolian_type_typedecl_get(tp);
if (!tpp)
{
char buf[256];
snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
return _type_error(vs, tp, buf);
}
- return _validate_type(vs, tpp);
+ return _validate_typedecl(vs, tpp);
}
case EOLIAN_TYPE_POINTER:
- case EOLIAN_TYPE_ALIAS:
return _validate_type(vs, tp->base_type);
- case EOLIAN_TYPE_STRUCT:
- {
- Val_Success succ;
- succ.vs = vs;
- succ.success = EINA_TRUE;
- eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_sf_map_cb, &succ);
- return succ.success;
- }
- case EOLIAN_TYPE_STRUCT_OPAQUE:
- return EINA_TRUE;
- case EOLIAN_TYPE_ENUM:
- {
- Val_Success succ;
- succ.vs = vs;
- succ.success = EINA_TRUE;
- eina_hash_foreach(tp->fields, (Eina_Hash_Foreach)_ef_map_cb, &succ);
- return succ.success;
- }
case EOLIAN_TYPE_CLASS:
{
if (!eolian_type_class_get(tp))
@@ -388,10 +400,10 @@ _validate_variable(const Validator *vs, const Eolian_Variable *var)
}
static Eina_Bool
-_type_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
- const Eolian_Type *tp, Val_Success *sc)
+_typedecl_map_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED,
+ const Eolian_Typedecl *tp, Val_Success *sc)
{
- sc->success = _validate_type(sc->vs, tp);
+ sc->success = _validate_typedecl(sc->vs, tp);
return sc->success;
}
@@ -424,15 +436,15 @@ database_validate(Eina_Bool silent_types)
succ.vs = &vs;
succ.success = EINA_TRUE;
- eina_hash_foreach(_aliases, (Eina_Hash_Foreach)_type_map_cb, &succ);
+ eina_hash_foreach(_aliases, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
if (!succ.success)
return EINA_FALSE;
- eina_hash_foreach(_structs, (Eina_Hash_Foreach)_type_map_cb, &succ);
+ eina_hash_foreach(_structs, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
if (!succ.success)
return EINA_FALSE;
- eina_hash_foreach(_enums, (Eina_Hash_Foreach)_type_map_cb, &succ);
+ eina_hash_foreach(_enums, (Eina_Hash_Foreach)_typedecl_map_cb, &succ);
if (!succ.success)
return EINA_FALSE;
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index d14c70ff23..0e98313d51 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -1015,6 +1015,7 @@ _temps_free(Eo_Lexer_Temps *tmp)
{
Eina_Strbuf *buf;
Eolian_Type *tp;
+ Eolian_Typedecl *tpd;
const char *s;
if (tmp->kls)
@@ -1027,10 +1028,10 @@ _temps_free(Eo_Lexer_Temps *tmp)
eina_strbuf_free(buf);
EINA_LIST_FREE(tmp->type_defs, tp)
- if (tp->type == EOLIAN_TYPE_ALIAS)
- database_typedef_del(tp);
- else
- database_type_del(tp);
+ database_type_del(tp);
+
+ EINA_LIST_FREE(tmp->type_decls, tpd)
+ database_typedecl_del(tpd);
EINA_LIST_FREE(tmp->strs, s)
if (s) eina_stringshare_del(s);
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 9908e265f2..b28a3fc530 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -118,6 +118,7 @@ typedef struct _Eo_Lexer_Temps
Eolian_Variable *var;
Eina_List *str_bufs;
Eina_List *type_defs;
+ Eina_List *type_decls;
Eina_List *expr_defs;
Eina_List *strs;
} Eo_Lexer_Temps;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 10fdfd83c5..6b6df140c0 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -117,12 +117,26 @@ push_type(Eo_Lexer *ls)
return def;
}
+static Eolian_Typedecl *
+push_typedecl(Eo_Lexer *ls)
+{
+ Eolian_Typedecl *def = calloc(1, sizeof(Eolian_Typedecl));
+ ls->tmp.type_decls = eina_list_prepend(ls->tmp.type_decls, def);
+ return def;
+}
+
static void
pop_type(Eo_Lexer *ls)
{
ls->tmp.type_defs = eina_list_remove_list(ls->tmp.type_defs, ls->tmp.type_defs);
}
+static void
+pop_typedecl(Eo_Lexer *ls)
+{
+ ls->tmp.type_decls = eina_list_remove_list(ls->tmp.type_decls, ls->tmp.type_decls);
+}
+
static Eina_Stringshare *
push_str(Eo_Lexer *ls, const char *val)
{
@@ -471,15 +485,15 @@ _struct_field_free(Eolian_Struct_Type_Field *def)
free(def);
}
-static Eolian_Type *
+static Eolian_Typedecl *
parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
int line, int column, const char *freefunc)
{
int bline = ls->line_number, bcolumn = ls->column;
- Eolian_Type *def = push_type(ls);
+ Eolian_Typedecl *def = push_typedecl(ls);
def->is_extern = is_extern;
if (name) _fill_name(name, &def->full_name, &def->name, &def->namespaces);
- def->type = EOLIAN_TYPE_STRUCT;
+ def->type = EOLIAN_TYPEDECL_STRUCT;
def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
def->freefunc = freefunc;
pop_str(ls);
@@ -524,15 +538,15 @@ _enum_field_free(Eolian_Enum_Type_Field *def)
free(def);
}
-static Eolian_Type *
+static Eolian_Typedecl *
parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
int line, int column)
{
int bline = ls->line_number, bcolumn = ls->column;
- Eolian_Type *def = push_type(ls);
+ Eolian_Typedecl *def = push_typedecl(ls);
def->is_extern = is_extern;
_fill_name(name, &def->full_name, &def->name, &def->namespaces);
- def->type = EOLIAN_TYPE_ENUM;
+ def->type = EOLIAN_TYPEDECL_ENUM;
def->fields = eina_hash_string_small_new(EINA_FREE_CB(_enum_field_free));
check_next(ls, '{');
FILL_DOC(ls, def, doc);
@@ -843,11 +857,11 @@ parse_type_void(Eo_Lexer *ls)
return parse_type_void_base(ls, EINA_FALSE);
}
-static Eolian_Type *
+static Eolian_Typedecl *
parse_typedef(Eo_Lexer *ls)
{
Eolian_Declaration *decl;
- Eolian_Type *def = push_type(ls);
+ Eolian_Typedecl *def = push_typedecl(ls);
Eina_Bool has_extern;
const char *freefunc;
Eina_Strbuf *buf;
@@ -855,7 +869,7 @@ parse_typedef(Eo_Lexer *ls)
parse_struct_attrs(ls, EINA_FALSE, &has_extern, &freefunc);
def->freefunc = freefunc;
pop_str(ls);
- def->type = EOLIAN_TYPE_ALIAS;
+ def->type = EOLIAN_TYPEDECL_ALIAS;
def->is_extern = has_extern;
buf = push_strbuf(ls);
eo_lexer_context_push(ls);
@@ -1856,7 +1870,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
case KW_type:
{
database_type_add(parse_typedef(ls));
- pop_type(ls);
+ pop_typedecl(ls);
break;
}
case KW_const:
@@ -1895,9 +1909,9 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
pop_strbuf(ls);
if (!is_enum && ls->t.token == ';')
{
- Eolian_Type *def = push_type(ls);
+ Eolian_Typedecl *def = push_typedecl(ls);
def->is_extern = has_extern;
- def->type = EOLIAN_TYPE_STRUCT_OPAQUE;
+ def->type = EOLIAN_TYPEDECL_STRUCT_OPAQUE;
def->freefunc = freefunc;
pop_str(ls);
_fill_name(name, &def->full_name, &def->name, &def->namespaces);
@@ -1905,14 +1919,14 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
FILL_DOC(ls, def, doc);
FILL_BASE(def->base, ls, line, col);
database_struct_add(def);
- pop_type(ls);
+ pop_typedecl(ls);
break;
}
if (is_enum)
parse_enum(ls, name, has_extern, line, col);
else
parse_struct(ls, name, has_extern, line, col, freefunc);
- pop_type(ls);
+ pop_typedecl(ls);
break;
}
def:
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index fa0931088e..3cdca384ce 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -43,9 +43,9 @@ database_init()
if (_database_init_count > 0) return ++_database_init_count;
eina_init();
_classes = eina_hash_stringshared_new(EINA_FREE_CB(database_class_del));
- _aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedef_del));
- _structs = eina_hash_stringshared_new(EINA_FREE_CB(database_type_del));
- _enums = eina_hash_stringshared_new(EINA_FREE_CB(database_type_del));
+ _aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
+ _structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
+ _enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
_globals = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
_constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del));
_classesf = eina_hash_stringshared_new(NULL);
@@ -156,14 +156,14 @@ eolian_declaration_class_get(const Eolian_Declaration *decl)
return (const Eolian_Class *)decl->data;
}
-EAPI const Eolian_Type *
+EAPI const Eolian_Typedecl *
eolian_declaration_data_type_get(const Eolian_Declaration *decl)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(decl, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(decl->type == EOLIAN_DECL_ALIAS ||
decl->type == EOLIAN_DECL_STRUCT ||
decl->type == EOLIAN_DECL_ENUM, NULL);
- return (const Eolian_Type *)decl->data;
+ return (const Eolian_Typedecl *)decl->data;
}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 6bc470bd3a..20cd91cf25 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -170,13 +170,24 @@ struct _Eolian_Type
Eina_Stringshare *name;
Eina_Stringshare *full_name;
Eina_List *namespaces;
+ Eina_Stringshare *freefunc;
+ Eina_Bool is_const :1;
+ Eina_Bool is_own :1;
+};
+
+struct _Eolian_Typedecl
+{
+ Eolian_Object base;
+ Eolian_Typedecl_Type type;
+ Eolian_Type *base_type;
+ Eina_Stringshare *name;
+ Eina_Stringshare *full_name;
+ Eina_List *namespaces;
Eina_Hash *fields;
Eina_List *field_list;
Eolian_Documentation *doc;
Eina_Stringshare *legacy;
Eina_Stringshare *freefunc;
- Eina_Bool is_const :1;
- Eina_Bool is_own :1;
Eina_Bool is_extern :1;
};
@@ -223,7 +234,7 @@ struct _Eolian_Struct_Type_Field
struct _Eolian_Enum_Type_Field
{
- Eolian_Type *base_enum;
+ Eolian_Typedecl *base_enum;
Eina_Stringshare *name;
Eolian_Object base;
Eolian_Expression *value;
@@ -281,14 +292,14 @@ void database_doc_del(Eolian_Documentation *doc);
/* types */
-void database_type_add(Eolian_Type *def);
-void database_struct_add(Eolian_Type *tp);
-void database_enum_add(Eolian_Type *tp);
+void database_type_add(Eolian_Typedecl *def);
+void database_struct_add(Eolian_Typedecl *tp);
+void database_enum_add(Eolian_Typedecl *tp);
void database_type_del(Eolian_Type *tp);
-void database_typedef_del(Eolian_Type *tp);
+void database_typedecl_del(Eolian_Typedecl *tp);
-void database_type_print(Eolian_Type *type);
void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name);
+void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf, const char *name);
/* expressions */
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index feec478cd9..13e93bbf45 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -346,7 +346,8 @@ END_TEST
START_TEST(eolian_typedef)
{
- const Eolian_Type *atype = NULL, *type = NULL;
+ const Eolian_Type *type = NULL;
+ const Eolian_Typedecl *tdl = NULL;
const char *type_name = NULL;
Eina_Iterator *iter = NULL;
const Eolian_Class *class;
@@ -361,14 +362,14 @@ START_TEST(eolian_typedef)
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* Basic type */
- fail_if(!(atype = eolian_type_alias_get_by_name("Evas.Coord")));
- fail_if(eolian_type_type_get(atype) != EOLIAN_TYPE_ALIAS);
- fail_if(!(type_name = eolian_type_name_get(atype)));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Evas.Coord")));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
fail_if(strcmp(type_name, "Coord"));
- fail_if(!(type_name = eolian_type_c_type_get(atype)));
+ fail_if(!(type_name = eolian_typedecl_c_type_get(tdl)));
fail_if(strcmp(type_name, "typedef int Evas_Coord"));
eina_stringshare_del(type_name);
- fail_if(!(type = eolian_type_base_type_get(atype)));
+ fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(eolian_type_is_own(type));
fail_if(eolian_type_is_const(type));
@@ -376,19 +377,19 @@ START_TEST(eolian_typedef)
fail_if(strcmp(type_name, "int"));
/* File */
- fail_if(!(file = eolian_type_file_get(atype)));
+ fail_if(!(file = eolian_typedecl_file_get(tdl)));
fail_if(strcmp(file, "typedef.eo"));
/* Lowest alias base */
- fail_if(!(atype = eolian_type_alias_get_by_name("Evas.Coord3")));
- fail_if(!(atype = eolian_type_aliased_base_get(atype)));
- fail_if(strcmp(eolian_type_name_get(atype), "int"));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Evas.Coord3")));
+ fail_if(!(type = eolian_typedecl_aliased_base_get(tdl)));
+ fail_if(strcmp(eolian_type_name_get(type), "int"));
/* Complex type */
- fail_if(!(atype = eolian_type_alias_get_by_name("List_Objects")));
- fail_if(!(type_name = eolian_type_name_get(atype)));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("List_Objects")));
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
fail_if(strcmp(type_name, "List_Objects"));
- fail_if(!(type = eolian_type_base_type_get(atype)));
+ fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(!(type_name = eolian_type_c_type_get(type)));
fail_if(!eolian_type_is_own(type));
fail_if(strcmp(type_name, "Eina_List *"));
@@ -403,21 +404,21 @@ START_TEST(eolian_typedef)
eina_iterator_free(iter);
/* List */
- fail_if(!(iter = eolian_type_aliases_get_by_file("typedef.eo")));
- fail_if(!eina_iterator_next(iter, (void**)&atype));
- fail_if(!(type_name = eolian_type_name_get(atype)));
+ fail_if(!(iter = eolian_typedecl_aliases_get_by_file("typedef.eo")));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
fail_if(strcmp(type_name, "Coord"));
- fail_if(!eina_iterator_next(iter, (void**)&atype));
- fail_if(!(type_name = eolian_type_name_get(atype)));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
fail_if(strcmp(type_name, "List_Objects"));
/* coord2 and coord3, skip */
- fail_if(!eina_iterator_next(iter, (void**)&atype));
- fail_if(!eina_iterator_next(iter, (void**)&atype));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
/* not generated extern, skip */
- fail_if(!eina_iterator_next(iter, (void**)&atype));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
/* not generated undefined type, skip */
- fail_if(!eina_iterator_next(iter, (void**)&atype));
- fail_if(eina_iterator_next(iter, (void**)&atype));
+ fail_if(!eina_iterator_next(iter, (void**)&tdl));
+ fail_if(eina_iterator_next(iter, (void**)&tdl));
eolian_shutdown();
}
@@ -664,6 +665,7 @@ START_TEST(eolian_struct)
{
const Eolian_Struct_Type_Field *field = NULL;
const Eolian_Type *type = NULL, *ftype = NULL;
+ const Eolian_Typedecl *tdl = NULL;
const Eolian_Class *class;
const Eolian_Function *func;
const char *type_name;
@@ -679,42 +681,40 @@ START_TEST(eolian_struct)
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* named struct */
- fail_if(!(type = eolian_type_struct_get_by_name("Named")));
- fail_if(!(type_name = eolian_type_name_get(type)));
- fail_if(!(file = eolian_type_file_get(type)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
- fail_if(eolian_type_is_own(type));
- fail_if(eolian_type_is_const(type));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named")));
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
+ fail_if(!(file = eolian_typedecl_file_get(tdl)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
fail_if(strcmp(type_name, "Named"));
fail_if(strcmp(file, "struct.eo"));
- fail_if(!(field = eolian_type_struct_field_get(type, "field")));
- fail_if(!(ftype = eolian_type_struct_field_type_get(field)));
+ fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
+ fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(!(type_name = eolian_type_name_get(ftype)));
fail_if(strcmp(type_name, "int"));
- fail_if(!(field = eolian_type_struct_field_get(type, "something")));
- fail_if(!(ftype = eolian_type_struct_field_type_get(field)));
+ fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
+ fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(!(type_name = eolian_type_c_type_get(ftype)));
fail_if(strcmp(type_name, "const char *"));
eina_stringshare_del(type_name);
/* referencing */
- fail_if(!(type = eolian_type_struct_get_by_name("Another")));
- fail_if(!(type_name = eolian_type_name_get(type)));
- fail_if(!(file = eolian_type_file_get(type)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Another")));
+ fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
+ fail_if(!(file = eolian_typedecl_file_get(tdl)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
fail_if(strcmp(type_name, "Another"));
fail_if(strcmp(file, "struct.eo"));
- fail_if(!(field = eolian_type_struct_field_get(type, "field")));
- fail_if(!(ftype = eolian_type_struct_field_type_get(field)));
+ fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
+ fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(!(type_name = eolian_type_name_get(ftype)));
fail_if(strcmp(type_name, "Named"));
fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_REGULAR);
- fail_if(eolian_type_type_get(eolian_type_base_type_get(ftype))
- != EOLIAN_TYPE_STRUCT);
+ fail_if(eolian_typedecl_type_get(eolian_type_typedecl_get(ftype))
+ != EOLIAN_TYPEDECL_STRUCT);
/* opaque struct */
- fail_if(!(type = eolian_type_struct_get_by_name("Opaque")));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT_OPAQUE);
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque")));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT_OPAQUE);
/* use in function */
fail_if(!(func = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
@@ -722,8 +722,8 @@ START_TEST(eolian_struct)
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_POINTER);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
- fail_if(!(type = eolian_type_base_type_get(type)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
+ fail_if(!(tdl = eolian_type_typedecl_get(type)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
eolian_shutdown();
}
@@ -731,7 +731,7 @@ END_TEST
START_TEST(eolian_extern)
{
- const Eolian_Type *type = NULL;
+ const Eolian_Typedecl *tdl = NULL;
const Eolian_Class *class;
eolian_init();
@@ -744,20 +744,20 @@ START_TEST(eolian_extern)
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* regular type */
- fail_if(!(type = eolian_type_alias_get_by_name("Foo")));
- fail_if(eolian_type_is_extern(type));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Foo")));
+ fail_if(eolian_typedecl_is_extern(tdl));
/* extern type */
- fail_if(!(type = eolian_type_alias_get_by_name("Evas.Coord")));
- fail_if(!eolian_type_is_extern(type));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Evas.Coord")));
+ fail_if(!eolian_typedecl_is_extern(tdl));
/* regular struct */
- fail_if(!(type = eolian_type_struct_get_by_name("X")));
- fail_if(eolian_type_is_extern(type));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("X")));
+ fail_if(eolian_typedecl_is_extern(tdl));
/* extern struct */
- fail_if(!(type = eolian_type_struct_get_by_name("Y")));
- fail_if(!eolian_type_is_extern(type));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Y")));
+ fail_if(!eolian_typedecl_is_extern(tdl));
eolian_shutdown();
}
@@ -831,6 +831,7 @@ START_TEST(eolian_enum)
{
const Eolian_Enum_Type_Field *field = NULL;
const Eolian_Variable *var = NULL;
+ const Eolian_Typedecl *tdl = NULL;
const Eolian_Type *type = NULL;
const Eolian_Class *class;
const Eolian_Expression *exp;
@@ -847,60 +848,60 @@ START_TEST(eolian_enum)
fail_if(!(class = eolian_class_get_by_name("Enum")));
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
- fail_if(!(type = eolian_type_enum_get_by_name("Foo")));
+ fail_if(!(tdl = eolian_typedecl_enum_get_by_name("Foo")));
- fail_if(!(field = eolian_type_enum_field_get(type, "first")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "first")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != 0);
- fail_if(!(field = eolian_type_enum_field_get(type, "bar")));
- fail_if(eolian_type_enum_field_value_get(field, EINA_FALSE));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "bar")));
+ fail_if(eolian_typedecl_enum_field_value_get(field, EINA_FALSE));
- fail_if(!(field = eolian_type_enum_field_get(type, "baz")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "baz")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != 15);
- fail_if(!(type = eolian_type_enum_get_by_name("Bar")));
- fail_if(strcmp(eolian_type_enum_legacy_prefix_get(type), "test"));
+ fail_if(!(tdl = eolian_typedecl_enum_get_by_name("Bar")));
+ fail_if(strcmp(eolian_typedecl_enum_legacy_prefix_get(tdl), "test"));
- fail_if(!(field = eolian_type_enum_field_get(type, "foo")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "foo")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != 15);
- cname = eolian_type_enum_field_c_name_get(field);
+ cname = eolian_typedecl_enum_field_c_name_get(field);
fail_if(strcmp(cname, "TEST_FOO"));
eina_stringshare_del(cname);
- fail_if(!(type = eolian_type_enum_get_by_name("Baz")));
+ fail_if(!(tdl = eolian_typedecl_enum_get_by_name("Baz")));
- fail_if(!(field = eolian_type_enum_field_get(type, "flag1")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag1")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != (1 << 0));
- fail_if(!(field = eolian_type_enum_field_get(type, "flag2")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag2")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != (1 << 1));
- fail_if(!(field = eolian_type_enum_field_get(type, "flag3")));
- fail_if(!(exp = eolian_type_enum_field_value_get(field, EINA_FALSE)));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag3")));
+ fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
v = eolian_expression_eval(exp, EOLIAN_MASK_ALL);
fail_if(v.type != EOLIAN_EXPR_INT);
fail_if(v.value.i != (1 << 2));
- fail_if(!(type = eolian_type_enum_get_by_name("Name.Spaced")));
- fail_if(!(field = eolian_type_enum_field_get(type, "pants")));
+ fail_if(!(tdl = eolian_typedecl_enum_get_by_name("Name.Spaced")));
+ fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "pants")));
- cname = eolian_type_enum_field_c_name_get(field);
+ cname = eolian_typedecl_enum_field_c_name_get(field);
fail_if(strcmp(cname, "NAME_SPACED_PANTS"));
eina_stringshare_del(cname);
@@ -963,6 +964,7 @@ END_TEST
START_TEST(eolian_free_func)
{
const Eolian_Class *class;
+ const Eolian_Typedecl *tdl;
const Eolian_Type *type;
eolian_init();
@@ -975,29 +977,29 @@ START_TEST(eolian_free_func)
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
/* regular struct */
- fail_if(!(type = eolian_type_struct_get_by_name("Named1")));
- fail_if(eolian_type_free_func_get(type));
- fail_if(!(type = eolian_type_struct_get_by_name("Named2")));
- fail_if(strcmp(eolian_type_free_func_get(type), "test_free"));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named1")));
+ fail_if(eolian_typedecl_free_func_get(tdl));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Named2")));
+ fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "test_free"));
/* typedef */
- fail_if(!(type = eolian_type_alias_get_by_name("Typedef1")));
- fail_if(eolian_type_free_func_get(type));
- fail_if(!(type = eolian_type_alias_get_by_name("Typedef2")));
- fail_if(strcmp(eolian_type_free_func_get(type), "def_free"));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Typedef1")));
+ fail_if(eolian_typedecl_free_func_get(tdl));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Typedef2")));
+ fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "def_free"));
/* opaque struct */
- fail_if(!(type = eolian_type_struct_get_by_name("Opaque1")));
- fail_if(eolian_type_free_func_get(type));
- fail_if(!(type = eolian_type_struct_get_by_name("Opaque2")));
- fail_if(strcmp(eolian_type_free_func_get(type), "opaque_free"));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque1")));
+ fail_if(eolian_typedecl_free_func_get(tdl));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque2")));
+ fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "opaque_free"));
/* pointer */
- fail_if(!(type = eolian_type_alias_get_by_name("Pointer1")));
- fail_if(!(type = eolian_type_base_type_get(type)));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Pointer1")));
+ fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(eolian_type_free_func_get(type));
- fail_if(!(type = eolian_type_alias_get_by_name("Pointer2")));
- fail_if(!(type = eolian_type_base_type_get(type)));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Pointer2")));
+ fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
fail_if(strcmp(eolian_type_free_func_get(type), "ptr_free"));
eolian_shutdown();
@@ -1055,7 +1057,7 @@ END_TEST
START_TEST(eolian_import)
{
const Eolian_Class *class;
- const Eolian_Type *type;
+ const Eolian_Typedecl *tdl;
eolian_init();
@@ -1064,11 +1066,11 @@ START_TEST(eolian_import)
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/import.eo"));
fail_if(!(class = eolian_class_get_by_name("Import")));
- fail_if(!(type = eolian_type_alias_get_by_name("Imported")));
- fail_if(strcmp(eolian_type_file_get(type), "import_types.eot"));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Imported")));
+ fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
- fail_if(!(type = eolian_type_struct_get_by_name("Imported_Struct")));
- fail_if(strcmp(eolian_type_file_get(type), "import_types.eot"));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Imported_Struct")));
+ fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
eolian_shutdown();
}
@@ -1077,7 +1079,7 @@ END_TEST
START_TEST(eolian_decl)
{
const Eolian_Declaration *decl;
- const Eolian_Type *type;
+ const Eolian_Typedecl *tdl;
const Eolian_Class *class;
const Eolian_Variable *var;
Eina_Iterator *itr;
@@ -1094,23 +1096,23 @@ START_TEST(eolian_decl)
fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_STRUCT);
fail_if(strcmp(eolian_declaration_name_get(decl), "A"));
- fail_if(!(type = eolian_declaration_data_type_get(decl)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_STRUCT);
- fail_if(strcmp(eolian_type_name_get(type), "A"));
+ fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
+ fail_if(strcmp(eolian_typedecl_name_get(tdl), "A"));
fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_ENUM);
fail_if(strcmp(eolian_declaration_name_get(decl), "B"));
- fail_if(!(type = eolian_declaration_data_type_get(decl)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_ENUM);
- fail_if(strcmp(eolian_type_name_get(type), "B"));
+ fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ENUM);
+ fail_if(strcmp(eolian_typedecl_name_get(tdl), "B"));
fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_ALIAS);
fail_if(strcmp(eolian_declaration_name_get(decl), "C"));
- fail_if(!(type = eolian_declaration_data_type_get(decl)));
- fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_ALIAS);
- fail_if(strcmp(eolian_type_name_get(type), "C"));
+ fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
+ fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
+ fail_if(strcmp(eolian_typedecl_name_get(tdl), "C"));
fail_if(!eina_iterator_next(itr, (void**)&decl));
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_VAR);
@@ -1137,7 +1139,7 @@ END_TEST
START_TEST(eolian_docs)
{
- const Eolian_Type *type;
+ const Eolian_Typedecl *tdl;
const Eolian_Class *class;
const Eolian_Event *event;
const Eolian_Variable *var;
@@ -1154,8 +1156,8 @@ START_TEST(eolian_docs)
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo"));
- fail_if(!(type = eolian_type_struct_get_by_name("Foo")));
- fail_if(!(doc = eolian_type_documentation_get(type)));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Foo")));
+ fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"This is struct Foo. It does stuff."));
fail_if(strcmp(eolian_documentation_description_get(doc),
@@ -1167,45 +1169,45 @@ START_TEST(eolian_docs)
fail_if(strcmp(eolian_documentation_since_get(doc),
"1.66"));
- fail_if(!(sfl = eolian_type_struct_field_get(type, "field1")));
- fail_if(!(doc = eolian_type_struct_field_documentation_get(sfl)));
+ fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field1")));
+ fail_if(!(doc = eolian_typedecl_struct_field_documentation_get(sfl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Field documentation."));
fail_if(eolian_documentation_description_get(doc));
- fail_if(!(sfl = eolian_type_struct_field_get(type, "field2")));
- fail_if(eolian_type_struct_field_documentation_get(sfl));
+ fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field2")));
+ fail_if(eolian_typedecl_struct_field_documentation_get(sfl));
- fail_if(!(sfl = eolian_type_struct_field_get(type, "field3")));
- fail_if(!(doc = eolian_type_struct_field_documentation_get(sfl)));
+ fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field3")));
+ fail_if(!(doc = eolian_typedecl_struct_field_documentation_get(sfl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Another field documentation."));
fail_if(eolian_documentation_description_get(doc));
- fail_if(!(type = eolian_type_enum_get_by_name("Bar")));
- fail_if(!(doc = eolian_type_documentation_get(type)));
+ fail_if(!(tdl = eolian_typedecl_enum_get_by_name("Bar")));
+ fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Docs for enum Bar."));
fail_if(eolian_documentation_description_get(doc));
fail_if(eolian_documentation_since_get(doc));
- fail_if(!(efl = eolian_type_enum_field_get(type, "blah")));
- fail_if(eolian_type_enum_field_documentation_get(efl));
+ fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "blah")));
+ fail_if(eolian_typedecl_enum_field_documentation_get(efl));
- fail_if(!(efl = eolian_type_enum_field_get(type, "foo")));
- fail_if(!(doc = eolian_type_enum_field_documentation_get(efl)));
+ fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "foo")));
+ fail_if(!(doc = eolian_typedecl_enum_field_documentation_get(efl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Docs for foo."));
fail_if(eolian_documentation_description_get(doc));
- fail_if(!(efl = eolian_type_enum_field_get(type, "bar")));
- fail_if(!(doc = eolian_type_enum_field_documentation_get(efl)));
+ fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "bar")));
+ fail_if(!(doc = eolian_typedecl_enum_field_documentation_get(efl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Docs for bar."));
fail_if(eolian_documentation_description_get(doc));
- fail_if(!(type = eolian_type_alias_get_by_name("Alias")));
- fail_if(!(doc = eolian_type_documentation_get(type)));
+ fail_if(!(tdl = eolian_typedecl_alias_get_by_name("Alias")));
+ fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Docs for typedef."));
fail_if(strcmp(eolian_documentation_description_get(doc),
@@ -1219,8 +1221,8 @@ START_TEST(eolian_docs)
"Docs for var."));
fail_if(eolian_documentation_description_get(doc));
- fail_if(!(type = eolian_type_struct_get_by_name("Opaque")));
- fail_if(!(doc = eolian_type_documentation_get(type)));
+ fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Opaque")));
+ fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
fail_if(strcmp(eolian_documentation_summary_get(doc),
"Opaque struct docs. See @Foo for another struct."));
fail_if(eolian_documentation_description_get(doc));