From: Stevan Little Date: Fri, 30 Jun 2006 17:23:52 +0000 (+0000) Subject: removing-bad-ideas X-Git-Tag: 0_11~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=637e2e32688e4267d9905e9ff3ea36bae9d1451f;p=gitmo%2FMoose.git removing-bad-ideas --- diff --git a/lib/Moose.pm b/lib/Moose.pm index ecb95a7..2b4a68a 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -1,4 +1,6 @@ +use lib '/Users/stevan/Projects/CPAN/Class-MOP/Class-MOP/lib/'; + package Moose; use strict; diff --git a/lib/Moose/Compiler.pm b/lib/Moose/Compiler.pm deleted file mode 100644 index e534b35..0000000 --- a/lib/Moose/Compiler.pm +++ /dev/null @@ -1,67 +0,0 @@ - -package Moose::Compiler; -use Moose; - -our $VERSION = '0.01'; - -has 'engine' => ( - is => 'rw', - does => 'Moose::Compiler::Engine', - handles => [qw( - compile_class - )], - required => 1, -); - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Compiler - The front end for the Moose compiler - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B - -This will return the metaclass associated with the given class. - -=item B - -=back - -=head1 DELEGATED METHODS - -=over 4 - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006 by Infinity Interactive, Inc. - -L - -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 diff --git a/lib/Moose/Compiler/Engine.pm b/lib/Moose/Compiler/Engine.pm deleted file mode 100644 index b2b0568..0000000 --- a/lib/Moose/Compiler/Engine.pm +++ /dev/null @@ -1,58 +0,0 @@ - -package Moose::Compiler::Engine; -use Moose::Role; - -our $VERSION = '0.01'; - -requires 'compile_class'; - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Compiler::Engine - An abstract roie for all Moose compiler engines - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B - -This will return the metaclass associated with the given role. - -=back - -=head1 REQUIRED METHODS - -=over 4 - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006 by Infinity Interactive, Inc. - -L - -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 diff --git a/lib/Moose/Compiler/Moose.pm b/lib/Moose/Compiler/Moose.pm deleted file mode 100644 index 2cc28c4..0000000 --- a/lib/Moose/Compiler/Moose.pm +++ /dev/null @@ -1,78 +0,0 @@ - -package Moose::Compiler::Moose; -use Moose; - -our $VERSION = '0.01'; - -with 'Moose::Compiler::Engine'; - -sub compile_class { - my ($self, $meta) = @_; - my $o = ''; - $o .= ('package ' . $meta->name . ";\n"); - $o .= ("use Moose;\n"); - $o .= ("\n"); - $o .= ("our \$VERSION = '" . $meta->version . "';\n"); - $o .= ("\n"); - foreach my $attr_name ($meta->get_attribute_list) { - my $attr = $meta->get_attribute($attr_name); - my @options; - push @options => ("is => '" . $attr->_is_metadata . "'") - if $attr->_is_metadata; - push @options => ("isa => '" . $attr->_isa_metadata . "'") - if $attr->_isa_metadata; - push @options => ("does => '" . $attr->_does_metadata . "'") - if $attr->_does_metadata; - $o .= ("has '" . $attr->name . "' => (" . (join ", " => @options) . ");\n"); - } - $o .= ("\n"); - $o .= ("1;\n"); - $o .= ("\n"); - $o .= ("__END__\n"); - return $o; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Compiler::Moose - A Moose compiler engine for compiling to Moose - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B - -This will return the metaclass associated with the given role. - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/Moose/Compiler/Perl5.pm b/lib/Moose/Compiler/Perl5.pm deleted file mode 100644 index 1776617..0000000 --- a/lib/Moose/Compiler/Perl5.pm +++ /dev/null @@ -1,87 +0,0 @@ - -package Moose::Compiler::Perl5; -use Moose; - -our $VERSION = '0.01'; - -with 'Moose::Compiler::Engine'; - -sub compile_class { - my ($self, $meta) = @_; - my $o = ''; - $o .= ('package ' . $meta->name . ";\n"); - $o .= ("\n"); - $o .= ("use strict;\n"); - $o .= ("use warnings;\n"); - $o .= ("\n"); - $o .= ("our \$VERSION = '" . $meta->version . "';\n"); - $o .= ("\n"); - $o .= ("sub new {\n"); - $o .= (" my (\$class, \%params) = \@_;\n"); - $o .= (" my \%proto = (\n"); - foreach my $attr_name ($meta->get_attribute_list) { - $o .= (" '" . $attr_name . "' => undef,\n"); - } - $o .= (" );\n"); - $o .= (" return bless { \%proto, \%params } => \$class;\n"); - $o .= ("}\n"); - $o .= ("\n"); - - foreach my $attr_name ($meta->get_attribute_list) { - my $attr = $meta->get_attribute($attr_name); - $o .= ("sub " . $attr->reader . " {" . ('') . "}\n\n") if $attr->has_reader; - $o .= ("sub " . $attr->writer . " {" . ('') . "}\n\n") if $attr->has_writer; - $o .= ("sub " . $attr->accessor . " {" . ('') . "}\n\n") if $attr->has_accessor; - $o .= ("sub " . $attr->predicate . " {" . ('') . "}\n\n") if $attr->has_predicate; - } - - $o .= ("1;\n"); - $o .= ("\n"); - $o .= ("__END__\n"); - return $o; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Compiler::Perl5 - A Moose compiler engine for compiling to Perl 5 - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B - -This will return the metaclass associated with the given role. - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/Moose/Compiler/Perl6.pm b/lib/Moose/Compiler/Perl6.pm deleted file mode 100644 index ec17dcb..0000000 --- a/lib/Moose/Compiler/Perl6.pm +++ /dev/null @@ -1,72 +0,0 @@ - -package Moose::Compiler::Perl6; -use Moose; - -our $VERSION = '0.01'; - -with 'Moose::Compiler::Engine'; - -sub compile_class { - my ($self, $meta) = @_; - my $o = ''; - $o .= ('class ' . $meta->name . "-" . $meta->version . " {\n"); - $o .= ("\n"); - foreach my $attr_name ($meta->get_attribute_list) { - my $attr = $meta->get_attribute($attr_name); - my @options; - push @options => ("is " . $attr->_is_metadata . "") - if $attr->_is_metadata; - push @options => ("does " . $attr->_does_metadata . "") - if $attr->_does_metadata; - $o .= (" has " . ($attr->_isa_metadata ? ($attr->_isa_metadata . " ") : '') - . "\$" . $attr->name . " " . (join " " => @options) . ";\n"); - } - $o .= ("\n"); - $o .= ("}\n"); - return $o; -} - -1; - -__END__ - -=pod - -=head1 NAME - -Moose::Compiler::Perl6 - A Moose compiler engine for compiling to Perl 6 - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B - -This will return the metaclass associated with the given role. - -=item B - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/t/300_Moose_Compiler_basic.t b/t/300_Moose_Compiler_basic.t deleted file mode 100644 index 61a05d2..0000000 --- a/t/300_Moose_Compiler_basic.t +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 25; -use Test::Exception; -use Test::LongString; - -BEGIN { - use_ok('Moose'); - use_ok('Moose::Compiler'); - use_ok('Moose::Compiler::Moose'); - use_ok('Moose::Compiler::Perl6'); - use_ok('Moose::Compiler::Perl5'); -} - -my $c = Moose::Compiler->new(engine => Moose::Compiler::Moose->new); -isa_ok($c, 'Moose::Compiler'); - -can_ok($c, 'engine'); -isa_ok($c->engine, 'Moose::Compiler::Moose'); -ok($c->engine->does('Moose::Compiler::Engine'), '... $c->engine does Moose::Compilter::Engine'); - -{ - package Foo; - use Moose; - our $VERSION = '1.0'; - - has 'bar' => (is => 'rw', isa => 'Bar'); - has 'baz' => (is => 'ro', does => 'Baz'); -} - -can_ok($c, 'compile_class'); - -{ - my $compiled; - lives_ok { - $compiled = $c->compile_class(Foo->meta); - } '... we compiled the class successfully'; - ok(defined $compiled, '... we go something'); - is_string($compiled, -q[package Foo; -use Moose; - -our $VERSION = '1.0'; - -has 'bar' => (is => 'rw', isa => 'Bar'); -has 'baz' => (is => 'ro', does => 'Baz'); - -1; - -__END__ -], - '... got the right compiled source'); -} - -lives_ok { - $c->engine(Moose::Compiler::Perl6->new); -} '... swapped engines successfully'; -isa_ok($c->engine, 'Moose::Compiler::Perl6'); -ok($c->engine->does('Moose::Compiler::Engine'), '... $c->engine does Moose::Compilter::Engine'); - -{ - my $compiled; - lives_ok { - $compiled = $c->compile_class(Foo->meta); - } '... we compiled the class successfully'; - ok(defined $compiled, '... we go something'); - is_string($compiled, -q[class Foo-1.0 { - - has Bar $bar is rw; - has $baz is ro does Baz; - -} -], - '... got the right compiled source'); -} - -lives_ok { - $c->engine(Moose::Compiler::Perl5->new); -} '... swapped engines successfully'; -isa_ok($c->engine, 'Moose::Compiler::Perl5'); -ok($c->engine->does('Moose::Compiler::Engine'), '... $c->engine does Moose::Compilter::Engine'); - -{ - my $compiled; - lives_ok { - $compiled = $c->compile_class(Foo->meta); - } '... we compiled the class successfully'; - ok(defined $compiled, '... we go something'); - is_string($compiled, -q[package Foo; - -use strict; -use warnings; - -our $VERSION = '1.0'; - -sub new { - my ($class, %params) = @_; - my %proto = ( - 'bar' => undef, - 'baz' => undef, - ); - return bless { %proto, %params } => $class; -} - -sub bar {} - -sub baz {} - -1; - -__END__ -], - '... got the right compiled source') or diag $compiled; -} - -