Bug 560404 – Prefix types when resolving aliases in included modules

* girepository/girparser.c: When resolving aliases in an included
module, prefix types before looking them up.

svn path=/trunk/; revision=889
This commit is contained in:
Owen Taylor 2008-11-11 22:02:37 +00:00
parent 7c221ce28b
commit 744f3a3004

View File

@ -478,19 +478,39 @@ resolve_aliases (ParseContext *ctx, const gchar *type)
gpointer orig; gpointer orig;
gpointer value; gpointer value;
GSList *seen_values = NULL; GSList *seen_values = NULL;
const char *lookup;
char *prefixed;
seen_values = g_slist_prepend (seen_values, (char*)type); /* If we are in an included module, then we need to qualify the
while (g_hash_table_lookup_extended (ctx->aliases, type, &orig, &value)) * 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); prefixed = g_strdup_printf ("%s.%s", ctx->namespace, type);
type = value; lookup = prefixed;
if (g_slist_find_custom (seen_values, type, }
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) (GCompareFunc)strcmp) != NULL)
break; break;
seen_values = g_slist_prepend (seen_values, (gchar*)type); seen_values = g_slist_prepend (seen_values, (gchar*)lookup);
} }
g_slist_free (seen_values); g_slist_free (seen_values);
return type;
if (lookup == prefixed)
lookup = type;
g_free (prefixed);
return lookup;
} }
static GIrNodeType * static GIrNodeType *