From: Dave Rolsky Date: Sun, 5 Jun 2011 21:34:04 +0000 (-0500) Subject: Add definition context to every accessor defined internally X-Git-Tag: 2.0100~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc2b7cc8f128cbc6c677b209553f6fe0c45af8be;p=gitmo%2FMoose.git Add definition context to every accessor defined internally --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index f079096..81f76b6 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -151,6 +151,15 @@ sub _is_valid_class_name { return 0; } +sub _definition_context { + my %context; + @context{qw(package file line)} = caller(1); + + return ( + definition_context => \%context, + ); +} + ## ---------------------------------------------------------------------------- ## Setting up our environment ... ## ---------------------------------------------------------------------------- @@ -186,7 +195,8 @@ Class::MOP::Mixin::HasMethods->meta->add_attribute( # rather than re-produce it here '_method_map' => \&Class::MOP::Mixin::HasMethods::_method_map }, - default => sub { {} } + default => sub { {} }, + _definition_context(), )) ); @@ -199,6 +209,7 @@ Class::MOP::Mixin::HasMethods->meta->add_attribute( 'method_metaclass' => \&Class::MOP::Mixin::HasMethods::method_metaclass }, default => 'Class::MOP::Method', + _definition_context(), )) ); @@ -211,6 +222,7 @@ Class::MOP::Mixin::HasMethods->meta->add_attribute( 'wrapped_method_metaclass' => \&Class::MOP::Mixin::HasMethods::wrapped_method_metaclass }, default => 'Class::MOP::Method::Wrapped', + _definition_context(), )) ); @@ -228,7 +240,8 @@ Class::MOP::Mixin::HasAttributes->meta->add_attribute( # rather than re-produce it here '_attribute_map' => \&Class::MOP::Mixin::HasAttributes::_attribute_map }, - default => sub { {} } + default => sub { {} }, + _definition_context(), )) ); @@ -241,6 +254,7 @@ Class::MOP::Mixin::HasAttributes->meta->add_attribute( 'attribute_metaclass' => \&Class::MOP::Mixin::HasAttributes::attribute_metaclass }, default => 'Class::MOP::Attribute', + _definition_context(), )) ); @@ -258,6 +272,7 @@ Class::MOP::Package->meta->add_attribute( # rather than re-produce it here 'name' => \&Class::MOP::Package::name }, + _definition_context(), )) ); @@ -270,7 +285,8 @@ Class::MOP::Package->meta->add_attribute( 'namespace' => \&Class::MOP::Package::namespace }, init_arg => undef, - default => sub { \undef } + default => sub { \undef }, + _definition_context(), )) ); @@ -296,7 +312,8 @@ Class::MOP::Module->meta->add_attribute( 'version' => \&Class::MOP::Module::version }, init_arg => undef, - default => sub { \undef } + default => sub { \undef }, + _definition_context(), )) ); @@ -315,7 +332,8 @@ Class::MOP::Module->meta->add_attribute( 'authority' => \&Class::MOP::Module::authority }, init_arg => undef, - default => sub { \undef } + default => sub { \undef }, + _definition_context(), )) ); @@ -331,7 +349,8 @@ Class::MOP::Class->meta->add_attribute( 'superclasses' => \&Class::MOP::Class::superclasses }, init_arg => undef, - default => sub { \undef } + default => sub { \undef }, + _definition_context(), )) ); @@ -347,6 +366,7 @@ Class::MOP::Class->meta->add_attribute( 'instance_metaclass' => \&Class::MOP::Class::instance_metaclass }, default => 'Class::MOP::Instance', + _definition_context(), )) ); @@ -356,6 +376,7 @@ Class::MOP::Class->meta->add_attribute( 'immutable_trait' => \&Class::MOP::Class::immutable_trait }, default => "Class::MOP::Class::Immutable::Trait", + _definition_context(), )) ); @@ -365,6 +386,7 @@ Class::MOP::Class->meta->add_attribute( 'constructor_name' => \&Class::MOP::Class::constructor_name, }, default => "new", + _definition_context(), )) ); @@ -374,6 +396,7 @@ Class::MOP::Class->meta->add_attribute( 'constructor_class' => \&Class::MOP::Class::constructor_class, }, default => "Class::MOP::Method::Constructor", + _definition_context(), )) ); @@ -383,6 +406,7 @@ Class::MOP::Class->meta->add_attribute( reader => { 'destructor_class' => \&Class::MOP::Class::destructor_class, }, + _definition_context(), )) ); @@ -404,7 +428,8 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( # we just alias the original method # rather than re-produce it here 'name' => \&Class::MOP::Mixin::AttributeCore::name - } + }, + _definition_context(), )) ); @@ -412,6 +437,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('accessor' => ( reader => { 'accessor' => \&Class::MOP::Mixin::AttributeCore::accessor }, predicate => { 'has_accessor' => \&Class::MOP::Mixin::AttributeCore::has_accessor }, + _definition_context(), )) ); @@ -419,6 +445,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('reader' => ( reader => { 'reader' => \&Class::MOP::Mixin::AttributeCore::reader }, predicate => { 'has_reader' => \&Class::MOP::Mixin::AttributeCore::has_reader }, + _definition_context(), )) ); @@ -426,12 +453,14 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('initializer' => ( reader => { 'initializer' => \&Class::MOP::Mixin::AttributeCore::initializer }, predicate => { 'has_initializer' => \&Class::MOP::Mixin::AttributeCore::has_initializer }, + _definition_context(), )) ); Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('definition_context' => ( reader => { 'definition_context' => \&Class::MOP::Mixin::AttributeCore::definition_context }, + _definition_context(), )) ); @@ -439,6 +468,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('writer' => ( reader => { 'writer' => \&Class::MOP::Mixin::AttributeCore::writer }, predicate => { 'has_writer' => \&Class::MOP::Mixin::AttributeCore::has_writer }, + _definition_context(), )) ); @@ -446,6 +476,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('predicate' => ( reader => { 'predicate' => \&Class::MOP::Mixin::AttributeCore::predicate }, predicate => { 'has_predicate' => \&Class::MOP::Mixin::AttributeCore::has_predicate }, + _definition_context(), )) ); @@ -453,6 +484,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('clearer' => ( reader => { 'clearer' => \&Class::MOP::Mixin::AttributeCore::clearer }, predicate => { 'has_clearer' => \&Class::MOP::Mixin::AttributeCore::has_clearer }, + _definition_context(), )) ); @@ -460,6 +492,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('builder' => ( reader => { 'builder' => \&Class::MOP::Mixin::AttributeCore::builder }, predicate => { 'has_builder' => \&Class::MOP::Mixin::AttributeCore::has_builder }, + _definition_context(), )) ); @@ -467,6 +500,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('init_arg' => ( reader => { 'init_arg' => \&Class::MOP::Mixin::AttributeCore::init_arg }, predicate => { 'has_init_arg' => \&Class::MOP::Mixin::AttributeCore::has_init_arg }, + _definition_context(), )) ); @@ -474,6 +508,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( Class::MOP::Attribute->new('default' => ( # default has a custom 'reader' method ... predicate => { 'has_default' => \&Class::MOP::Mixin::AttributeCore::has_default }, + _definition_context(), )) ); @@ -482,6 +517,7 @@ Class::MOP::Mixin::AttributeCore->meta->add_attribute( reader => { 'insertion_order' => \&Class::MOP::Mixin::AttributeCore::insertion_order }, writer => { '_set_insertion_order' => \&Class::MOP::Mixin::AttributeCore::_set_insertion_order }, predicate => { 'has_insertion_order' => \&Class::MOP::Mixin::AttributeCore::has_insertion_order }, + _definition_context(), )) ); @@ -497,14 +533,16 @@ Class::MOP::Attribute->meta->add_attribute( # we just alias the original method # rather than re-produce it here 'associated_class' => \&Class::MOP::Attribute::associated_class - } + }, + _definition_context(), )) ); Class::MOP::Attribute->meta->add_attribute( Class::MOP::Attribute->new('associated_methods' => ( reader => { 'associated_methods' => \&Class::MOP::Attribute::associated_methods }, - default => sub { [] } + default => sub { [] }, + _definition_context(), )) ); @@ -518,24 +556,28 @@ Class::MOP::Attribute->meta->add_method('clone' => sub { Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('body' => ( reader => { 'body' => \&Class::MOP::Method::body }, + _definition_context(), )) ); Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('associated_metaclass' => ( reader => { 'associated_metaclass' => \&Class::MOP::Method::associated_metaclass }, + _definition_context(), )) ); Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('package_name' => ( reader => { 'package_name' => \&Class::MOP::Method::package_name }, + _definition_context(), )) ); Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('name' => ( reader => { 'name' => \&Class::MOP::Method::name }, + _definition_context(), )) ); @@ -543,6 +585,7 @@ Class::MOP::Method->meta->add_attribute( Class::MOP::Attribute->new('original_method' => ( reader => { 'original_method' => \&Class::MOP::Method::original_method }, writer => { '_set_original_method' => \&Class::MOP::Method::_set_original_method }, + _definition_context(), )) ); @@ -555,7 +598,9 @@ Class::MOP::Method->meta->add_attribute( # practices of attributes, but we put # it here for completeness Class::MOP::Method::Wrapped->meta->add_attribute( - Class::MOP::Attribute->new('modifier_table') + Class::MOP::Attribute->new('modifier_table' => ( + _definition_context(), + )) ); ## -------------------------------------------------------- @@ -564,13 +609,15 @@ Class::MOP::Method::Wrapped->meta->add_attribute( Class::MOP::Method::Generated->meta->add_attribute( Class::MOP::Attribute->new('is_inline' => ( reader => { 'is_inline' => \&Class::MOP::Method::Generated::is_inline }, - default => 0, + default => 0, + _definition_context(), )) ); Class::MOP::Method::Generated->meta->add_attribute( Class::MOP::Attribute->new('definition_context' => ( reader => { 'definition_context' => \&Class::MOP::Method::Generated::definition_context }, + _definition_context(), )) ); @@ -581,6 +628,7 @@ Class::MOP::Method::Generated->meta->add_attribute( Class::MOP::Method::Inlined->meta->add_attribute( Class::MOP::Attribute->new('_expected_method_class' => ( reader => { '_expected_method_class' => \&Class::MOP::Method::Inlined::_expected_method_class }, + _definition_context(), )) ); @@ -592,12 +640,14 @@ Class::MOP::Method::Accessor->meta->add_attribute( reader => { 'associated_attribute' => \&Class::MOP::Method::Accessor::associated_attribute }, + _definition_context(), )) ); Class::MOP::Method::Accessor->meta->add_attribute( Class::MOP::Attribute->new('accessor_type' => ( reader => { 'accessor_type' => \&Class::MOP::Method::Accessor::accessor_type }, + _definition_context(), )) ); @@ -609,7 +659,8 @@ Class::MOP::Method::Constructor->meta->add_attribute( reader => { 'options' => \&Class::MOP::Method::Constructor::options }, - default => sub { +{} } + default => sub { +{} }, + _definition_context(), )) ); @@ -619,6 +670,7 @@ Class::MOP::Method::Constructor->meta->add_attribute( reader => { 'associated_metaclass' => \&Class::MOP::Method::Constructor::associated_metaclass }, + _definition_context(), )) ); @@ -632,6 +684,7 @@ Class::MOP::Method::Constructor->meta->add_attribute( Class::MOP::Instance->meta->add_attribute( Class::MOP::Attribute->new('associated_metaclass', reader => { associated_metaclass => \&Class::MOP::Instance::associated_metaclass }, + _definition_context(), ), ); @@ -641,24 +694,28 @@ Class::MOP::Instance->meta->add_attribute( reader => { _class_name => \&Class::MOP::Instance::_class_name }, #lazy => 1, # not yet supported by Class::MOP but out our version does it anyway #default => sub { $_[0]->associated_metaclass->name }, + _definition_context(), ), ); Class::MOP::Instance->meta->add_attribute( Class::MOP::Attribute->new('attributes', reader => { attributes => \&Class::MOP::Instance::get_all_attributes }, + _definition_context(), ), ); Class::MOP::Instance->meta->add_attribute( Class::MOP::Attribute->new('slots', reader => { slots => \&Class::MOP::Instance::slots }, + _definition_context(), ), ); Class::MOP::Instance->meta->add_attribute( Class::MOP::Attribute->new('slot_hash', reader => { slot_hash => \&Class::MOP::Instance::slot_hash }, + _definition_context(), ), ); diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index aec1ef1..b0160bc 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -25,6 +25,7 @@ Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); __PACKAGE__->meta->add_attribute('traits' => ( reader => 'applied_traits', predicate => 'has_applied_traits', + Class::MOP::_definition_context(), )); # we need to have a ->does method in here to diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 7d8e55d..f0f6253 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -28,34 +28,40 @@ Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); __PACKAGE__->meta->add_attribute('roles' => ( reader => 'roles', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('role_applications' => ( reader => '_get_role_applications', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute( Class::MOP::Attribute->new('immutable_trait' => ( accessor => "immutable_trait", default => 'Moose::Meta::Class::Immutable::Trait', + Class::MOP::_definition_context(), )) ); __PACKAGE__->meta->add_attribute('constructor_class' => ( accessor => 'constructor_class', default => 'Moose::Meta::Method::Constructor', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('destructor_class' => ( accessor => 'destructor_class', default => 'Moose::Meta::Method::Destructor', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('error_class' => ( accessor => 'error_class', default => 'Moose::Error::Default', + Class::MOP::_definition_context(), )); sub initialize { diff --git a/lib/Moose/Meta/Mixin/AttributeCore.pm b/lib/Moose/Meta/Mixin/AttributeCore.pm index 35d579f..3152611 100644 --- a/lib/Moose/Meta/Mixin/AttributeCore.pm +++ b/lib/Moose/Meta/Mixin/AttributeCore.pm @@ -5,41 +5,98 @@ use warnings; use base 'Class::MOP::Mixin::AttributeCore'; -__PACKAGE__->meta->add_attribute( 'isa' => ( reader => '_isa_metadata' ) ); -__PACKAGE__->meta->add_attribute( 'does' => ( reader => '_does_metadata' ) ); -__PACKAGE__->meta->add_attribute( 'is' => ( reader => '_is_metadata' ) ); +__PACKAGE__->meta->add_attribute( + 'isa' => ( + reader => '_isa_metadata', + Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'does' => ( + reader => '_does_metadata', + Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'is' => ( + reader => '_is_metadata', + Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'required' => ( + reader => 'is_required', + Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'lazy' => ( + reader => 'is_lazy', Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'lazy_build' => ( + reader => 'is_lazy_build', + Class::MOP::_definition_context(), + ) +); + +__PACKAGE__->meta->add_attribute( + 'coerce' => ( + reader => 'should_coerce', + Class::MOP::_definition_context(), + ) +); -__PACKAGE__->meta->add_attribute( 'required' => ( reader => 'is_required' ) ); -__PACKAGE__->meta->add_attribute( 'lazy' => ( reader => 'is_lazy' ) ); __PACKAGE__->meta->add_attribute( - 'lazy_build' => ( reader => 'is_lazy_build' ) ); -__PACKAGE__->meta->add_attribute( 'coerce' => ( reader => 'should_coerce' ) ); -__PACKAGE__->meta->add_attribute( 'weak_ref' => ( reader => 'is_weak_ref' ) ); + 'weak_ref' => ( + reader => 'is_weak_ref', + Class::MOP::_definition_context(), + ) +); + __PACKAGE__->meta->add_attribute( - 'auto_deref' => ( reader => 'should_auto_deref' ) ); + 'auto_deref' => ( + reader => 'should_auto_deref', + Class::MOP::_definition_context(), + ) +); + __PACKAGE__->meta->add_attribute( 'type_constraint' => ( reader => 'type_constraint', predicate => 'has_type_constraint', + Class::MOP::_definition_context(), ) ); + __PACKAGE__->meta->add_attribute( 'trigger' => ( reader => 'trigger', predicate => 'has_trigger', + Class::MOP::_definition_context(), ) ); + __PACKAGE__->meta->add_attribute( 'handles' => ( reader => 'handles', writer => '_set_handles', predicate => 'has_handles', + Class::MOP::_definition_context(), ) ); + __PACKAGE__->meta->add_attribute( 'documentation' => ( reader => 'documentation', predicate => 'has_documentation', + Class::MOP::_definition_context(), ) ); diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index fe2e2a0..495a9bb 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -82,7 +82,8 @@ foreach my $action ( # create the attribute $META->add_attribute($action->{name} => ( reader => $attr_reader, - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); # create some helper methods @@ -121,42 +122,49 @@ $META->add_attribute( 'method_metaclass', reader => 'method_metaclass', default => 'Moose::Meta::Role::Method', + Class::MOP::_definition_context(), ); $META->add_attribute( 'required_method_metaclass', reader => 'required_method_metaclass', default => 'Moose::Meta::Role::Method::Required', + Class::MOP::_definition_context(), ); $META->add_attribute( 'conflicting_method_metaclass', reader => 'conflicting_method_metaclass', default => 'Moose::Meta::Role::Method::Conflicting', + Class::MOP::_definition_context(), ); $META->add_attribute( 'application_to_class_class', reader => 'application_to_class_class', default => 'Moose::Meta::Role::Application::ToClass', + Class::MOP::_definition_context(), ); $META->add_attribute( 'application_to_role_class', reader => 'application_to_role_class', default => 'Moose::Meta::Role::Application::ToRole', + Class::MOP::_definition_context(), ); $META->add_attribute( 'application_to_instance_class', reader => 'application_to_instance_class', default => 'Moose::Meta::Role::Application::ToInstance', + Class::MOP::_definition_context(), ); $META->add_attribute( 'applied_attribute_metaclass', reader => 'applied_attribute_metaclass', default => 'Moose::Meta::Attribute', + Class::MOP::_definition_context(), ); # More or less copied from Moose::Meta::Class @@ -291,7 +299,8 @@ foreach my $modifier_type (qw[ before around after ]) { # create the attribute ... $META->add_attribute("${modifier_type}_method_modifiers" => ( reader => $attr_reader, - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); # and some helper methods ... @@ -336,7 +345,8 @@ foreach my $modifier_type (qw[ before around after ]) { $META->add_attribute('override_method_modifiers' => ( reader => 'get_override_method_modifiers_map', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); # NOTE: @@ -381,7 +391,8 @@ sub _meta_method_class { 'Moose::Meta::Method::Meta' } $META->add_attribute('roles' => ( reader => 'get_roles', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); sub add_role { diff --git a/lib/Moose/Meta/Role/Application.pm b/lib/Moose/Meta/Role/Application.pm index dcb1352..d9d4c2f 100644 --- a/lib/Moose/Meta/Role/Application.pm +++ b/lib/Moose/Meta/Role/Application.pm @@ -7,13 +7,15 @@ use metaclass; __PACKAGE__->meta->add_attribute('method_exclusions' => ( init_arg => '-excludes', reader => 'get_method_exclusions', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('method_aliases' => ( init_arg => '-alias', reader => 'get_method_aliases', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); sub new { diff --git a/lib/Moose/Meta/Role/Application/RoleSummation.pm b/lib/Moose/Meta/Role/Application/RoleSummation.pm index db0452d..cdedb94 100644 --- a/lib/Moose/Meta/Role/Application/RoleSummation.pm +++ b/lib/Moose/Meta/Role/Application/RoleSummation.pm @@ -12,7 +12,8 @@ use base 'Moose::Meta::Role::Application'; __PACKAGE__->meta->add_attribute('role_params' => ( reader => 'role_params', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); sub get_exclusions_for_role { diff --git a/lib/Moose/Meta/Role/Application/ToClass.pm b/lib/Moose/Meta/Role/Application/ToClass.pm index 2ec5531..704310b 100644 --- a/lib/Moose/Meta/Role/Application/ToClass.pm +++ b/lib/Moose/Meta/Role/Application/ToClass.pm @@ -11,10 +11,12 @@ use base 'Moose::Meta::Role::Application'; __PACKAGE__->meta->add_attribute('role' => ( reader => 'role', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('class' => ( accessor => 'class', + Class::MOP::_definition_context(), )); sub apply { diff --git a/lib/Moose/Meta/Role/Application/ToInstance.pm b/lib/Moose/Meta/Role/Application/ToInstance.pm index 1f12e5f..d1eb924 100644 --- a/lib/Moose/Meta/Role/Application/ToInstance.pm +++ b/lib/Moose/Meta/Role/Application/ToInstance.pm @@ -11,7 +11,8 @@ use base 'Moose::Meta::Role::Application'; __PACKAGE__->meta->add_attribute('rebless_params' => ( reader => 'rebless_params', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); sub apply { diff --git a/lib/Moose/Meta/Role/Attribute.pm b/lib/Moose/Meta/Role/Attribute.pm index 1344fa2..bc0bd1f 100644 --- a/lib/Moose/Meta/Role/Attribute.pm +++ b/lib/Moose/Meta/Role/Attribute.pm @@ -12,30 +12,35 @@ use base 'Moose::Meta::Mixin::AttributeCore', 'Class::MOP::Object'; __PACKAGE__->meta->add_attribute( 'metaclass' => ( reader => 'metaclass', + Class::MOP::_definition_context(), ) ); __PACKAGE__->meta->add_attribute( 'associated_role' => ( reader => 'associated_role', + Class::MOP::_definition_context(), ) ); __PACKAGE__->meta->add_attribute( '_original_role' => ( reader => '_original_role', + Class::MOP::_definition_context(), ) ); __PACKAGE__->meta->add_attribute( 'is' => ( reader => 'is', + Class::MOP::_definition_context(), ) ); __PACKAGE__->meta->add_attribute( 'original_options' => ( reader => 'original_options', + Class::MOP::_definition_context(), ) ); diff --git a/lib/Moose/Meta/Role/Composite.pm b/lib/Moose/Meta/Role/Composite.pm index e3a6d57..51e6691 100644 --- a/lib/Moose/Meta/Role/Composite.pm +++ b/lib/Moose/Meta/Role/Composite.pm @@ -14,7 +14,10 @@ use base 'Moose::Meta::Role'; # since we don't have an actual # package for this. # - SL -__PACKAGE__->meta->add_attribute('name' => (reader => 'name')); +__PACKAGE__->meta->add_attribute('name' => ( + reader => 'name', + Class::MOP::_definition_context(), +)); # NOTE: # Again, since we don't have a real @@ -23,13 +26,15 @@ __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); # - SL __PACKAGE__->meta->add_attribute('_methods' => ( reader => '_method_map', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute( 'application_role_summation_class', reader => 'application_role_summation_class', default => 'Moose::Meta::Role::Application::RoleSummation', + Class::MOP::_definition_context(), ); sub new { diff --git a/lib/Moose/Meta/Role/Method/Conflicting.pm b/lib/Moose/Meta/Role/Method/Conflicting.pm index 7b0f8e0..d018ee0 100644 --- a/lib/Moose/Meta/Role/Method/Conflicting.pm +++ b/lib/Moose/Meta/Role/Method/Conflicting.pm @@ -11,6 +11,7 @@ use base qw(Moose::Meta::Role::Method::Required); __PACKAGE__->meta->add_attribute('roles' => ( reader => 'roles', required => 1, + Class::MOP::_definition_context(), )); sub roles_as_english_list { diff --git a/lib/Moose/Meta/Role/Method/Required.pm b/lib/Moose/Meta/Role/Method/Required.pm index cbfe742..bc0781e 100644 --- a/lib/Moose/Meta/Role/Method/Required.pm +++ b/lib/Moose/Meta/Role/Method/Required.pm @@ -16,6 +16,7 @@ use base qw(Class::MOP::Object); __PACKAGE__->meta->add_attribute('name' => ( reader => 'name', required => 1, + Class::MOP::_definition_context(), )); sub new { shift->_new(@_) } diff --git a/lib/Moose/Meta/TypeCoercion.pm b/lib/Moose/Meta/TypeCoercion.pm index e6c71b0..6ecafba 100644 --- a/lib/Moose/Meta/TypeCoercion.pm +++ b/lib/Moose/Meta/TypeCoercion.pm @@ -10,19 +10,22 @@ use Moose::Util::TypeConstraints (); __PACKAGE__->meta->add_attribute('type_coercion_map' => ( reader => 'type_coercion_map', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute( Moose::Meta::Attribute->new('type_constraint' => ( reader => 'type_constraint', - weak_ref => 1 + weak_ref => 1, + Class::MOP::_definition_context(), )) ); # private accessor __PACKAGE__->meta->add_attribute('compiled_type_coercion' => ( - accessor => '_compiled_type_coercion' + accessor => '_compiled_type_coercion', + Class::MOP::_definition_context(), )); sub new { diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 9d5e128..db0fbc0 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -17,25 +17,35 @@ use Try::Tiny; use base qw(Class::MOP::Object); -__PACKAGE__->meta->add_attribute('name' => (reader => 'name')); +__PACKAGE__->meta->add_attribute('name' => ( + reader => 'name', + Class::MOP::_definition_context(), +)); __PACKAGE__->meta->add_attribute('parent' => ( reader => 'parent', predicate => 'has_parent', + Class::MOP::_definition_context(), )); my $null_constraint = sub { 1 }; __PACKAGE__->meta->add_attribute('constraint' => ( reader => 'constraint', writer => '_set_constraint', - default => sub { $null_constraint } + default => sub { $null_constraint }, + Class::MOP::_definition_context(), )); + __PACKAGE__->meta->add_attribute('message' => ( accessor => 'message', - predicate => 'has_message' + predicate => 'has_message', + Class::MOP::_definition_context(), )); + __PACKAGE__->meta->add_attribute('_default_message' => ( accessor => '_default_message', + Class::MOP::_definition_context(), )); + # can't make this a default because it has to close over the type name, and # cmop attributes don't have lazy my $_default_message_generator = sub { @@ -59,25 +69,29 @@ my $_default_message_generator = sub { }; __PACKAGE__->meta->add_attribute('coercion' => ( accessor => 'coercion', - predicate => 'has_coercion' + predicate => 'has_coercion', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => ( init_arg => 'optimized', accessor => 'hand_optimized_type_constraint', predicate => 'has_hand_optimized_type_constraint', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('inlined' => ( init_arg => 'inlined', accessor => 'inlined', predicate => '_has_inlined_type_constraint', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('inline_environment' => ( init_arg => 'inline_environment', accessor => '_inline_environment', default => sub { {} }, + Class::MOP::_definition_context(), )); sub parents { @@ -89,10 +103,13 @@ sub parents { __PACKAGE__->meta->add_attribute('compiled_type_constraint' => ( accessor => '_compiled_type_constraint', - predicate => '_has_compiled_type_constraint' + predicate => '_has_compiled_type_constraint', + Class::MOP::_definition_context(), )); + __PACKAGE__->meta->add_attribute('package_defined_in' => ( - accessor => '_package_defined_in' + accessor => '_package_defined_in', + Class::MOP::_definition_context(), )); sub new { diff --git a/lib/Moose/Meta/TypeConstraint/Class.pm b/lib/Moose/Meta/TypeConstraint/Class.pm index 88ed2d6..5d66bc6 100644 --- a/lib/Moose/Meta/TypeConstraint/Class.pm +++ b/lib/Moose/Meta/TypeConstraint/Class.pm @@ -12,6 +12,7 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('class' => ( reader => 'class', + Class::MOP::_definition_context(), )); my $inliner = sub { diff --git a/lib/Moose/Meta/TypeConstraint/DuckType.pm b/lib/Moose/Meta/TypeConstraint/DuckType.pm index beab63f..0a8ef8a 100644 --- a/lib/Moose/Meta/TypeConstraint/DuckType.pm +++ b/lib/Moose/Meta/TypeConstraint/DuckType.pm @@ -15,6 +15,7 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('methods' => ( accessor => 'methods', + Class::MOP::_definition_context(), )); my $inliner = sub { diff --git a/lib/Moose/Meta/TypeConstraint/Enum.pm b/lib/Moose/Meta/TypeConstraint/Enum.pm index fdafd39..7b52645 100644 --- a/lib/Moose/Meta/TypeConstraint/Enum.pm +++ b/lib/Moose/Meta/TypeConstraint/Enum.pm @@ -11,10 +11,12 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('values' => ( accessor => 'values', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('_inline_var_name' => ( accessor => '_inline_var_name', + Class::MOP::_definition_context(), )); my $inliner = sub { diff --git a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm index a5b9052..aa8cf2d 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterizable.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterizable.pm @@ -13,11 +13,13 @@ use Carp 'confess'; __PACKAGE__->meta->add_attribute('constraint_generator' => ( accessor => 'constraint_generator', predicate => 'has_constraint_generator', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('inline_generator' => ( accessor => 'inline_generator', predicate => 'has_inline_generator', + Class::MOP::_definition_context(), )); sub generate_constraint_for { diff --git a/lib/Moose/Meta/TypeConstraint/Parameterized.pm b/lib/Moose/Meta/TypeConstraint/Parameterized.pm index 61db448..175c9ab 100644 --- a/lib/Moose/Meta/TypeConstraint/Parameterized.pm +++ b/lib/Moose/Meta/TypeConstraint/Parameterized.pm @@ -13,11 +13,13 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('type_parameter' => ( accessor => 'type_parameter', predicate => 'has_type_parameter', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('parameterized_from' => ( accessor => 'parameterized_from', predicate => 'has_parameterized_from', + Class::MOP::_definition_context(), )); sub equals { diff --git a/lib/Moose/Meta/TypeConstraint/Registry.pm b/lib/Moose/Meta/TypeConstraint/Registry.pm index 7d0a596..59105d1 100644 --- a/lib/Moose/Meta/TypeConstraint/Registry.pm +++ b/lib/Moose/Meta/TypeConstraint/Registry.pm @@ -13,11 +13,13 @@ __PACKAGE__->meta->add_attribute('parent_registry' => ( reader => 'get_parent_registry', writer => 'set_parent_registry', predicate => 'has_parent_registry', + Class::MOP::_definition_context(), )); __PACKAGE__->meta->add_attribute('type_constraints' => ( reader => 'type_constraints', - default => sub { {} } + default => sub { {} }, + Class::MOP::_definition_context(), )); sub new { diff --git a/lib/Moose/Meta/TypeConstraint/Role.pm b/lib/Moose/Meta/TypeConstraint/Role.pm index d1e6dbc..3451f13 100644 --- a/lib/Moose/Meta/TypeConstraint/Role.pm +++ b/lib/Moose/Meta/TypeConstraint/Role.pm @@ -12,6 +12,7 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('role' => ( reader => 'role', + Class::MOP::_definition_context(), )); my $inliner = sub { diff --git a/lib/Moose/Meta/TypeConstraint/Union.pm b/lib/Moose/Meta/TypeConstraint/Union.pm index f1c0262..2ec80ab 100644 --- a/lib/Moose/Meta/TypeConstraint/Union.pm +++ b/lib/Moose/Meta/TypeConstraint/Union.pm @@ -14,7 +14,8 @@ use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('type_constraints' => ( accessor => 'type_constraints', - default => sub { [] } + default => sub { [] }, + Class::MOP::_definition_context(), )); sub new {