]> git.draconx.ca Git - gob-dx.git/blobdiff - src/util.c
Release 2.0.1
[gob-dx.git] / src / util.c
index cc523ed529a4e0d7bbce4e62416adbcfa0d8a2bf..78eaaaa6c02b32b857677568bf81545d95895345 100644 (file)
@@ -310,3 +310,38 @@ setup_special_array(Class *c, gboolean *special_array)
 
        return any_special;
 }
+
+char *
+get_type (const Type *t, gboolean postfix_to_stars)
+{
+       char *s;
+       int i;
+       int extra;
+       GString *gs;
+
+       s = remove_sep(t->name);
+       gs = g_string_new(s);
+       g_free(s);
+
+       extra = 0;
+       if (postfix_to_stars) {
+               const char *p;
+               /*XXX: this is ugly perhaps we can do this whole postfix thing
+                 in a nicer way, we just count the number of '[' s and from
+                 that we deduce the number of dimensions, so that we can print
+                 that many stars */
+               for (p = t->postfix; p && *p; p++)
+                       if(*p == '[') extra++;
+       }
+       g_string_append_c(gs, ' ');
+
+       if (t->pointer != NULL) {
+               g_string_append (gs, t->pointer);
+               for (i=0; i < extra; i++)
+                       g_string_append_c (gs, '*');
+               g_string_append_c (gs, ' ');
+       }
+       
+       return g_string_free (gs, FALSE);
+}
+