From 744f3a3004a7c4db32de9c21cf315f82f257b0e7 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 11 Nov 2008 22:02:37 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20560404=20=E2=80=93=20Prefix=20types=20whe?= =?UTF-8?q?n=20resolving=20aliases=20in=20included=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * girepository/girparser.c: When resolving aliases in an included module, prefix types before looking them up. svn path=/trunk/; revision=889 --- girparser.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/girparser.c b/girparser.c index 74d7275ce..850833f37 100644 --- a/girparser.c +++ b/girparser.c @@ -478,19 +478,39 @@ resolve_aliases (ParseContext *ctx, const gchar *type) gpointer orig; gpointer value; GSList *seen_values = NULL; + const char *lookup; + char *prefixed; - seen_values = g_slist_prepend (seen_values, (char*)type); - while (g_hash_table_lookup_extended (ctx->aliases, type, &orig, &value)) + /* If we are in an included module, then we need to qualify the + * names of types before resolving them, since they will have + * been stored in the aliases qualified. + */ + if (ctx->prefix_aliases && strchr (type, '.') == NULL) { - g_debug ("Resolved: %s => %s", type, (char*)value); - type = value; - if (g_slist_find_custom (seen_values, type, + prefixed = g_strdup_printf ("%s.%s", ctx->namespace, type); + lookup = prefixed; + } + else + lookup = type; + + seen_values = g_slist_prepend (seen_values, (char*)lookup); + while (g_hash_table_lookup_extended (ctx->aliases, lookup, &orig, &value)) + { + g_debug ("Resolved: %s => %s\n", lookup, (char*)value); + lookup = value; + if (g_slist_find_custom (seen_values, lookup, (GCompareFunc)strcmp) != NULL) break; - seen_values = g_slist_prepend (seen_values, (gchar*)type); + seen_values = g_slist_prepend (seen_values, (gchar*)lookup); } g_slist_free (seen_values); - return type; + + if (lookup == prefixed) + lookup = type; + + g_free (prefixed); + + return lookup; } static GIrNodeType *