=?utf-8?q?=5Bperl-Glib-Object-Introspection=5D_SV_=E2=86=92_GValue=3A_cor?= =?utf-8?q?rectly_handle_ownership_transfer_and_value_semantics?=



commit a04a1ed5d55c375eed4bacf6c00ef07c787f56a8
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Fri Jan 25 17:36:14 2013 +0100

    SV â GValue: correctly handle ownership transfer and value semantics

 gperl-i11n-marshal-interface.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gperl-i11n-marshal-interface.c b/gperl-i11n-marshal-interface.c
index dc1496c..c8a50d3 100644
--- a/gperl-i11n-marshal-interface.c
+++ b/gperl-i11n-marshal-interface.c
@@ -171,11 +171,22 @@ sv_to_interface (GIArgInfo * arg_info,
 			g_assert (!need_value_semantics);
 			arg->v_pointer = gperl_closure_new (sv, NULL, FALSE);
 		} else if (type == G_TYPE_VALUE) {
+			GValue *gvalue = SvGValueWrapper (sv);
 			dwarn ("    value type\n");
-			g_assert (!need_value_semantics);
-			arg->v_pointer = SvGValueWrapper (sv);
-			if (!arg->v_pointer)
+			if (!gvalue)
 				ccroak ("Cannot convert arbitrary SV to GValue");
+			if (need_value_semantics) {
+				g_value_init (arg->v_pointer, G_VALUE_TYPE (gvalue));
+				g_value_copy (gvalue, arg->v_pointer);
+			} else {
+				if (GI_TRANSFER_EVERYTHING == transfer) {
+					arg->v_pointer = g_new0 (GValue, 1);
+					g_value_init (arg->v_pointer, G_VALUE_TYPE (gvalue));
+					g_value_copy (gvalue, arg->v_pointer);
+				} else {
+					arg->v_pointer = gvalue;
+				}
+			}
 		} else {
 			dwarn ("    boxed type: %s, name=%s, caller-allocates=%d, is-pointer=%d\n",
 			       g_type_name (type),



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