diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-11-03 14:57:11 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-11-03 15:04:34 +0000 |
commit | 25a9ffce153b0e67cfefd260754edeb097da5be7 (patch) | |
tree | 6d7e60d1842fa73c3f0fcec7cc9a2e2272baf085 /ext/XS-APItest | |
parent | 7d255dc8b56bf0fe58c3f8a5aa84ba17aade145f (diff) | |
download | perl-25a9ffce153b0e67cfefd260754edeb097da5be7.tar.gz |
Add Perl_amagic_deref_call() to implement the bulk of tryAMAGICunDEREF_var().
This removes around 300 bytes of object code from each place it was previously
inlined. It also provides a better interface - quite a lot of the core
currently bodges things by creating a local variable C<SV **sp = &sv> to use
the macro.
Change the XS::APItest wrapper to amagic_deref_call().
Diffstat (limited to 'ext/XS-APItest')
-rw-r--r-- | ext/XS-APItest/APItest.xs | 8 | ||||
-rw-r--r-- | ext/XS-APItest/t/overload.t | 8 |
2 files changed, 6 insertions, 10 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 51e898a4d2..3bad3286f2 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -916,16 +916,12 @@ INCLUDE: numeric.xs MODULE = XS::APItest:Overload PACKAGE = XS::APItest::Overload SV * -tryAMAGICunDEREF_var(sv, what) +amagic_deref_call(sv, what) SV *sv int what PPCODE: - { - SV **sp = &sv; - tryAMAGICunDEREF_var(what); - } /* The reference is owned by something else. */ - PUSHs(sv); + PUSHs(amagic_deref_call(sv, what)); MODULE = XS::APItest PACKAGE = XS::APItest::XSUB diff --git a/ext/XS-APItest/t/overload.t b/ext/XS-APItest/t/overload.t index 1f7e52b8b1..1c391e9701 100644 --- a/ext/XS-APItest/t/overload.t +++ b/ext/XS-APItest/t/overload.t @@ -60,13 +60,13 @@ while (my ($type, $enum) = each %types) { foreach (@non_ref, @ref, ) { my ($desc, $input) = @$_; - my $got = tryAMAGICunDEREF_var($input, $enum); + my $got = amagic_deref_call($input, $enum); is($got, $input, "Expect no change for to_$type $desc"); } foreach (@non_ref) { my ($desc, $sucker) = @$_; my $input = bless [$sucker], 'Chain'; - is(eval {tryAMAGICunDEREF_var($input, $enum)}, undef, + is(eval {amagic_deref_call($input, $enum)}, undef, "Chain to $desc for to_$type"); like($@, qr/Overloaded dereference did not return a reference/, 'expected error'); @@ -75,10 +75,10 @@ while (my ($type, $enum) = each %types) { ) { my ($desc, $sucker) = @$_; my $input = bless [$sucker], 'Chain'; - my $got = tryAMAGICunDEREF_var($input, $enum); + my $got = amagic_deref_call($input, $enum); is($got, $sucker, "Chain to $desc for to_$type"); $input = bless [bless [$sucker], 'Chain'], 'Chain'; - my $got = tryAMAGICunDEREF_var($input, $enum); + my $got = amagic_deref_call($input, $enum); is($got, $sucker, "Chain to chain to $desc for to_$type"); } } |