[perl-Glib-Object-Introspection] Improve support for boxed and struct objects



commit 2ec44fc665a69572edce7f76d8483482cfca37d8
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sat Apr 17 22:42:29 2010 +0200

    Improve support for boxed and struct objects
    
    Correctly setup and resolve methods, properly convert instance pointers.

 GObjectIntrospection.xs |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index ad9ac13..8b342a1 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -94,6 +94,12 @@ get_function_info (GIRepository *repository,
 				(GIInterfaceInfo *) namespace_info,
 				method);
 			break;
+		    case GI_INFO_TYPE_BOXED:
+		    case GI_INFO_TYPE_STRUCT:
+			function_info = g_struct_info_find_method (
+				(GIStructInfo *) namespace_info,
+				method);
+			break;
 		    default:
 			croak ("Base info for namespace %s has incorrect type",
 			       namespace);
@@ -362,6 +368,7 @@ instance_sv_to_pointer (GIFunctionInfo *function_info, SV *sv)
 		break;
 
 	    case GI_INFO_TYPE_BOXED:
+	    case GI_INFO_TYPE_STRUCT:
 	    {
 		GType type = g_registered_type_info_get_g_type (
 			       (GIRegisteredTypeInfo *) container);
@@ -1136,17 +1143,32 @@ store_methods (HV *namespaced_functions, GIBaseInfo *info, GIInfoType info_type)
 			g_base_info_unref ((GIBaseInfo *) function_info);
 		}
 		break;
-		break;
 	    }
 
 	    case GI_INFO_TYPE_BOXED:
 	    case GI_INFO_TYPE_STRUCT:
 	    {
-		/* FIXME */
+		gint n_methods = g_struct_info_get_n_methods (
+		                   (GIStructInfo *) info);
+		for (i = 0; i < n_methods; i++) {
+			GIFunctionInfo *function_info =
+				g_struct_info_get_method (
+					(GIStructInfo *) info, i);
+			const gchar *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;
 	    }
 
 	    case GI_INFO_TYPE_UNION:
+	    {
+		/* FIXME */
+		break;
+	    }
+
 	    default:
 		croak ("store_methods: unsupported info type %d", info_type);
 	}



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