From 4b902ef37bae392d5d4dc31e860ebd204ef12c43 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 29 Feb 2024 13:29:21 +0100 Subject: [PATCH 1/3] Revert "fix docs for new XS module dependency" This reverts commit 30e58b6ab24c4d4921f51cf5246ad779746e9cb2. --- lib/B/Hooks/EndOfScope.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/B/Hooks/EndOfScope.pm b/lib/B/Hooks/EndOfScope.pm index 040db12..1f817d8 100644 --- a/lib/B/Hooks/EndOfScope.pm +++ b/lib/B/Hooks/EndOfScope.pm @@ -51,10 +51,10 @@ This is exported by default. See L on how to customize it. =head2 Pure-perl mode caveat -This caveat applies to B version of perl where L +This caveat applies to B version of perl where L is unavailable or otherwise disabled. -While L has access to some very dark sorcery to make it +While L has access to some very dark sorcery to make it possible to throw an exception from within a callback, the pure-perl implementation does not have access to these hacks. Therefore, what would have been a B is instead B is disabled +In order to stabilize this workaround use of L is disabled on perls prior to version 5.8.4. On such systems loading/requesting L explicitly will result in a compile-time exception. @@ -101,6 +101,6 @@ file F included with the distribution. L -L +L =cut From 38c3ecb714386b05df37c422f25ec2e55dde8af1 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 29 Feb 2024 13:29:32 +0100 Subject: [PATCH 2/3] Revert "switch from Variable::Magic to Variable::OnDestruct" This reverts commit 8f9ae5759ec8419c398a963aaa43d9a45360dfbe. --- dist.ini | 2 +- lib/B/Hooks/EndOfScope/XS.pm | 27 ++++++++++++++++++++++----- t/10-test_without_vm_pure_pp.t | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/dist.ini b/dist.ini index 495bdec..5f1df8c 100644 --- a/dist.ini +++ b/dist.ini @@ -46,7 +46,7 @@ Devel::Hide = 0.0007 ; releasers *must* test both the XS and PP imple -body = |if ("$]" >= 5.008004 and want_xs()) { ; IMPORTANT!!! when changing prereqs here, also update in B::Hooks::EndOfScope::XS ; and t/10-test_without_vm_pure_pp.t --body = | requires('Variable::OnDestruct', '0.07'); +-body = | requires('Variable::Magic', '0.48'); -body = | -body = | # make sure we smoke the pure-perl version fallback ; IMPORTANT!!! when changing prereqs here, also update in t/10-test_without_vm_pure_pp.t diff --git a/lib/B/Hooks/EndOfScope/XS.pm b/lib/B/Hooks/EndOfScope/XS.pm index f3f1657..7f9756f 100644 --- a/lib/B/Hooks/EndOfScope/XS.pm +++ b/lib/B/Hooks/EndOfScope/XS.pm @@ -6,7 +6,7 @@ use warnings; our $VERSION = '0.28'; -# Limit the Variable::OnDestruct-based (XS) version to perl 5.8.4+ +# Limit the V::M-based (XS) version to perl 5.8.4+ # # Given the unorthodox stuff we do to work around the hinthash double-free # might as well play it safe and only implement it in the PP version @@ -15,16 +15,33 @@ our $VERSION = '0.28'; # use 5.008004; -use Variable::OnDestruct 0.07 (); +use Variable::Magic 0.48 (); use Sub::Exporter::Progressive 0.001006 -setup => { exports => ['on_scope_end'], groups => { default => ['on_scope_end'] }, }; +my $wiz = Variable::Magic::wizard + data => sub { [$_[1]] }, + free => sub { $_->() for @{ $_[1] }; () }, + # When someone localise %^H, our magic doesn't want to be copied + # down. We want it to be around only for the scope we've initially + # attached ourselves to. Merely having MGf_LOCAL and a noop svt_local + # callback achieves this. If anything wants to attach more magic of our + # kind to a localised %^H, things will continue to just work as we'll be + # attached with a new and empty callback list. + local => \undef +; + sub on_scope_end (&) { $^H |= 0x020000; - Variable::OnDestruct::on_destruct_fifo(%^H, \&{$_[0]}); + if (my $stack = Variable::Magic::getdata %^H, $wiz) { + push @{ $stack }, $_[0]; + } + else { + Variable::Magic::cast %^H, $wiz, $_[0]; + } } 1; @@ -35,8 +52,8 @@ __END__ =head1 DESCRIPTION This is the implementation of L based on -L, which is an XS module dependent on a compiler. It will -always be automatically preferred if L is available. +L, which is an XS module dependent on a compiler. It will +always be automatically preferred if L is available. =func on_scope_end diff --git a/t/10-test_without_vm_pure_pp.t b/t/10-test_without_vm_pure_pp.t index 39ccb31..8529f66 100644 --- a/t/10-test_without_vm_pure_pp.t +++ b/t/10-test_without_vm_pure_pp.t @@ -36,7 +36,7 @@ for my $fn (@files) { note "retesting $fn"; my @cmd = ( $^X, - $has_dh ? '-MDevel::Hide=Variable::OnDestruct' : (), + $has_dh ? '-MDevel::Hide=Variable::Magic' : (), $fn ); From 92c3359c9134942def1d955ac945dae4162e33d8 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 29 Feb 2024 13:32:12 +0100 Subject: [PATCH 3/3] fix develop and suggests prereqs to refer to Variable::Magic --- dist.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist.ini b/dist.ini index 5f1df8c..7d5c2dc 100644 --- a/dist.ini +++ b/dist.ini @@ -30,13 +30,13 @@ Scalar::Util = 0 ; authordep Dist::Zilla::Plugin::SurgicalPodWeaver [Prereqs / RuntimeSuggests] -Variable::OnDestruct = 0.07 ; for the XS implementation +Variable::Magic = 0.48 ; for the XS implementation [Prereqs / TestSuggests] Devel::Hide = 0.0007 ; for testing the PP implementation [Prereqs / DevelopRequires] -Variable::OnDestruct = 0.07 +Variable::Magic = 0.48 Devel::Hide = 0.0007 ; releasers *must* test both the XS and PP implementations ; authordep ExtUtils::HasCompiler = 0.014