From a0890f3d8f9c2008302c86ac39f65694789101eb Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 18 Feb 2011 18:14:25 +0100 Subject: [PATCH] GIrNode: fix lookup of cached type nodes Different types of array have different type nodes, so they should produce different keys in the cache of already seen type nodes, to avoid turning a GByteArray into a reference to a GPtrArray. https://bugzilla.gnome.org/show_bug.cgi?id=642300 --- girnode.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/girnode.c b/girnode.c index fe45503d7..fe10e543b 100644 --- a/girnode.c +++ b/girnode.c @@ -1227,19 +1227,42 @@ serialize_type (GIrTypelibBuild *build, } else if (node->tag == GI_TYPE_TAG_ARRAY) { - serialize_type (build, node->parameter_type1, str); - g_string_append (str, "["); + if (node->array_type == GI_ARRAY_TYPE_C) + { + serialize_type (build, node->parameter_type1, str); + g_string_append (str, "["); - if (node->has_length) - g_string_append_printf (str, "length=%d", node->length); - else if (node->has_size) - g_string_append_printf (str, "fixed-size=%d", node->size); + if (node->has_length) + g_string_append_printf (str, "length=%d", node->length); + else if (node->has_size) + g_string_append_printf (str, "fixed-size=%d", node->size); - if (node->zero_terminated) - g_string_append_printf (str, "%szero-terminated=1", - node->has_length ? "," : ""); + if (node->zero_terminated) + g_string_append_printf (str, "%szero-terminated=1", + node->has_length ? "," : ""); - g_string_append (str, "]"); + g_string_append (str, "]"); + } + else if (node->array_type == GI_ARRAY_TYPE_BYTE_ARRAY) + { + /* We on purpose skip serializing parameter_type1, which should + always be void* + */ + g_string_append (str, "GByteArray"); + } + else + { + if (node->array_type == GI_ARRAY_TYPE_ARRAY) + g_string_append (str, "GArray"); + else + g_string_append (str, "GPtrArray"); + if (node->parameter_type1) + { + g_string_append (str, "<"); + serialize_type (build, node->parameter_type1, str); + g_string_append (str, ">"); + } + } } else if (node->tag == GI_TYPE_TAG_INTERFACE) { @@ -1284,7 +1307,7 @@ serialize_type (GIrTypelibBuild *build, } else if (node->tag == GI_TYPE_TAG_GHASH) { - g_string_append (str, "GHashTable<"); + g_string_append (str, "GHashTable"); if (node->parameter_type1) { g_string_append (str, "<");