[perl-Glib-Object-Introspection] Implement SV → GClosure



commit d741ae91141ba23214bd7a19d1562d73d1af7457
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Wed Nov 10 21:53:07 2010 +0100

    Implement SV â?? GClosure

 GObjectIntrospection.xs |    4 ++++
 t/closures.t            |   14 ++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index d8506fa..432322d 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -795,6 +795,10 @@ sv_to_interface (GIArgInfo * arg_info,
 			                               interface,
 			                               info_type,
 			                               sv);
+		} else if (type == G_TYPE_CLOSURE) {
+			/* FIXME: User cannot supply user data. */
+			dwarn ("    closure type\n");
+			arg->v_pointer = gperl_closure_new (sv, NULL, FALSE);
 		} else {
 			dwarn ("    boxed type: %s (%d)\n",
 			       g_type_name (type), type);
diff --git a/t/closures.t b/t/closures.t
new file mode 100644
index 0000000..b04e714
--- /dev/null
+++ b/t/closures.t
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+BEGIN { require './t/inc/setup.pl' };
+
+use strict;
+use warnings;
+
+plan tests => 3;
+
+TODO: {
+  local $TODO = 'User cannot supply user data';
+  is (test_closure (sub { return 23; }), 23);
+  is (test_closure_one_arg (sub { is (shift, 42); return 23; }, 42), 23);
+}



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