From: Emmanuel Rodriguez Date: Thu, 9 Jul 2009 20:22:13 +0000 (+0200) Subject: Scalar context on a XS method is too strange X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9c20f31905889fd84b957158193e69efb3b3d29;p=libchamplain Scalar context on a XS method is too strange --- diff --git a/bindings/perl/Champlain/t/ChamplainSelectionLayer.t b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t index e4944da..c042bd6 100644 --- a/bindings/perl/Champlain/t/ChamplainSelectionLayer.t +++ b/bindings/perl/Champlain/t/ChamplainSelectionLayer.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Clutter::TestHelper tests => 25; +use Clutter::TestHelper tests => 24; use Champlain; use Data::Dumper; @@ -23,18 +23,16 @@ sub test_empty { my $layer = Champlain::SelectionLayer->new(); isa_ok($layer, 'Champlain::Layer'); - my $count; - my @markers; - is($layer->get_selected, undef, "[empty] get_selected()"); # In single mode get_selected_markers doesn't work - @markers = $layer->get_selected_markers; - is_deeply(\@markers, [], "[empty] get_selected_markers() list context"); - $count = $layer->get_selected_markers; - is($count, 0, "[empty] get_selected_markers() scalar context"); + is_deeply( + [$layer->get_selected_markers], + [], + "[empty] get_selected_markers()" + ); - $count = $layer->count_selected_markers; + my $count = $layer->count_selected_markers; is($count, 0, "[empty] count_selected_markers()"); my $marker = Champlain::BaseMarker->new(); diff --git a/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs index e36fb31..72d4f29 100644 --- a/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs +++ b/bindings/perl/Champlain/xs/ChamplainSelectionLayer.xs @@ -20,12 +20,7 @@ champlain_selection_layer_get_selected_markers (ChamplainSelectionLayer *layer) PPCODE: item = champlain_selection_layer_get_selected_markers(layer); - if (!item) { - if (GIMME == G_SCALAR) { - XPUSHs(sv_2mortal(newSViv(0))); - return; - } XSRETURN_EMPTY; }