X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/69c350c69e70bddb040dfc5d90b0368376a6389e..489e97ede850a8de01ca3bd653dce9c25dcd54a1:/src/util.c diff --git a/src/util.c b/src/util.c index cc523ed..78eaaaa 100644 --- a/src/util.c +++ b/src/util.c @@ -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); +} +