From: Vincent Pit Date: Wed, 26 Oct 2011 09:40:16 +0000 (+0200) Subject: MGf_COPY and MGf_DUP should always be set for the perls we consider X-Git-Tag: v0.47~16 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=30631ed72aef81f7a424009effb91f408481463e MGf_COPY and MGf_DUP should always be set for the perls we consider --- diff --git a/MANIFEST b/MANIFEST index 894b32b..f533af0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,6 +14,7 @@ samples/uvar.pl samples/vm_vs_tie.pl t/00-load.t t/01-import.t +t/02-constants.t t/10-simple.t t/11-multiple.t t/13-data.t diff --git a/Magic.xs b/Magic.xs index 5b3be56..334a0a8 100644 --- a/Magic.xs +++ b/Magic.xs @@ -139,14 +139,6 @@ STATIC SV *vmg_clone(pTHX_ SV *sv, tTHX owner) { # define PERL_MAGIC_tied 'P' #endif -#ifndef MGf_COPY -# define MGf_COPY 0 -#endif - -#ifndef MGf_DUP -# define MGf_DUP 0 -#endif - #ifndef MGf_LOCAL # define MGf_LOCAL 0 #endif @@ -441,12 +433,8 @@ typedef struct { SV *cb_data; SV *cb_get, *cb_set, *cb_len, *cb_clear, *cb_free; -#if MGf_COPY SV *cb_copy; -#endif /* MGf_COPY */ -#if MGf_DUP SV *cb_dup; -#endif /* MGf_DUP */ #if MGf_LOCAL SV *cb_local; #endif /* MGf_LOCAL */ @@ -499,12 +487,10 @@ STATIC void vmg_mgwiz_free(pTHX_ MGWIZ *w) { SvREFCNT_dec(w->cb_len); SvREFCNT_dec(w->cb_clear); SvREFCNT_dec(w->cb_free); -#if MGf_COPY SvREFCNT_dec(w->cb_copy); -#endif /* MGf_COPY */ -#if 0 /* MGf_DUP */ +#if 0 SvREFCNT_dec(w->cb_dup); -#endif /* MGf_DUP */ +#endif #if MGf_LOCAL SvREFCNT_dec(w->cb_local); #endif /* MGf_LOCAL */ @@ -550,12 +536,8 @@ STATIC MGWIZ *vmg_mgwiz_clone(pTHX_ const MGWIZ *w) { VMG_CLONE_CB(len); VMG_CLONE_CB(clear); VMG_CLONE_CB(free); -#if MGf_COPY VMG_CLONE_CB(copy); -#endif /* MGf_COPY */ -#if MGf_DUP VMG_CLONE_CB(dup); -#endif /* MGf_DUP */ #if MGf_LOCAL VMG_CLONE_CB(local); #endif /* MGf_LOCAL */ @@ -631,12 +613,8 @@ STATIC MGVTBL vmg_wizard_vtbl = { NULL, /* len */ NULL, /* clear */ vmg_wizard_free, /* free */ -#if MGf_COPY NULL, /* copy */ -#endif /* MGf_COPY */ -#if MGf_DUP NULL, /* dup */ -#endif /* MGf_DUP */ #if MGf_LOCAL NULL, /* local */ #endif /* MGf_LOCAL */ @@ -817,14 +795,12 @@ STATIC UV vmg_cast(pTHX_ SV *sv, const SV *wiz, SV **args, I32 items) { (const char *) wiz, HEf_SVKEY); SvREFCNT_dec(data); mg->mg_private = SIG_WIZ; -#if MGf_COPY if (w->cb_copy) mg->mg_flags |= MGf_COPY; -#endif /* MGf_COPY */ -#if 0 /* MGf_DUP */ +#if 0 if (w->cb_dup) mg->mg_flags |= MGf_DUP; -#endif /* MGf_DUP */ +#endif #if MGf_LOCAL if (w->cb_local) mg->mg_flags |= MGf_LOCAL; @@ -1224,7 +1200,6 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { return ret; } -#if MGf_COPY STATIC int vmg_svt_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *key, # if VMG_HAS_PERL_MAINT(5, 11, 0, 33256) || VMG_HAS_PERL(5, 12, 0) I32 keylen @@ -1250,13 +1225,12 @@ STATIC int vmg_svt_copy(pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *key, return ret; } -#endif /* MGf_COPY */ -#if 0 /* MGf_DUP */ +#if 0 STATIC int vmg_svt_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param) { return 0; } -#endif /* MGf_DUP */ +#endif #if MGf_LOCAL STATIC int vmg_svt_local(pTHX_ SV *nsv, MAGIC *mg) { @@ -1470,13 +1444,7 @@ PREINIT: CODE: dMY_CXT; - if (items != 7 -#if MGf_COPY - + 1 -#endif /* MGf_COPY */ -#if MGf_DUP - + 1 -#endif /* MGf_DUP */ + if (items != 9 #if MGf_LOCAL + 1 #endif /* MGf_LOCAL */ @@ -1496,15 +1464,11 @@ CODE: VMG_SET_SVT_CB(ST(i++), len); VMG_SET_SVT_CB(ST(i++), clear); VMG_SET_SVT_CB(ST(i++), free); -#if MGf_COPY VMG_SET_SVT_CB(ST(i++), copy); -#endif /* MGf_COPY */ -#if MGf_DUP /* VMG_SET_SVT_CB(ST(i++), dup); */ i++; t->svt_dup = NULL; w->cb_dup = NULL; -#endif /* MGf_DUP */ #if MGf_LOCAL VMG_SET_SVT_CB(ST(i++), local); #endif /* MGf_LOCAL */ diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index fd2c0ef..af44f01 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -311,9 +311,7 @@ sub wizard { my %opts = @_; - my @keys = qw; - push @keys, 'copy' if MGf_COPY; - push @keys, 'dup' if MGf_DUP; + my @keys = qw; push @keys, 'local' if MGf_LOCAL; push @keys, qw if VMG_UVAR; diff --git a/t/02-constants.t b/t/02-constants.t new file mode 100644 index 0000000..f211897 --- /dev/null +++ b/t/02-constants.t @@ -0,0 +1,11 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 2; + +use Variable::Magic qw; + +ok MGf_COPY, 'MGf_COPY is always true'; +ok MGf_DUP, 'MGf_DUP is always true'; diff --git a/t/10-simple.t b/t/10-simple.t index 70b4f6e..1692b44 100644 --- a/t/10-simple.t +++ b/t/10-simple.t @@ -5,13 +5,11 @@ use warnings; use Test::More tests => 43; -use Variable::Magic qw; +use Variable::Magic qw; my $inv_wiz_obj = qr/Invalid\s+wizard\s+object\s+at\s+\Q$0\E/; -my $args = 7; -++$args if MGf_COPY; -++$args if MGf_DUP; +my $args = 9; ++$args if MGf_LOCAL; $args += 5 if VMG_UVAR; for (0 .. 20) { diff --git a/t/25-copy.t b/t/25-copy.t index 7e13dfd..04ed1c9 100644 --- a/t/25-copy.t +++ b/t/25-copy.t @@ -5,13 +5,9 @@ use warnings; use Test::More; -use Variable::Magic qw; +use Variable::Magic qw; -if (MGf_COPY) { - plan tests => 2 + ((2 * 5 + 3) + (2 * 2 + 1)) + (2 * 9 + 6) + 1; -} else { - plan skip_all => 'No copy magic for this perl'; -} +plan tests => 2 + ((2 * 5 + 3) + (2 * 2 + 1)) + (2 * 9 + 6) + 1; use lib 't/lib'; use Variable::Magic::TestWatcher; diff --git a/t/30-scalar.t b/t/30-scalar.t index c92b186..dfd88bd 100644 --- a/t/30-scalar.t +++ b/t/30-scalar.t @@ -7,7 +7,7 @@ use Config qw<%Config>; use Test::More tests => (2 * 14 + 2) + 2 * (2 * 8 + 4) + 3 + 1; -use Variable::Magic qw; +use Variable::Magic qw; use lib 't/lib'; use Variable::Magic::TestWatcher; @@ -103,18 +103,9 @@ is $b, 6, 'scalar: hash element: delete correctly'; watch { $h{b} = 4 } { }, 'hash element: set after delete'; SKIP: { - my $SKIP; - - if (!MGf_COPY) { - $SKIP = 'No copy magic for this perl'; - } else { - local $@; - unless (eval { require Tie::Array; 1 }) { - $SKIP = 'Tie::Array required to test clear magic on tied array values'; - } + unless (do { local $@; eval { require Tie::Array; 1 } }) { + skip 'Tie::Array required to test clear magic on tied array values' => 3; } - - skip $SKIP => 3 if $SKIP; defined and diag "Using Tie::Array $_" for $Tie::Array::VERSION; tie my @a, 'Tie::StdArray'; diff --git a/t/32-hash.t b/t/32-hash.t index a7408fc..c1e0831 100644 --- a/t/32-hash.t +++ b/t/32-hash.t @@ -5,7 +5,7 @@ use warnings; use Test::More tests => (2 * 21 + 7) + (2 * 5 + 5) + 1; -use Variable::Magic qw; +use Variable::Magic qw; use lib 't/lib'; use Variable::Magic::TestWatcher;