eolian: add APIs to get all things of each type

This commit is contained in:
Daniel Kolesa 2016-03-29 14:49:30 +01:00
parent 18c208c7f9
commit 9b845e7135
5 changed files with 138 additions and 0 deletions

View File

@ -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)

View File

@ -1329,6 +1329,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.
*
@ -1974,6 +2007,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)
*
@ -2089,6 +2144,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
*

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{