eolian: remove eolian_show and replace it with variants for class/struct/typedef/all.

This commit is contained in:
Daniel Kolesa 2014-07-11 13:10:04 +01:00
parent 9e3417aad8
commit 888dc3b6fe
3 changed files with 140 additions and 2 deletions

View File

@ -341,7 +341,7 @@ int main(int argc, char **argv)
EINA_LIST_FOREACH(files4gen, itr, filename)
{
class = eolian_class_find_by_file(filename);
if (class) eolian_show(class);
if (class) eolian_show_class(class);
}
}

View File

@ -222,9 +222,68 @@ EAPI Eina_Bool eolian_all_eot_files_parse();
*
* @param[in] klass the class to show
*
* @return EINA_TRUE on success, EINA_FALSE otherwise (currently always
* succeeds).
*
* @see eolian_show_typedef
* @see eolian_show_struct
* @see eolian_show_all
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_show(const Eolian_Class *klass);
EAPI Eina_Bool eolian_show_class(const Eolian_Class *klass);
/*
* @brief Show information about a given typedef.
*
* If @c alias is NULL, this function will print information of
* all the typedefs.
*
* @param[in] alias the typedef to show.
*
* @return EINA_TRUE on success, EINA_FALSE otherwise (when typedef is not
* found).
*
* @see eolian_show_class
* @see eolian_show_struct
* @see eolian_show_all
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_show_typedef(const char *alias);
/*
* @brief Show information about a given struct.
*
* If @c name is NULL, this function will print information of
* all the named global structs.
*
* @param[in] name the struct to show.
*
* @return EINA_TRUE on success, EINA_FALSE otherwise (when struct is not
* found).
*
* @see eolian_show_class
* @see eolian_show_typedef
* @see eolian_show_all
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_show_struct(const char *name);
/*
* @brief Show information about everything.
*
* This will print a complete dump of all information stored in the Eolian
* database.
*
* @see eolian_show_class
* @see eolian_show_typedef
* @see eolian_show_struct
*
* @ingroup Eolian
*/
EAPI void eolian_show_all();
/*
* @brief Finds a class by its name

View File

@ -263,3 +263,82 @@ eolian_show(const Eolian_Class *class)
}
return EINA_TRUE;
}
EAPI Eina_Bool
eolian_show_class(const Eolian_Class *class)
{
if (!class)
{
Eina_List *itr;
Eolian_Class *cl;
EINA_LIST_FOREACH(_classes, itr, cl)
_class_print(cl);
}
else
{
_class_print(class);
}
return EINA_TRUE;
}
static Eina_Bool
_typedef_cb(Eina_Hash *hash EINA_UNUSED, const char *alias,
const Eolian_Typedef *tp, const void *fdata EINA_UNUSED)
{
printf("Typedef: %s\n", alias);
printf(" type: <");
database_type_print(tp->type);
printf(">\n");
return EINA_TRUE;
}
EAPI Eina_Bool
eolian_show_typedef(const char *alias)
{
if (!alias)
eina_hash_foreach(_types, (Eina_Hash_Foreach)_typedef_cb, NULL);
else
{
Eina_Stringshare *shr = eina_stringshare_add(alias);
Eolian_Typedef *tp = eina_hash_find(_types, shr);
eina_stringshare_del(shr);
if (!tp) return EINA_FALSE;
_typedef_cb(NULL, alias, tp, NULL);
}
return EINA_TRUE;
}
static Eina_Bool
_struct_cb(Eina_Hash *hash EINA_UNUSED, const char *name,
const Eolian_Type *tp, const void *fdata EINA_UNUSED)
{
printf("Struct: %s\n", name);
printf(" type: <");
database_type_print((Eolian_Type*)tp);
printf(">\n");
return EINA_TRUE;
}
EAPI Eina_Bool
eolian_show_struct(const char *name)
{
if (!name)
eina_hash_foreach(_structs, (Eina_Hash_Foreach)_struct_cb, NULL);
else
{
Eina_Stringshare *shr = eina_stringshare_add(name);
Eolian_Type *tp = eina_hash_find(_structs, shr);
eina_stringshare_del(shr);
if (!tp) return EINA_FALSE;
_struct_cb(NULL, name, tp, NULL);
}
return EINA_TRUE;
}
EAPI void
eolian_show_all()
{
eolian_show_class(NULL);
eolian_show_typedef(NULL);
eolian_show_struct(NULL);
}