Revision history for Perl extension Moose
+0.18_001
+
+0.17 Tues. Nov. 14, 2006
+ * Moose::Meta::Method::Accessor
+ - bugfix for read-only accessors which
+ are have a type constraint and lazy.
+ Thanks to chansen for finding it.
+
+0.16 Tues. Nov. 14, 2006
+ ++ NOTE ++
+ There are some speed improvements in this release,
+ but they are only the begining, so stay tuned.
+
+ * Moose::Object
+ - BUILDALL and DEMOLISHALL no longer get
+ called unless they actually need to be.
+ This gave us a signifigant speed boost
+ for the cases when there is no BUILD or
+ DEMOLISH method present.
+
+ * Moose::Util::TypeConstraints
+ * Moose::Meta::TypeConstraint
+ - added an 'optimize_as' option to the
+ type constraint, which allows for a
+ hand optimized version of the type
+ constraint to be used when possible.
+ - Any internally created type constraints
+ now provide an optimized version as well.
+
0.15 Sun. Nov. 5, 2006
++ NOTE ++
This version of Moose *must* have Class::MOP 0.36 in order
Build.PL
Changes
-META.yml
Makefile.PL
+META.yml
MANIFEST
MANIFEST.SKIP
README
lib/Moose/Meta/TypeCoercion.pm
lib/Moose/Meta/TypeConstraint.pm
lib/Moose/Meta/Method/Accessor.pm
+lib/Moose/Meta/Method/Constructor.pm
+lib/Moose/Meta/Method/Destructor.pm
lib/Moose/Meta/Method/Overriden.pm
lib/Moose/Meta/Role/Method.pm
lib/Moose/Meta/TypeConstraint/Union.pm
t/101_subtype_conflict_bug.t
t/102_Moose_Object_error.t
t/103_subclass_use_base_bug.t
+t/104_inline_reader_bug.t
t/201_example.t
t/202_example_Moose_POOP.t
t/203_example.t
-Moose version 0.15
+Moose version 0.17
===========================
See the individual module documentation for more information
TODO
-------------------------------------------------------------------------------
+- DDuncan's Str types
+
+subtype 'Str'
+ => as 'Value'
+ => where { Encode::is_utf8( $_[0] ) or $_[0] !~ m/[^0x00-0x7F]/x }
+ => optimize_as { defined($_[0]) && !ref($_[0]) };
+
+subtype 'Blob'
+ => as 'Value'
+ => where { !Encode::is_utf8( $_[0] ) }
+ => optimize_as { defined($_[0]) && !ref($_[0]) };
+
+
- should handle some moose-specific options in &Moose::Meta::Class::create
things like roles, and method modifiers (although those can probably be
ignored if i want to)
--- /dev/null
+#!perl
+
+### MODULES
+
+package MooseHorse;
+use Moose;
+has foo => (is => 'rw');
+no Moose;
+
+package MooseHorseImmut;
+use Moose;
+has foo => (is => 'rw');
+__PACKAGE__->meta->make_immutable();
+no Moose;
+
+package MooseHorseImmutNoConst;
+use Moose;
+has foo => (is => 'rw');
+__PACKAGE__->meta->make_immutable(inline_constructor => 0);
+no Moose;
+
+
+package CAFHorse;
+use warnings;
+use strict;
+use base 'Class::Accessor::Fast';
+__PACKAGE__->mk_accessors(qw(foo));
+
+
+package main;
+use warnings;
+use strict;
+
+use Benchmark qw(cmpthese);
+use Benchmark ':hireswallclock';
+
+my $moose = MooseHorse->new;
+my $moose_immut = MooseHorseImmut->new;
+my $moose_immut_no_const = MooseHorseImmutNoConst->new;
+my $caf = CAFHorse->new;
+
+my $acc_rounds = 1_000_000;
+my $ins_rounds = 1_000_000;
+
+print "\nSETTING\n";
+cmpthese($acc_rounds, {
+ Moose => sub { $moose->foo(23) },
+ MooseImmut => sub { $moose_immut->foo(23) },
+ MooseImmutNoConst => sub { $moose_immut_no_const->foo(23) },
+ CAF => sub { $caf->foo(23) },
+}, 'noc');
+
+print "\nGETTING\n";
+cmpthese($acc_rounds, {
+ Moose => sub { $moose->foo },
+ MooseImmut => sub { $moose_immut->foo },
+ MooseImmutNoConst => sub { $moose_immut_no_const->foo },
+ CAF => sub { $caf->foo },
+}, 'noc');
+
+my (@moose, @moose_immut, @moose_immut_no_const, @caf_stall);
+print "\nCREATION\n";
+cmpthese($ins_rounds, {
+ Moose => sub { push @moose, MooseHorse->new(foo => 23) },
+ MooseImmut => sub { push @moose_immut, MooseHorseImmut->new(foo => 23) },
+ MooseImmutNoConst => sub { push @moose_immut_no_const, MooseHorseImmutNoConst->new(foo => 23) },
+ CAF => sub { push @caf_stall, CAFHorse->new({foo => 23}) },
+}, 'noc');
+
+my ( $moose_idx, $moose_immut_idx, $moose_immut_no_const_idx, $caf_idx ) = ( 0, 0, 0, 0 );
+print "\nDESTRUCTION\n";
+cmpthese($ins_rounds, {
+ Moose => sub {
+ $moose[$moose_idx] = undef;
+ $moose_idx++;
+ },
+ MooseImmut => sub {
+ $moose_immut[$moose_immut_idx] = undef;
+ $moose_immut_idx++;
+ },
+ MooseImmutNoConst => sub {
+ $moose_immut_no_const[$moose_immut_no_const_idx] = undef;
+ $moose_immut_no_const_idx++;
+ },
+ CAF => sub {
+ $caf_stall[$caf_idx] = undef;
+ $caf_idx++;
+ },
+}, 'noc');
+
+
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $num_iterations = shift || 100;
+
+{
+ package Foo;
+ use Moose;
+
+ has 'default' => (is => 'rw', default => 10);
+ has 'default_sub' => (is => 'rw', default => sub { [] });
+ has 'lazy' => (is => 'rw', default => 10, lazy => 1);
+ has 'required' => (is => 'rw', required => 1);
+ has 'weak_ref' => (is => 'rw', weak_ref => 1);
+ has 'type_constraint' => (is => 'rw', isa => 'ArrayRef');
+}
+
+foreach (0 .. $num_iterations) {
+ my $foo = Foo->new(
+ required => 'BAR',
+ type_constraint => [],
+ weak_ref => {},
+ );
+}
\ No newline at end of file
has 'baz' => (is => 'rw');
has 'bar' => (is => 'rw', isa => 'Foo');
- #has 'boo' => (is => 'rw', isa => type 'CustomFoo' => where { blessed($_) && $_->isa('Foo') });
}
{
},
'w_constraint' => sub {
$foo->bar($foo);
- },
- #'w_custom_constraint' => sub {
- # $foo->boo($foo);
- #},
+ },
}
);
-use lib '/Users/stevan/Projects/Moose/Moose/Class-MOP/branches/Class-MOP-tranformations/lib';
-
package Moose;
use strict;
use warnings;
-our $VERSION = '0.15';
+our $VERSION = '0.18_001';
use Scalar::Util 'blessed', 'reftype';
use Carp 'confess';
use Carp 'confess';
use Scalar::Util 'weaken', 'blessed', 'reftype';
-our $VERSION = '0.08';
+our $VERSION = '0.09';
use Moose::Meta::Method::Overriden;
use Carp 'confess';
-our $VERSION = '0.01';
+our $VERSION = '0.03';
use base 'Moose::Meta::Method',
'Class::MOP::Method::Accessor';
*generate_writer_method = \&generate_writer_method_inline;
*generate_accessor_method = \&generate_accessor_method_inline;
-## ... private helpers
-
sub _inline_check_constraint {
my ($self, $value) = @_;
(exists $options{options} && ref $options{options} eq 'HASH')
|| confess "You must pass a hash of options";
-
- (blessed $options{meta_instance} && $options{meta_instance}->isa('Class::MOP::Instance'))
- || confess "You must supply a meta-instance";
-
- (exists $options{attributes} && ref $options{attributes} eq 'ARRAY')
- || confess "You must pass an array of options";
-
- (blessed($_) && $_->isa('Class::MOP::Attribute'))
- || confess "You must supply a list of attributes which is a 'Class::MOP::Attribute' instance"
- for @{$options{attributes}};
my $self = bless {
# from our superclass
'&!body' => undef,
# specific to this subclass
'%!options' => $options{options},
- '$!meta_instance' => $options{meta_instance},
- '@!attributes' => $options{attributes},
+ '$!meta_instance' => $options{metaclass}->get_meta_instance,
+ '@!attributes' => [ $options{metaclass}->compute_all_applicable_attributes ],
# ...
'$!associated_metaclass' => $options{metaclass},
} => $class;
# we don't want this creating
# a cycle in the code, if not
# needed
- weaken($self->{'$!meta_instance'});
+# weaken($self->{'$!meta_instance'});
weaken($self->{'$!associated_metaclass'});
$self->intialize_body;
my $source = 'sub {';
$source .= "\n" . 'my $class = shift;';
- $source .= "\n" . 'return $class->Moose::Object::' . $self->options->{constructor_name} . '(@_)';
+ $source .= "\n" . 'return $class->Moose::Object::new(@_)';
$source .= "\n" . ' if $class ne \'' . $self->associated_metaclass->name . '\';';
$source .= "\n" . 'my %params = (scalar @_ == 1) ? %{$_[0]} : @_;';
=pod
-=cut
\ No newline at end of file
+=head1 NAME
+
+Moose::Meta::Method::Destructor - Method Meta Object for destructors
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 METHODS
+
+=over 4
+
+=item B<new>
+
+=item B<attributes>
+
+=item B<meta_instance>
+
+=item B<options>
+
+=item B<is_needed>
+
+=item B<intialize_body>
+
+=item B<associated_metaclass>
+
+=back
+
+=head1 AUTHORS
+
+Stevan Little E<lt>stevan@iinteractive.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
use Carp 'confess';
use Scalar::Util 'blessed';
-our $VERSION = '0.06';
+our $VERSION = '0.07';
use Moose::Meta::TypeConstraint::Union;
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-=cut
\ No newline at end of file
+=cut
-use lib '/Users/stevan/Projects/Moose/Moose/Class-MOP/branches/Class-MOP-tranformations/lib';
-
package Moose::Role;
use strict;
-use lib '/Users/stevan/Projects/Moose/Moose/Class-MOP/branches/Class-MOP-tranformations/lib';
-
package Moose::Util::TypeConstraints;
use strict;
use B 'svref_2object';
use Sub::Exporter;
-our $VERSION = '0.09';
+our $VERSION = '0.10';
use Moose::Meta::TypeConstraint;
use Moose::Meta::TypeCoercion;
$message = $_->{message} if exists $_->{message};
$optimized = $_->{optimized} if exists $_->{optimized};
}
-
+
my $pkg_defined_in = scalar(caller(1));
($TYPES{$name}->[0] eq $pkg_defined_in)
|| confess "The type constraint '$name' has already been created "
=head2 Type Coercion Constructors
-Type constraints can also contain type coercions as well. In most
-cases Moose will run the type-coercion code first, followed by the
-type constraint check. This feature should be used carefully as it
-is very powerful and could easily take off a limb if you are not
-careful.
+Type constraints can also contain type coercions as well. If you
+ask your accessor too coerce, the Moose will run the type-coercion
+code first, followed by the type constraint check. This feature
+should be used carefully as it is very powerful and could easily
+take off a limb if you are not careful.
See the L<SYNOPOSIS> for an example of how to use these.
use strict;
use warnings;
-use Test::More tests => 58;
+use Test::More tests => 60;
use Test::Exception;
BEGIN {
[ 'Moose::Object' ],
'... Point got the automagic base class');
-my @Point_methods = qw(meta new x y clear);
+my @Point_methods = qw(meta new x y clear DESTROY);
my @Point_attrs = ('x', 'y');
is_deeply(
[ 'Point' ],
'... Point3D gets the parent given to it');
-my @Point3D_methods = qw(new meta clear);
+my @Point3D_methods = qw(new meta clear DESTROY);
my @Point3D_attrs = ('z');
is_deeply(
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::Exception;
+
+BEGIN {
+ use_ok('Moose');
+}
+
+=pod
+
+This was a bug, but it is fixed now. This
+test makes sure it does not creep back in.
+
+=cut
+
+{
+ package Foo;
+ use Moose;
+
+ ::lives_ok {
+ has 'bar' => (
+ is => 'ro',
+ isa => 'Int',
+ lazy => 1,
+ default => 10,
+ );
+ } '... this didnt die';
+}
+