From: Stevan Little Date: Sat, 12 Aug 2006 06:13:02 +0000 (+0000) Subject: adding Class::MOP::Object X-Git-Tag: 0_33~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6e57504d833b252832d0f5306f0db97784647148;p=gitmo%2FClass-MOP.git adding Class::MOP::Object --- diff --git a/Changes b/Changes index 7263bec..b396a95 100644 --- a/Changes +++ b/Changes @@ -1,11 +1,17 @@ Revision history for Perl extension Class-MOP. 0.32 + + added Class::MOP::Object so that the + metamodel is more complete (and closer + to what Perl 6 will probably be). + * Class::MOP::Package - refactored entire class, this is now the primary gateway between the metaclass and the Perl 5 symbol table - added many tests for this + - this class is now a subclass of + Class::MOP::Object * Class::MOP::Class - refactored all symbol table access to diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 3c809e0..855ef20 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -286,6 +286,7 @@ Class::MOP::Class ->meta->make_immutable(inline_constructor => 0); Class::MOP::Attribute->meta->make_immutable(inline_constructor => 0); Class::MOP::Method ->meta->make_immutable(inline_constructor => 0); Class::MOP::Instance ->meta->make_immutable(inline_constructor => 0); +Class::MOP::Object ->meta->make_immutable(inline_constructor => 0); 1; diff --git a/lib/Class/MOP/Object.pm b/lib/Class/MOP/Object.pm new file mode 100644 index 0000000..b115ffa --- /dev/null +++ b/lib/Class/MOP/Object.pm @@ -0,0 +1,79 @@ + +package Class::MOP::Object; + +use strict; +use warnings; + +use Scalar::Util 'blessed'; + +our $VERSION = '0.01'; +our $AUTHORITY = 'cpan:STEVAN'; + +# introspection + +sub meta { + require Class::MOP::Class; + Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Class::MOP::Object - Object Meta Object + +=head1 DESCRIPTION + +This class is basically a stub, it provides no functionality at all, +and really just exists to make the Class::MOP metamodel complete. + + ...... + : : + : v + +-------------------+ + +-----| Class::MOP::Class | + | +-------------------+ + | ^ ^ ^ + v : : : + +--------------------+ : +--------------------+ + | Class::MOP::Module | : | Class::MOP::Object | + +--------------------+ : +--------------------+ + | : ^ + | : | + | +---------------------+ | + +--->| Class::MOP::Package |-----+ + +---------------------+ + + legend: + ..(is an instance of)..> + --(is a subclass of)--> + +A deeper discussion of this model is currently beyond the scope of +this documenation. + +=head1 METHODS + +=over 4 + +=item B + +=back + +=head1 AUTHORS + +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/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm index 297ee82..18e2c10 100644 --- a/lib/Class/MOP/Package.pm +++ b/lib/Class/MOP/Package.pm @@ -10,6 +10,8 @@ use Carp 'confess'; our $VERSION = '0.02'; our $AUTHORITY = 'cpan:STEVAN'; +use base 'Class::MOP::Object'; + # introspection sub meta { diff --git a/t/000_load.t b/t/000_load.t index 0dd8492..61be01a 100644 --- a/t/000_load.t +++ b/t/000_load.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 16; BEGIN { use_ok('Class::MOP'); @@ -11,6 +11,7 @@ BEGIN { use_ok('Class::MOP::Attribute'); use_ok('Class::MOP::Method'); use_ok('Class::MOP::Instance'); + use_ok('Class::MOP::Object'); } # make sure we are tracking metaclasses correctly @@ -21,7 +22,8 @@ my %METAS = ( 'Class::MOP::Module' => Class::MOP::Module->meta, 'Class::MOP::Class' => Class::MOP::Class->meta, 'Class::MOP::Method' => Class::MOP::Method->meta, - 'Class::MOP::Instance' => Class::MOP::Instance->meta, + 'Class::MOP::Instance' => Class::MOP::Instance->meta, + 'Class::MOP::Object' => Class::MOP::Object->meta, ); ok($_->is_immutable(), '... ' . $_->name . ' is immutable') for values %METAS; @@ -38,7 +40,8 @@ is_deeply( Class::MOP::Class->meta, Class::MOP::Instance->meta, Class::MOP::Method->meta, - Class::MOP::Module->meta, + Class::MOP::Module->meta, + Class::MOP::Object->meta, Class::MOP::Package->meta, ], '... got all the metaclass instances'); @@ -51,6 +54,7 @@ is_deeply( Class::MOP::Instance Class::MOP::Method Class::MOP::Module + Class::MOP::Object Class::MOP::Package / ], '... got all the metaclass names'); \ No newline at end of file diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index ec0533c..570084e 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -277,7 +277,8 @@ is_deeply( [ qw/ Class::MOP::Class Class::MOP::Module - Class::MOP::Package + Class::MOP::Package + Class::MOP::Object / ], '... Class::MOP::Class->class_precedence_list == [ Class::MOP::Class Class::MOP::Module Class::MOP::Package ]');