[gobject-introspection] g_object_info_find_method_using_interfaces: New function
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] g_object_info_find_method_using_interfaces: New function
- Date: Mon, 6 Dec 2010 15:20:36 +0000 (UTC)
commit ef97d3e097dccf44d790b2ab02d12189f9a04a6c
Author: Colin Walters <walters verbum org>
Date: Fri Oct 22 14:22:19 2010 -0400
g_object_info_find_method_using_interfaces: New function
Pull this down into introspection from gjs; this will allow us
to cache this better in the future (for example, by caching the
infos for interfaces in the info for the object).
https://bugzilla.gnome.org/show_bug.cgi?id=632924
girepository/giobjectinfo.c | 57 +++++++++++++++++++++++++++++++++++++++++++
girepository/giobjectinfo.h | 5 ++++
2 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c
index e1f0bc1..d6bdce6 100644
--- a/girepository/giobjectinfo.c
+++ b/girepository/giobjectinfo.c
@@ -414,6 +414,63 @@ g_object_info_find_method (GIObjectInfo *info,
}
/**
+ * g_object_info_find_method_using_interfaces:
+ * @info: a #GIObjectInfo
+ * @name: name of method to obtain
+ * @implementor: (out) (transfer full): The implementor of the interface
+ *
+ * Obtain a method of the object given a @name, searching both the
+ * object @info and any interfaces it implements. %NULL will be
+ * returned if there's no method available with that name.
+ *
+ * Note that this function does *not* search parent classes; you will have
+ * to chain up if that's desired.
+ *
+ * Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling
+ * g_base_info_unref() when done.
+ */
+GIFunctionInfo *
+g_object_info_find_method_using_interfaces (GIObjectInfo *info,
+ const gchar *name,
+ GIObjectInfo **implementor)
+{
+ GIFunctionInfo *result = NULL;
+ GIObjectInfo *implementor_result = NULL;
+
+ result = g_object_info_find_method (info, name);
+ if (result)
+ implementor_result = g_base_info_ref ((GIBaseInfo*) info);
+
+ if (result == NULL)
+ {
+ int n_interfaces;
+ int i;
+
+ n_interfaces = g_object_info_get_n_interfaces (info);
+ for (i = 0; i < n_interfaces; ++i)
+ {
+ GIInterfaceInfo *iface_info;
+
+ iface_info = g_object_info_get_interface (info, i);
+
+ result = g_interface_info_find_method (iface_info, name);
+
+ if (result != NULL)
+ {
+ implementor_result = iface_info;
+ break;
+ }
+ g_base_info_unref ((GIBaseInfo*) iface_info);
+ }
+ }
+ if (implementor)
+ *implementor = implementor_result;
+ else
+ g_base_info_unref ((GIBaseInfo*) implementor_result);
+ return result;
+}
+
+/**
* g_object_info_get_n_signals:
* @info: a #GIObjectInfo
*
diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h
index 09e4bec..fd35ef8 100644
--- a/girepository/giobjectinfo.h
+++ b/girepository/giobjectinfo.h
@@ -91,6 +91,11 @@ GIFunctionInfo * g_object_info_get_method (GIObjectInfo *info,
gint n);
GIFunctionInfo * g_object_info_find_method (GIObjectInfo *info,
const gchar *name);
+
+GIFunctionInfo * g_object_info_find_method_using_interfaces (GIObjectInfo *info,
+ const gchar *name,
+ GIObjectInfo **implementor);
+
gint g_object_info_get_n_signals (GIObjectInfo *info);
GISignalInfo * g_object_info_get_signal (GIObjectInfo *info,
gint n);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]