eolian: remove eolian_show and replace it with variants for class/struct/typedef...
authorDaniel Kolesa <d.kolesa@samsung.com>
Fri, 11 Jul 2014 12:10:04 +0000 (13:10 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Fri, 11 Jul 2014 12:10:04 +0000 (13:10 +0100)
src/bin/eolian/main.c
src/lib/eolian/Eolian.h
src/lib/eolian/database_print.c

index 8d1b6e5..469c738 100644 (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);
           }
      }
 
index 764a16e..6307d6f 100644 (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_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 Eina_Bool eolian_show(const Eolian_Class *klass);
+EAPI void eolian_show_all();
 
 /*
  * @brief Finds a class by its name
index 274ff3c..d10647c 100644 (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);
+}