From cf9dbaa7dac5a51a414784149eea3cc4d17f5b6d Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 11 Feb 2016 15:21:12 +0000 Subject: [PATCH] eolian: add matching APIs to get typedecls by file --- src/lib/eolian/Eolian.h | 3 +++ src/lib/eolian/database_type.c | 6 ++++++ src/lib/eolian/database_type_api.c | 35 ++++++++++++++++++++++++++++++++++- src/lib/eolian/eolian_database.c | 9 +++++++++ src/lib/eolian/eolian_database.h | 3 +++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index f91989d..18e0e53 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -1311,6 +1311,7 @@ EAPI const Eolian_Typedecl *eolian_typedecl_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. @@ -1323,6 +1324,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. @@ -1335,6 +1337,7 @@ 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) diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index 0d0440d..03bea33 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -95,6 +95,8 @@ database_type_add(Eolian_Type *def) eina_hash_set(_aliases, def->full_name, def); eina_hash_set(_aliasesf, def->base.file, eina_list_append ((Eina_List*)eina_hash_find(_aliasesf, def->base.file), def)); + eina_hash_set(_aliasesd, def->base.file, eina_list_append + ((Eina_List*)eina_hash_find(_aliasesd, def->base.file), def->decl)); database_decl_add(def->full_name, EOLIAN_DECL_ALIAS, def->base.file, def); } @@ -105,6 +107,8 @@ database_struct_add(Eolian_Type *tp) eina_hash_set(_structs, tp->full_name, tp); eina_hash_set(_structsf, tp->base.file, eina_list_append ((Eina_List*)eina_hash_find(_structsf, tp->base.file), tp)); + eina_hash_set(_structsd, tp->base.file, eina_list_append + ((Eina_List*)eina_hash_find(_structsd, tp->base.file), tp->decl)); database_decl_add(tp->full_name, EOLIAN_DECL_STRUCT, tp->base.file, tp); } @@ -115,6 +119,8 @@ database_enum_add(Eolian_Type *tp) eina_hash_set(_enums, tp->full_name, tp); eina_hash_set(_enumsf, tp->base.file, eina_list_append ((Eina_List*)eina_hash_find(_enumsf, tp->base.file), tp)); + eina_hash_set(_enumsd, tp->base.file, eina_list_append + ((Eina_List*)eina_hash_find(_enumsd, tp->base.file), tp->decl)); database_decl_add(tp->full_name, EOLIAN_DECL_ENUM, tp->base.file, tp); } diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index ddfdcb4..97fb00d 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -72,6 +72,17 @@ eolian_type_aliases_get_by_file(const char *fname) } EAPI Eina_Iterator * +eolian_typedecl_aliases_get_by_file(const char *fname) +{ + if (!_aliasesd) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(fname); + Eina_List *l = eina_hash_find(_aliasesd, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + +EAPI Eina_Iterator * eolian_type_structs_get_by_file(const char *fname) { if (!_structsf) return NULL; @@ -83,9 +94,20 @@ eolian_type_structs_get_by_file(const char *fname) } EAPI Eina_Iterator * +eolian_typedecl_structs_get_by_file(const char *fname) +{ + if (!_structsd) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(fname); + Eina_List *l = eina_hash_find(_structsd, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + +EAPI Eina_Iterator * eolian_type_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); @@ -93,6 +115,17 @@ eolian_type_enums_get_by_file(const char *fname) return eina_list_iterator_new(l); } +EAPI Eina_Iterator * +eolian_typedecl_enums_get_by_file(const char *fname) +{ + if (!_enumsd) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(fname); + Eina_List *l = eina_hash_find(_enumsd, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp) { diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index fa09310..a9bcd97 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -17,6 +17,9 @@ Eina_Hash *_classesf = NULL; Eina_Hash *_aliasesf = NULL; Eina_Hash *_structsf = NULL; Eina_Hash *_enumsf = NULL; +Eina_Hash *_aliasesd = NULL; +Eina_Hash *_structsd = NULL; +Eina_Hash *_enumsd = NULL; Eina_Hash *_globalsf = NULL; Eina_Hash *_constantsf = NULL; Eina_Hash *_filenames = NULL; @@ -54,6 +57,9 @@ database_init() _enumsf = eina_hash_stringshared_new(_hashlist_free); _globalsf = eina_hash_stringshared_new(_hashlist_free); _constantsf = eina_hash_stringshared_new(_hashlist_free); + _aliasesd = eina_hash_stringshared_new(_hashlist_free); + _structsd = eina_hash_stringshared_new(_hashlist_free); + _enumsd = eina_hash_stringshared_new(_hashlist_free); _filenames = eina_hash_string_small_new(free); _tfilenames = eina_hash_string_small_new(free); _decls = eina_hash_stringshared_new(free); @@ -88,6 +94,9 @@ database_shutdown() eina_hash_free(_enumsf ); _enumsf = NULL; eina_hash_free(_globalsf ); _globalsf = NULL; eina_hash_free(_constantsf); _constantsf = NULL; + eina_hash_free(_aliasesd ); _aliasesd = NULL; + eina_hash_free(_structsd ); _structsd = NULL; + eina_hash_free(_enumsd ); _enumsd = NULL; eina_hash_free(_filenames ); _filenames = NULL; eina_hash_free(_tfilenames); _tfilenames = NULL; eina_hash_free(_decls ); _decls = NULL; diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 28327c5..ca9f23f 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -41,6 +41,9 @@ extern Eina_Hash *_classesf; extern Eina_Hash *_aliasesf; extern Eina_Hash *_structsf; extern Eina_Hash *_enumsf; +extern Eina_Hash *_aliasesd; +extern Eina_Hash *_structsd; +extern Eina_Hash *_enumsd; extern Eina_Hash *_globalsf; extern Eina_Hash *_constantsf; extern Eina_Hash *_filenames; /* Hash: filename without extension -> full path */ -- 2.7.4