eolian: support for structs in eolian_show
authorDaniel Kolesa <d.kolesa@samsung.com>
Wed, 9 Jul 2014 12:06:46 +0000 (13:06 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Wed, 9 Jul 2014 12:06:46 +0000 (13:06 +0100)
src/lib/eolian/eolian_database.c

index 5d823e2..56bd848 100644 (file)
@@ -1422,6 +1422,19 @@ _event_print(Eolian_Event ev, int nb_spaces)
    printf("%*s <%s> <%s> <%s>\n", nb_spaces + 5, "", name, type, comment);
 }
 
+static void _type_print(Eolian_Type tp, Eina_Strbuf *buf);
+
+static Eina_Bool
+_field_print(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data,
+             void *fdata)
+{
+   Eina_Strbuf *buf = (Eina_Strbuf*)fdata;
+   eina_strbuf_append_printf(buf, "%s: ", (const char*)key);
+   _type_print((Eolian_Type)data, buf);
+   eina_strbuf_append(buf, "; ");
+   return EINA_TRUE;
+}
+
 static void
 _type_print(Eolian_Type tp, Eina_Strbuf *buf)
 {
@@ -1462,6 +1475,14 @@ _type_print(Eolian_Type tp, Eina_Strbuf *buf)
           }
         eina_strbuf_append_char(buf, ')');
      }
+   else if (tpp->type == EOLIAN_TYPE_STRUCT)
+     {
+        eina_strbuf_append(buf, "struct ");
+        if (tpp->name) eina_strbuf_append_printf(buf, "%s ", tpp->name);
+        eina_strbuf_append(buf, "{ ");
+        eina_hash_foreach(tpp->fields, _field_print, buf);
+        eina_strbuf_append(buf, "}");
+     }
    if (tpp->is_own)
      eina_strbuf_append_char(buf, ')');
    if (tpp->is_const)