[perl-Glib-Object-Introspection] Correctly marshal arrays with length arguments in signal callbacks
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Glib-Object-Introspection] Correctly marshal arrays with length arguments in signal callbacks
- Date: Sun, 20 May 2018 15:15:32 +0000 (UTC)
commit 2162a9b16a08fbbc9fd7ef2cc85e482ff149c373
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Sun May 20 17:13:07 2018 +0200
Correctly marshal arrays with length arguments in signal callbacks
Signals have an implicit invocant, and hence their argument indexing is off by
one.
gperl-i11n-invoke-perl.c | 6 ++++--
t/arrays.t | 16 +++++++++++++++-
t/inc/setup.pl | 5 ++++-
3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/gperl-i11n-invoke-perl.c b/gperl-i11n-invoke-perl.c
index 2638f56..5dc338e 100644
--- a/gperl-i11n-invoke-perl.c
+++ b/gperl-i11n-invoke-perl.c
@@ -358,8 +358,10 @@ _prepare_perl_invocation_info (GPerlI11nPerlInvocationInfo *iinfo,
if (arg_tag == GI_TYPE_TAG_ARRAY) {
gint pos = g_type_info_get_array_length (arg_type);
if (pos >= 0) {
- GITypeInfo *length_arg_type = &(iinfo->base.arg_types[pos]);
- raw_to_arg (args[pos], &iinfo->base.aux_args[pos], length_arg_type);
+ GITypeInfo *length_arg_type;
+ guint args_pos = iinfo->base.is_signal ? pos+1 : pos;
+ length_arg_type = &(iinfo->base.arg_types[pos]);
+ raw_to_arg (args[args_pos], &iinfo->base.aux_args[pos], length_arg_type);
dwarn (" pos %d is array length => %"G_GSIZE_FORMAT"\n",
pos, iinfo->base.aux_args[pos].v_size);
}
diff --git a/t/arrays.t b/t/arrays.t
index 2358fbb..19e2cff 100644
--- a/t/arrays.t
+++ b/t/arrays.t
@@ -6,7 +6,7 @@ use strict;
use warnings;
use utf8;
-plan tests => 68;
+plan tests => 72;
ok (Regress::test_strv_in ([ '1', '2', '3' ]));
@@ -163,3 +163,17 @@ SKIP: {
is_deeply (GI::bytearray_full_return (), $byte_array_ref);
GI::bytearray_none_in ($byte_array_ref);
}
+
+# -----------------------------------------------------------------------------
+
+{
+ my $obj = Regress::TestObj->constructor ();
+ $obj->signal_connect ('sig-with-array-len-prop' => sub {
+ my ($self, $array, $len, $data) = @_;
+ is ($self, $obj);
+ is_deeply ($array, [0, 1, 2, 3, 4]);
+ is ($len, 5);
+ is ($data, 'user23');
+ }, 'user23');
+ $obj->emit_sig_with_array_len_prop ();
+}
diff --git a/t/inc/setup.pl b/t/inc/setup.pl
index 754b489..60e4ac5 100644
--- a/t/inc/setup.pl
+++ b/t/inc/setup.pl
@@ -34,7 +34,10 @@ Glib::Object::Introspection->setup(
basename => 'Regress',
version => '1.0',
package => 'Regress',
- search_path => 'build');
+ search_path => 'build',
+ use_generic_signal_marshaller_for => [
+ ['Regress::TestObj', 'sig-with-array-len-prop'],
+ ]);
Glib::Object::Introspection->setup(
basename => 'GIMarshallingTests',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]