[perl-Glib-Object-Introspection] Support calling methods on unions
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] Support calling methods on unions
- Date: Sun, 27 Feb 2011 19:15:54 +0000 (UTC)
commit 5b1a7712abb2d10f71848cbb2e4338bb1eee57ea
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Sun Feb 27 19:13:27 2011 +0000
Support calling methods on unions
Methods of unions with a registered boxed type, like:
clutter_event_get_coords (ClutterEvent*, gfloat*, gfloat*)
or:
gdk_event_get_time (GdkEvent*)
should be handled exactly like methods on structs.
GObjectIntrospection.xs | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index 020dd7e..895dd4d 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -142,6 +142,11 @@ get_function_info (GIRepository *repository,
(GIStructInfo *) namespace_info,
method);
break;
+ case GI_INFO_TYPE_UNION:
+ function_info = g_union_info_find_method (
+ (GIUnionInfo *) namespace_info,
+ method);
+ break;
default:
ccroak ("Base info for namespace %s has incorrect type",
namespace);
@@ -1003,6 +1008,7 @@ instance_sv_to_pointer (GIFunctionInfo *function_info, SV *sv)
case GI_INFO_TYPE_BOXED:
case GI_INFO_TYPE_STRUCT:
+ case GI_INFO_TYPE_UNION:
{
GType type = g_registered_type_info_get_g_type (
(GIRegisteredTypeInfo *) container);
@@ -1710,8 +1716,18 @@ store_methods (HV *namespaced_functions, GIBaseInfo *info, GIInfoType info_type)
case GI_INFO_TYPE_UNION:
{
- dwarn ("%s: unions not handled yet", G_STRFUNC);
- break;
+ gint n_methods = g_union_info_get_n_methods ((GIUnionInfo *) info);
+ for (i = 0; i < n_methods; i++) {
+ GIFunctionInfo *function_info;
+ const gchar *function_name;
+
+ function_info = g_union_info_get_method ((GIUnionInfo *) info, i);
+ function_name = g_base_info_get_name ((GIBaseInfo *) function_info);
+
+ av_push (av, newSVpv (function_name, PL_na));
+ g_base_info_unref ((GIBaseInfo *) function_info);
+ }
+ break;
}
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]