X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FVariable%2FMagic.pm;h=dd41d05ac7c21de32a6b6377d153d6625d145489;hb=c2de7be01154d2df9ede0dff3ae1136422d462fc;hp=0ac5b52187598e9c47616498dc8b6e84c32af5a9;hpb=751094f5d7b43171afc7104e957ca7fe2d21eb34;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index 0ac5b52..dd41d05 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -13,13 +13,13 @@ Variable::Magic - Associate user-defined magic to variables from Perl. =head1 VERSION -Version 0.09 +Version 0.12 =cut our $VERSION; BEGIN { - $VERSION = '0.09'; + $VERSION = '0.12'; } =head1 SYNOPSIS @@ -117,7 +117,7 @@ The places where magic is invoked have changed a bit through perl history. Here' =over 4 -=item 'len' magic is no longer called when pushing an element into a magic array. +=item I : 'len' magic is no longer called when pushing an element into a magic array. =item I : 'local' magic. @@ -133,6 +133,14 @@ The places where magic is invoked have changed a bit through perl history. Here' =back +=head2 B<5.10.0> + +=over 4 + +=item Since C is uppercased, C triggers 'copy' magic on hash stores for (non-tied) hashes that also have 'uvar' magic. + +=back + =head1 CONSTANTS =head2 C @@ -163,6 +171,14 @@ Evaluates to true iff the 'local' magic is available. When this constant is true, you can use the C callbacks on hashes. +=head2 C + +True for perls that don't call 'len' magic when you push an element in a magical array. + +=head2 C + +True for perls that call 'clear' magic when undefining magical arrays. + =head1 FUNCTIONS =cut @@ -181,7 +197,7 @@ BEGIN { len => sub { my ($ref, $data, $len) = @_; ... ; return $newlen; }, clear => sub { my ($ref, $data) = @_; ... }, free => sub { my ($ref, $data) = @_, ... }, - copy => sub { my ($ref, $data, $elt) = @_; ... }, + copy => sub { my ($ref, $data, $key, $elt) = @_; ... }, local => sub { my ($ref, $data) = @_; ... }, fetch => sub { my ($ref, $data, $key) = @_; ... }, store => sub { my ($ref, $data, $key) = @_; ... }, @@ -202,7 +218,7 @@ A code reference to a private data constructor. It is called each time this magi =item C, C, C, C, C, C, C, C, C, C and C -Code references to corresponding magic callbacks. You don't have to specify all of them : the magic associated with undefined entries simply won't be hooked. In those callbacks, C<$_[0]> is always a reference to the magic object and C<$_[1]> is always the private data (or C when no private data constructor was supplied). In the special case of C magic and when the variable is an array, C<$_[2]> contains its normal length. C magic receives the current element (i.e. the value) in C<$_[2]>. C<$_[2]> is also the current key in C, C, C and C callbacks. +Code references to corresponding magic callbacks. You don't have to specify all of them : the magic associated with undefined entries simply won't be hooked. In those callbacks, C<$_[0]> is always a reference to the magic object and C<$_[1]> is always the private data (or C when no private data constructor was supplied). In the special case of C magic and when the variable is an array, C<$_[2]> contains its normal length. C<$_[2]> is the current key in C, C, C, C and C callbacks, although for C it may just be a copy of the actual key so it's useless to (for example) cast magic on it. C magic also receives the current element (i.e. the value) in C<$_[3]>. =back @@ -281,7 +297,8 @@ use base qw/Exporter/; our @EXPORT = (); our %EXPORT_TAGS = ( 'funcs' => [ qw/wizard gensig getsig cast getdata dispell/ ], - 'consts' => [ qw/SIG_MIN SIG_MAX SIG_NBR MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR/ ] + 'consts' => [ qw/SIG_MIN SIG_MAX SIG_NBR MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR/, + qw/VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNDEF_CLEAR/ ] ); our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];