static GIRepository *default_repository = NULL;
static GSList *search_path = NULL;
-static GSList *override_search_path = NULL;
struct _GIRepositoryPrivate
{
type_lib_path_env = g_getenv ("GI_TYPELIB_PATH");
search_path = NULL;
- override_search_path = NULL;
if (type_lib_path_env)
{
gchar **custom_dirs;
d = custom_dirs;
while (*d)
{
- override_search_path = g_slist_prepend (override_search_path, *d);
+ search_path = g_slist_prepend (search_path, *d);
d++;
}
g_free (custom_dirs);
}
- if (override_search_path != NULL)
- override_search_path = g_slist_reverse (override_search_path);
-
libdir = GOBJECT_INTROSPECTION_LIBDIR;
typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL);
return search_path;
}
-static GSList *
-build_search_path_with_overrides (void)
-{
- GSList *result;
-
- init_globals ();
-
- if (override_search_path != NULL)
- {
- result = g_slist_copy (override_search_path);
- g_slist_last (result)->next = g_slist_copy (search_path);
- }
- else
- result = g_slist_copy (search_path);
- return result;
-}
-
static char *
build_typelib_key (const char *name, const char *source)
{
g_return_val_if_fail (namespace != NULL, NULL);
repository = get_repository (repository);
- transitive_dependencies = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- /* Load the dependencies. */
typelib = get_registered (repository, namespace, NULL);
g_return_val_if_fail (typelib != NULL, NULL);
+
+ /* Load the dependencies. */
+ transitive_dependencies = g_hash_table_new (g_str_hash, g_str_equal);
get_typelib_dependencies_transitive (repository, typelib,
transitive_dependencies);
g_hash_table_iter_steal (&iter);
}
+ g_hash_table_unref (transitive_dependencies);
+
/* Add a NULL terminator. */
g_ptr_array_add (out, NULL);
typedef struct {
const gchar *gtype_name;
GITypelib *result_typelib;
- gboolean found_prefix;
} FindByGTypeData;
static DirEntry *
{
if (!g_typelib_matches_gtype_name_prefix (typelib, data->gtype_name))
continue;
-
- data->found_prefix = TRUE;
}
ret = g_typelib_get_dir_entry_by_gtype_name (typelib, data->gtype_name);
data.gtype_name = g_type_name (gtype);
data.result_typelib = NULL;
- data.found_prefix = FALSE;
-
- /* There is a corner case regarding GdkRectangle. GdkRectangle is a
- * boxed type, but it is just an alias to boxed struct
- * CairoRectangleInt. Scanner automatically converts all references
- * to GdkRectangle to CairoRectangleInt, so GdkRectangle does not
- * appear in the typelibs at all, although user code might query it.
- * So if we get such query, we also change it to lookup of
- * CairoRectangleInt.
- * https://bugzilla.gnome.org/show_bug.cgi?id=655423
- */
- if (G_UNLIKELY (!strcmp (data.gtype_name, "GdkRectangle")))
- data.gtype_name = "CairoRectangleInt";
/* Inside each typelib, we include the "C prefix" which acts as
* a namespace mechanism. For GtkTreeView, the C prefix is Gtk.
if (entry == NULL)
entry = find_by_gtype (repository->priv->lazy_typelibs, &data, TRUE);
- /* If we have no result, but we did find a typelib claiming to
- * offer bindings for such a prefix, bail out now on the assumption
- * that a more exhaustive search would not produce any results.
- */
- if (entry == NULL && data.found_prefix)
- return NULL;
-
/* Not ever class library necessarily specifies a correct c_prefix,
* so take a second pass. This time we will try a global lookup,
* ignoring prefixes.
const gchar *namespace_)
{
GList *ret = NULL;
- GSList *search_path;
GSList *candidates, *link;
const gchar *loaded_version;
- search_path = build_search_path_with_overrides ();
+ init_globals ();
candidates = enumerate_namespace_versions (namespace_, search_path);
- g_slist_free (search_path);
for (link = candidates; link; link = link->next)
{
GIRepositoryLoadFlags flags,
GError **error)
{
- GSList *search_path;
GITypelib *typelib;
- search_path = build_search_path_with_overrides ();
+ init_globals ();
typelib = require_internal (repository, namespace, version, flags,
search_path, error);
- g_slist_free (search_path);
return typelib;
}