summaryrefslogtreecommitdiff
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
parentd624464ab4c61140ed3d46a2bbc183b8cb500d2b (diff)
downloadefl-18e18ca74c5456e0ecb7f03065959fb9fb7b58f4.tar.gz
eolian: remove remaining global state (+ modify APIs accordingly)
-rw-r--r--src/bin/eolian/docs.c2
-rw-r--r--src/bin/eolian/headers.c18
-rw-r--r--src/bin/eolian/headers.h2
-rw-r--r--src/bin/eolian/sources.c51
-rw-r--r--src/bin/eolian/types.c10
-rw-r--r--src/bindings/luajit/eolian.lua24
-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
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua9
-rw-r--r--src/scripts/elua/modules/lualian.lua16
-rw-r--r--src/tests/eolian/eolian_parsing.c48
20 files changed, 170 insertions, 160 deletions
diff --git a/src/bin/eolian/docs.c b/src/bin/eolian/docs.c
index 09e63bf9ac..a38ac19ff7 100644
--- a/src/bin/eolian/docs.c
+++ b/src/bin/eolian/docs.c
@@ -377,7 +377,7 @@ eo_gen_docs_event_gen(const Eolian_Unit *src, const Eolian_Event *ev,
if (rt)
{
p = buf;
- Eina_Stringshare *rts = eolian_type_c_type_get(rt, EOLIAN_C_TYPE_DEFAULT);
+ Eina_Stringshare *rts = eolian_type_c_type_get(src, rt, EOLIAN_C_TYPE_DEFAULT);
snprintf(buf, sizeof(buf), "@return %s", rts);
eina_stringshare_del(rts);
}
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index 90fc1ea611..b2fe73a00c 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -12,12 +12,13 @@ _get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
}
static int
-_gen_param(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, Eolian_Function_Type ftype, int *rpid)
+_gen_param(const Eolian_Unit *src, Eina_Strbuf *buf,
+ Eolian_Function_Parameter *pr, Eolian_Function_Type ftype, int *rpid)
{
const Eolian_Type *prt = eolian_parameter_type_get(pr);
- const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
+ const Eolian_Typedecl *ptd = eolian_type_typedecl_get(src, prt);
const char *prn = eolian_parameter_name_get(pr);
- Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *prtn = eolian_type_c_type_get(src, prt, EOLIAN_C_TYPE_PARAM);
if (ptd && (eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER))
{
@@ -39,7 +40,8 @@ _gen_param(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, Eolian_Function_Type
}
void
-eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype)
+eo_gen_params(const Eolian_Unit *src, Eina_Iterator *itr, Eina_Strbuf *buf,
+ Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype)
{
Eolian_Function_Parameter *pr;
EINA_ITERATOR_FOREACH(itr, pr)
@@ -47,7 +49,7 @@ eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *
int rpid = 0;
if (*nidx)
eina_strbuf_append(buf, ", ");
- *nidx += _gen_param(buf, pr, ftype, &rpid);
+ *nidx += _gen_param(src, buf, pr, ftype, &rpid);
if (!eolian_parameter_is_nonull(pr) || !flagbuf)
continue;
@@ -110,7 +112,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
if (rtp)
{
- Eina_Stringshare *rtps = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
+ Eina_Stringshare *rtps = eolian_type_c_type_get(src, rtp, EOLIAN_C_TYPE_RETURN);
eina_strbuf_append(buf, rtps);
if (rtps[strlen(rtps) - 1] != '*')
eina_strbuf_append_char(buf, ' ');
@@ -139,7 +141,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
eina_strbuf_append(buf, "Eo *obj");
}
- eo_gen_params(eolian_property_keys_get(fid, ftype), buf, &flagbuf, &nidx, EOLIAN_PROPERTY);
+ eo_gen_params(src, eolian_property_keys_get(fid, ftype), buf, &flagbuf, &nidx, EOLIAN_PROPERTY);
if (!var_as_ret)
{
@@ -148,7 +150,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
itr = eolian_property_values_get(fid, ftype);
else
itr = eolian_function_parameters_get(fid);
- eo_gen_params(itr, buf, &flagbuf, &nidx, ftype);
+ eo_gen_params(src, itr, buf, &flagbuf, &nidx, ftype);
}
if (flagbuf)
diff --git a/src/bin/eolian/headers.h b/src/bin/eolian/headers.h
index 56e4b4ffdf..41c7658b96 100644
--- a/src/bin/eolian/headers.h
+++ b/src/bin/eolian/headers.h
@@ -3,7 +3,7 @@
#include "main.h"
-void eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype);
+void eo_gen_params(const Eolian_Unit *src, Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype);
void eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy);
#endif
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index a8a349fa86..a012e8c602 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -123,13 +123,13 @@ _append_defval(const Eolian_Unit *src, Eina_Strbuf *buf,
else WRN("evaluation of default value failed");
}
/* default value or fallback */
- const Eolian_Type *btp = eolian_type_aliased_base_get(tp);
+ const Eolian_Type *btp = eolian_type_aliased_base_get(src, tp);
if (eolian_type_is_ptr(btp))
{
eina_strbuf_append(buf, "NULL");
return;
}
- const Eolian_Typedecl *tdcl = eolian_type_typedecl_get(btp);
+ const Eolian_Typedecl *tdcl = eolian_type_typedecl_get(src, btp);
if (tdcl && (eolian_typedecl_type_get(tdcl) == EOLIAN_TYPEDECL_STRUCT))
{
char *sn = eo_gen_c_full_name_get(eolian_typedecl_full_name_get(tdcl));
@@ -140,7 +140,7 @@ _append_defval(const Eolian_Unit *src, Eina_Strbuf *buf,
free(sn);
return;
}
- Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT);
+ Eina_Stringshare *ctp = eolian_type_c_type_get(src, btp, EOLIAN_C_TYPE_DEFAULT);
if (strchr(ctp, '*'))
{
eina_strbuf_append(buf, "NULL");
@@ -182,7 +182,7 @@ _generate_loop_content(Eina_Strbuf **buf, const Eolian_Type *inner_type, const E
}
static void
-_generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolian_Type *inner_type, Eolian_Function_Parameter *parameter, Eina_Strbuf *param)
+_generate_iterative_free(const Eolian_Unit *src, Eina_Strbuf **buf, const Eolian_Type *type, const Eolian_Type *inner_type, Eolian_Function_Parameter *parameter, Eina_Strbuf *param)
{
Eina_Strbuf *iterator_header, *iter_param;
@@ -194,7 +194,7 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
eina_strbuf_append_printf(iter_param, "%s_iter", eolian_parameter_name_get(parameter));
//generate the field definition
- eina_strbuf_append_printf(*buf, " %s", eolian_type_c_type_get(inner_type, EOLIAN_C_TYPE_DEFAULT));
+ eina_strbuf_append_printf(*buf, " %s", eolian_type_c_type_get(src, inner_type, EOLIAN_C_TYPE_DEFAULT));
if(t == EOLIAN_TYPE_BUILTIN_INARRAY
|| t == EOLIAN_TYPE_BUILTIN_INLIST)
{
@@ -328,7 +328,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
{
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(src, pt, EOLIAN_C_TYPE_PARAM);
if (eina_strbuf_length_get(params))
eina_strbuf_append(params, ", ");
@@ -400,7 +400,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
}
else if (inner_type && eolian_type_is_owned(inner_type))
{
- _generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call);
+ _generate_iterative_free(src, &fallback_free_ownership, type, inner_type, pr, param_call);
}
}
eina_iterator_free(itr);
@@ -429,8 +429,8 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr);
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
- const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(src, pt, EOLIAN_C_TYPE_PARAM);
+ const Eolian_Typedecl *ptd = eolian_type_typedecl_get(src, pt);
Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
const char *add_star = _get_add_star(ftype, pd);
@@ -501,7 +501,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
impl_need = EINA_FALSE;
- Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)
+ Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(src, rtp, EOLIAN_C_TYPE_RETURN)
: eina_stringshare_add("void");
char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
@@ -1018,8 +1018,9 @@ eo_gen_source_gen(const Eolian_Unit *src,
}
static void
-_gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
- Eina_Bool var_as_ret, Eina_Strbuf *params, Eina_Strbuf *params_full)
+_gen_params(const Eolian_Unit *src, const Eolian_Function *fid,
+ Eolian_Function_Type ftype, Eina_Bool var_as_ret,
+ Eina_Strbuf *params, Eina_Strbuf *params_full)
{
Eina_Bool is_prop = (ftype == EOLIAN_PROP_GET || ftype == EOLIAN_PROP_SET);
@@ -1031,7 +1032,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
{
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(src, pt, EOLIAN_C_TYPE_PARAM);
eina_strbuf_append(params, ", ");
eina_strbuf_append(params, prn);
@@ -1060,8 +1061,8 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
Eolian_Parameter_Dir pd = eolian_parameter_direction_get(pr);
const char *prn = eolian_parameter_name_get(pr);
const Eolian_Type *pt = eolian_parameter_type_get(pr);
- const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
- Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
+ const Eolian_Typedecl *ptd = eolian_type_typedecl_get(src, pt);
+ Eina_Stringshare *ptn = eolian_type_c_type_get(src, pt, EOLIAN_C_TYPE_PARAM);
if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
{
@@ -1092,9 +1093,9 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
}
static void
-_gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
- Eolian_Function_Type ftype, Eina_Strbuf *buf,
- const Eolian_Implement *impl, const char *dtype,
+_gen_proto(const Eolian_Unit *src, const Eolian_Class *cl,
+ const Eolian_Function *fid, Eolian_Function_Type ftype,
+ Eina_Strbuf *buf, const Eolian_Implement *impl, const char *dtype,
const char *cnamel)
{
Eina_Bool impl_same_class = (eolian_implement_class_get(impl) == cl);
@@ -1141,7 +1142,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
eina_strbuf_append(buf, "EOLIAN static ");
if (rtp)
{
- Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
+ Eina_Stringshare *rtpn = eolian_type_c_type_get(src, rtp, EOLIAN_C_TYPE_RETURN);
eina_strbuf_append(buf, rtpn);
eina_stringshare_del(rtpn);
}
@@ -1162,7 +1163,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
/* gen params here */
Eina_Strbuf *params = eina_strbuf_new();
Eina_Strbuf *params_full = eina_strbuf_new();
- _gen_params(fid, ftype, var_as_ret, params, params_full);
+ _gen_params(src, fid, ftype, var_as_ret, params, params_full);
if (eina_strbuf_length_get(params_full))
eina_strbuf_append(buf, eina_strbuf_string_get(params_full));
@@ -1192,7 +1193,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
}
void
-eo_gen_impl_gen(const Eolian_Unit *src EINA_UNUSED,
+eo_gen_impl_gen(const Eolian_Unit *src,
const Eolian_Class *cl, Eina_Strbuf *buf)
{
if (!cl)
@@ -1243,14 +1244,14 @@ eo_gen_impl_gen(const Eolian_Unit *src EINA_UNUSED,
{
case EOLIAN_PROP_GET:
case EOLIAN_PROP_SET:
- _gen_proto(cl, fid, ftype, buf, imp, dt, cnamel);
+ _gen_proto(src, cl, fid, ftype, buf, imp, dt, cnamel);
break;
case EOLIAN_PROPERTY:
- _gen_proto(cl, fid, EOLIAN_PROP_SET, buf, imp, dt, cnamel);
- _gen_proto(cl, fid, EOLIAN_PROP_GET, buf, imp, dt, cnamel);
+ _gen_proto(src, cl, fid, EOLIAN_PROP_SET, buf, imp, dt, cnamel);
+ _gen_proto(src, cl, fid, EOLIAN_PROP_GET, buf, imp, dt, cnamel);
break;
default:
- _gen_proto(cl, fid, EOLIAN_METHOD, buf, imp, dt, cnamel);
+ _gen_proto(src, cl, fid, EOLIAN_METHOD, buf, imp, dt, cnamel);
}
}
eina_iterator_free(itr);
diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c
index c98791e965..d8285fbeb4 100644
--- a/src/bin/eolian/types.c
+++ b/src/bin/eolian/types.c
@@ -41,7 +41,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
{
const Eolian_Type *mtp = eolian_typedecl_struct_field_type_get(memb);
Eina_Stringshare *ct = NULL;
- ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
+ ct = eolian_type_c_type_get(src, mtp, EOLIAN_C_TYPE_DEFAULT);
eina_strbuf_append_printf(buf, " %s%s%s;",
ct, strchr(ct, '*') ? "" : " ",
eolian_typedecl_struct_field_name_get(memb));
@@ -135,7 +135,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
eina_strbuf_append(buf, "void ");
else
{
- Eina_Stringshare *ct = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
+ Eina_Stringshare *ct = eolian_type_c_type_get(src, rtp, EOLIAN_C_TYPE_RETURN);
eina_strbuf_append_printf(buf, "%s ", ct);
}
@@ -147,7 +147,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
/* Parameters */
eina_strbuf_append(buf, "(void *data");
int nidx = 1;
- eo_gen_params(eolian_function_parameters_get(fid), buf, NULL, &nidx, EOLIAN_FUNCTION_POINTER);
+ eo_gen_params(src, eolian_function_parameters_get(fid), buf, NULL, &nidx, EOLIAN_FUNCTION_POINTER);
eina_strbuf_append(buf, ")");
break;
@@ -195,7 +195,7 @@ _var_generate(const Eolian_Unit *src, const Eolian_Variable *vr, Eina_Bool legac
}
else
{
- Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
+ Eina_Stringshare *ct = eolian_type_c_type_get(src, vt, EOLIAN_C_TYPE_DEFAULT);
eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn);
eina_stringshare_del(ct);
}
@@ -285,7 +285,7 @@ void eo_gen_types_source_gen(const Eolian_Unit *src,
eina_str_toupper(&fn);
const Eolian_Type *vt = eolian_variable_base_type_get(vr);
- Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
+ Eina_Stringshare *ct = eolian_type_c_type_get(src, vt, EOLIAN_C_TYPE_DEFAULT);
eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn);
eina_stringshare_del(ct);
free(fn);
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 2851df007a..080e06bde2 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -399,10 +399,10 @@ ffi.cdef [[
const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
const Eolian_Type *eolian_type_next_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_Typedecl *eolian_type_typedecl_get(const Eolian_Unit *unit, 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_Type *eolian_type_aliased_base_get(const Eolian_Unit *unit, const Eolian_Type *tp);
+ const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
@@ -411,7 +411,7 @@ ffi.cdef [[
Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
- const char *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
+ const char *eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp, Eolian_C_Type_Type ctype);
const char *eolian_typedecl_c_type_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
const char *eolian_type_name_get(const Eolian_Type *tp);
@@ -766,8 +766,8 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", {
return v
end,
- aliased_base_get = function(self)
- local v = eolian.eolian_typedecl_aliased_byse_get(self)
+ aliased_base_get = function(self, unit)
+ local v = eolian.eolian_typedecl_aliased_byse_get(unit, self)
if v == nil then return nil end
return v
end,
@@ -841,14 +841,14 @@ M.Type = ffi.metatype("Eolian_Type", {
return v
end,
- typedecl_get = function(self)
- local v = eolian.eolian_type_typedecl_get(self)
+ typedecl_get = function(self, unit)
+ local v = eolian.eolian_type_typedecl_get(unit, 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)
+ aliased_base_get = function(self, unit)
+ local v = eolian.eolian_type_aliased_byse_get(unit, self)
if v == nil then return nil end
return v
end,
@@ -871,8 +871,8 @@ M.Type = ffi.metatype("Eolian_Type", {
return eolian.eolian_type_is_ptr(self) ~= 0
end,
- c_type_get = function(self, ctype)
- local v = eolian.eolian_type_c_type_get(self, ctype)
+ c_type_get = function(self, unit, ctype)
+ local v = eolian.eolian_type_c_type_get(unit, self, ctype)
if v == nil then return nil end
return ffi_stringshare(v)
end,
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)
{
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index 2cc16cf70e..cd24b0aad9 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -710,7 +710,8 @@ M.Type = Node:clone {
end,
typedecl_get = function(self)
- local v = self.type:typedecl_get()
+ -- FIXME: unit
+ local v = self.type:typedecl_get(eos:unit_get())
if not v then
return nil
end
@@ -718,7 +719,8 @@ M.Type = Node:clone {
end,
aliased_base_get = function(self)
- local v = self.type:aliased_base_get()
+ -- FIXME: unit
+ local v = self.type:aliased_base_get(eos:unit_get())
if not v then
return nil
end
@@ -894,7 +896,8 @@ M.Typedecl = Node:clone {
end,
aliased_base_get = function(self)
- local v = self.typedecl:aliased_base_get()
+ -- FIXME: unit
+ local v = self.typedecl:aliased_base_get(eos:unit_get())
if not v then
return nil
end
diff --git a/src/scripts/elua/modules/lualian.lua b/src/scripts/elua/modules/lualian.lua
index 3864bd1d02..b8b32a830c 100644
--- a/src/scripts/elua/modules/lualian.lua
+++ b/src/scripts/elua/modules/lualian.lua
@@ -102,7 +102,7 @@ end
local typeconv = function(tps, expr, isin)
if tps:type_get() == type_type.POINTER then
local base = tps:base_type_get()
- local f = (isin and known_ptr_in or known_ptr_out)[base:c_type_get(eolian.c_type_type.DEFAULT)]
+ local f = (isin and known_ptr_in or known_ptr_out)[base:c_type_get(gen_unit, eolian.c_type_type.DEFAULT)]
if f then return f(expr) end
return build_calln(tps, expr, isin)
end
@@ -188,7 +188,7 @@ local Method = Node:clone {
local proto = {
name = meth:name_get()
}
- proto.ret_type = rett and rett:c_type_get(eolian.c_type_type.RETURN) or "void"
+ proto.ret_type = rett and rett:c_type_get(gen_unit, eolian.c_type_type.RETURN) or "void"
local args, cargs, vargs = { "self" }, {}, {}
proto.args, proto.cargs, proto.vargs = args, cargs, vargs
local rets = {}
@@ -206,7 +206,7 @@ local Method = Node:clone {
for v in pars do
local dir, tps, nm = v:direction_get(), v:type_get(), kw_t(v:name_get())
- local tp = tps:c_type_get(eolian.c_type_type.PARAM)
+ local tp = tps:c_type_get(gen_unit, eolian.c_type_type.PARAM)
if dir == param_dir.OUT or dir == param_dir.INOUT then
if dir == param_dir.INOUT then
args[#args + 1] = nm
@@ -283,7 +283,7 @@ local Property = Method:clone {
nkeys = #keys,
nvals = #vals
}
- proto.ret_type = rett and rett:c_type_get(eolian.c_type_type.RETURN) or "void"
+ proto.ret_type = rett and rett:c_type_get(gen_unit, eolian.c_type_type.RETURN) or "void"
local args, cargs, vargs = { "self" }, {}, {}
proto.args, proto.cargs, proto.vargs = args, cargs, vargs
local rets = {}
@@ -298,7 +298,7 @@ local Property = Method:clone {
for i, v in ipairs(keys) do
local nm = kw_t(v:name_get())
local tps = v:type_get()
- local tp = tps:c_type_get(eolian.c_type_type.PARAM)
+ local tp = tps:c_type_get(gen_unit, eolian.c_type_type.PARAM)
args [#args + 1] = nm
cargs[#cargs + 1] = tp .. " " .. nm
vargs[#vargs + 1] = typeconv(tps, nm, true)
@@ -310,13 +310,13 @@ local Property = Method:clone {
if self.isget then
if #vals == 1 and not rett then
local tps = vals[1]:type_get()
- proto.ret_type = tps:c_type_get(eolian.c_type_type.PARAM)
+ proto.ret_type = tps:c_type_get(gen_unit, eolian.c_type_type.PARAM)
rets[#rets + 1] = typeconv(tps, "v", false)
else
for i, v in ipairs(vals) do
local dir, tps, nm = v:direction_get(), v:type_get(),
kw_t(v:name_get())
- local tp = tps:c_type_get(eolian.c_type_type.PARAM)
+ local tp = tps:c_type_get(gen_unit, eolian.c_type_type.PARAM)
cargs [#cargs + 1] = tp .. " *" .. nm
vargs [#vargs + 1] = nm
allocs[#allocs + 1] = { tp, nm }
@@ -327,7 +327,7 @@ local Property = Method:clone {
for i, v in ipairs(vals) do
local dir, tps, nm = v:direction_get(), v:type_get(),
kw_t(v:name_get())
- local tp = tps:c_type_get(eolian.c_type_type.PARAM)
+ local tp = tps:c_type_get(gen_unit, eolian.c_type_type.PARAM)
args [#args + 1] = nm
cargs[#cargs + 1] = tp .. " " .. nm
vargs[#vargs + 1] = typeconv(tps, nm, true)
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 58acf555f1..f1b443049d 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -364,7 +364,7 @@ START_TEST(eolian_typedef)
/* Lowest alias base */
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Evas.Coord3")));
- fail_if(!(type = eolian_typedecl_aliased_base_get(tdl)));
+ fail_if(!(type = eolian_typedecl_aliased_base_get(unit, tdl)));
fail_if(strcmp(eolian_type_name_get(type), "int"));
/* Complex type */
@@ -372,13 +372,13 @@ START_TEST(eolian_typedef)
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
fail_if(strcmp(type_name, "List_Objects"));
fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(strcmp(type_name, "Eo *"));
fail_if(eolian_type_is_owned(type));
eina_stringshare_del(type_name);
@@ -428,21 +428,21 @@ START_TEST(eolian_complex_type)
/* Properties return type */
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_PROP_SET)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_RETURN)));
fail_if(!eolian_type_is_owned(type));
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_LIST);
fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_ARRAY);
fail_if(strcmp(type_name, "Eina_Array *"));
eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eo *"));
eina_stringshare_del(type_name);
@@ -453,13 +453,13 @@ START_TEST(eolian_complex_type)
eina_iterator_free(iter);
fail_if(strcmp(eolian_parameter_name_get(param), "value"));
fail_if(!(type = eolian_parameter_type_get(param)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_owned(type));
fail_if(strcmp(type_name, "const char *"));
eina_stringshare_del(type_name);
@@ -467,13 +467,13 @@ START_TEST(eolian_complex_type)
/* Methods return type */
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_METHOD)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_RETURN)));
fail_if(!eolian_type_is_owned(type));
fail_if(strcmp(type_name, "Eina_List *"));
eina_stringshare_del(type_name);
fail_if(!(type = eolian_type_base_type_get(type)));
fail_if(!!eolian_type_next_type_get(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_DEFAULT)));
fail_if(eolian_type_is_owned(type));
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_STRINGSHARE);
fail_if(strcmp(type_name, "Eina_Stringshare *"));
@@ -485,7 +485,7 @@ START_TEST(eolian_complex_type)
eina_iterator_free(iter);
fail_if(strcmp(eolian_parameter_name_get(param), "buf"));
fail_if(!(type = eolian_parameter_type_get(param)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(!eolian_type_is_owned(type));
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_MSTRING);
fail_if(strcmp(type_name, "char *"));
@@ -621,7 +621,7 @@ START_TEST(eolian_simple_parsing)
/* Function return */
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
fail_if(!tp);
- string = eolian_type_c_type_get(tp, EOLIAN_C_TYPE_RETURN);
+ string = eolian_type_c_type_get(unit, tp, EOLIAN_C_TYPE_RETURN);
fail_if(!string);
fail_if(strcmp(string, "char *"));
eina_stringshare_del(string);
@@ -708,7 +708,7 @@ START_TEST(eolian_struct)
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
fail_if(eolian_type_is_ptr(ftype));
- fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, ftype, EOLIAN_C_TYPE_DEFAULT)));
fail_if(strcmp(type_name, "const char *"));
eina_stringshare_del(type_name);
@@ -724,7 +724,7 @@ START_TEST(eolian_struct)
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_typedecl_type_get(eolian_type_typedecl_get(ftype))
+ fail_if(eolian_typedecl_type_get(eolian_type_typedecl_get(unit, ftype))
!= EOLIAN_TYPEDECL_STRUCT);
/* opaque struct */
@@ -736,7 +736,7 @@ START_TEST(eolian_struct)
fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD)));
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
fail_if(!eolian_type_is_ptr(type));
- fail_if(!(tdl = eolian_type_typedecl_get(type)));
+ fail_if(!(tdl = eolian_type_typedecl_get(unit, type)));
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
eolian_free(eos);
@@ -1468,20 +1468,20 @@ START_TEST(eolian_function_types)
fail_if(strcmp(eolian_function_name_get(fid), "SimpleFunc"));
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER))); // void is null_return_type?
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_RETURN)));
fail_if(strcmp(type_name, "const char *"));
fail_if(!(iter = (eolian_function_parameters_get(fid))));
fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(strcmp(eolian_parameter_name_get(param), "a"));
fail_if(!(type = eolian_parameter_type_get(param)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "int"));
fail_if(!(eina_iterator_next(iter, (void**)&param)));
fail_if(strcmp(eolian_parameter_name_get(param), "b"));
fail_if(!(type = eolian_parameter_type_get(param)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "double"));
fail_if(eina_iterator_next(iter, &dummy));
@@ -1494,7 +1494,7 @@ START_TEST(eolian_function_types)
fail_if(eolian_function_type_get(fid) != EOLIAN_FUNCTION_POINTER);
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER)));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_RETURN)));
fail_if(strcmp(type_name, "double"));
fail_if(!(iter = (eolian_function_parameters_get(fid))));
@@ -1504,7 +1504,7 @@ START_TEST(eolian_function_types)
fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
fail_if(eolian_type_is_owned(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "const char *"));
/*out own string */
@@ -1513,7 +1513,7 @@ START_TEST(eolian_function_types)
fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
fail_if(!(type = eolian_parameter_type_get(param)));
fail_if(!eolian_type_is_owned(type));
- fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
+ fail_if(!(type_name = eolian_type_c_type_get(unit, type, EOLIAN_C_TYPE_PARAM)));
fail_if(strcmp(type_name, "char *"));
fail_if(eina_iterator_next(iter, &dummy));
@@ -1536,7 +1536,7 @@ START_TEST(eolian_function_types)
fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "VoidFunc"));
- fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
+ fail_if(!(arg_decl = eolian_type_typedecl_get(unit, type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
fail_if(!(eina_iterator_next(iter, (void**)&param)));
@@ -1547,7 +1547,7 @@ START_TEST(eolian_function_types)
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc"));
- fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
+ fail_if(!(arg_decl = eolian_type_typedecl_get(unit, type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
fail_if(eina_iterator_next(iter, &dummy));
@@ -1589,7 +1589,7 @@ START_TEST(eolian_function_as_arguments)
fail_if(eolian_type_is_owned(type));
fail_if(!(type_name = eolian_type_name_get(type)));
fail_if(strcmp(type_name, "SimpleFunc"));
- fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
+ fail_if(!(arg_decl = eolian_type_typedecl_get(unit, type)));
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
fail_if(eina_iterator_next(iter, &dummy));