Changeset 14742 for lang/perl/Attribute-Constant
- Timestamp:
- 06/28/08 04:51:24 (5 years ago)
- Location:
- lang/perl/Attribute-Constant/trunk
- Files:
-
- 10 modified
-
Changes (modified) (1 diff)
-
Makefile.PL (modified) (1 diff)
-
README (modified) (1 diff)
-
lib/Attribute/Constant.pm (modified) (4 diffs)
-
lib/Data/Lock.pm (modified) (3 diffs)
-
t/01-atomic.t (modified) (1 diff)
-
t/02-avhv.t (modified) (1 diff)
-
t/03-obj.t (modified) (3 diffs)
-
t/04-dlock.t (modified) (1 diff)
-
t/benchmark.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Attribute-Constant/trunk/Changes
r14741 r14742 1 1 # Revision history for Attribute-Constant 2 2 # 3 # $Id: Changes,v 0. 1 2008/06/27 19:11:42 dankogai Exp dankogai $3 # $Id: Changes,v 0.2 2008/06/27 19:50:52 dankogai Exp dankogai $ 4 4 # 5 $Revision: 0.1 $ $Date: 2008/06/27 19:11:42 $ 5 $Revision: 0.2 $ $Date: 2008/06/27 19:50:52 $ 6 ! lib/Attribute/Constant.pm t/03-obj.t 7 Perl 5.8.x supported -- with caveats. See POD 8 9 0.01 2008/06/27 19:11:42 6 10 + * 7 11 First Release. -
lang/perl/Attribute-Constant/trunk/Makefile.PL
r14741 r14742 1 1 # 2 # $Id: Makefile.PL,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$2 # $Id: Makefile.PL,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 3 3 # 4 4 use 5.008001; -
lang/perl/Attribute-Constant/trunk/README
r14741 r14742 1 1 Attribute-Constant 2 2 3 $Id: README,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$3 $Id: README,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 4 4 5 5 This distribution contains Attribute::Constant and Data::Lock. -
lang/perl/Attribute-Constant/trunk/lib/Attribute/Constant.pm
r14741 r14742 3 3 use warnings; 4 4 use strict; 5 our $VERSION = sprintf "%d.%02d", q$Revision: 0. 1$ =~ /(\d+)/g;5 our $VERSION = sprintf "%d.%02d", q$Revision: 0.2 $ =~ /(\d+)/g; 6 6 use Attribute::Handlers; 7 7 use Data::Lock (); … … 9 9 sub UNIVERSAL::Constant : ATTR { 10 10 my ( $pkg, $sym, $ref, $attr, $data, $phase ) = @_; 11 ( ref $ref eq 'HASH' ? %$ref 11 ( 12 ref $ref eq 'HASH' ? %$ref 12 13 : ref $ref eq 'ARRAY' ? @$ref 13 : ($$ref) 14 ) = @$data; 14 : ($$ref) 15 ) = ref $data 16 ? ref $data eq 'ARRAY' ? @$data # perl 5.10.x 17 : $data : $data; # perl 5.8.x 15 18 Data::Lock::dlock($ref); 16 19 } … … 25 28 =head1 VERSION 26 29 27 $Id: Constant.pm,v 0. 1 2008/06/27 19:11:42 dankogai Exp dankogai $30 $Id: Constant.pm,v 0.2 2008/06/27 19:50:52 dankogai Exp dankogai $ 28 31 29 32 =head1 SYNOPSIS … … 45 48 ommited but it is semantically more elegant and thanks to 46 49 L<Data::Lock>, it imposes almost no performance penalty. 50 51 =head1 CAVEAT 52 53 Multi-line attributes are not allowed in Perl 5.8.x. 54 55 my $o : Constant(Foo->new(1,2,3)) # ok; 56 my $p : Constant(Bar->new( 57 1,2,3 58 ) 59 ) # needs Perl 5.10 60 61 In which case you can use L<Data::Lock> instead: 62 63 dlock(my $p = Bar->new( 64 1, 2, 3 65 )); 66 67 After all, this module is a wrapper to L<Data::Lock>; 47 68 48 69 =head1 BENCHMARK -
lang/perl/Attribute-Constant/trunk/lib/Data/Lock.pm
r14741 r14742 3 3 use warnings; 4 4 use strict; 5 our $VERSION = sprintf "%d.%02d", q$Revision: 0. 1$ =~ /(\d+)/g;5 our $VERSION = sprintf "%d.%02d", q$Revision: 0.2 $ =~ /(\d+)/g; 6 6 7 7 use Attribute::Handlers; … … 37 37 Internals::SvREADONLY( $_[0], $locked ); 38 38 }; 39 40 39 } 41 40 … … 49 48 =head1 VERSION 50 49 51 $Id: Lock.pm,v 0. 1 2008/06/27 19:11:42 dankogai Exp dankogai $50 $Id: Lock.pm,v 0.2 2008/06/27 19:50:52 dankogai Exp dankogai $ 52 51 53 52 =head1 SYNOPSIS -
lang/perl/Attribute-Constant/trunk/t/01-atomic.t
r14741 r14742 1 1 #!perl -T 2 2 # 3 # $Id: 01-atomic.t,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$3 # $Id: 01-atomic.t,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 4 4 # 5 5 use strict; -
lang/perl/Attribute-Constant/trunk/t/02-avhv.t
r14741 r14742 1 1 #!perl -T 2 2 # 3 # $Id: 02-avhv.t,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$3 # $Id: 02-avhv.t,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 4 4 # 5 5 use strict; -
lang/perl/Attribute-Constant/trunk/t/03-obj.t
r14741 r14742 1 1 #!perl -T 2 2 # 3 # $Id: 03-obj.t,v 0. 1 2008/06/27 19:11:42 dankogai Exp dankogai $3 # $Id: 03-obj.t,v 0.2 2008/06/27 19:50:52 dankogai Exp dankogai $ 4 4 # 5 5 use strict; … … 7 7 use Attribute::Constant; 8 8 #use Test::More 'no_plan'; 9 use Test::More tests => 5;9 use Test::More tests => 10; 10 10 11 11 { … … 16 16 } 17 17 { 18 my $o : Constant( 19 Foo->new(foo=>1) 18 my $o : Constant( Foo->new(foo=>1) ); 19 isa_ok $o, 'Foo'; 20 is $o->get, 1, '$o->get == 1'; 21 eval{ $o = Foo->new(foo=>2) }; 22 ok $@, $@; 23 eval{ $o->set(2) }; 24 ok !$@, '$o->set(2)'; 25 is $o->get, 2, '$o->get == 2'; 26 } 27 SKIP: { 28 skip 'Perl 5.9.5 or better required', 5 unless $] >= 5.009005; 29 my $o : Constant( 30 Foo->new(foo=>1) 20 31 ); 21 32 isa_ok $o, 'Foo'; -
lang/perl/Attribute-Constant/trunk/t/04-dlock.t
r14741 r14742 1 1 #!perl -T 2 2 # 3 # $Id: 04-dlock.t,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$3 # $Id: 04-dlock.t,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 4 4 # 5 5 use strict; -
lang/perl/Attribute-Constant/trunk/t/benchmark.pl
r14741 r14742 1 1 #!perl 2 2 # 3 # $Id: benchmark.pl,v 0.1 2008/06/27 19:11:42 dankogai Exp dankogai$3 # $Id: benchmark.pl,v 0.1 2008/06/27 19:11:42 dankogai Exp $ 4 4 # 5 5 use strict;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)