diff options
author | Simon van der Linden <svdlinden@src.gnome.org> | 2009-11-20 10:38:36 +0100 |
---|---|---|
committer | Simon van der Linden <svdlinden@leonard.(none)> | 2009-11-20 10:40:07 +0100 |
commit | 869ef1ada512d2c47995f9dfbbe7c814d784aff8 (patch) | |
tree | cab3251c8ab0ad086caeccf6e289ef28fa08c04a | |
parent | 7bc82cad17064caf59630dbcc92e25ed3fe172cd (diff) | |
download | gobject-introspection-869ef1ada512d2c47995f9dfbbe7c814d784aff8.tar.gz |
Add a method to compare infos
Add g_base_info_equal.
-rw-r--r-- | girepository/ginfo.c | 20 | ||||
-rw-r--r-- | girepository/girepository.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/girepository/ginfo.c b/girepository/ginfo.c index 1f14cb6f..2aacb763 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 c881c8bb..c30418a8 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, |