[perl-Glib-Object-Introspection] Construct GPerlI11nPerlCallbackInfo from GICallableInfo



commit 01d58d3c889e946b44dc5df8766ea424b210de10
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Aug 25 15:29:00 2012 +0200

    Construct GPerlI11nPerlCallbackInfo from GICallableInfo
    
    We won't have a GITypeInfo everywhere we want to construct a closure.

 GObjectIntrospection.xs       |    4 ++--
 gperl-i11n-callback.c         |   10 ++++------
 gperl-i11n-marshal-callback.c |    5 ++++-
 gperl-i11n-vfunc-interface.c  |    5 ++++-
 gperl-i11n-vfunc-object.c     |    5 ++++-
 5 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index 306cfe4..c37d6f5 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -115,8 +115,8 @@ typedef struct {
 } GPerlI11nInvocationInfo;
 
 /* callbacks */
-static GPerlI11nPerlCallbackInfo * create_perl_callback_closure_for_named_sub (GITypeInfo *cb_type, gchar *sub_name);
-static GPerlI11nPerlCallbackInfo * create_perl_callback_closure (GITypeInfo *cb_type, SV *code);
+static GPerlI11nPerlCallbackInfo * create_perl_callback_closure_for_named_sub (GIBaseInfo *cb_info, gchar *sub_name);
+static GPerlI11nPerlCallbackInfo * create_perl_callback_closure (GIBaseInfo *cb_info, SV *code);
 static void attach_perl_callback_data (GPerlI11nPerlCallbackInfo *info, SV *data);
 static void release_perl_callback (gpointer data);
 
diff --git a/gperl-i11n-callback.c b/gperl-i11n-callback.c
index 59aec95..7f0f3fa 100644
--- a/gperl-i11n-callback.c
+++ b/gperl-i11n-callback.c
@@ -1,7 +1,7 @@
 /* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8; -*- */
 
 static GPerlI11nPerlCallbackInfo *
