q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=f8505eddbd4af487b163573b4d56f1f7da432641
commit f8505eddbd4af487b163573b4d56f1f7da432641 Author: Daniel Kolesa <[email protected]> Date: Thu Mar 1 12:42:40 2018 +0100 eolian: new APIs for typedecl lookups --- src/lib/eolian/Eolian.h | 297 +++++++++++++++++++++++-------------- src/lib/eolian/database_type_api.c | 84 ----------- src/lib/eolian/eolian_database.c | 177 ++++++++++++++++++++++ 3 files changed, 366 insertions(+), 192 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index b4581478cb..bf8918be23 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -755,6 +755,105 @@ EAPI Eina_Iterator *eolian_state_constants_get(const Eolian_State *state); EAPI Eina_Iterator *eolian_state_globals_get(const Eolian_State *state); /* + * @brief Get an alias type declaration within a state by name. + * + * @param[in] state The state. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_state_alias_by_name_get(const Eolian_State *state, const char *name); + +/* + * @brief Get a struct declaration within a state by name. + * + * @param[in] state The state. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_state_struct_by_name_get(const Eolian_State *state, const char *name); + +/* + * @brief Get an enum declaration within a state by name. + * + * @param[in] state The state. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_state_enum_by_name_get(const Eolian_State *state, const char *name); + +/* + * @brief Get an iterator to all aliases contained in a file. + * + * @param[in] state The state. + * @param[in] file_name The file name. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_aliases_by_file_get(const Eolian_State *state, const char *file_name); + +/* + * @brief Get an iterator to all named structs contained in a file. + * + * @param[in] state The state. + * @param[in] file_name The file name. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_structs_by_file_get(const Eolian_State *state, const char *file_name); + +/* + * @brief Get an iterator to all enums contained in a file. + * + * @param[in] state The state. + * @param[in] file_name The file name. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_enums_by_file_get(const Eolian_State *state, const char *file_name); + +/* + * @brief Get an iterator to all aliases in the Eolian database. + * + * @param[in] state The state. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_aliases_get(const Eolian_State *state); + +/* + * @brief Get an iterator to all structs in the Eolian database. + * + * @param[in] state The state. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_structs_get(const Eolian_State *state); + +/* + * @brief Get an iterator to all enums in the Eolian database. + * + * @param[in] state The state. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_state_enums_get(const Eolian_State *state); + +/* * @brief Get the children (dependencies) of a unit. * * The iterator is obviously again to `const Eolian_Unit *`. @@ -839,6 +938,69 @@ EAPI Eina_Iterator *eolian_unit_constants_get(const Eolian_Unit *unit); EAPI Eina_Iterator *eolian_unit_globals_get(const Eolian_Unit *unit); /* + * @brief Get an alias type declaration within a unit by name. + * + * @param[in] unit The unit. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_unit_alias_by_name_get(const Eolian_Unit *unit, const char *name); + +/* + * @brief Get a struct declaration within a unit by name. + * + * @param[in] unit The unit. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_unit_struct_by_name_get(const Eolian_Unit *unit, const char *name); + +/* + * @brief Get an enum declaration within a unit by name. + * + * @param[in] unit The unit. + * @param[in] name The name of the alias. + * + * @ingroup Eolian + */ +EAPI const Eolian_Typedecl *eolian_unit_enum_by_name_get(const Eolian_Unit *unit, const char *name); + +/* + * @brief Get an iterator to all aliases in the Eolian database. + * + * @param[in] unit The unit. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_unit_aliases_get(const Eolian_Unit *unit); + +/* + * @brief Get an iterator to all structs in the Eolian database. + * + * @param[in] unit The unit. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit); + +/* + * @brief Get an iterator to all enums in the Eolian database. + * + * @param[in] unit The unit. + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit); + +/* * @brief Returns the name of the file containing the given class. * * @param[in] klass the class. @@ -1700,114 +1862,6 @@ EAPI Eina_Stringshare *eolian_class_c_name_get(const Eolian_Class *klass); EAPI Eina_Stringshare *eolian_class_c_data_type_get(const Eolian_Class *klass); /* - * @brief Get an alias type declaration by name. Supports namespaces. - * - * @param[in] unit the unit to look in - * @param[in] name the name of the alias - * @return the alias type or NULL - * - * @ingroup Eolian - */ -EAPI const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name); - -/* - * @brief Get a struct declaration by name. Supports namespaces. - * - * @param[in] unit the unit to look in - * @param[in] name the name of the struct - * @return the struct or NULL - * - * @ingroup Eolian - */ -EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name); - -/* - * @brief Get an enum declaration by name. Supports namespaces. - * - * @param[in] unit the unit to look in - * @param[in] name the name of the struct - * @return the struct or NULL - * - * @ingroup Eolian - */ -EAPI const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name); - -/* - * @brief Get an iterator to all aliases contained in a file. - * - * @param[in] unit the unit to look in - * @param[in] fname the file name without full path - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname); - -/* - * @brief Get an iterator to all named structs contained in a file. - * - * @param[in] unit the unit to look in - * @param[in] fname the file name without full path - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname); - -/* - * @brief Get an iterator to all enums contained in a file. - * - * @param[in] unit the unit to look in - * @param[in] fname the file name without full path - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname); - -/* - * @brief Get an iterator to all aliases in the Eolian database. - * - * @param[in] unit the unit to look in - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_all_aliases_get(const Eolian_Unit *unit); - -/* - * @brief Get an iterator to all structs in the Eolian database. - * - * @param[in] unit the unit to look in - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_all_structs_get(const Eolian_Unit *unit); - -/* - * @brief Get an iterator to all enums in the Eolian database. - * - * @param[in] unit the unit to look in - * @return the iterator or NULL - * - * Thanks to internal caching, this is an O(1) operation. - * - * @ingroup Eolian - */ -EAPI Eina_Iterator *eolian_typedecl_all_enums_get(const Eolian_Unit *unit); - -/* * @brief Get the type of a type declaration. * * @param[in] tp the type declaration. @@ -2772,6 +2826,33 @@ EAPI Eina_Iterator *eolian_variable_all_constants_get(const Eolian_Unit *unit); /* DEPRECATED */ EAPI Eina_Iterator *eolian_variable_all_globals_get(const Eolian_Unit *unit); +/* DEPRECATED */ +EAPI const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name); + +/* DEPRECATED */ +EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name); + +/* DEPRECATED */ +EAPI const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_all_aliases_get(const Eolian_Unit *unit); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_all_structs_get(const Eolian_Unit *unit); + +/* DEPRECATED */ +EAPI Eina_Iterator *eolian_typedecl_all_enums_get(const Eolian_Unit *unit); + #endif /** diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 7041fd8db4..544ce4368e 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -6,90 +6,6 @@ #include "eolian_database.h" #include "eo_lexer.h" -EAPI const Eolian_Typedecl * -eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Typedecl *tp = eina_hash_find(unit->aliases, shr); - eina_stringshare_del(shr); - if (!tp) return NULL; - return tp; -} - -EAPI const Eolian_Typedecl * -eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Typedecl *tp = eina_hash_find(unit->structs, shr); - eina_stringshare_del(shr); - if (!tp) return NULL; - return tp; -} - -EAPI const Eolian_Typedecl * -eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Typedecl *tp = eina_hash_find(unit->enums, shr); - eina_stringshare_del(shr); - if (!tp) return NULL; - return tp; -} - -EAPI Eina_Iterator * -eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(fname); - Eina_List *l = eina_hash_find(unit->state->aliases_f, shr); - eina_stringshare_del(shr); - if (!l) return NULL; - return eina_list_iterator_new(l); -} - -EAPI Eina_Iterator * -eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(fname); - Eina_List *l = eina_hash_find(unit->state->structs_f, shr); - eina_stringshare_del(shr); - if (!l) return NULL; - return eina_list_iterator_new(l); -} - -EAPI Eina_Iterator * -eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname) -{ - if (!unit) return NULL; - Eina_Stringshare *shr = eina_stringshare_add(fname); - Eina_List *l = eina_hash_find(unit->state->enums_f, shr); - eina_stringshare_del(shr); - if (!l) return NULL; - return eina_list_iterator_new(l); -} - -EAPI Eina_Iterator * -eolian_typedecl_all_aliases_get(const Eolian_Unit *unit) -{ - return (unit ? eina_hash_iterator_data_new(unit->aliases) : NULL); -} - -EAPI Eina_Iterator * -eolian_typedecl_all_structs_get(const Eolian_Unit *unit) -{ - return (unit ? eina_hash_iterator_data_new(unit->structs) : NULL); -} - -EAPI Eina_Iterator * -eolian_typedecl_all_enums_get(const Eolian_Unit *unit) -{ - return (unit ? eina_hash_iterator_data_new(unit->enums) : NULL); -} - 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 578d38027d..d6d7915fb0 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -1002,6 +1002,75 @@ eolian_state_globals_get(const Eolian_State *state) return eolian_unit_globals_get((Eolian_Unit *)state); } +EAPI const Eolian_Typedecl * +eolian_state_alias_by_name_get(const Eolian_State *state, const char *name) +{ + return eolian_unit_alias_by_name_get((Eolian_Unit *)state, name); +} + +EAPI const Eolian_Typedecl * +eolian_state_struct_by_name_get(const Eolian_State *state, const char *name) +{ + return eolian_unit_struct_by_name_get((Eolian_Unit *)state, name); +} + +EAPI const Eolian_Typedecl * +eolian_state_enum_by_name_get(const Eolian_State *state, const char *name) +{ + return eolian_unit_enum_by_name_get((Eolian_Unit *)state, name); +} + +EAPI Eina_Iterator * +eolian_state_aliases_by_file_get(const Eolian_State *state, const char *file_name) +{ + if (!state) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(file_name); + Eina_List *l = eina_hash_find(state->aliases_f, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + +EAPI Eina_Iterator * +eolian_state_structs_by_file_get(const Eolian_State *state, const char *file_name) +{ + if (!state) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(file_name); + Eina_List *l = eina_hash_find(state->structs_f, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + +EAPI Eina_Iterator * +eolian_state_enums_by_file_get(const Eolian_State *state, const char *file_name) +{ + if (!state) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(file_name); + Eina_List *l = eina_hash_find(state->enums_f, shr); + eina_stringshare_del(shr); + if (!l) return NULL; + return eina_list_iterator_new(l); +} + +EAPI Eina_Iterator * +eolian_state_aliases_get(const Eolian_State *state) +{ + return eolian_unit_aliases_get((Eolian_Unit *)state); +} + +EAPI Eina_Iterator * +eolian_state_structs_get(const Eolian_State *state) +{ + return eolian_unit_structs_get((Eolian_Unit *)state); +} + +EAPI Eina_Iterator * +eolian_state_enums_get(const Eolian_State *state) +{ + return eolian_unit_enums_get((Eolian_Unit *)state); +} + EAPI Eina_Iterator * eolian_unit_children_get(const Eolian_Unit *unit) { @@ -1122,6 +1191,114 @@ eolian_variable_all_globals_get(const Eolian_Unit *unit) return eolian_unit_globals_get(unit); } +EAPI const Eolian_Typedecl * +eolian_unit_alias_by_name_get(const Eolian_Unit *unit, const char *name) +{ + if (!unit) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(name); + Eolian_Typedecl *tp = eina_hash_find(unit->aliases, shr); + eina_stringshare_del(shr); + if (!tp) return NULL; + return tp; +} + +EAPI const Eolian_Typedecl * +eolian_unit_struct_by_name_get(const Eolian_Unit *unit, const char *name) +{ + if (!unit) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(name); + Eolian_Typedecl *tp = eina_hash_find(unit->structs, shr); + eina_stringshare_del(shr); + if (!tp) return NULL; + return tp; +} + +EAPI const Eolian_Typedecl * +eolian_unit_enum_by_name_get(const Eolian_Unit *unit, const char *name) +{ + if (!unit) return NULL; + Eina_Stringshare *shr = eina_stringshare_add(name); + Eolian_Typedecl *tp = eina_hash_find(unit->enums, shr); + eina_stringshare_del(shr); + if (!tp) return NULL; + return tp; +} + +EAPI Eina_Iterator * +eolian_unit_aliases_get(const Eolian_Unit *unit) +{ + return (unit ? eina_hash_iterator_data_new(unit->aliases) : NULL); +} + +EAPI Eina_Iterator * +eolian_unit_structs_get(const Eolian_Unit *unit) +{ + return (unit ? eina_hash_iterator_data_new(unit->structs) : NULL); +} + +EAPI Eina_Iterator * +eolian_unit_enums_get(const Eolian_Unit *unit) +{ + return (unit ? eina_hash_iterator_data_new(unit->enums) : NULL); +} + +EAPI const Eolian_Typedecl * +eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name) +{ + return eolian_unit_alias_by_name_get(unit, name); +} + +EAPI const Eolian_Typedecl * +eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name) +{ + return eolian_unit_struct_by_name_get(unit, name); +} + +EAPI const Eolian_Typedecl * +eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name) +{ + return eolian_unit_enum_by_name_get(unit, name); +} + +EAPI Eina_Iterator * +eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname) +{ + if (!unit) return NULL; + return eolian_state_aliases_by_file_get(unit->state, fname); +} + +EAPI Eina_Iterator * +eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname) +{ + if (!unit) return NULL; + return eolian_state_structs_by_file_get(unit->state, fname); +} + +EAPI Eina_Iterator * +eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname) +{ + if (!unit) return NULL; + return eolian_state_enums_by_file_get(unit->state, fname); +} + +EAPI Eina_Iterator * +eolian_typedecl_all_aliases_get(const Eolian_Unit *unit) +{ + return eolian_unit_aliases_get(unit); +} + +EAPI Eina_Iterator * +eolian_typedecl_all_structs_get(const Eolian_Unit *unit) +{ + return eolian_unit_structs_get(unit); +} + +EAPI Eina_Iterator * +eolian_typedecl_all_enums_get(const Eolian_Unit *unit) +{ + return eolian_unit_enums_get(unit); +} + char * database_class_to_filename(const char *cname) { --
