From: Stevan Little Date: Thu, 29 Jun 2006 18:27:47 +0000 (+0000) Subject: class-module-package X-Git-Tag: 0_33~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2243a22b2f3dd10fe1d860722e83526fa3c998b3;p=gitmo%2FClass-MOP.git class-module-package --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 1782718..0e9a577 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -11,6 +11,8 @@ use B 'svref_2object'; our $VERSION = '0.15'; +use base 'Class::MOP::Module'; + use Class::MOP::Instance; # Self-introspection diff --git a/lib/Class/MOP/Class/Immutable.pm b/lib/Class/MOP/Class/Immutable.pm index 346e120..d0a58f6 100644 --- a/lib/Class/MOP/Class/Immutable.pm +++ b/lib/Class/MOP/Class/Immutable.pm @@ -88,8 +88,53 @@ to this class. =back +=head2 Methods which will die if you touch them. + +=over 4 + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=back + +=head2 Cached methods + =over 4 +=item B + +=item B + +=item B + +=back + +=head2 Introspection and Construction + +=over 4 + +=item B + +=item B + +=item B + +=item B =back diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm new file mode 100644 index 0000000..1776d13 --- /dev/null +++ b/lib/Class/MOP/Module.pm @@ -0,0 +1,55 @@ + +package Class::MOP::Module; + +use strict; +use warnings; + +use Scalar::Util 'blessed'; + +our $VERSION = '0.01'; + +use base 'Class::MOP::Package'; + +# introspection + +sub meta { + require Class::MOP::Class; + Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Class::MOP::Module - Module Meta Object + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=over 4 + +=item B + +=back + +=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/Class/MOP/Package.pm b/lib/Class/MOP/Package.pm new file mode 100644 index 0000000..275c165 --- /dev/null +++ b/lib/Class/MOP/Package.pm @@ -0,0 +1,53 @@ + +package Class::MOP::Package; + +use strict; +use warnings; + +use Scalar::Util 'blessed'; + +our $VERSION = '0.01'; + +# introspection + +sub meta { + require Class::MOP::Class; + Class::MOP::Class->initialize(blessed($_[0]) || $_[0]); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Class::MOP::Package - Package Meta Object + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=over 4 + +=item B + +=back + +=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/t/000_load.t b/t/000_load.t index f70fd69..8e88fc0 100644 --- a/t/000_load.t +++ b/t/000_load.t @@ -17,9 +17,11 @@ BEGIN { my %METAS = ( 'Class::MOP::Attribute' => Class::MOP::Attribute->meta, + 'Class::MOP::Package' => Class::MOP::Package->meta, + '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, ); is_deeply( @@ -29,10 +31,24 @@ is_deeply( is_deeply( [ sort { $a->name cmp $b->name } Class::MOP::Class->get_all_metaclass_instances ], - [ Class::MOP::Attribute->meta, Class::MOP::Class->meta, Class::MOP::Instance->meta, Class::MOP::Method->meta ], + [ + Class::MOP::Attribute->meta, + Class::MOP::Class->meta, + Class::MOP::Instance->meta, + Class::MOP::Method->meta, + Class::MOP::Module->meta, + Class::MOP::Package->meta, + ], '... got all the metaclass instances'); is_deeply( [ sort Class::MOP::Class->get_all_metaclass_names ], - [ 'Class::MOP::Attribute', 'Class::MOP::Class', 'Class::MOP::Instance', 'Class::MOP::Method' ], + [ qw/ + Class::MOP::Attribute + Class::MOP::Class + Class::MOP::Instance + Class::MOP::Method + Class::MOP::Module + 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 caf532a..cbd1afa 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 152; +use Test::More tests => 153; use Test::Exception; BEGIN { @@ -166,14 +166,19 @@ is(${$meta->get_package_variable('$VERSION')}, is_deeply( [ $meta->superclasses ], - [], - '... Class::MOP::Class->superclasses == []'); + [ qw/Class::MOP::Module/ ], + '... Class::MOP::Class->superclasses == [ Class::MOP::Module ]'); is_deeply( [ $meta->class_precedence_list ], - [ 'Class::MOP::Class' ], - '... Class::MOP::Class->class_precedence_list == []'); + [ qw/ + Class::MOP::Class + Class::MOP::Module + Class::MOP::Package + / ], + '... Class::MOP::Class->class_precedence_list == [ Class::MOP::Class Class::MOP::Module Class::MOP::Package ]'); is($meta->attribute_metaclass, 'Class::MOP::Attribute', '... got the right value for attribute_metaclass'); is($meta->method_metaclass, 'Class::MOP::Method', '... got the right value for method_metaclass'); +is($meta->instance_metaclass, 'Class::MOP::Instance', '... got the right value for instance_metaclass');