]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
This is 0.30 v0.30
authorVincent Pit <vince@profvince.com>
Thu, 12 Feb 2009 17:04:12 +0000 (18:04 +0100)
committerVincent Pit <vince@profvince.com>
Thu, 12 Feb 2009 17:04:12 +0000 (18:04 +0100)
Changes
META.yml
README
lib/Variable/Magic.pm

diff --git a/Changes b/Changes
index c7f706779f9be67b8b64d85b791ba414a25641a2..1e1e019a6628feb3734a417264b04428470b7808 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,16 @@
 Revision history for Variable-Magic
 
+0.30    2009-02-12 17:05 UTC
+        + Add : You can now get in all the callbacks either the name or a B::OP
+                object representing the current op if you pass the new 'op_info'
+                option to wizard() with respective values VMG_OP_INFO_NAME and
+                VMG_OP_INFO_OBJECT.
+        + Doc : Document magic on array/hashes values.
+        + Fix : Completely skip free callbacks during global destruction.
+        + Tst : Tests now pass again on 5.8.3 and lower (they were broken since
+                0.27).
+        + Tst : Test magic on symbol table and on array/hash values.
+
 0.29    2009-02-08 11:10 UTC
         + Add : Set $_[2] to the default length for len magic on scalars.
         + Chg : Perl 5.8 is required.
index 59644352d17ce58e4c350e3e8cde121ee5a55dc9..1008465f787b5e140bd916ab2b6d2e0f6e304fa5 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Variable-Magic
-version:            0.29
+version:            0.30
 abstract:           Associate user-defined magic to variables from Perl.
 author:
     - Vincent Pit <perl@profvince.com>
@@ -10,6 +10,7 @@ configure_requires:
     Config:               0
     ExtUtils::MakeMaker:  0
 build_requires:
+    Carp:                 0
     Config:               0
     ExtUtils::MakeMaker:  0
     Test::More:           0
diff --git a/README b/README
index 476e5a3eeb6fbad81e150537655f74ae892a277e..4b7401275cd6dc507c5b39bcf0b3f4493ba3b805 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@ NAME
     Variable::Magic - Associate user-defined magic to variables from Perl.
 
 VERSION
-    Version 0.29
+    Version 0.30
 
 SYNOPSIS
         use Variable::Magic qw/wizard cast dispell/;
@@ -204,22 +204,31 @@ CONSTANTS
     True iff this module could have been built with thread-safety features
     enabled.
 
+  "VMG_OP_INFO_NAME"
+    Value to pass with "op_info" to get the current op name in the magic
+    callbacks.
+
+  "VMG_OP_INFO_OBJECT"
+    Value to pass with "op_info" to get a "B::OP" object representing the
+    current op in the magic callbacks.
+
 FUNCTIONS
   "wizard"
         wizard sig      => ...,
                data     => sub { ... },
-               get      => sub { my ($ref, $data) = @_; ... },
-               set      => sub { my ($ref, $data) = @_; ... },
-               len      => sub { my ($ref, $data, $len) = @_; ... ; return $newlen; },
-               clear    => sub { my ($ref, $data) = @_; ... },
-               free     => sub { my ($ref, $data) = @_, ... },
-               copy     => sub { my ($ref, $data, $key, $elt) = @_; ... },
-               local    => sub { my ($ref, $data) = @_; ... },
-               fetch    => sub { my ($ref, $data, $key) = @_; ... },
-               store    => sub { my ($ref, $data, $key) = @_; ... },
-               exists   => sub { my ($ref, $data, $key) = @_; ... },
-               delete   => sub { my ($ref, $data, $key) = @_; ... },
-               copy_key => $bool
+               get      => sub { my ($ref, $data [, $op]) = @_; ... },
+               set      => sub { my ($ref, $data [, $op]) = @_; ... },
+               len      => sub { my ($ref, $data, $len [, $op]) = @_; ... ; return $newlen; },
+               clear    => sub { my ($ref, $data [, $op]) = @_; ... },
+               free     => sub { my ($ref, $data [, $op]) = @_, ... },
+               copy     => sub { my ($ref, $data, $key, $elt [, $op]) = @_; ... },
+               local    => sub { my ($ref, $data [, $op]) = @_; ... },
+               fetch    => sub { my ($ref, $data, $key [, $op]) = @_; ... },
+               store    => sub { my ($ref, $data, $key [, $op]) = @_; ... },
+               exists   => sub { my ($ref, $data, $key [, $op]) = @_; ... },
+               delete   => sub { my ($ref, $data, $key [, $op]) = @_; ... },
+               copy_key => $bool,
+               op_info  => [ 0 | VMG_OP_INFO_NAME | VMG_OP_INFO_OBJECT ]
 
     This function creates a 'wizard', an opaque type that holds the magic
     information. It takes a list of keys / values as argument, whose keys
@@ -246,8 +255,15 @@ FUNCTIONS
         to specify all of them : the magic associated with undefined entries
         simply won't be hooked. In those callbacks, $_[0] is always a
         reference to the magic object and $_[1] is always the private data
-        (or "undef" when no private data constructor was supplied). Other
-        arguments are specific to the magic hooked :
+        (or "undef" when no private data constructor was supplied).
+
+        Moreover, when you pass "op_info => $num" to "wizard", the last
+        element of @_ will be the current op name if "$num ==
+        VMG_OP_INFO_NAME" and a "B::OP" object representing the current op
+        if "$num == VMG_OP_INFO_OBJECT". Both have a performance hit, but
+        just getting the name is lighter than getting the op object.
+
+        Other arguments are specific to the magic hooked :
 
         *       "len"
 
@@ -315,6 +331,18 @@ FUNCTIONS
         my $x;
         die 'error' unless cast $x, $wiz;
 
+    The "var" argument can be an array or hash value. Magic for those
+    behaves like for any other scalar, except that it is dispelled when the
+    entry is deleted from the container. For example, if you want to call
+    "POSIX::tzset" each time the 'TZ' environment variable is changed in
+    %ENV, you can use :
+
+        use POSIX;
+        cast $ENV{TZ}, wizard set => sub { POSIX::tzset(); () };
+
+    If you want to overcome the possible deletion of the 'TZ' entry, you
+    have no choice but to rely on "store" uvar magic.
+
   "getdata"
         getdata [$@%&*]var, [$wiz|$sig]
 
index e09ef044d5bd767c239fdc74f5f50ab5bca4829b..eca6f03446ca6599c4e1291d9e4a30e023ffca19 100644 (file)
@@ -13,13 +13,13 @@ Variable::Magic - Associate user-defined magic to variables from Perl.
 
 =head1 VERSION
 
-Version 0.29
+Version 0.30
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.29';
+ $VERSION = '0.30';
 }
 
 =head1 SYNOPSIS