-create_perl_callback_closure (GITypeInfo *cb_type, SV *code)
+create_perl_callback_closure (GICallableInfo *cb_info, SV *code)
 {
 	GPerlI11nPerlCallbackInfo *info;
 
@@ -9,8 +9,7 @@ create_perl_callback_closure (GITypeInfo *cb_type, SV *code)
 	if (!gperl_sv_is_defined (code))
 		return info;
 
-	info->interface =
-		(GICallableInfo *) g_type_info_get_interface (cb_type);
+	info->interface = g_base_info_ref (cb_info);
 	info->cif = g_new0 (ffi_cif, 1);
 	info->closure =
 		g_callable_info_prepare_closure (info->interface, info->cif,
@@ -36,13 +35,12 @@ attach_perl_callback_data (GPerlI11nPerlCallbackInfo *info, SV *data)
 
 /* assumes ownership of sub_name */
 static GPerlI11nPerlCallbackInfo *
-create_perl_callback_closure_for_named_sub (GITypeInfo *cb_type, gchar *sub_name)
+create_perl_callback_closure_for_named_sub (GICallableInfo *cb_info, gchar *sub_name)
 {
 	GPerlI11nPerlCallbackInfo *info;
 
 	info = g_new0 (GPerlI11nPerlCallbackInfo, 1);
-	info->interface =
-		(GICallableInfo *) g_type_info_get_interface (cb_type);
+	info->interface = g_base_info_ref (cb_info);
 	info->cif = g_new0 (ffi_cif, 1);
 	info->closure =
 		g_callable_info_prepare_closure (info->interface, info->cif,
diff --git a/gperl-i11n-marshal-callback.c b/gperl-i11n-marshal-callback.c
index b8ec353..3620f33 100644
--- a/gperl-i11n-marshal-callback.c
+++ b/gperl-i11n-marshal-callback.c
@@ -6,6 +6,7 @@ sv_to_callback (GIArgInfo * arg_info,
                 SV * sv,
                 GPerlI11nInvocationInfo * invocation_info)
 {
+	GIBaseInfo *callback_interface_info;
 	GPerlI11nPerlCallbackInfo *callback_info;
 	GIScopeType scope;
 
@@ -15,10 +16,12 @@ sv_to_callback (GIArgInfo * arg_info,
 	       invocation_info->current_pos,
 	       g_base_info_get_name (arg_info));
 
-	callback_info = create_perl_callback_closure (type_info, sv);
+	callback_interface_info = g_type_info_get_interface (type_info);
+	callback_info = create_perl_callback_closure (callback_interface_info, sv);
 	callback_info->data_pos = g_arg_info_get_closure (arg_info);
 	callback_info->destroy_pos = g_arg_info_get_destroy (arg_info);
 	callback_info->free_after_use = FALSE;
+	g_base_info_unref (callback_interface_info);
 
 	dwarn ("      Perl callback data at %d, destroy at %d\n",
 	       callback_info->data_pos, callback_info->destroy_pos);
diff --git a/gperl-i11n-vfunc-interface.c b/gperl-i11n-vfunc-interface.c
index b49f471..b094310 100644
--- a/gperl-i11n-vfunc-interface.c
+++ b/gperl-i11n-vfunc-interface.c
@@ -14,6 +14,7 @@ generic_interface_init (gpointer iface, gpointer data)
 		GIFieldInfo *field_info;
 		gint field_offset;
 		GITypeInfo *field_type_info;
+		GIBaseInfo *field_interface_info;
 		gchar *perl_method_name;
 		GPerlI11nPerlCallbackInfo *callback_info;
 
@@ -34,16 +35,18 @@ generic_interface_init (gpointer iface, gpointer data)
 		g_assert (field_info);
 		field_offset = g_field_info_get_offset (field_info);
 		field_type_info = g_field_info_get_type (field_info);
+		field_interface_info = g_type_info_get_interface (field_type_info);
 
 		/* callback_info takes over ownership of perl_method_name. */
 		callback_info = create_perl_callback_closure_for_named_sub (
-		                  field_type_info, perl_method_name);
+		                  field_interface_info, perl_method_name);
 		dwarn ("installing vfunc %s as %s at offset %d (vs. %d) inside %p\n",
 		       vfunc_name, perl_method_name,
 		       field_offset, g_vfunc_info_get_offset (vfunc_info),
 		       iface);
 		G_STRUCT_MEMBER (gpointer, iface, field_offset) = callback_info->closure;
 
+		g_base_info_unref (field_interface_info);
 		g_base_info_unref (field_type_info);
 		g_base_info_unref (field_info);
 		g_base_info_unref (vfunc_info);
diff --git a/gperl-i11n-vfunc-object.c b/gperl-i11n-vfunc-object.c
index 5db3a12..5a63223 100644
--- a/gperl-i11n-vfunc-object.c
+++ b/gperl-i11n-vfunc-object.c
@@ -13,6 +13,7 @@ generic_class_init (GIObjectInfo *info, const gchar *target_package, gpointer cl
 		GIFieldInfo *field_info;
 		gint field_offset;
 		GITypeInfo *field_type_info;
+		GIBaseInfo *field_interface_info;
 		gchar *perl_method_name;
 		GPerlI11nPerlCallbackInfo *callback_info;
 
@@ -49,16 +50,18 @@ generic_class_init (GIObjectInfo *info, const gchar *target_package, gpointer cl
 		g_assert (field_info);
 		field_offset = g_field_info_get_offset (field_info);
 		field_type_info = g_field_info_get_type (field_info);
+		field_interface_info = g_type_info_get_interface (field_type_info);
 
 		/* callback_info takes over ownership of perl_method_name. */
 		callback_info = create_perl_callback_closure_for_named_sub (
-		                  field_type_info, perl_method_name);
+		                  field_interface_info, perl_method_name);
 		dwarn ("installing vfunc %s as %s at offset %d (vs. %d) inside %p\n",
 		       vfunc_name, perl_method_name,
 		       field_offset, g_vfunc_info_get_offset (vfunc_info),
 		       class);
 		G_STRUCT_MEMBER (gpointer, class, field_offset) = callback_info->closure;
 
+		g_base_info_unref (field_interface_info);
 		g_base_info_unref (field_type_info);
 		g_base_info_unref (field_info);
 		g_base_info_unref (vfunc_info);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]