[gobject-introspection] Add a method to compare infos
- From: Simon van der Linden <svdlinden src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Add a method to compare infos
- Date: Fri, 20 Nov 2009 09:40:30 +0000 (UTC)
commit 869ef1ada512d2c47995f9dfbbe7c814d784aff8
Author: Simon van der Linden <svdlinden src gnome org>
Date: Fri Nov 20 10:38:36 2009 +0100
Add a method to compare infos
Add g_base_info_equal.
girepository/ginfo.c | 20 ++++++++++++++++++++
girepository/girepository.h | 2 ++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/girepository/ginfo.c b/girepository/ginfo.c
index 1f14cb6..2aacb76 100644
--- a/girepository/ginfo.c
+++ b/girepository/ginfo.c
@@ -554,6 +554,26 @@ g_base_info_get_typelib (GIBaseInfo *info)
return info->typelib;
}
+/*
+ * g_base_info_equal:
+ * @info1: A #GIBaseInfo
+ * @info2: A #GIBaseInfo
+ *
+ * Compare two #GIBaseInfo.
+ *
+ * Using pointer comparison is not practical since many functions return
+ * different instances of #GIBaseInfo that refers to the same part of the
+ * TypeLib; use this function instead to do #GIBaseInfo comparisons.
+ *
+ * Return value: TRUE if and only if @info1 equals @info2.
+ */
+gboolean
+g_base_info_equal (GIBaseInfo *info1, GIBaseInfo *info2)
+{
+ /* Compare the TypeLib pointers, which are mmapped. */
+ return info1->typelib->data + info1->offset == info2->typelib->data + info2->offset;
+}
+
/* GIFunctionInfo functions */
const gchar *
g_function_info_get_symbol (GIFunctionInfo *info)
diff --git a/girepository/girepository.h b/girepository/girepository.h
index c881c8b..c30418a 100644
--- a/girepository/girepository.h
+++ b/girepository/girepository.h
@@ -203,6 +203,8 @@ gboolean g_base_info_iterate_attributes (GIBaseInfo *info,
char **value);
GIBaseInfo * g_base_info_get_container (GIBaseInfo *info);
GTypelib * g_base_info_get_typelib (GIBaseInfo *info);
+gboolean g_base_info_equal (GIBaseInfo *info1,
+ GIBaseInfo *info2);
GIBaseInfo * g_info_new (GIInfoType type,
GIBaseInfo *container,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]