r45378 - in /trunk/libvariable-magic-perl: Changes META.yml Magic.xs Makefile.PL README debian/changelog debian/control debian/copyright lib/Variable/Magic.pm t/01-import.t t/31-array.t t/99-kwalitee.t
angelabad-guest at users.alioth.debian.org
angelabad-guest at users.alioth.debian.org
Mon Oct 5 11:50:50 UTC 2009
Author: angelabad-guest
Date: Mon Oct 5 11:50:45 2009
New Revision: 45378
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45378
Log:
New upstream 0.38
Modified:
trunk/libvariable-magic-perl/Changes
trunk/libvariable-magic-perl/META.yml
trunk/libvariable-magic-perl/Magic.xs
trunk/libvariable-magic-perl/Makefile.PL
trunk/libvariable-magic-perl/README
trunk/libvariable-magic-perl/debian/changelog
trunk/libvariable-magic-perl/debian/control
trunk/libvariable-magic-perl/debian/copyright
trunk/libvariable-magic-perl/lib/Variable/Magic.pm
trunk/libvariable-magic-perl/t/01-import.t
trunk/libvariable-magic-perl/t/31-array.t
trunk/libvariable-magic-perl/t/99-kwalitee.t
Modified: trunk/libvariable-magic-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/Changes?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/Changes (original)
+++ trunk/libvariable-magic-perl/Changes Mon Oct 5 11:50:45 2009
@@ -1,4 +1,19 @@
Revision history for Variable-Magic
+
+0.38 2009-10-04 16:10 UTC
+ + Dep : All the signature-related features are DEPRECATED and will be
+ removed in december 2009. This includes the 'sig' option to
+ wizard(), the getsig() and gensig() functions, and the SIG_*
+ constants.
+ Afaik those features were never used in real life, and they make
+ the XS code slow and brittle. If you want your wizards to be
+ globally available, you'll have to handle that yourself by
+ storing them in a hash.
+ + Doc : More examples in a new COOKBOOK section.
+ + Fix : Compatiblity with the 5.11.0 release. The new compatibility
+ constant VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID was added to cover
+ this.
+ + Fix : Work around Kwalitee test misfailures.
0.37 2009-08-25 15:25 UTC
+ Add : The new constant VMG_FORKSAFE can be tested to know whether the
Modified: trunk/libvariable-magic-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/META.yml?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/META.yml (original)
+++ trunk/libvariable-magic-perl/META.yml Mon Oct 5 11:50:45 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Variable-Magic
-version: 0.37
+version: 0.38
abstract: Associate user-defined magic to variables from Perl.
author:
- Vincent Pit <perl at profvince.com>
@@ -10,10 +10,13 @@
Config: 0
ExtUtils::MakeMaker: 0
build_requires:
+ base: 0
Carp: 0
Config: 0
+ Exporter: 0
ExtUtils::MakeMaker: 0
Test::More: 0
+ XSLoader: 0
requires:
base: 0
Carp: 0
@@ -29,7 +32,8 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.54
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
+dynamic_config: 1
Modified: trunk/libvariable-magic-perl/Magic.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/Magic.xs?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/Magic.xs (original)
+++ trunk/libvariable-magic-perl/Magic.xs Mon Oct 5 11:50:45 2009
@@ -148,12 +148,21 @@
# define VMG_UVAR 0
#endif
-/* Applied to dev-5.9 as 25854, integrated to maint-5.8 as 28160 */
-#ifndef VMG_COMPAT_ARRAY_PUSH_NOLEN
-# if VMG_HAS_PERL_MAINT(5, 8, 9, 28160) || VMG_HAS_PERL_MAINT(5, 9, 3, 25854) || VMG_HAS_PERL(5, 10, 0)
+/* Applied to dev-5.9 as 25854, integrated to maint-5.8 as 28160, partially
+ * reverted to dev-5.11 as 9cdcb38b */
+#if VMG_HAS_PERL_MAINT(5, 8, 9, 28160) || VMG_HAS_PERL_MAINT(5, 9, 3, 25854) || VMG_HAS_PERL(5, 10, 0)
+# ifndef VMG_COMPAT_ARRAY_PUSH_NOLEN
# define VMG_COMPAT_ARRAY_PUSH_NOLEN 1
-# else
+# endif
+# ifndef VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID
+# define VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID 1
+# endif
+#else
+# ifndef VMG_COMPAT_ARRAY_PUSH_NOLEN
# define VMG_COMPAT_ARRAY_PUSH_NOLEN 0
+# endif
+# ifndef VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID
+# define VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID 0
# endif
#endif
@@ -1260,6 +1269,8 @@
newCONSTSUB(stash, "VMG_UVAR", newSVuv(VMG_UVAR));
newCONSTSUB(stash, "VMG_COMPAT_ARRAY_PUSH_NOLEN",
newSVuv(VMG_COMPAT_ARRAY_PUSH_NOLEN));
+ newCONSTSUB(stash, "VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID",
+ newSVuv(VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID));
newCONSTSUB(stash, "VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID",
newSVuv(VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID));
newCONSTSUB(stash, "VMG_COMPAT_ARRAY_UNDEF_CLEAR",
Modified: trunk/libvariable-magic-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/Makefile.PL?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/Makefile.PL (original)
+++ trunk/libvariable-magic-perl/Makefile.PL Mon Oct 5 11:50:45 2009
@@ -19,6 +19,7 @@
push @DEFINES, '-DVMG_PERL_PATCHLEVEL=' . $pl;
print $pl, "\n";
} else {
+ $pl = undef;
print "none\n";
}
@@ -40,6 +41,17 @@
}
print $is_as ? "yes\n" : "no\n";
+my $is_5110rel = 0;
+print "Checking if this is a released perl 5.11.0... ";
+if ($^V eq v5.11.0 and not defined $pl) {
+ my $describe = $Config{git_describe};
+ if (defined $describe and $describe !~ /^GitLive-/) {
+ $is_5110rel = 1;
+ push @DEFINES, '-DVMG_COMPAT_ARRAY_PUSH_NOLEN=0';
+ }
+}
+print $is_5110rel ? "yes\n" : "no\n";
+
# Threads, Windows and 5.8.x don't seem to be best friends
if ($^O eq 'MSWin32' && $^V lt v5.9.0) {
push @DEFINES, '-DVMG_MULTIPLICITY=0';
@@ -54,6 +66,18 @@
my $dist = 'Variable-Magic';
+(my $name = $dist) =~ s{-}{::}g;
+
+(my $file = $dist) =~ s{-}{/}g;
+$file = "lib/$file.pm";
+
+my %PREREQ_PM = (
+ 'Carp' => 0,
+ 'Exporter' => 0,
+ 'XSLoader' => 0,
+ 'base' => 0,
+);
+
my %META = (
configure_requires => {
'Config' => 0,
@@ -64,7 +88,9 @@
'Config' => 0,
'ExtUtils::MakeMaker' => 0,
'Test::More' => 0,
+ %PREREQ_PM,
},
+ dynamic_config => 1,
resources => {
bugtracker => "http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$dist",
homepage => "http://search.cpan.org/dist/$dist/",
@@ -74,26 +100,21 @@
);
WriteMakefile(
- NAME => 'Variable::Magic',
- AUTHOR => 'Vincent Pit <perl at profvince.com>',
- LICENSE => 'perl',
- VERSION_FROM => 'lib/Variable/Magic.pm',
- ABSTRACT_FROM => 'lib/Variable/Magic.pm',
- PL_FILES => {},
- @DEFINES,
- PREREQ_PM => {
- 'Carp' => 0,
- 'Exporter' => 0,
- 'XSLoader' => 0,
- 'base' => 0,
- },
- MIN_PERL_VERSION => 5.008,
- META_MERGE => \%META,
- dist => {
- PREOP => 'pod2text lib/Variable/Magic.pm > $(DISTVNAME)/README',
- COMPRESS => 'gzip -9f', SUFFIX => 'gz'
- },
- clean => {
- FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
- },
+ NAME => $name,
+ AUTHOR => 'Vincent Pit <perl at profvince.com>',
+ LICENSE => 'perl',
+ VERSION_FROM => $file,
+ ABSTRACT_FROM => $file,
+ PL_FILES => {},
+ @DEFINES,
+ PREREQ_PM => \%PREREQ_PM,
+ MIN_PERL_VERSION => 5.008,
+ META_MERGE => \%META,
+ dist => {
+ PREOP => "pod2text $file > \$(DISTVNAME)/README",
+ COMPRESS => 'gzip -9f', SUFFIX => 'gz'
+ },
+ clean => {
+ FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt"
+ },
);
Modified: trunk/libvariable-magic-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/README?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/README (original)
+++ trunk/libvariable-magic-perl/README Mon Oct 5 11:50:45 2009
@@ -2,7 +2,7 @@
Variable::Magic - Associate user-defined magic to variables from Perl.
VERSION
- Version 0.37
+ Version 0.38
SYNOPSIS
use Variable::Magic qw/wizard cast VMG_OP_INFO_NAME/;
@@ -159,8 +159,7 @@
FUNCTIONS
"wizard"
- wizard sig => ...,
- data => sub { ... },
+ wizard data => sub { ... },
get => sub { my ($ref, $data [, $op]) = @_; ... },
set => sub { my ($ref, $data [, $op]) = @_; ... },
len => sub { my ($ref, $data, $len [, $op]) = @_; ... ; return $newlen; },
@@ -185,6 +184,8 @@
signature is generated. If the signature matches an already defined
magic, then the existant magic object is returned.
+ This option is deprecated and will be removed in december 2009.
+
* "data"
A code reference to a private data constructor. It is called each
@@ -256,6 +257,8 @@
# Generate a signature
my $sig = gensig;
+ This function is deprecated and will be removed in december 2009.
+
"getsig"
getsig $wiz
@@ -264,17 +267,17 @@
# Get $wiz signature
my $sig = getsig $wiz;
+ This function is deprecated and will be removed in december 2009.
+
"cast"
- cast [$@%&*]var, [$wiz|$sig], ...
+ cast [$@%&*]var, $wiz, ...
This function associates $wiz magic to the variable supplied, without
- overwriting any other kind of magic. You can also supply the numeric
- signature $sig instead of $wiz. It returns true on success or when $wiz
- magic is already present, and croaks on error or when no magic
- corresponds to the given signature (in case a $sig was supplied). All
- extra arguments specified after $wiz are passed to the private data
- constructor in @_[1 .. @_-1]. If the variable isn't a hash, any "uvar"
- callback of the wizard is safely ignored.
+ overwriting any other kind of magic. It returns true on success or when
+ $wiz magic is already present, and croaks on error. All extra arguments
+ specified after $wiz are passed to the private data constructor in @_[1
+ .. @_-1]. If the variable isn't a hash, any "uvar" callback of the
+ wizard is safely ignored.
# Casts $wiz onto $x, and pass '1' to the data constructor.
my $x;
@@ -292,28 +295,153 @@
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
+
+ This accessor fetches the private data associated with the magic $wiz in
+ the variable. It croaks when $wiz do not represent a valid magic object,
+ and returns an empty list if no such magic is attached to the variable
+ or when the wizard has no data constructor.
+
+ # Get the attached data, or undef if the wizard does not attach any.
+ my $data = getdata $x, $wiz;
+
+ "dispell"
+ dispell [$@%&*]variable, $wiz
+
+ The exact opposite of "cast" : it dissociates $wiz magic from the
+ variable. This function returns true on success, 0 when no magic
+ represented by $wiz could be found in the variable, and croaks if the
+ supplied wizard is invalid.
+
+ # Dispell now.
+ die 'no such magic in $x' unless dispell $x, $wiz;
+
+CONSTANTS
+ "SIG_MIN"
+ The minimum integer used as a signature for user-defined magic.
+
+ This constant is deprecated and will be removed in december 2009.
+
+ "SIG_MAX"
+ The maximum integer used as a signature for user-defined magic.
+
+ This constant is deprecated and will be removed in december 2009.
+
+ "SIG_NBR"
+ SIG_NBR = SIG_MAX - SIG_MIN + 1
+
+ This constant is deprecated and will be removed in december 2009.
+
+ "MGf_COPY"
+ Evaluates to true iff the 'copy' magic is available.
+
+ "MGf_DUP"
+ Evaluates to true iff the 'dup' magic is available.
+
+ "MGf_LOCAL"
+ Evaluates to true iff the 'local' magic is available.
+
+ "VMG_UVAR"
+ When this constant is true, you can use the "fetch,store,exists,delete"
+ callbacks on hashes.
+
+ "VMG_COMPAT_ARRAY_PUSH_NOLEN"
+ True for perls that don't call 'len' magic when you push an element in a
+ magical array. Starting from perl 5.11.0, this only refers to pushes in
+ non-void context and hence is false.
+
+ "VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID"
+ True for perls that don't call 'len' magic when you push in void context
+ an element in a magical array.
+
+ "VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID"
+ True for perls that don't call 'len' magic when you unshift in void
+ context an element in a magical array.
+
+ "VMG_COMPAT_ARRAY_UNDEF_CLEAR"
+ True for perls that call 'clear' magic when undefining magical arrays.
+
+ "VMG_COMPAT_SCALAR_LENGTH_NOLEN"
+ True for perls that don't call 'len' magic when taking the "length" of a
+ magical scalar.
+
+ "VMG_PERL_PATCHLEVEL"
+ The perl patchlevel this module was built with, or 0 for non-debugging
+ perls.
+
+ "VMG_THREADSAFE"
+ True iff this module could have been built with thread-safety features
+ enabled.
+
+ "VMG_FORKSAFE"
+ True iff this module could have been built with fork-safety features
+ enabled. This will always be true except on Windows where it's false for
+ perl 5.10.0 and below .
+
+ "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.
+
+COOKBOOK
+ Associate an object to any perl variable
+ This can be useful for passing user data through limited APIs.
+
+ {
+ package Magical::UserData;
+
+ use Variable::Magic qw/wizard cast getdata/;
+
+ my $wiz = wizard data => sub { \$_[1] };
+
+ sub ud (\[$@%*&]) : lvalue {
+ my ($var) = @_;
+ my $data = &getdata($var, $wiz);
+ unless (defined $data) {
+ &cast($var, $wiz);
+ $data = &getdata($var, $wiz);
+ die "Couldn't cast UserData magic onto the variable" unless defined $data;
+ }
+ $$data;
+ }
+ }
+
+ {
+ BEGIN { *ud = \&Magical::UserData::ud }
+
+ my $cb;
+ $cb = sub { print 'Hello, ', ud(&$cb), "!\n" };
+
+ ud(&$cb) = 'world';
+ $cb->(); # Hello, world!
+ }
+
+ Recursively cast magic on datastructures
"cast" can be called from any magical callback, and in particular from
"data". This allows you to recursively cast magic on datastructures :
my $wiz;
- $wiz = wizard
- data => sub {
- my ($var, $depth) = @_;
- $depth ||= 0;
- my $r = ref $var;
- if ($r eq 'ARRAY') {
- &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for @$var;
- } elsif ($r eq 'HASH') {
- &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for values %$var;
- }
- return $depth;
- },
- free => sub {
- my ($var, $depth) = @_;
- my $r = ref $var;
- print "free $r at depth $depth\n";
- ();
- };
+ $wiz = wizard data => sub {
+ my ($var, $depth) = @_;
+ $depth ||= 0;
+ my $r = ref $var;
+ if ($r eq 'ARRAY') {
+ &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for @$var;
+ } elsif ($r eq 'HASH') {
+ &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for values %$var;
+ }
+ return $depth;
+ },
+ free => sub {
+ my ($var, $depth) = @_;
+ my $r = ref $var;
+ print "free $r at depth $depth\n";
+ ();
+ };
{
my %h = (
@@ -336,89 +464,6 @@
Of course, this example does nothing with the values that are added
after the "cast".
- "getdata"
- getdata [$@%&*]var, [$wiz|$sig]
-
- This accessor fetches the private data associated with the magic $wiz
- (or the signature $sig) in the variable. It croaks when $wiz or $sig do
- not represent a valid magic object, and returns an empty list if no such
- magic is attached to the variable or when the wizard has no data
- constructor.
-
- # Get the attached data, or undef if the wizard does not attach any.
- my $data = getdata $x, $wiz;
-
- "dispell"
- dispell [$@%&*]variable, [$wiz|$sig]
-
- The exact opposite of "cast" : it dissociates $wiz magic from the
- variable. You can also pass the magic signature $sig as the second
- argument. This function returns true on success, 0 when no magic
- represented by $wiz or $sig could be found in the variable, and croaks
- if the supplied wizard or signature is invalid.
-
- # Dispell now.
- die 'no such magic in $x' unless dispell $x, $wiz;
-
-CONSTANTS
- "SIG_MIN"
- The minimum integer used as a signature for user-defined magic.
-
- "SIG_MAX"
- The maximum integer used as a signature for user-defined magic.
-
- "SIG_NBR"
- SIG_NBR = SIG_MAX - SIG_MIN + 1
-
- "MGf_COPY"
- Evaluates to true iff the 'copy' magic is available.
-
- "MGf_DUP"
- Evaluates to true iff the 'dup' magic is available.
-
- "MGf_LOCAL"
- Evaluates to true iff the 'local' magic is available.
-
- "VMG_UVAR"
- When this constant is true, you can use the "fetch,store,exists,delete"
- callbacks on hashes.
-
- "VMG_COMPAT_ARRAY_PUSH_NOLEN"
- True for perls that don't call 'len' magic when you push an element in a
- magical array.
-
- "VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID"
- True for perls that don't call 'len' magic when you unshift in void
- context an element in a magical array.
-
- "VMG_COMPAT_ARRAY_UNDEF_CLEAR"
- True for perls that call 'clear' magic when undefining magical arrays.
-
- "VMG_COMPAT_SCALAR_LENGTH_NOLEN"
- True for perls that don't call 'len' magic when taking the "length" of a
- magical scalar.
-
- "VMG_PERL_PATCHLEVEL"
- The perl patchlevel this module was built with, or 0 for non-debugging
- perls.
-
- "VMG_THREADSAFE"
- True iff this module could have been built with thread-safety features
- enabled.
-
- "VMG_FORKSAFE"
- True iff this module could have been built with fork-safety features
- enabled. This will always be true except on Windows where it's false for
- perl 5.10.0 and below .
-
- "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.
-
PERL MAGIC HISTORY
The places where magic is invoked have changed a bit through perl
history. Here's a little list of the most recent ones.
@@ -461,6 +506,9 @@
*p34908* : 'len' magic is no longer called when pushing / unshifting
an element into a magical array in void context. The "push" part was
already covered by *p25854*.
+
+ *g9cdcb38b* : 'len' magic is called again when pushing into a
+ magical array in non-void context.
EXPORT
The functions "wizard", "gensig", "getsig", "cast", "getdata" and
Modified: trunk/libvariable-magic-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/debian/changelog?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/debian/changelog (original)
+++ trunk/libvariable-magic-perl/debian/changelog Mon Oct 5 11:50:45 2009
@@ -1,8 +1,13 @@
-libvariable-magic-perl (0.37-2) UNRELEASED; urgency=low
+libvariable-magic-perl (0.38-1) unstable; urgency=low
+ [ Ryan Niebur ]
* Update jawnsy's email address
- -- Ryan Niebur <ryanryan52 at gmail.com> Tue, 01 Sep 2009 21:19:59 -0700
+ [ Angel Abad (Ikusnet SLL) ]
+ * New upstream release
+ * Add myself to Uploaders
+
+ -- Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com> Mon, 05 Oct 2009 13:47:00 +0200
libvariable-magic-perl (0.37-1) unstable; urgency=low
Modified: trunk/libvariable-magic-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/debian/control?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/debian/control (original)
+++ trunk/libvariable-magic-perl/debian/control Mon Oct 5 11:50:45 2009
@@ -1,12 +1,13 @@
Source: libvariable-magic-perl
Section: perl
Priority: optional
-Build-Depends: debhelper (>= 7), perl, libtest-pod-perl,
- libtest-pod-coverage-perl, libtest-portability-files-perl
+Build-Depends: debhelper (>= 7), libtest-pod-coverage-perl, libtest-pod-perl,
+ libtest-portability-files-perl, perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Antonio Radici <antonio at dyne.org>,
Ansgar Burchardt <ansgar at 43-1.org>, Nathan Handler <nhandler at ubuntu.com>,
- Jonathan Yu <jawnsy at cpan.org>
+ Jonathan Yu <jawnsy at cpan.org>,
+ Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>
Standards-Version: 3.8.3
Homepage: http://search.cpan.org/dist/Variable-Magic/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libvariable-magic-perl/
@@ -14,7 +15,7 @@
Package: libvariable-magic-perl
Architecture: any
-Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, perl (>= 5.8)
+Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, perl (>= 5.8.8)
Description: module to associate user-defined magic to variables from Perl
Variable::Magic is Perl way of enhancing objects. This mechanism lets the user
add extra data to any variable and hook syntaxical operations (such as access,
Modified: trunk/libvariable-magic-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/debian/copyright?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/debian/copyright (original)
+++ trunk/libvariable-magic-perl/debian/copyright Mon Oct 5 11:50:45 2009
@@ -10,10 +10,12 @@
License: Artistic | GPL-1+
Files: debian/*
-Copyright: 2009, Jonathan Yu <jawnsy at cpan.org>
- 2009, Nathan Handler <nhandler at ubuntu.com>
+Copyright: 2009, Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>
2009, Ansgar Burchardt <ansgar at 43-1.org>
2009, Antonio Radici <antonio at dyne.org>
+ 2009, Jonathan Yu <frequency at cpan.org>
+ 2009, Nathan Handler <nhandler at ubuntu.com>
+ 2009, Ryan Niebur <ryanryan52 at gmail.com>
License: Artistic | GPL-1+
License: Artistic
Modified: trunk/libvariable-magic-perl/lib/Variable/Magic.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/lib/Variable/Magic.pm?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/lib/Variable/Magic.pm (original)
+++ trunk/libvariable-magic-perl/lib/Variable/Magic.pm Mon Oct 5 11:50:45 2009
@@ -13,13 +13,13 @@
=head1 VERSION
-Version 0.37
+Version 0.38
=cut
our $VERSION;
BEGIN {
- $VERSION = '0.37';
+ $VERSION = '0.38';
}
=head1 SYNOPSIS
@@ -208,8 +208,7 @@
=head2 C<wizard>
- wizard sig => ...,
- data => sub { ... },
+ wizard data => sub { ... },
get => sub { my ($ref, $data [, $op]) = @_; ... },
set => sub { my ($ref, $data [, $op]) = @_; ... },
len => sub { my ($ref, $data, $len [, $op]) = @_; ... ; return $newlen; },
@@ -236,6 +235,8 @@
The numerical signature.
If not specified or undefined, a random signature is generated.
If the signature matches an already defined magic, then the existant magic object is returned.
+
+This option is B<deprecated> and will be removed in december 2009.
=item *
@@ -324,6 +325,8 @@
# Generate a signature
my $sig = gensig;
+This function is B<deprecated> and will be removed in december 2009.
+
=head2 C<getsig>
getsig $wiz
@@ -333,13 +336,14 @@
# Get $wiz signature
my $sig = getsig $wiz;
+This function is B<deprecated> and will be removed in december 2009.
+
=head2 C<cast>
- cast [$@%&*]var, [$wiz|$sig], ...
+ cast [$@%&*]var, $wiz, ...
This function associates C<$wiz> magic to the variable supplied, without overwriting any other kind of magic.
-You can also supply the numeric signature C<$sig> instead of C<$wiz>.
-It returns true on success or when C<$wiz> magic is already present, and croaks on error or when no magic corresponds to the given signature (in case a C<$sig> was supplied).
+It returns true on success or when C<$wiz> magic is already present, and croaks on error.
All extra arguments specified after C<$wiz> are passed to the private data constructor in C<@_[1 .. @_-1]>.
If the variable isn't a hash, any C<uvar> callback of the wizard is safely ignored.
@@ -356,28 +360,162 @@
If you want to overcome the possible deletion of the C<'TZ'> entry, you have no choice but to rely on C<store> uvar magic.
+=head2 C<getdata>
+
+ getdata [$@%&*]var, $wiz
+
+This accessor fetches the private data associated with the magic C<$wiz> in the variable.
+It croaks when C<$wiz> do not represent a valid magic object, and returns an empty list if no such magic is attached to the variable or when the wizard has no data constructor.
+
+ # Get the attached data, or undef if the wizard does not attach any.
+ my $data = getdata $x, $wiz;
+
+=head2 C<dispell>
+
+ dispell [$@%&*]variable, $wiz
+
+The exact opposite of L</cast> : it dissociates C<$wiz> magic from the variable.
+This function returns true on success, C<0> when no magic represented by C<$wiz> could be found in the variable, and croaks if the supplied wizard is invalid.
+
+ # Dispell now.
+ die 'no such magic in $x' unless dispell $x, $wiz;
+
+=head1 CONSTANTS
+
+=head2 C<SIG_MIN>
+
+The minimum integer used as a signature for user-defined magic.
+
+This constant is B<deprecated> and will be removed in december 2009.
+
+=head2 C<SIG_MAX>
+
+The maximum integer used as a signature for user-defined magic.
+
+This constant is B<deprecated> and will be removed in december 2009.
+
+=head2 C<SIG_NBR>
+
+ SIG_NBR = SIG_MAX - SIG_MIN + 1
+
+This constant is B<deprecated> and will be removed in december 2009.
+
+=head2 C<MGf_COPY>
+
+Evaluates to true iff the 'copy' magic is available.
+
+=head2 C<MGf_DUP>
+
+Evaluates to true iff the 'dup' magic is available.
+
+=head2 C<MGf_LOCAL>
+
+Evaluates to true iff the 'local' magic is available.
+
+=head2 C<VMG_UVAR>
+
+When this constant is true, you can use the C<fetch,store,exists,delete> callbacks on hashes.
+
+=head2 C<VMG_COMPAT_ARRAY_PUSH_NOLEN>
+
+True for perls that don't call 'len' magic when you push an element in a magical array.
+Starting from perl 5.11.0, this only refers to pushes in non-void context and hence is false.
+
+=head2 C<VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID>
+
+True for perls that don't call 'len' magic when you push in void context an element in a magical array.
+
+=head2 C<VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID>
+
+True for perls that don't call 'len' magic when you unshift in void context an element in a magical array.
+
+=head2 C<VMG_COMPAT_ARRAY_UNDEF_CLEAR>
+
+True for perls that call 'clear' magic when undefining magical arrays.
+
+=head2 C<VMG_COMPAT_SCALAR_LENGTH_NOLEN>
+
+True for perls that don't call 'len' magic when taking the C<length> of a magical scalar.
+
+=head2 C<VMG_PERL_PATCHLEVEL>
+
+The perl patchlevel this module was built with, or C<0> for non-debugging perls.
+
+=head2 C<VMG_THREADSAFE>
+
+True iff this module could have been built with thread-safety features enabled.
+
+=head2 C<VMG_FORKSAFE>
+
+True iff this module could have been built with fork-safety features enabled.
+This will always be true except on Windows where it's false for perl 5.10.0 and below .
+
+=head2 C<VMG_OP_INFO_NAME>
+
+Value to pass with C<op_info> to get the current op name in the magic callbacks.
+
+=head2 C<VMG_OP_INFO_OBJECT>
+
+Value to pass with C<op_info> to get a C<B::OP> object representing the current op in the magic callbacks.
+
+=head1 COOKBOOK
+
+=head2 Associate an object to any perl variable
+
+This can be useful for passing user data through limited APIs.
+
+ {
+ package Magical::UserData;
+
+ use Variable::Magic qw/wizard cast getdata/;
+
+ my $wiz = wizard data => sub { \$_[1] };
+
+ sub ud (\[$@%*&]) : lvalue {
+ my ($var) = @_;
+ my $data = &getdata($var, $wiz);
+ unless (defined $data) {
+ &cast($var, $wiz);
+ $data = &getdata($var, $wiz);
+ die "Couldn't cast UserData magic onto the variable" unless defined $data;
+ }
+ $$data;
+ }
+ }
+
+ {
+ BEGIN { *ud = \&Magical::UserData::ud }
+
+ my $cb;
+ $cb = sub { print 'Hello, ', ud(&$cb), "!\n" };
+
+ ud(&$cb) = 'world';
+ $cb->(); # Hello, world!
+ }
+
+=head2 Recursively cast magic on datastructures
+
C<cast> can be called from any magical callback, and in particular from C<data>.
This allows you to recursively cast magic on datastructures :
my $wiz;
- $wiz = wizard
- data => sub {
- my ($var, $depth) = @_;
- $depth ||= 0;
- my $r = ref $var;
- if ($r eq 'ARRAY') {
- &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for @$var;
- } elsif ($r eq 'HASH') {
- &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for values %$var;
- }
- return $depth;
- },
- free => sub {
- my ($var, $depth) = @_;
- my $r = ref $var;
- print "free $r at depth $depth\n";
- ();
- };
+ $wiz = wizard data => sub {
+ my ($var, $depth) = @_;
+ $depth ||= 0;
+ my $r = ref $var;
+ if ($r eq 'ARRAY') {
+ &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for @$var;
+ } elsif ($r eq 'HASH') {
+ &cast((ref() ? $_ : \$_), $wiz, $depth + 1) for values %$var;
+ }
+ return $depth;
+ },
+ free => sub {
+ my ($var, $depth) = @_;
+ my $r = ref $var;
+ print "free $r at depth $depth\n";
+ ();
+ };
{
my %h = (
@@ -398,94 +536,6 @@
Of course, this example does nothing with the values that are added after the C<cast>.
-=head2 C<getdata>
-
- getdata [$@%&*]var, [$wiz|$sig]
-
-This accessor fetches the private data associated with the magic C<$wiz> (or the signature C<$sig>) in the variable.
-It croaks when C<$wiz> or C<$sig> do not represent a valid magic object, and returns an empty list if no such magic is attached to the variable or when the wizard has no data constructor.
-
- # Get the attached data, or undef if the wizard does not attach any.
- my $data = getdata $x, $wiz;
-
-=head2 C<dispell>
-
- dispell [$@%&*]variable, [$wiz|$sig]
-
-The exact opposite of L</cast> : it dissociates C<$wiz> magic from the variable.
-You can also pass the magic signature C<$sig> as the second argument.
-This function returns true on success, C<0> when no magic represented by C<$wiz> or C<$sig> could be found in the variable, and croaks if the supplied wizard or signature is invalid.
-
- # Dispell now.
- die 'no such magic in $x' unless dispell $x, $wiz;
-
-=head1 CONSTANTS
-
-=head2 C<SIG_MIN>
-
-The minimum integer used as a signature for user-defined magic.
-
-=head2 C<SIG_MAX>
-
-The maximum integer used as a signature for user-defined magic.
-
-=head2 C<SIG_NBR>
-
- SIG_NBR = SIG_MAX - SIG_MIN + 1
-
-=head2 C<MGf_COPY>
-
-Evaluates to true iff the 'copy' magic is available.
-
-=head2 C<MGf_DUP>
-
-Evaluates to true iff the 'dup' magic is available.
-
-=head2 C<MGf_LOCAL>
-
-Evaluates to true iff the 'local' magic is available.
-
-=head2 C<VMG_UVAR>
-
-When this constant is true, you can use the C<fetch,store,exists,delete> callbacks on hashes.
-
-=head2 C<VMG_COMPAT_ARRAY_PUSH_NOLEN>
-
-True for perls that don't call 'len' magic when you push an element in a magical array.
-
-=head2 C<VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID>
-
-True for perls that don't call 'len' magic when you unshift in void context an element in a magical array.
-
-=head2 C<VMG_COMPAT_ARRAY_UNDEF_CLEAR>
-
-True for perls that call 'clear' magic when undefining magical arrays.
-
-=head2 C<VMG_COMPAT_SCALAR_LENGTH_NOLEN>
-
-True for perls that don't call 'len' magic when taking the C<length> of a magical scalar.
-
-=head2 C<VMG_PERL_PATCHLEVEL>
-
-The perl patchlevel this module was built with, or C<0> for non-debugging perls.
-
-=head2 C<VMG_THREADSAFE>
-
-True iff this module could have been built with thread-safety features enabled.
-
-=head2 C<VMG_FORKSAFE>
-
-True iff this module could have been built with fork-safety features enabled.
-This will always be true except on Windows where it's false for perl 5.10.0 and below .
-
-=head2 C<VMG_OP_INFO_NAME>
-
-Value to pass with C<op_info> to get the current op name in the magic callbacks.
-
-=head2 C<VMG_OP_INFO_OBJECT>
-
-Value to pass with C<op_info> to get a C<B::OP> object representing the current op in the magic callbacks.
-
=head1 PERL MAGIC HISTORY
The places where magic is invoked have changed a bit through perl history.
@@ -538,6 +588,8 @@
I<p34908> : 'len' magic is no longer called when pushing / unshifting an element into a magical array in void context.
The C<push> part was already covered by I<p25854>.
+
+I<g9cdcb38b> : 'len' magic is called again when pushing into a magical array in non-void context.
=back
@@ -557,7 +609,10 @@
'funcs' => [ qw/wizard gensig getsig cast getdata dispell/ ],
'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_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR VMG_COMPAT_SCALAR_LENGTH_NOLEN/,
+ qw/VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID/,
+ qw/VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID/,
+ qw/VMG_COMPAT_ARRAY_UNDEF_CLEAR/,
+ qw/VMG_COMPAT_SCALAR_LENGTH_NOLEN/,
qw/VMG_PERL_PATCHLEVEL/,
qw/VMG_THREADSAFE VMG_FORKSAFE/,
qw/VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/
Modified: trunk/libvariable-magic-perl/t/01-import.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/t/01-import.t?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/t/01-import.t (original)
+++ trunk/libvariable-magic-perl/t/01-import.t Mon Oct 5 11:50:45 2009
@@ -3,18 +3,32 @@
use strict;
use warnings;
-use Test::More tests => 22;
+use Test::More tests => 2 * 23;
require Variable::Magic;
-for (qw/wizard gensig getsig cast getdata dispell
- SIG_MIN SIG_MAX SIG_NBR
- MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR
- VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID
- VMG_COMPAT_ARRAY_UNDEF_CLEAR VMG_COMPAT_SCALAR_LENGTH_NOLEN
- VMG_PERL_PATCHLEVEL
- VMG_THREADSAFE VMG_FORKSAFE
- VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/) {
+my %syms = (
+ wizard => undef,
+ gensig => '',
+ getsig => '$',
+ cast => '\[$@%&*]$@',
+ getdata => '\[$@%&*]$',
+ dispell => '\[$@%&*]$',
+ map { $_ => '' } qw/
+ SIG_MIN SIG_MAX SIG_NBR
+ MGf_COPY MGf_DUP MGf_LOCAL VMG_UVAR
+ VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID
+ VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID
+ VMG_COMPAT_ARRAY_UNDEF_CLEAR
+ VMG_COMPAT_SCALAR_LENGTH_NOLEN
+ VMG_PERL_PATCHLEVEL
+ VMG_THREADSAFE VMG_FORKSAFE
+ VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT
+ /
+);
+
+for (sort keys %syms) {
eval { Variable::Magic->import($_) };
- is($@, '', 'import ' . $_);
+ is $@, '', "import $_";
+ is prototype($_), $syms{$_}, "prototype $_";
}
Modified: trunk/libvariable-magic-perl/t/31-array.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/t/31-array.t?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/t/31-array.t (original)
+++ trunk/libvariable-magic-perl/t/31-array.t Mon Oct 5 11:50:45 2009
@@ -5,7 +5,7 @@
use Test::More tests => 2 * 27 + 13 + 1;
-use Variable::Magic qw/cast dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR/;
+use Variable::Magic qw/cast dispell VMG_COMPAT_ARRAY_PUSH_NOLEN VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR/;
use lib 't/lib';
use Variable::Magic::TestWatcher;
@@ -53,10 +53,12 @@
is $b, 2, 'array: length $# correctly';
watch { push @a, 'x'; () }
- { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_PUSH_NOLEN },'push (void)';
+ { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID },
+ 'push (void)';
$b = watch { push @a, 'y' }
- { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_PUSH_NOLEN }, 'push (scalar)';
+ { set => 1, (len => 1) x !VMG_COMPAT_ARRAY_PUSH_NOLEN },
+ 'push (scalar)';
is $b, 5, 'array: push (scalar) correctly';
$b = watch { pop @a } { set => 1, len => 1 }, 'pop';
Modified: trunk/libvariable-magic-perl/t/99-kwalitee.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/t/99-kwalitee.t?rev=45378&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/t/99-kwalitee.t (original)
+++ trunk/libvariable-magic-perl/t/99-kwalitee.t Mon Oct 5 11:50:45 2009
@@ -5,5 +5,17 @@
use Test::More;
-eval { require Test::Kwalitee; Test::Kwalitee->import() };
-plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;
+eval { require Test::Kwalitee; };
+plan(skip_all => 'Test::Kwalitee not installed') if $@;
+
+SKIP: {
+ eval { Test::Kwalitee->import(); };
+ if (my $err = $@) {
+ 1 while chomp $err;
+ require Test::Builder;
+ my $Test = Test::Builder->new;
+ my $plan = $Test->has_plan;
+ $Test->skip_all($err) if not defined $plan or $plan eq 'no_plan';
+ skip $err => $plan - $Test->current_test;
+ }
+}
More information about the Pkg-perl-cvs-commits
mailing list