From: Daniel Kolesa Date: Tue, 29 Mar 2016 13:49:30 +0000 (+0100) Subject: eolian: add APIs to get all things of each type X-Git-Tag: upstream/1.20.0~7040 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b845e71358e60daf3a66cac38fa53778c50efb5;p=platform%2Fupstream%2Fefl.git eolian: add APIs to get all things of each type --- diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index 509053e..f457c6a 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -272,6 +272,9 @@ ffi.cdef [[ Eina_Iterator *eolian_typedecl_aliases_get_by_file(const char *fname); Eina_Iterator *eolian_typedecl_structs_get_by_file(const char *fname); Eina_Iterator *eolian_typedecl_enums_get_by_file(const char *fname); + Eina_Iterator *eolian_typedecl_all_aliases_get(void); + Eina_Iterator *eolian_typedecl_all_structs_get(void); + Eina_Iterator *eolian_typedecl_all_enums_get(void); Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp); Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp); Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp); @@ -338,6 +341,8 @@ ffi.cdef [[ const Eolian_Variable *eolian_variable_constant_get_by_name(const char *name); Eina_Iterator *eolian_variable_globals_get_by_file(const char *fname); Eina_Iterator *eolian_variable_constants_get_by_file(const char *fname); + Eina_Iterator *eolian_variable_all_constants_get(void); + Eina_Iterator *eolian_variable_all_globals_get(void); Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var); const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var); const char *eolian_variable_file_get(const Eolian_Variable *var); @@ -349,6 +354,7 @@ ffi.cdef [[ Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var); const Eolian_Declaration *eolian_declaration_get_by_name(const char *name); Eina_Iterator *eolian_declarations_get_by_file(const char *fname); + Eina_Iterator *eolian_all_declarations_get(void); Eolian_Declaration_Type eolian_declaration_type_get(const Eolian_Declaration *decl); const char *eolian_declaration_name_get(const Eolian_Declaration *decl); const Eolian_Class *eolian_declaration_class_get(const Eolian_Declaration *decl); @@ -1136,6 +1142,21 @@ M.typedecl_enums_get_by_file = function(fname) eolian.eolian_type_enums_get_by_file(self)) end +M.typedecl_all_aliases_get = function() + return Ptr_Iterator("const Eolian_Typedecl *", + eolian.eolian_typedecl_all_aliases_get()) +end + +M.typedecl_all_structs_get = function() + return Ptr_Iterator("const Eolian_Typedecl *", + eolian.eolian_typedecl_all_structs_get()) +end + +M.typedecl_all_enums_get = function() + return Ptr_Iterator("const Eolian_Typedecl *", + eolian.eolian_typedecl_all_enums_get()) +end + M.expression_type = { UNKNOWN = 0, INT = 1, @@ -1333,6 +1354,16 @@ M.variable_constants_get_by_file = function(fname) eolian.eolian_variable_constants_get_by_file(fname)) end +M.variable_all_constants_get = function() + return Ptr_Iterator("const Eolian_Variable *", + eolian.eolian_variable_all_constants_get()) +end + +M.variable_all_globals_get = function() + return Ptr_Iterator("const Eolian_Variable *", + eolian.eolian_variable_all_globals_get()) +end + M.Variable = ffi.metatype("Eolian_Variable", { __index = { type_get = function(self) @@ -1399,6 +1430,11 @@ M.declarations_get_by_file = function(fname) eolian.eolian_declarations_get_by_file(fname)) end +M.all_declarations_get = function() + return Ptr_Iterator("const Eolian_Declaration *", + eolian.eolian_all_declarations_get()) +end + M.Declaration = ffi.metatype("Eolian_Declaration", { __index = { type_get = function(self) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 70c5a1c..e2294a2 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -1330,6 +1330,39 @@ EAPI Eina_Iterator *eolian_typedecl_structs_get_by_file(const char *fname); EAPI Eina_Iterator *eolian_typedecl_enums_get_by_file(const char *fname); /* + * @brief Get an iterator to all aliases in the Eolian database. + * + * @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(void); + +/* + * @brief Get an iterator to all structs in the Eolian database. + * + * @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(void); + +/* + * @brief Get an iterator to all enums in the Eolian database. + * + * @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(void); + +/* * @brief Get the type of a type declaration. * * @param[in] tp the type declaration. @@ -1975,6 +2008,28 @@ EAPI Eina_Iterator *eolian_variable_globals_get_by_file(const char *fname); EAPI Eina_Iterator *eolian_variable_constants_get_by_file(const char *fname); /* + * @brief Get an iterator to all constant variables in the Eolian database. + * + * @return the iterator or NULL + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_variable_all_constants_get(void); + +/* + * @brief Get an iterator to all global variables in the Eolian database. + * + * @return the iterator or NULL + * + * Thanks to internal caching, this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_variable_all_globals_get(void); + +/* * @brief Get the type of a variable (global, constant) * * @param[in] var the variable. @@ -2090,6 +2145,17 @@ EAPI const Eolian_Declaration *eolian_declaration_get_by_name(const char *name); EAPI Eina_Iterator *eolian_declarations_get_by_file(const char *fname); /* + * @brief Get an iterator to all declarations in the Eolian database. + * + * @return the iterator or NULL. + * + * Thanks to internal caching this is an O(1) operation. + * + * @ingroup Eolian + */ +EAPI Eina_Iterator *eolian_all_declarations_get(void); + +/* * @brief Get the type of a declaration * * @param[in] decl the declaration diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 763112e..062ece9 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -72,6 +72,24 @@ eolian_typedecl_enums_get_by_file(const char *fname) return eina_list_iterator_new(l); } +EAPI Eina_Iterator * +eolian_typedecl_all_aliases_get(void) +{ + return (_aliases ? eina_hash_iterator_data_new(_aliases) : NULL); +} + +EAPI Eina_Iterator * +eolian_typedecl_all_structs_get(void) +{ + return (_structs ? eina_hash_iterator_data_new(_structs) : NULL); +} + +EAPI Eina_Iterator * +eolian_typedecl_all_enums_get(void) +{ + return (_enums ? eina_hash_iterator_data_new(_enums) : NULL); +} + EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp) { diff --git a/src/lib/eolian/database_var_api.c b/src/lib/eolian/database_var_api.c index 4ac0424..0e1af2d 100644 --- a/src/lib/eolian/database_var_api.c +++ b/src/lib/eolian/database_var_api.c @@ -47,6 +47,18 @@ eolian_variable_constants_get_by_file(const char *fname) return eina_list_iterator_new(l); } +EAPI Eina_Iterator * +eolian_variable_all_constants_get(void) +{ + return (_constants ? eina_hash_iterator_data_new(_constants) : NULL); +} + +EAPI Eina_Iterator * +eolian_variable_all_globals_get(void) +{ + return (_globals ? eina_hash_iterator_data_new(_globals) : NULL); +} + EAPI Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var) { diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 3cdca38..67f056e 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -134,6 +134,12 @@ eolian_declarations_get_by_file(const char *fname) return eina_list_iterator_new(l); } +EAPI Eina_Iterator * +eolian_all_declarations_get(void) +{ + return (_decls ? eina_hash_iterator_data_new(_decls) : NULL); +} + EAPI Eolian_Declaration_Type eolian_declaration_type_get(const Eolian_Declaration *decl) {