]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
This is 0.58 v0.58
authorVincent Pit <vince@profvince.com>
Tue, 21 Jul 2015 16:00:13 +0000 (13:00 -0300)
committerVincent Pit <vince@profvince.com>
Tue, 21 Jul 2015 16:00:13 +0000 (13:00 -0300)
Changes
META.json
META.yml
README
lib/Variable/Magic.pm

diff --git a/Changes b/Changes
index 7591b34f7034259c99b7af9c2bbd063c2e625b2f..3108d12e61eb6b97bea868bf3cec634dd061a817 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,15 @@
 Revision history for Variable-Magic
 
 Revision history for Variable-Magic
 
+0.58    2015-07-21 16:00 UTC
+        + Add : If a non-len magic callback returns a reference, it will now
+                only be freed at the end of the statement that caused the
+                magic to trigger. This allows the user to attach free magic
+                (or a plain destructor) to a token returned from the callbacks
+                in order to defer an action after the magic is processed by
+                perl.
+        + Fix : Test failures of threads tests on systems with harsh resource
+                constraints causing the threads to exit() during run.
+
 0.57    2015-04-17 15:20 UTC
         + Chg : The new environment variable to enable thread tests on older
                 perls is PERL_FORCE_TEST_THREADS. Note that this variable
 0.57    2015-04-17 15:20 UTC
         + Chg : The new environment variable to enable thread tests on older
                 perls is PERL_FORCE_TEST_THREADS. Note that this variable
index 135f085c8e440482b9b00804d73efef677d24472..53760d6b0bec1fcbc2e9a228880bdd980479ad45 100644 (file)
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
       "Vincent Pit <perl@profvince.com>"
    ],
    "dynamic_config" : 1,
       "Vincent Pit <perl@profvince.com>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001",
+   "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005",
    "license" : [
       "perl_5"
    ],
    "license" : [
       "perl_5"
    ],
@@ -66,5 +66,6 @@
          "url" : "http://git.profvince.com/?p=perl%2Fmodules%2FVariable-Magic.git"
       }
    },
          "url" : "http://git.profvince.com/?p=perl%2Fmodules%2FVariable-Magic.git"
       }
    },
-   "version" : "0.57"
+   "version" : "0.58",
+   "x_serialization_backend" : "JSON::PP version 2.27300"
 }
 }
index 386a77d15155174d73d3370c03a5f6927bd94adc..14a21aaa5584e99a492c673c47f28d9c05593b61 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -20,7 +20,7 @@ configure_requires:
   Config: '0'
   ExtUtils::MakeMaker: '0'
 dynamic_config: 1
   Config: '0'
   ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001'
+generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -41,4 +41,5 @@ resources:
   homepage: http://search.cpan.org/dist/Variable-Magic/
   license: http://dev.perl.org/licenses/
   repository: http://git.profvince.com/?p=perl%2Fmodules%2FVariable-Magic.git
   homepage: http://search.cpan.org/dist/Variable-Magic/
   license: http://dev.perl.org/licenses/
   repository: http://git.profvince.com/?p=perl%2Fmodules%2FVariable-Magic.git
-version: '0.57'
+version: '0.58'
+x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
diff --git a/README b/README
index b10ea32ae8d3002cad4bf5842eddb182b843218d..fc1ea925bc0f79c1bf561dc4d852dccd171b8876 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@ NAME
     Variable::Magic - Associate user-defined magic to variables from Perl.
 
 VERSION
     Variable::Magic - Associate user-defined magic to variables from Perl.
 
 VERSION
-    Version 0.57
+    Version 0.58
 
 SYNOPSIS
         use Variable::Magic qw<wizard cast VMG_OP_INFO_NAME>;
 
 SYNOPSIS
         use Variable::Magic qw<wizard cast VMG_OP_INFO_NAME>;
@@ -265,10 +265,17 @@ FUNCTIONS
         Both result in a small performance hit, but just getting the name is
         lighter than getting the op object.
 
         Both result in a small performance hit, but just getting the name is
         lighter than getting the op object.
 
-        These callbacks are executed in scalar context and are expected to
-        return an integer, which is then passed straight to the perl magic
-        API. However, only the return value of the *len* magic callback
-        currently holds a meaning.
+        These callbacks are always executed in scalar context. The returned
+        value is coerced into a signed integer, which is then passed
+        straight to the perl magic API. However, note that perl currently
+        only cares about the return value of the *len* magic callback and
+        ignores all the others. Starting with Variable::Magic 0.58, a
+        reference returned from a non-*len* magic callback will not be
+        destroyed immediately but will be allowed to survive until the end
+        of the statement that triggered the magic. This lets you use this
+        return value as a token for triggering a destructor after the
+        original magic action takes place. You can see an example of this
+        technique in the cookbook.
 
     Each callback can be specified as :
 
 
     Each callback can be specified as :
 
@@ -501,6 +508,45 @@ COOKBOOK
     Of course, this example does nothing with the values that are added
     after the "cast".
 
     Of course, this example does nothing with the values that are added
     after the "cast".
 
+  Delayed magic actions
+    Starting with Variable::Magic 0.58, the return value of the magic
+    callbacks can be used to delay the action until after the original
+    action takes place :
+
+        my $delayed;
+        my $delayed_aux = wizard(
+         data => sub { $_[1] },
+         free => sub {
+          my ($target) = $_[1];
+          my $target_data = &getdata($target, $delayed);
+          local $target_data->{guard} = 1;
+          if (ref $target eq 'SCALAR') {
+           my $orig = $$target;
+           $$target = $target_data->{mangler}->($orig);
+          }
+          return;
+         },
+        );
+        $delayed = wizard(
+         data => sub {
+          return +{ guard => 0, mangler => $_[1] };
+         },
+         set  => sub {
+          return if $_[1]->{guard};
+          my $token;
+          cast $token, $delayed_aux, $_[0];
+          return \$token;
+         },
+        );
+        my $x = 1;
+        cast $x, $delayed => sub { $_[0] * 2 };
+        $x = 2;
+        # $x is now 4
+        # But note that the delayed action only takes place at the end of the
+        # current statement :
+        my @y = ($x = 5, $x);
+        # $x is now 10, but @y is (5, 5)
+
 PERL MAGIC HISTORY
     The places where magic is invoked have changed a bit through perl
     history. Here is a little list of the most recent ones.
 PERL MAGIC HISTORY
     The places where magic is invoked have changed a bit through perl
     history. Here is a little list of the most recent ones.
index 7c866494233c59ffdd7729ad8f6a124d396282ef..2de79bcd8ad5119873e402dd2f9dd95b189151ca 100644 (file)
@@ -11,13 +11,13 @@ Variable::Magic - Associate user-defined magic to variables from Perl.
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-Version 0.57
+Version 0.58
 
 =cut
 
 our $VERSION;
 BEGIN {
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.57';
+ $VERSION = '0.58';
 }
 
 =head1 SYNOPSIS
 }
 
 =head1 SYNOPSIS