aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-15 17:00:36 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-15 17:11:11 +0100
commit18e18ca74c5456e0ecb7f03065959fb9fb7b58f4 (patch)
treeeda220d83a70bdec5b2b14227fa1bac8d3381b3c /src/lib
parenteolian: filename retrieval APIs are read only (diff)
downloadefl-18e18ca74c5456e0ecb7f03065959fb9fb7b58f4.tar.gz
eolian: remove remaining global state (+ modify APIs accordingly)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eolian/Eolian.h12
-rw-r--r--src/lib/eolian/database_expr.c2
-rw-r--r--src/lib/eolian/database_expr_api.c4
-rw-r--r--src/lib/eolian/database_type.c35
-rw-r--r--src/lib/eolian/database_type_api.c19
-rw-r--r--src/lib/eolian/database_validate.c8
-rw-r--r--src/lib/eolian/database_var.c4
-rw-r--r--src/lib/eolian/eo_parser.c10
-rw-r--r--src/lib/eolian/eolian_database.c39
-rw-r--r--src/lib/eolian/eolian_database.h13
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp4
11 files changed, 77 insertions, 73 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index ad35d16c0a..2f6336664e 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1807,12 +1807,13 @@ EAPI const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp)
* 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] unit the unit to look in
* @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);
+EAPI const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
/*
* @brief Check if a struct or alias type declaration is extern.
@@ -1955,12 +1956,13 @@ EAPI const Eolian_Type *eolian_type_next_type_get(const Eolian_Type *tp);
*
* This tries to look up alias, struct and enum in that order.
*
+ * @param[in] unit the unit to look in
* @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);
+EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Unit *unit, const Eolian_Type *tp);
/*
* @brief Get the lowest base type of an alias stack.
@@ -1972,12 +1974,13 @@ EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Type *tp);
* type actually is while still having convenience. Keep in mind that this stops
* if the found type is actually a pointer (has a ptr() on it).
*
+ * @param[in] unit the unit to look in
* @param[in] tp the type.
* @return the lowest alias base or the given type.
*
* @ingroup Eolian
*/
-EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Type *tp);
+EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Unit *unit, const Eolian_Type *tp);
/*
* @brief Get the class associated with an EOLIAN_TYPE_CLASS type.
@@ -2025,6 +2028,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
/*
* @brief Get the full C type name of the given type.
*
+ * @param[in] unit the unit to look in
* @param[in] tp the type.
* @param[in] ctype the context within which the C type string will be used.
* @return The C type name assuming @c tp is not NULL.
@@ -2035,7 +2039,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
*
* @ingroup Eolian
*/
-EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
+EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp, Eolian_C_Type_Type ctype);
/*
* @brief Get the name of the given type. For regular types, this is for
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index 6a3b1d52f1..1b0a6d10e3 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -522,7 +522,7 @@ eval_exp(const Eolian_Unit *unit, const Eolian_Expression *expr,
const Eolian_Type *etp = eolian_typedecl_base_type_get(etpd);
if (!etp || etp->type != EOLIAN_TYPE_REGULAR)
break;
- etpd = eolian_type_typedecl_get(etp);
+ etpd = eolian_type_typedecl_get(unit, etp);
}
if (!etpd) etpd = eolian_typedecl_enum_get_by_name(unit, fulln);
diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index 9e8e1f61fd..adf573435a 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -29,12 +29,12 @@ _eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr,
return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
case EOLIAN_TYPE_REGULAR:
{
- if (database_type_is_ownable(type))
+ if (database_type_is_ownable(unit, type))
return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
int kw = eo_lexer_keyword_str_to_id(type->name);
if (!kw || kw < KW_byte || kw >= KW_void)
{
- const Eolian_Typedecl *base = eolian_type_typedecl_get(type);
+ const Eolian_Typedecl *base = eolian_type_typedecl_get(unit, type);
if (!base)
return err;
if (base->type == EOLIAN_TYPEDECL_ALIAS)
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 5258709d1a..1400aa028c 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -47,7 +47,7 @@ database_type_add(Eolian *state, Eolian_Typedecl *def)
eina_hash_set(state->aliases_f, def->base.file, eina_list_append
((Eina_List*)eina_hash_find(state->aliases_f, def->base.file),
def));
- database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def);
+ database_decl_add(state, def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def);
}
void
@@ -56,7 +56,7 @@ database_struct_add(Eolian *state, Eolian_Typedecl *tp)
eina_hash_set(state->unit.structs, tp->full_name, tp);
eina_hash_set(state->structs_f, tp->base.file, eina_list_append
((Eina_List*)eina_hash_find(state->structs_f, tp->base.file), tp));
- database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
+ database_decl_add(state, tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp);
}
void
@@ -65,11 +65,11 @@ database_enum_add(Eolian *state, Eolian_Typedecl *tp)
eina_hash_set(state->unit.enums, tp->full_name, tp);
eina_hash_set(state->enums_f, tp->base.file, eina_list_append
((Eina_List*)eina_hash_find(state->enums_f, tp->base.file), tp));
- database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
+ database_decl_add(state, tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp);
}
Eina_Bool
-database_type_is_ownable(const Eolian_Type *tp)
+database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp)
{
if (tp->is_ptr)
return EINA_TRUE;
@@ -79,13 +79,13 @@ database_type_is_ownable(const Eolian_Type *tp)
const char *ct = eo_lexer_get_c_type(kw);
if (!ct)
{
- const Eolian_Typedecl *tpp = eolian_type_typedecl_get(tp);
+ const Eolian_Typedecl *tpp = eolian_type_typedecl_get(unit, tp);
if (!tpp)
return EINA_FALSE;
if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER)
return EINA_TRUE;
if (tpp->type == EOLIAN_TYPEDECL_ALIAS)
- return database_type_is_ownable(tpp->base_type);
+ return database_type_is_ownable(unit, tpp->base_type);
return EINA_FALSE;
}
return (ct[strlen(ct) - 1] == '*');
@@ -103,14 +103,15 @@ _buf_add_suffix(Eina_Strbuf *buf, const char *suffix)
}
void
-database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
+database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp,
+ Eina_Strbuf *buf, const char *name,
Eolian_C_Type_Type ctype)
{
if ((tp->type == EOLIAN_TYPE_REGULAR
|| tp->type == EOLIAN_TYPE_CLASS
|| tp->type == EOLIAN_TYPE_VOID)
&& tp->is_const
- && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(tp)))
+ && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(src, tp)))
{
eina_strbuf_append(buf, "const ");
}
@@ -137,7 +138,8 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
else
{
/* handles arrays and pointers as they all serialize to pointers */
- database_type_to_str(tp->base_type, buf, NULL, EOLIAN_C_TYPE_DEFAULT);
+ database_type_to_str(src, tp->base_type, buf, NULL,
+ EOLIAN_C_TYPE_DEFAULT);
_buf_add_suffix(buf, "*");
if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN))
eina_strbuf_append(buf, " const");
@@ -150,7 +152,8 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
}
static void
-_stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
+_stype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
+ Eina_Strbuf *buf)
{
Eolian_Struct_Type_Field *sf;
Eina_List *l;
@@ -167,7 +170,8 @@ _stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
eina_strbuf_append(buf, " { ");
EINA_LIST_FOREACH(tp->field_list, l, sf)
{
- database_type_to_str(sf->type, buf, sf->name, EOLIAN_C_TYPE_DEFAULT);
+ database_type_to_str(src, sf->type, buf, sf->name,
+ EOLIAN_C_TYPE_DEFAULT);
eina_strbuf_append(buf, "; ");
}
eina_strbuf_append(buf, "}");
@@ -222,7 +226,8 @@ _append_name(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
}
static void
-_atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
+_atype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
+ Eina_Strbuf *buf)
{
eina_strbuf_append(buf, "typedef ");
@@ -239,7 +244,7 @@ _atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
Eina_Strbuf *fulln = eina_strbuf_new();
_append_name(tp, fulln);
- database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln),
+ database_type_to_str(src, tp->base_type, buf, eina_strbuf_string_get(fulln),
EOLIAN_C_TYPE_DEFAULT);
eina_strbuf_free(fulln);
}
@@ -251,14 +256,14 @@ database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
switch (tp->type)
{
case EOLIAN_TYPEDECL_ALIAS:
- _atype_to_str(tp, buf);
+ _atype_to_str(src, tp, buf);
break;
case EOLIAN_TYPEDECL_ENUM:
_etype_to_str(src, tp, buf);
break;
case EOLIAN_TYPEDECL_STRUCT:
case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
- _stype_to_str(tp, buf);
+ _stype_to_str(src, tp, buf);
break;
default:
break;
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 5edaed94af..d733a93ed3 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -266,7 +266,7 @@ eolian_type_next_type_get(const Eolian_Type *tp)
}
EAPI const Eolian_Typedecl *
-eolian_type_typedecl_get(const Eolian_Type *tp)
+eolian_type_typedecl_get(const Eolian_Unit *unit, const Eolian_Type *tp)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
if (eolian_type_type_get(tp) != EOLIAN_TYPE_REGULAR)
@@ -277,7 +277,7 @@ eolian_type_typedecl_get(const Eolian_Type *tp)
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);
+ Eolian_Declaration *decl = eina_hash_find(unit->state->unit.decls, tp->full_name);
if (decl && decl->type != EOLIAN_DECL_CLASS
&& decl->type != EOLIAN_DECL_VAR)
return decl->data;
@@ -293,22 +293,22 @@ eolian_typedecl_base_type_get(const Eolian_Typedecl *tp)
}
EAPI const Eolian_Type *
-eolian_type_aliased_base_get(const Eolian_Type *tp)
+eolian_type_aliased_base_get(const Eolian_Unit *unit, const Eolian_Type *tp)
{
if (!tp || tp->type != EOLIAN_TYPE_REGULAR || tp->is_ptr)
return tp;
- const Eolian_Typedecl *btp = eolian_type_typedecl_get(tp);
+ const Eolian_Typedecl *btp = eolian_type_typedecl_get(unit, tp);
if (btp && (btp->type == EOLIAN_TYPEDECL_ALIAS))
- return eolian_typedecl_aliased_base_get(btp);
+ return eolian_typedecl_aliased_base_get(unit, btp);
return tp;
}
EAPI const Eolian_Type *
-eolian_typedecl_aliased_base_get(const Eolian_Typedecl *tp)
+eolian_typedecl_aliased_base_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp)
{
if (!tp || tp->type != EOLIAN_TYPEDECL_ALIAS)
return NULL;
- return eolian_type_aliased_base_get(tp->base_type);
+ return eolian_type_aliased_base_get(unit, tp->base_type);
}
EAPI const Eolian_Class *
@@ -349,13 +349,14 @@ eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
}
EAPI Eina_Stringshare *
-eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype)
+eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp,
+ Eolian_C_Type_Type ctype)
{
Eina_Stringshare *ret;
Eina_Strbuf *buf;
EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
buf = eina_strbuf_new();
- database_type_to_str(tp, buf, NULL, ctype);
+ database_type_to_str(unit, tp, buf, NULL, ctype);
ret = eina_stringshare_add(eina_strbuf_string_get(buf));
eina_strbuf_free(buf);
return ret;
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index e4cf4ca16a..6706464172 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -173,7 +173,7 @@ _validate_type(const Eolian_Unit *src, Eolian_Type *tp)
{
char buf[256];
- if (tp->owned && !database_type_is_ownable(tp))
+ if (tp->owned && !database_type_is_ownable(src, tp))
{
snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
return _obj_error(&tp->base, buf);
@@ -182,7 +182,7 @@ _validate_type(const Eolian_Unit *src, Eolian_Type *tp)
if (tp->is_ptr && !tp->legacy)
{
tp->is_ptr = EINA_FALSE;
- Eina_Bool still_ownable = database_type_is_ownable(tp);
+ Eina_Bool still_ownable = database_type_is_ownable(src, tp);
tp->is_ptr = EINA_TRUE;
if (still_ownable)
{
@@ -213,7 +213,7 @@ _validate_type(const Eolian_Unit *src, Eolian_Type *tp)
return EINA_FALSE;
if ((kwid >= KW_accessor) && (kwid <= KW_list))
{
- if (!database_type_is_ownable(itp))
+ if (!database_type_is_ownable(src, itp))
{
snprintf(buf, sizeof(buf),
"%s cannot contain value types (%s)",
@@ -253,7 +253,7 @@ _validate_type(const Eolian_Unit *src, Eolian_Type *tp)
return _validate(&tp->base);
}
/* user defined */
- tpp = (Eolian_Typedecl *)eolian_type_typedecl_get(tp);
+ tpp = (Eolian_Typedecl *)eolian_type_typedecl_get(src, tp);
if (!tpp)
{
snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
diff --git a/src/lib/eolian/database_var.c b/src/lib/eolian/database_var.c
index b14a99a2fa..d0870c3f34 100644
--- a/src/lib/eolian/database_var.c
+++ b/src/lib/eolian/database_var.c
@@ -28,7 +28,7 @@ database_var_global_add(Eolian *state, Eolian_Variable *var)
eina_hash_set(state->unit.globals, var->full_name, var);
eina_hash_set(state->globals_f, var->base.file, eina_list_append
((Eina_List*)eina_hash_find(state->globals_f, var->base.file), var));
- database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
+ database_decl_add(state, var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
}
static void
@@ -37,7 +37,7 @@ database_var_constant_add(Eolian *state, Eolian_Variable *var)
eina_hash_set(state->unit.constants, var->full_name, var);
eina_hash_set(state->constants_f, var->base.file, eina_list_append
((Eina_List*)eina_hash_find(state->constants_f, var->base.file), var));
- database_decl_add(var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
+ database_decl_add(state, var->full_name, EOLIAN_DECL_VAR, var->base.file, var);
}
void
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 71e1d7ee55..b8e721a11b 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -866,7 +866,7 @@ parse_typedef(Eo_Lexer *ls)
parse_name(ls, buf);
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
&def->full_name, &def->name, &def->namespaces);
- decl = (Eolian_Declaration *)eina_hash_find(_decls, def->full_name);
+ decl = (Eolian_Declaration *)eina_hash_find(ls->state->unit.decls, def->full_name);
if (decl)
{
eo_lexer_context_restore(ls);
@@ -902,7 +902,7 @@ parse_variable(Eo_Lexer *ls, Eina_Bool global)
parse_name(ls, buf);
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
&def->full_name, &def->name, &def->namespaces);
- decl = (Eolian_Declaration *)eina_hash_find(_decls, def->full_name);
+ decl = (Eolian_Declaration *)eina_hash_find(ls->state->unit.decls, def->full_name);
if (decl)
{
eo_lexer_context_restore(ls);
@@ -2117,7 +2117,7 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
&ls->tmp.kls->full_name, &ls->tmp.kls->name,
&ls->tmp.kls->namespaces);
- decl = (Eolian_Declaration *)eina_hash_find(_decls, ls->tmp.kls->full_name);
+ decl = (Eolian_Declaration *)eina_hash_find(ls->state->unit.decls, ls->tmp.kls->full_name);
if (decl)
{
eo_lexer_context_restore(ls);
@@ -2233,7 +2233,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
col = ls->column;
parse_name(ls, buf);
name = eina_stringshare_add(eina_strbuf_string_get(buf));
- decl = (Eolian_Declaration *)eina_hash_find(_decls, name);
+ decl = (Eolian_Declaration *)eina_hash_find(ls->state->unit.decls, name);
if (decl)
{
eina_stringshare_del(name);
@@ -2271,7 +2271,7 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
}
return EINA_FALSE;
found_class:
- database_decl_add(ls->tmp.kls->full_name, EOLIAN_DECL_CLASS,
+ database_decl_add(ls->state, ls->tmp.kls->full_name, EOLIAN_DECL_CLASS,
ls->tmp.kls->base.file, ls->tmp.kls);
return EINA_TRUE;
}
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index bf8f17f1af..fdba068728 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -8,9 +8,6 @@
#include "eolian_database.h"
#include "eolian_priv.h"
-Eina_Hash *_decls = NULL;
-Eina_Hash *_declsf = NULL;
-
static int _database_init_count = 0;
static void
@@ -23,8 +20,6 @@ int
database_init()
{
if (_database_init_count > 0) return ++_database_init_count;
- _decls = eina_hash_stringshared_new(free);
- _declsf = eina_hash_stringshared_new(_hashlist_free);
return ++_database_init_count;
}
@@ -38,52 +33,48 @@ database_shutdown()
}
_database_init_count--;
- if (_database_init_count == 0)
- {
- eina_hash_free(_decls ); _decls = NULL;
- eina_hash_free(_declsf ); _declsf = NULL;
- }
return _database_init_count;
}
void
-database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
+database_decl_add(Eolian *state, Eina_Stringshare *name,
+ Eolian_Declaration_Type type,
Eina_Stringshare *file, void *ptr)
{
Eolian_Declaration *decl = calloc(1, sizeof(Eolian_Declaration));
decl->type = type;
decl->name = name;
decl->data = ptr;
- eina_hash_set(_decls, name, decl);
- eina_hash_set(_declsf, file, eina_list_append
- ((Eina_List*)eina_hash_find(_declsf, file), decl));
+ eina_hash_set(state->unit.decls, name, decl);
+ eina_hash_set(state->decls_f, file, eina_list_append
+ ((Eina_List*)eina_hash_find(state->decls_f, file), decl));
}
EAPI const Eolian_Declaration *
-eolian_declaration_get_by_name(const Eolian_Unit *unit EINA_UNUSED, const char *name)
+eolian_declaration_get_by_name(const Eolian_Unit *unit, const char *name)
{
- if (!_decls) return NULL;
+ if (!unit) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(name);
- const Eolian_Declaration *decl = eina_hash_find(_decls, shr);
+ const Eolian_Declaration *decl = eina_hash_find(unit->state->unit.decls, shr);
eina_stringshare_del(shr);
return decl;
}
EAPI Eina_Iterator *
-eolian_declarations_get_by_file(const Eolian *state EINA_UNUSED, const char *fname)
+eolian_declarations_get_by_file(const Eolian *state, const char *fname)
{
- if (!_declsf) return NULL;
+ if (!state) return NULL;
Eina_Stringshare *shr = eina_stringshare_add(fname);
- Eina_List *l = eina_hash_find(_declsf, shr);
+ Eina_List *l = eina_hash_find(state->decls_f, shr);
eina_stringshare_del(shr);
if (!l) return NULL;
return eina_list_iterator_new(l);
}
EAPI Eina_Iterator *
-eolian_all_declarations_get(const Eolian_Unit *unit EINA_UNUSED)
+eolian_all_declarations_get(const Eolian_Unit *unit)
{
- return (_decls ? eina_hash_iterator_data_new(_decls) : NULL);
+ return (unit ? eina_hash_iterator_data_new(unit->state->unit.decls) : NULL);
}
EAPI Eolian_Declaration_Type
@@ -551,6 +542,7 @@ database_unit_init(Eolian *state, Eolian_Unit *unit)
unit->aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
unit->structs = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
unit->enums = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del));
+ unit->decls = eina_hash_stringshared_new(free);
}
void
@@ -565,6 +557,7 @@ database_unit_del(Eolian_Unit *unit)
eina_hash_free(unit->aliases);
eina_hash_free(unit->structs);
eina_hash_free(unit->enums);
+ eina_hash_free(unit->decls);
}
EAPI Eolian *
@@ -591,6 +584,7 @@ eolian_new(void)
state->enums_f = eina_hash_stringshared_new(_hashlist_free);
state->globals_f = eina_hash_stringshared_new(_hashlist_free);
state->constants_f = eina_hash_stringshared_new(_hashlist_free);
+ state->decls_f = eina_hash_stringshared_new(_hashlist_free);
return state;
}
@@ -618,6 +612,7 @@ eolian_free(Eolian *state)
eina_hash_free(state->enums_f);
eina_hash_free(state->globals_f);
eina_hash_free(state->constants_f);
+ eina_hash_free(state->decls_f);
free(state);
}
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index b2e72907ab..edef41e94c 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -31,10 +31,6 @@ extern Eina_Prefix *_eolian_prefix;
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_eolian_log_dom, __VA_ARGS__)
-/* a hash holding all declarations, for redef checking etc */
-extern Eina_Hash *_decls;
-extern Eina_Hash *_declsf;
-
struct _Eolian_Unit
{
Eolian *state;
@@ -45,6 +41,7 @@ struct _Eolian_Unit
Eina_Hash *aliases;
Eina_Hash *structs;
Eina_Hash *enums;
+ Eina_Hash *decls;
};
struct _Eolian
@@ -66,6 +63,7 @@ struct _Eolian
Eina_Hash *enums_f;
Eina_Hash *globals_f;
Eina_Hash *constants_f;
+ Eina_Hash *decls_f;
};
typedef struct _Eolian_Object
@@ -322,7 +320,8 @@ int database_shutdown(void);
char *database_class_to_filename(const char *cname);
Eina_Bool database_validate(Eolian *state, const Eolian_Unit *src);
-void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
+void database_decl_add(Eolian *state, Eina_Stringshare *name,
+ Eolian_Declaration_Type type,
Eina_Stringshare *file, void *ptr);
void database_doc_del(Eolian_Documentation *doc);
@@ -338,10 +337,10 @@ void database_enum_add(Eolian *state, Eolian_Typedecl *tp);
void database_type_del(Eolian_Type *tp);
void database_typedecl_del(Eolian_Typedecl *tp);
-void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
+void database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
-Eina_Bool database_type_is_ownable(const Eolian_Type *tp);
+Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp);
/* expressions */
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index e7a32ad396..d1fce8f6d9 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -259,7 +259,7 @@ type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_n
inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, Eolian_C_Type_Type ctype)
{
- c_type = ::eolian_type_c_type_get(eolian_type, ctype);
+ c_type = ::eolian_type_c_type_get(unit, eolian_type, ctype);
// ::eina_stringshare_del(stringshare); // this crashes
Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
has_own = !!::eolian_type_is_owned(eolian_type);
@@ -273,7 +273,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
if (!stp)
{
bool is_undefined = false;
- Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
+ Eolian_Typedecl const* decl = eolian_type_typedecl_get(unit, eolian_type);
bool is_function_ptr = decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_FUNCTION_POINTER;
if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS)
{