1 /* -*- Mode: C; c-file-style: "gnu"; -*- */
2 /* GObject introspection: Repository implementation
4 * Copyright (C) 2005 Matthias Clasen
5 * Copyright (C) 2008 Colin Walters <walters@verbum.org>
6 * Copyright (C) 2008 Red Hat, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include <glib/gprintf.h>
30 #include "girepository.h"
33 static GStaticMutex globals_lock = G_STATIC_MUTEX_INIT;
34 static GIRepository *default_repository = NULL;
35 static GSList *search_path = NULL;
37 struct _GIRepositoryPrivate
39 GHashTable *typelibs; /* (string) namespace -> GTypelib */
40 GHashTable *lazy_typelibs; /* (string) namespace-version -> GTypelib */
43 G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT);
46 g_irepository_init (GIRepository *repository)
48 repository->priv = G_TYPE_INSTANCE_GET_PRIVATE (repository, G_TYPE_IREPOSITORY,
50 repository->priv->typelibs
51 = g_hash_table_new_full (g_str_hash, g_str_equal,
52 (GDestroyNotify) NULL,
53 (GDestroyNotify) g_typelib_free);
54 repository->priv->lazy_typelibs
55 = g_hash_table_new (g_str_hash, g_str_equal);
59 g_irepository_finalize (GObject *object)
61 GIRepository *repository = G_IREPOSITORY (object);
63 g_hash_table_destroy (repository->priv->typelibs);
64 g_hash_table_destroy (repository->priv->lazy_typelibs);
66 (* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository));
70 g_irepository_class_init (GIRepositoryClass *class)
72 GObjectClass *gobject_class;
74 gobject_class = G_OBJECT_CLASS (class);
76 gobject_class->finalize = g_irepository_finalize;
78 g_type_class_add_private (class, sizeof (GIRepositoryPrivate));
84 g_static_mutex_lock (&globals_lock);
86 if (default_repository == NULL)
88 default_repository = g_object_new (G_TYPE_IREPOSITORY, NULL);
91 if (search_path == NULL)
93 const gchar *const *datadirs;
94 const gchar *const *dir;
96 datadirs = g_get_system_data_dirs ();
99 for (dir = datadirs; *dir; dir++) {
100 char *path = g_build_filename (*dir, "girepository", NULL);
101 search_path = g_slist_prepend (search_path, path);
103 search_path = g_slist_reverse (search_path);
106 g_static_mutex_unlock (&globals_lock);
110 g_irepository_prepend_search_path (const char *directory)
113 search_path = g_slist_prepend (search_path, g_strdup (directory));
117 build_typelib_key (const char *name, const char *source)
119 GString *str = g_string_new (name);
120 g_string_append_c (str, '\0');
121 g_string_append (str, source);
122 return g_string_free (str, FALSE);
126 get_typelib_dependencies (GTypelib *typelib)
129 const char *dependencies_glob;
131 header = (Header *)typelib->data;
133 if (header->dependencies == 0)
136 dependencies_glob = g_typelib_get_string (typelib, header->dependencies);
137 return g_strsplit (dependencies_glob, "|", 0);
140 static GIRepository *
141 get_repository (GIRepository *repository)
143 if (repository != NULL)
148 return default_repository;
153 check_version_conflict (GTypelib *typelib,
154 const gchar *namespace,
155 const gchar *expected_version,
156 char **version_conflict)
159 const char *loaded_version;
161 if (expected_version == NULL)
163 if (version_conflict)
164 *version_conflict = NULL;
168 header = (Header*)typelib->data;
169 loaded_version = g_typelib_get_string (typelib, header->nsversion);
170 g_assert (loaded_version != NULL);
172 if (strcmp (expected_version, loaded_version) != 0)
174 if (version_conflict)
175 *version_conflict = (char*)loaded_version;
178 if (version_conflict)
179 *version_conflict = NULL;
184 get_registered_status (GIRepository *repository,
185 const char *namespace,
188 gboolean *lazy_status,
189 char **version_conflict)
192 repository = get_repository (repository);
194 *lazy_status = FALSE;
195 typelib = g_hash_table_lookup (repository->priv->typelibs, namespace);
197 return check_version_conflict (typelib, namespace, version, version_conflict);
198 typelib = g_hash_table_lookup (repository->priv->lazy_typelibs, namespace);
205 return check_version_conflict (typelib, namespace, version, version_conflict);
209 get_registered (GIRepository *repository,
210 const char *namespace,
213 return get_registered_status (repository, namespace, version, TRUE, NULL, NULL);
217 load_dependencies_recurse (GIRepository *repository,
223 dependencies = get_typelib_dependencies (typelib);
225 if (dependencies != NULL)
229 for (i = 0; dependencies[i]; i++)
231 char *dependency = dependencies[i];
232 const char *last_dash;
233 char *dependency_namespace;
234 const char *dependency_version;
236 last_dash = strrchr (dependency, '-');
237 dependency_namespace = g_strndup (dependency, last_dash - dependency);
238 dependency_version = last_dash+1;
240 if (!g_irepository_require (repository, dependency_namespace, dependency_version,
243 g_free (dependency_namespace);
244 g_strfreev (dependencies);
247 g_free (dependency_namespace);
249 g_strfreev (dependencies);
255 register_internal (GIRepository *repository,
262 const gchar *namespace;
263 const gchar *version;
265 gboolean currently_lazy;
267 g_return_val_if_fail (typelib != NULL, FALSE);
269 header = (Header *)typelib->data;
271 g_return_val_if_fail (header != NULL, FALSE);
273 namespace = g_typelib_get_string (typelib, header->namespace);
274 version = g_typelib_get_string (typelib, header->nsversion);
278 g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs,
280 g_hash_table_insert (repository->priv->lazy_typelibs,
281 build_typelib_key (namespace, source), (void *)typelib);
288 /* First, try loading all the dependencies */
289 if (!load_dependencies_recurse (repository, typelib, error))
292 /* Check if we are transitioning from lazily loaded state */
293 if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs,
295 (gpointer)&key, &value))
296 g_hash_table_remove (repository->priv->lazy_typelibs, key);
298 key = build_typelib_key (namespace, source);
300 g_hash_table_insert (repository->priv->typelibs, key, (void *)typelib);
303 if (typelib->modules == NULL)
304 typelib->modules = g_list_append(typelib->modules, g_module_open (NULL, 0));
310 * g_irepository_get_dependencies
311 * @repository: A #GIRepository, may be %NULL for the default
312 * @namespace: Namespace of interest
314 * Return an array of all (transitive) dependencies for namespace
315 * @namespace, including version. The returned strings are of the
316 * form <code>namespace-version</code>.
318 * Note: The namespace must have already been loaded using a function
319 * such as #g_irepository_require before calling this function.
321 * Returns: Zero-terminated string array of versioned dependencies
324 g_irepository_get_dependencies (GIRepository *repository,
325 const char *namespace)
329 g_return_val_if_fail (namespace != NULL, NULL);
331 repository = get_repository (repository);
333 typelib = get_registered (repository, namespace, NULL);
334 g_return_val_if_fail (typelib != NULL, NULL);
336 return get_typelib_dependencies (typelib);
340 g_irepository_load_typelib (GIRepository *repository,
342 GIRepositoryLoadFlags flags,
346 const char *namespace;
347 const char *nsversion;
348 gboolean allow_lazy = flags & G_IREPOSITORY_LOAD_FLAG_LAZY;
350 char *version_conflict;
352 repository = get_repository (repository);
354 header = (Header *) typelib->data;
355 namespace = g_typelib_get_string (typelib, header->namespace);
356 nsversion = g_typelib_get_string (typelib, header->nsversion);
358 if (get_registered_status (repository, namespace, nsversion, allow_lazy,
359 &is_lazy, &version_conflict))
361 if (version_conflict != NULL)
363 g_set_error (error, G_IREPOSITORY_ERROR,
364 G_IREPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT,
365 "Attempting to load namespace '%s', version '%s', but '%s' is already loaded",
366 namespace, nsversion, version_conflict);
371 return register_internal (repository, "<builtin>",
372 allow_lazy, typelib, error);
376 * g_irepository_is_registered
377 * @repository: A #GIRepository, may be %NULL for the default
378 * @namespace: Namespace of interest
379 * @version: <allow-none>: Required version, may be %NULL for latest
381 * Check whether a particular namespace (and optionally, a specific
382 * version thereof) is currently loaded. This function is likely to
383 * only be useful in unusual circumstances; in order to act upon
384 * metadata in the namespace, you should call #g_irepository_require
385 * instead which will ensure the namespace is loaded, and return as
386 * quickly as this function will if it has already been loaded.
388 * Returns: %TRUE if namespace-version is loaded, %FALSE otherwise
391 g_irepository_is_registered (GIRepository *repository,
392 const gchar *namespace,
393 const gchar *version)
395 repository = get_repository (repository);
396 return get_registered (repository, namespace, version) != NULL;
400 * g_irepository_get_default
402 * Returns the singleton process-global default #GIRepository. It is
403 * not currently supported to have multiple repositories in a
404 * particular process, but this function is provided in the unlikely
405 * eventuality that it would become possible, and as a convenience for
406 * higher level language bindings to conform to the GObject method
409 * All methods on #GIRepository also accept %NULL as an instance
410 * parameter to mean this default repository, which is usually more
413 * Returns: The global singleton #GIRepository
416 g_irepository_get_default (void)
418 return get_repository (NULL);
422 count_interfaces (gpointer key,
426 guchar *typelib = ((GTypelib *) value)->data;
427 gint *n_interfaces = (gint *)data;
429 *n_interfaces += ((Header *)typelib)->n_local_entries;
433 * g_irepository_get_n_infos
434 * @repository: A #GIRepository, may be %NULL for the default
435 * @namespace: Namespace to inspect
437 * This function returns the number of metadata entries in
438 * given namespace @namespace. The namespace must have
439 * already been loaded before calling this function.
441 * Returns: number of metadata entries
444 g_irepository_get_n_infos (GIRepository *repository,
445 const gchar *namespace)
448 gint n_interfaces = 0;
450 g_return_val_if_fail (namespace != NULL, -1);
452 repository = get_repository (repository);
454 typelib = get_registered (repository, namespace, NULL);
456 g_return_val_if_fail (typelib != NULL, -1);
458 n_interfaces = ((Header *)typelib->data)->n_local_entries;
472 find_interface (gpointer key,
477 GTypelib *typelib = (GTypelib *)value;
478 IfaceData *iface_data = (IfaceData *)data;
487 n_entries = ((Header *)typelib->data)->n_local_entries;
489 if (iface_data->name)
491 for (i = 1; i <= n_entries; i++)
493 entry = g_typelib_get_dir_entry (typelib, i);
494 name = g_typelib_get_string (typelib, entry->name);
495 if (strcmp (name, iface_data->name) == 0)
502 else if (iface_data->type)
504 for (i = 1; i <= n_entries; i++)
506 RegisteredTypeBlob *blob;
508 entry = g_typelib_get_dir_entry (typelib, i);
509 if (!BLOB_IS_REGISTERED_TYPE (entry))
512 blob = (RegisteredTypeBlob *)(&typelib->data[entry->offset]);
513 if (!blob->gtype_name)
516 type = g_typelib_get_string (typelib, blob->gtype_name);
517 if (strcmp (type, iface_data->type) == 0)
524 else if (iface_data->index > n_entries)
525 iface_data->index -= n_entries;
526 else if (iface_data->index > 0)
528 index = iface_data->index;
529 iface_data->index = 0;
534 entry = g_typelib_get_dir_entry (typelib, index);
535 iface_data->iface = g_info_new (entry->blob_type, NULL,
536 typelib, entry->offset);
541 * g_irepository_get_info
542 * @repository: A #GIRepository, may be %NULL for the default
543 * @namespace: Namespace to inspect
544 * @index: Offset into namespace metadata for entry
546 * This function returns a particular metadata entry in the
547 * given namespace @namespace. The namespace must have
548 * already been loaded before calling this function.
550 * Returns: #GIBaseInfo containing metadata
553 g_irepository_get_info (GIRepository *repository,
554 const gchar *namespace,
560 g_return_val_if_fail (namespace != NULL, NULL);
562 repository = get_repository (repository);
566 data.index = index + 1;
569 typelib = get_registered (repository, namespace, NULL);
571 g_return_val_if_fail (typelib != NULL, NULL);
573 find_interface ((void *)namespace, typelib, &data);
579 * g_irepository_find_by_gtype
580 * @repository: A #GIRepository, may be %NULL for the default
581 * @type: GType to search for
583 * Searches all loaded namespaces for a particular #GType. Note that
584 * in order to locate the metadata, the namespace corresponding to
585 * the type must first have been loaded. There is currently no
586 * mechanism for determining the namespace which corresponds to an
587 * arbitrary GType - thus, this function will function most reliably
588 * when you have expect the GType to be from a known namespace.
590 * Returns: #GIBaseInfo representing metadata about @type, or %NULL
593 g_irepository_find_by_gtype (GIRepository *repository,
598 repository = get_repository (repository);
601 data.type = g_type_name (type);
605 g_hash_table_foreach (repository->priv->typelibs, find_interface, &data);
606 g_hash_table_foreach (repository->priv->lazy_typelibs, find_interface, &data);
612 * g_irepository_find_by_name
613 * @repository: A #GIRepository, may be %NULL for the default
614 * @namespace: Namespace which will be searched
615 * @name: Entry name to find
617 * Searches for a particular entry in a namespace. Before calling
618 * this function for a particular namespace, you must call
619 * #g_irepository_require once to load the namespace, or otherwise
620 * ensure the namespace has already been loaded.
622 * Returns: #GIBaseInfo representing metadata about @name, or %NULL
625 g_irepository_find_by_name (GIRepository *repository,
626 const gchar *namespace,
632 g_return_val_if_fail (namespace != NULL, NULL);
634 repository = get_repository (repository);
641 typelib = get_registered (repository, namespace, NULL);
643 g_return_val_if_fail (typelib != NULL, NULL);
645 find_interface ((void *)namespace, typelib, &data);
651 collect_namespaces (gpointer key,
657 *list = g_list_append (*list, key);
661 * g_irepository_get_namespaces
662 * @repository: A #GIRepository, may be %NULL for the default
664 * Return the list of currently loaded namespaces.
666 * Returns: <utf8,transfer>: List of namespaces
669 g_irepository_get_loaded_namespaces (GIRepository *repository)
671 GList *l, *list = NULL;
675 repository = get_repository (repository);
677 g_hash_table_foreach (repository->priv->typelibs, collect_namespaces, &list);
678 g_hash_table_foreach (repository->priv->lazy_typelibs, collect_namespaces, &list);
680 names = g_malloc0 (sizeof (gchar *) * (g_list_length (list) + 1));
682 for (l = list; l; l = l->next)
683 names[i++] = g_strdup (l->data);
690 * g_irepository_get_version
691 * @repository: A #GIRepository, may be %NULL for the default
692 * @namespace: Namespace to inspect
694 * This function returns the loaded version associated with the given
695 * namespace @namespace.
697 * Note: The namespace must have already been loaded using a function
698 * such as #g_irepository_require before calling this function.
700 * Returns: Loaded version
703 g_irepository_get_version (GIRepository *repository,
704 const gchar *namespace)
709 g_return_val_if_fail (namespace != NULL, NULL);
711 repository = get_repository (repository);
713 typelib = get_registered (repository, namespace, NULL);
715 g_return_val_if_fail (typelib != NULL, NULL);
717 header = (Header *) typelib->data;
718 return g_typelib_get_string (typelib, header->nsversion);
722 * g_irepository_get_shared_library
723 * @repository: A #GIRepository, may be %NULL for the default
724 * @namespace: Namespace to inspect
726 * This function returns the full path to the shared C library
727 * associated with the given namespace @namespace. There may be no
728 * shared library path associated, in which case this function will
731 * Note: The namespace must have already been loaded using a function
732 * such as #g_irepository_require before calling this function.
734 * Returns: Full path to shared library, or %NULL if none associated
737 g_irepository_get_shared_library (GIRepository *repository,
738 const gchar *namespace)
743 g_return_val_if_fail (namespace != NULL, NULL);
745 repository = get_repository (repository);
747 typelib = get_registered (repository, namespace, NULL);
749 g_return_val_if_fail (typelib != NULL, NULL);
751 header = (Header *) typelib->data;
752 if (header->shared_library)
753 return g_typelib_get_string (typelib, header->shared_library);
759 * g_irepository_get_typelib_path
760 * @repository: Repository, may be %NULL for the default
761 * @namespace: GI namespace to use, e.g. "Gtk"
762 * @version: <allow-none>: Version of namespace to use, e.g. "0.8", may be %NULL
764 * If namespace @namespace is loaded, return the full path to the
765 * .typelib file it was loaded from. If the typelib for
766 * namespace @namespace was included in a shared library, return
767 * the special string "<builtin>".
769 * Returns: Filesystem path (or <builtin>) if successful, %NULL if namespace is not loaded
773 g_irepository_get_typelib_path (GIRepository *repository,
774 const gchar *namespace)
776 gpointer orig_key, value;
778 repository = get_repository (repository);
780 if (!g_hash_table_lookup_extended (repository->priv->typelibs, namespace,
783 if (!g_hash_table_lookup_extended (repository->priv->lazy_typelibs, namespace,
788 return ((char*)orig_key) + strlen ((char *) orig_key) + 1;
791 /* This simple search function looks for a specified namespace-version;
792 it's faster than the full directory listing required for latest version. */
794 find_namespace_version (const gchar *namespace,
795 const gchar *version,
799 GError *error = NULL;
800 GMappedFile *mfile = NULL;
803 fname = g_strdup_printf ("%s-%s.typelib", namespace, version);
805 for (ldir = search_path; ldir; ldir = ldir->next)
808 char *path = g_build_filename (ldir->data, fname, NULL);
810 mfile = g_mapped_file_new (path, FALSE, &error);
814 g_clear_error (&error);
825 parse_version (const char *version,
832 *major = strtol (version, &end, 10);
833 dot = strchr (version, '.');
841 *minor = strtol (dot+1, &end, 10);
842 if (end != (version + strlen (version)))
848 compare_version (const char *v1,
852 int v1_major, v1_minor;
853 int v2_major, v2_minor;
855 success = parse_version (v1, &v1_major, &v1_minor);
858 success = parse_version (v2, &v2_major, &v2_minor);
861 if (v1_major > v2_major)
863 else if (v2_major > v1_major)
865 else if (v1_minor > v2_minor)
867 else if (v2_minor > v1_minor)
872 struct NamespaceVersionCandidadate
880 compare_candidate_reverse (struct NamespaceVersionCandidadate *c1,
881 struct NamespaceVersionCandidadate *c2)
883 int result = compare_version (c1->version, c2->version);
893 free_candidate (struct NamespaceVersionCandidadate *candidate)
895 g_mapped_file_free (candidate->mfile);
896 g_free (candidate->path);
897 g_free (candidate->version);
902 find_namespace_latest (const gchar *namespace,
907 GError *error = NULL;
908 char *namespace_dash;
909 char *namespace_typelib;
910 GSList *candidates = NULL;
911 GMappedFile *result = NULL;
916 namespace_dash = g_strdup_printf ("%s-", namespace);
917 namespace_typelib = g_strdup_printf ("%s.typelib", namespace);
919 for (ldir = search_path; ldir; ldir = ldir->next)
925 dirname = (const char*)ldir->data;
926 dir = g_dir_open (dirname, 0, NULL);
929 while ((entry = g_dir_read_name (dir)) != NULL)
932 char *path, *version;
933 struct NamespaceVersionCandidadate *candidate;
935 if (!g_str_has_suffix (entry, ".typelib"))
938 if (g_str_has_prefix (entry, namespace_dash))
940 const char *last_dash;
941 const char *name_end;
944 name_end = strrchr (entry, '.');
945 last_dash = strrchr (entry, '-');
946 version = g_strndup (last_dash+1, name_end-(last_dash+1));
947 if (!parse_version (version, &major, &minor))
953 path = g_build_filename (dirname, entry, NULL);
954 mfile = g_mapped_file_new (path, FALSE, &error);
959 g_clear_error (&error);
962 candidate = g_new0 (struct NamespaceVersionCandidadate, 1);
963 candidate->mfile = mfile;
964 candidate->path = path;
965 candidate->version = version;
966 candidates = g_slist_prepend (candidates, candidate);
971 if (candidates != NULL)
973 struct NamespaceVersionCandidadate *elected;
974 candidates = g_slist_sort (candidates, (GCompareFunc) compare_candidate_reverse);
976 elected = (struct NamespaceVersionCandidadate *) candidates->data;
977 /* Remove the elected one so we don't try to free it */
978 candidates = g_slist_delete_link (candidates, candidates);
980 result = elected->mfile;
981 *path_ret = elected->path;
982 *version_ret = elected->version;
983 g_slist_foreach (candidates, (GFunc) free_candidate, NULL);
984 g_slist_free (candidates);
987 g_free (namespace_dash);
988 g_free (namespace_typelib);
993 * g_irepository_require
994 * @repository: <allow-none>: Repository, may be %NULL for the default
995 * @namespace: GI namespace to use, e.g. "Gtk"
996 * @version: <allow-none>: Version of namespace, may be %NULL for latest
997 * @flags: Set of %GIRepositoryLoadFlags, may be %0
1000 * Force the namespace @namespace to be loaded if it isn't already.
1001 * If @namespace is not loaded, this function will search for a
1002 * ".typelib" file using the repository search path. In addition, a
1003 * version @version of namespace may be specified. If @version is
1004 * not specified, the latest will be used.
1006 * Returns: %TRUE if successful, %NULL otherwise
1009 g_irepository_require (GIRepository *repository,
1010 const gchar *namespace,
1011 const gchar *version,
1012 GIRepositoryLoadFlags flags,
1017 gboolean ret = FALSE;
1018 GError *error1 = NULL;
1020 GTypelib *typelib = NULL;
1021 const gchar *typelib_namespace, *typelib_version, *shlib_fname;
1024 gboolean allow_lazy = (flags & G_IREPOSITORY_LOAD_FLAG_LAZY) > 0;
1026 char *version_conflict = NULL;
1028 char *tmp_version = NULL;
1030 g_return_val_if_fail (namespace != NULL, FALSE);
1032 repository = get_repository (repository);
1034 if (get_registered_status (repository, namespace, version, allow_lazy,
1035 &is_lazy, &version_conflict))
1038 if (version_conflict != NULL)
1040 g_set_error (error, G_IREPOSITORY_ERROR,
1041 G_IREPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT,
1042 "Requiring namespace '%s' version '%s', but '%s' is already loaded",
1043 namespace, version, version_conflict);
1047 if (version != NULL)
1049 mfile = find_namespace_version (namespace, version, &path);
1050 tmp_version = g_strdup (version);
1054 mfile = find_namespace_latest (namespace, &tmp_version, &path);
1059 const char *error_fmt;
1060 if (version != NULL)
1061 g_set_error (error, G_IREPOSITORY_ERROR,
1062 G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
1063 "Typelib file %s for namespace '%s', version '%s' not found",
1064 namespace, version);
1066 g_set_error (error, G_IREPOSITORY_ERROR,
1067 G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
1068 "Typelib file for namespace '%s' (any version) not found",
1073 typelib = g_typelib_new_from_mapped_file (mfile);
1074 header = (Header *) typelib->data;
1075 typelib_namespace = g_typelib_get_string (typelib, header->namespace);
1076 typelib_version = g_typelib_get_string (typelib, header->nsversion);
1078 if (strcmp (typelib_namespace, namespace) != 0)
1080 g_set_error (error, G_IREPOSITORY_ERROR,
1081 G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
1082 "Typelib file %s for namespace '%s' contains "
1083 "namespace '%s' which doesn't match the file name",
1084 path, namespace, typelib_namespace);
1087 if (version != NULL && strcmp (typelib_version, version) != 0)
1089 g_set_error (error, G_IREPOSITORY_ERROR,
1090 G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH,
1091 "Typelib file %s for namespace '%s' contains "
1092 "version '%s' which doesn't match the expected version '%s'",
1093 path, namespace, typelib_version, version);
1097 if (!register_internal (repository, path, allow_lazy,
1100 g_typelib_free (typelib);
1105 g_free (tmp_version);
1112 g_irepository_error_quark (void)
1114 static GQuark quark = 0;
1116 quark = g_quark_from_static_string ("g-irepository-error-quark");
1121 g_type_tag_to_string (GITypeTag type)
1125 case GI_TYPE_TAG_VOID:
1127 case GI_TYPE_TAG_BOOLEAN:
1129 case GI_TYPE_TAG_INT8:
1131 case GI_TYPE_TAG_UINT8:
1133 case GI_TYPE_TAG_INT16:
1135 case GI_TYPE_TAG_UINT16:
1137 case GI_TYPE_TAG_INT32:
1139 case GI_TYPE_TAG_UINT32:
1141 case GI_TYPE_TAG_INT64:
1143 case GI_TYPE_TAG_UINT64:
1145 case GI_TYPE_TAG_INT:
1147 case GI_TYPE_TAG_UINT:
1149 case GI_TYPE_TAG_LONG:
1151 case GI_TYPE_TAG_ULONG:
1153 case GI_TYPE_TAG_SSIZE:
1155 case GI_TYPE_TAG_SIZE:
1157 case GI_TYPE_TAG_FLOAT:
1159 case GI_TYPE_TAG_DOUBLE:
1161 case GI_TYPE_TAG_TIME_T:
1163 case GI_TYPE_TAG_GTYPE:
1165 case GI_TYPE_TAG_UTF8:
1167 case GI_TYPE_TAG_FILENAME:
1169 case GI_TYPE_TAG_ARRAY:
1171 case GI_TYPE_TAG_INTERFACE:
1173 case GI_TYPE_TAG_GLIST:
1175 case GI_TYPE_TAG_GSLIST:
1177 case GI_TYPE_TAG_GHASH:
1179 case GI_TYPE_TAG_ERROR: