summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eolian/Eolian.h3
-rw-r--r--src/lib/eolian/database_expr.c2
-rw-r--r--src/lib/eolian/database_expr_api.c2
-rw-r--r--src/lib/eolian/database_type.c22
-rw-r--r--src/lib/eolian/database_type_api.c17
-rw-r--r--src/lib/eolian/database_validate.c2
-rw-r--r--src/lib/eolian/eolian_database.h2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp2
8 files changed, 31 insertions, 21 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 8e9017b778..34b47c5fca 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1956,13 +1956,12 @@ EAPI const Eolian_Type *eolian_type_next_type_get(const Eolian_Type *tp);
1956 * 1956 *
1957 * This tries to look up alias, struct and enum in that order. 1957 * This tries to look up alias, struct and enum in that order.
1958 * 1958 *
1959 * @param[in] unit the unit to look in
1960 * @param[in] tp the type. 1959 * @param[in] tp the type.
1961 * @return the pointed to type decalration or NULL. 1960 * @return the pointed to type decalration or NULL.
1962 * 1961 *
1963 * @ingroup Eolian 1962 * @ingroup Eolian
1964 */ 1963 */
1965EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Unit *unit, const Eolian_Type *tp); 1964EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Type *tp);
1966 1965
1967/* 1966/*
1968 * @brief Get the lowest base type of an alias stack. 1967 * @brief Get the lowest base type of an alias stack.
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index 1b0a6d10e3..f22a09e308 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,
522 const Eolian_Type *etp = eolian_typedecl_base_type_get(etpd); 522 const Eolian_Type *etp = eolian_typedecl_base_type_get(etpd);
523 if (!etp || etp->type != EOLIAN_TYPE_REGULAR) 523 if (!etp || etp->type != EOLIAN_TYPE_REGULAR)
524 break; 524 break;
525 etpd = eolian_type_typedecl_get(unit, etp); 525 etpd = database_type_decl_find(unit, etp);
526 } 526 }
527 527
528 if (!etpd) etpd = eolian_typedecl_enum_get_by_name(unit, fulln); 528 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 adf573435a..791d59e104 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -34,7 +34,7 @@ _eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr,
34 int kw = eo_lexer_keyword_str_to_id(type->name); 34 int kw = eo_lexer_keyword_str_to_id(type->name);
35 if (!kw || kw < KW_byte || kw >= KW_void) 35 if (!kw || kw < KW_byte || kw >= KW_void)
36 { 36 {
37 const Eolian_Typedecl *base = eolian_type_typedecl_get(unit, type); 37 const Eolian_Typedecl *base = database_type_decl_find(unit, type);
38 if (!base) 38 if (!base)
39 return err; 39 return err;
40 if (base->type == EOLIAN_TYPEDECL_ALIAS) 40 if (base->type == EOLIAN_TYPEDECL_ALIAS)
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 1400aa028c..33be724c60 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -79,7 +79,7 @@ database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp)
79 const char *ct = eo_lexer_get_c_type(kw); 79 const char *ct = eo_lexer_get_c_type(kw);
80 if (!ct) 80 if (!ct)
81 { 81 {
82 const Eolian_Typedecl *tpp = eolian_type_typedecl_get(unit, tp); 82 const Eolian_Typedecl *tpp = database_type_decl_find(unit, tp);
83 if (!tpp) 83 if (!tpp)
84 return EINA_FALSE; 84 return EINA_FALSE;
85 if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER) 85 if (tpp->type == EOLIAN_TYPEDECL_FUNCTION_POINTER)
@@ -269,3 +269,23 @@ database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
269 break; 269 break;
270 } 270 }
271} 271}
272
273Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *unit, const Eolian_Type *tp)
274{
275 if (tp->type != EOLIAN_TYPE_REGULAR)
276 return NULL;
277 if (tp->tdecl)
278 return tp->tdecl;
279 /* try looking up if it belongs to a struct, enum or an alias... otherwise
280 * return NULL, but first check for builtins
281 */
282 int kw = eo_lexer_keyword_str_to_id(tp->full_name);
283 if (!kw || kw < KW_byte || kw >= KW_true)
284 {
285 Eolian_Declaration *decl = eina_hash_find(unit->state->unit.decls, tp->full_name);
286 if (decl && decl->type != EOLIAN_DECL_CLASS
287 && decl->type != EOLIAN_DECL_VAR)
288 return decl->data;
289 }
290 return NULL;
291}
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index 4528b7c9ed..eedb42a828 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -266,23 +266,12 @@ eolian_type_next_type_get(const Eolian_Type *tp)
266} 266}
267 267
268EAPI const Eolian_Typedecl * 268EAPI const Eolian_Typedecl *
269eolian_type_typedecl_get(const Eolian_Unit *unit, const Eolian_Type *tp) 269eolian_type_typedecl_get(const Eolian_Type *tp)
270{ 270{
271 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 271 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
272 if (eolian_type_type_get(tp) != EOLIAN_TYPE_REGULAR) 272 if (eolian_type_type_get(tp) != EOLIAN_TYPE_REGULAR)
273 return NULL; 273 return NULL;
274 /* try looking up if it belongs to a struct, enum or an alias... otherwise 274 return tp->tdecl;
275 * return NULL, but first check for builtins
276 */
277 int kw = eo_lexer_keyword_str_to_id(tp->full_name);
278 if (!kw || kw < KW_byte || kw >= KW_true)
279 {
280 Eolian_Declaration *decl = eina_hash_find(unit->state->unit.decls, tp->full_name);
281 if (decl && decl->type != EOLIAN_DECL_CLASS
282 && decl->type != EOLIAN_DECL_VAR)
283 return decl->data;
284 }
285 return NULL;
286} 275}
287 276
288EAPI const Eolian_Type * 277EAPI const Eolian_Type *
@@ -297,7 +286,7 @@ eolian_type_aliased_base_get(const Eolian_Unit *unit, const Eolian_Type *tp)
297{ 286{
298 if (!tp || tp->type != EOLIAN_TYPE_REGULAR || tp->is_ptr) 287 if (!tp || tp->type != EOLIAN_TYPE_REGULAR || tp->is_ptr)
299 return tp; 288 return tp;
300 const Eolian_Typedecl *btp = eolian_type_typedecl_get(unit, tp); 289 const Eolian_Typedecl *btp = database_type_decl_find(unit, tp);
301 if (btp && (btp->type == EOLIAN_TYPEDECL_ALIAS)) 290 if (btp && (btp->type == EOLIAN_TYPEDECL_ALIAS))
302 return eolian_typedecl_aliased_base_get(unit, btp); 291 return eolian_typedecl_aliased_base_get(unit, btp);
303 return tp; 292 return tp;
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index fbbf26e03d..c5b3664201 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -252,7 +252,7 @@ _validate_type(const Eolian_Unit *src, Eolian_Type *tp)
252 return _validate(&tp->base); 252 return _validate(&tp->base);
253 } 253 }
254 /* user defined */ 254 /* user defined */
255 tp->tdecl = (Eolian_Typedecl *)eolian_type_typedecl_get(src, tp); 255 tp->tdecl = database_type_decl_find(src, tp);
256 if (!tp->tdecl) 256 if (!tp->tdecl)
257 { 257 {
258 snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name); 258 snprintf(buf, sizeof(buf), "undefined type %s", tp->full_name);
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 00a3967183..5f804a5aa9 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -341,6 +341,8 @@ void database_typedecl_del(Eolian_Typedecl *tp);
341void database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype); 341void database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
342void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf); 342void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf);
343 343
344Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp);
345
344Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp); 346Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *tp);
345 347
346/* expressions */ 348/* expressions */
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index e7e6018872..3872feaf4a 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -353,7 +353,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
353 if (!stp) 353 if (!stp)
354 { 354 {
355 bool is_undefined = false; 355 bool is_undefined = false;
356 Eolian_Typedecl const* decl = eolian_type_typedecl_get(unit, eolian_type); 356 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
357 typedecl_type type_type = (decl ? typedecl_type_get(decl) : typedecl_type::unknown); 357 typedecl_type type_type = (decl ? typedecl_type_get(decl) : typedecl_type::unknown);
358 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS) 358 if(decl && eolian_typedecl_type_get(decl) == EOLIAN_TYPEDECL_ALIAS)
359 { 359 {