Profile of Class/MOP.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:42 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm
Statements | Executed 2591 statements in 9.97ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 5.53ms | 22.7ms | Class::MOP::::BEGIN@26Class::MOP::BEGIN@26
1 | 1 | 1 | 2.12ms | 2.44ms | Class::MOP::::BEGIN@27Class::MOP::BEGIN@27
1589 | 10 | 7 | 1.94ms | 1.94ms | Class::MOP::::get_metaclass_by_nameClass::MOP::get_metaclass_by_name
1 | 1 | 1 | 1.29ms | 6.06ms | Class::MOP::::BEGIN@25Class::MOP::BEGIN@25
123 | 120 | 23 | 700µs | 700µs | Class::MOP::::_definition_contextClass::MOP::_definition_context
519 | 3 | 2 | 623µs | 623µs | Class::MOP::::get_code_infoClass::MOP::get_code_info (xsub)
90 | 9 | 6 | 511µs | 580µs | Class::MOP::::class_ofClass::MOP::class_of
1 | 1 | 1 | 487µs | 625µs | Class::MOP::::BEGIN@24Class::MOP::BEGIN@24
1 | 1 | 1 | 431µs | 784µs | Class::MOP::::BEGIN@23Class::MOP::BEGIN@23
88 | 2 | 1 | 373µs | 484µs | Class::MOP::::metaclass_is_weakClass::MOP::metaclass_is_weak
80 | 2 | 2 | 190µs | 190µs | Class::MOP::::store_metaclass_by_nameClass::MOP::store_metaclass_by_name
13 | 2 | 2 | 34µs | 34µs | Class::MOP::::__ANON__[:132]Class::MOP::__ANON__[:132]
13 | 2 | 2 | 28µs | 28µs | Class::MOP::::__ANON__[:177]Class::MOP::__ANON__[:177]
13 | 2 | 2 | 27µs | 27µs | Class::MOP::::__ANON__[:222]Class::MOP::__ANON__[:222]
13 | 2 | 2 | 26µs | 26µs | Class::MOP::::__ANON__[:249]Class::MOP::__ANON__[:249]
13 | 2 | 2 | 24µs | 24µs | Class::MOP::::__ANON__[:269]Class::MOP::__ANON__[:269]
9 | 1 | 1 | 23µs | 23µs | Class::MOP::::__ANON__[:286]Class::MOP::__ANON__[:286]
9 | 2 | 2 | 23µs | 23µs | Class::MOP::::__ANON__[:478]Class::MOP::__ANON__[:478]
17 | 1 | 1 | 22µs | 22µs | Class::MOP::::__ANON__Class::MOP::__ANON__ (xsub)
1 | 1 | 1 | 18µs | 18µs | Class::MOP::::BEGIN@13Class::MOP::BEGIN@13
1 | 1 | 1 | 11µs | 41µs | Class::MOP::::BEGIN@21Class::MOP::BEGIN@21
1 | 1 | 1 | 11µs | 11µs | Class::MOP::::BEGIN@28Class::MOP::BEGIN@28
1 | 1 | 1 | 9µs | 18µs | Class::MOP::::BEGIN@18Class::MOP::BEGIN@18
1 | 1 | 1 | 8µs | 8µs | Class::MOP::::BEGIN@30Class::MOP::BEGIN@30
1 | 1 | 1 | 8µs | 8µs | Class::MOP::::load_classClass::MOP::load_class
1 | 1 | 1 | 7µs | 7µs | Class::MOP::::BEGIN@3Class::MOP::BEGIN@3
1 | 1 | 1 | 6µs | 10µs | Class::MOP::::BEGIN@20Class::MOP::BEGIN@20
1 | 1 | 1 | 6µs | 31µs | Class::MOP::::BEGIN@17Class::MOP::BEGIN@17
1 | 1 | 1 | 6µs | 8µs | Class::MOP::::BEGIN@10Class::MOP::BEGIN@10
1 | 1 | 1 | 6µs | 39µs | Class::MOP::::BEGIN@19Class::MOP::BEGIN@19
1 | 1 | 1 | 6µs | 13µs | Class::MOP::::BEGIN@11Class::MOP::BEGIN@11
1 | 1 | 1 | 5µs | 5µs | Class::MOP::::BEGIN@15Class::MOP::BEGIN@15
0 | 0 | 0 | 0s | 0s | Class::MOP::::__ANON__[:486]Class::MOP::__ANON__[:486]
0 | 0 | 0 | 0s | 0s | Class::MOP::::__ANON__[:596]Class::MOP::__ANON__[:596]
0 | 0 | 0 | 0s | 0s | Class::MOP::::does_metaclass_existClass::MOP::does_metaclass_exist
0 | 0 | 0 | 0s | 0s | Class::MOP::::get_all_metaclass_instancesClass::MOP::get_all_metaclass_instances
0 | 0 | 0 | 0s | 0s | Class::MOP::::get_all_metaclass_namesClass::MOP::get_all_metaclass_names
0 | 0 | 0 | 0s | 0s | Class::MOP::::get_all_metaclassesClass::MOP::get_all_metaclasses
0 | 0 | 0 | 0s | 0s | Class::MOP::::is_class_loadedClass::MOP::is_class_loaded
0 | 0 | 0 | 0s | 0s | Class::MOP::::load_first_existing_classClass::MOP::load_first_existing_class
0 | 0 | 0 | 0s | 0s | Class::MOP::::remove_metaclass_by_nameClass::MOP::remove_metaclass_by_name
0 | 0 | 0 | 0s | 0s | Class::MOP::::weaken_metaclassClass::MOP::weaken_metaclass

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  |
2 |  |  |  |  | package Class::MOP;
3 |  |  |  |  | # spent 7µs within Class::MOP::BEGIN@3 which was called: # once (7µs+0s) by Moose::Exporter::BEGIN@13 at line 5 BEGIN {
4 | 1 | 6µs |  |  | $Class::MOP::AUTHORITY = 'cpan:STEVAN';
5 | 1 | 20µs | 1 | 7µs | } # spent 7µs making 1 call to Class::MOP::BEGIN@3
6 |  |  |  |  | {
7 | 2 | 2µs |  |  | $Class::MOP::VERSION = '2.0602';
8 |  |  |  |  | }
9 |  |  |  |  |
10 | 3 | 15µs | 2 | 10µs | # spent 8µs (6+2) within Class::MOP::BEGIN@10 which was called: # once (6µs+2µs) by Moose::Exporter::BEGIN@13 at line 10 use strict; # spent 8µs making 1 call to Class::MOP::BEGIN@10 # spent 2µs making 1 call to strict::import
11 | 3 | 17µs | 2 | 21µs | # spent 13µs (6+8) within Class::MOP::BEGIN@11 which was called: # once (6µs+8µs) by Moose::Exporter::BEGIN@13 at line 11 use warnings; # spent 13µs making 1 call to Class::MOP::BEGIN@11 # spent 8µs making 1 call to warnings::import
12 |  |  |  |  |
13 | 3 | 30µs | 1 | 18µs | # spent 18µs within Class::MOP::BEGIN@13 which was called: # once (18µs+0s) by Moose::Exporter::BEGIN@13 at line 13 use 5.008; # spent 18µs making 1 call to Class::MOP::BEGIN@13
14 |  |  |  |  |
15 | 3 | 20µs | 1 | 5µs | # spent 5µs within Class::MOP::BEGIN@15 which was called: # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 15 use MRO::Compat; # spent 5µs making 1 call to Class::MOP::BEGIN@15
16 |  |  |  |  |
17 | 3 | 18µs | 2 | 56µs | # spent 31µs (6+25) within Class::MOP::BEGIN@17 which was called: # once (6µs+25µs) by Moose::Exporter::BEGIN@13 at line 17 use Carp 'confess'; # spent 31µs making 1 call to Class::MOP::BEGIN@17 # spent 25µs making 1 call to Exporter::import
18 | 3 | 34µs | 2 | 27µs | # spent 18µs (9+9) within Class::MOP::BEGIN@18 which was called: # once (9µs+9µs) by Moose::Exporter::BEGIN@13 at line 18 use Class::Load 0.07 (); # spent 18µs making 1 call to Class::MOP::BEGIN@18 # spent 9µs making 1 call to UNIVERSAL::VERSION
19 | 3 | 17µs | 2 | 72µs | # spent 39µs (6+33) within Class::MOP::BEGIN@19 which was called: # once (6µs+33µs) by Moose::Exporter::BEGIN@13 at line 19 use Scalar::Util 'weaken', 'isweak', 'reftype', 'blessed'; # spent 39µs making 1 call to Class::MOP::BEGIN@19 # spent 33µs making 1 call to Exporter::import
20 | 3 | 16µs | 2 | 14µs | # spent 10µs (6+4) within Class::MOP::BEGIN@20 which was called: # once (6µs+4µs) by Moose::Exporter::BEGIN@13 at line 20 use Data::OptList; # spent 10µs making 1 call to Class::MOP::BEGIN@20 # spent 4µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
21 | 3 | 18µs | 2 | 71µs | # spent 41µs (11+30) within Class::MOP::BEGIN@21 which was called: # once (11µs+30µs) by Moose::Exporter::BEGIN@13 at line 21 use Try::Tiny; # spent 41µs making 1 call to Class::MOP::BEGIN@21 # spent 30µs making 1 call to Exporter::import
22 |  |  |  |  |
23 | 3 | 82µs | 1 | 784µs | # spent 784µs (431+353) within Class::MOP::BEGIN@23 which was called: # once (431µs+353µs) by Moose::Exporter::BEGIN@13 at line 23 use Class::MOP::Mixin::AttributeCore; # spent 784µs making 1 call to Class::MOP::BEGIN@23
24 | 3 | 79µs | 1 | 625µs | # spent 625µs (487+138) within Class::MOP::BEGIN@24 which was called: # once (487µs+138µs) by Moose::Exporter::BEGIN@13 at line 24 use Class::MOP::Mixin::HasAttributes; # spent 625µs making 1 call to Class::MOP::BEGIN@24
25 | 3 | 87µs | 1 | 6.06ms | # spent 6.06ms (1.29+4.78) within Class::MOP::BEGIN@25 which was called: # once (1.29ms+4.78ms) by Moose::Exporter::BEGIN@13 at line 25 use Class::MOP::Mixin::HasMethods; # spent 6.06ms making 1 call to Class::MOP::BEGIN@25
26 | 3 | 127µs | 1 | 22.7ms | # spent 22.7ms (5.53+17.1) within Class::MOP::BEGIN@26 which was called: # once (5.53ms+17.1ms) by Moose::Exporter::BEGIN@13 at line 26 use Class::MOP::Class; # spent 22.7ms making 1 call to Class::MOP::BEGIN@26
27 | 3 | 138µs | 1 | 2.44ms | # spent 2.44ms (2.12+321µs) within Class::MOP::BEGIN@27 which was called: # once (2.12ms+321µs) by Moose::Exporter::BEGIN@13 at line 27 use Class::MOP::Attribute; # spent 2.44ms making 1 call to Class::MOP::BEGIN@27
28 | 3 | 72µs | 1 | 11µs | # spent 11µs within Class::MOP::BEGIN@28 which was called: # once (11µs+0s) by Moose::Exporter::BEGIN@13 at line 28 use Class::MOP::Method; # spent 11µs making 1 call to Class::MOP::BEGIN@28
29 |  |  |  |  |
30 |  |  |  |  | # spent 8µs within Class::MOP::BEGIN@30 which was called: # once (8µs+0s) by Moose::Exporter::BEGIN@13 at line 37 BEGIN {
31 |  |  |  |  | *IS_RUNNING_ON_5_10 = ($] < 5.009_005)
32 |  |  |  |  | ? sub () { 0 }
33 | 2 | 8µs |  |  | : sub () { 1 };
34 |  |  |  |  |
35 |  |  |  |  | # this is either part of core or set up appropriately by MRO::Compat
36 |  |  |  |  | *check_package_cache_flag = \&mro::get_pkg_gen;
37 | 1 | 2.15ms | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::BEGIN@30
38 |  |  |  |  |
39 |  |  |  |  | XSLoader::load(
40 |  |  |  |  | 'Moose',
41 | 1 | 117µs | 1 | 105µs | $Class::MOP::{VERSION} ? ${ $Class::MOP::{VERSION} } : () # spent 105µs making 1 call to XSLoader::load
42 |  |  |  |  | );
43 |  |  |  |  |
44 |  |  |  |  | {
45 |  |  |  |  | # Metaclasses are singletons, so we cache them here.
46 |  |  |  |  | # there is no need to worry about destruction though
47 |  |  |  |  | # because they should die only when the program dies.
48 |  |  |  |  | # After all, do package definitions even get reaped?
49 |  |  |  |  | # Anonymous classes manage their own destruction.
50 | 2 | 2µs |  |  | my %METAS;
51 |  |  |  |  |
52 |  |  |  |  | sub get_all_metaclasses { %METAS }
53 |  |  |  |  | sub get_all_metaclass_instances { values %METAS }
54 |  |  |  |  | sub get_all_metaclass_names { keys %METAS }
55 | 1589 | 3.34ms |  |  | # spent 1.94ms within Class::MOP::get_metaclass_by_name which was called 1589 times, avg 1µs/call: # 1404 times (1.70ms+0s) by Class::MOP::Class::initialize at line 47 of Class/MOP/Class.pm, avg 1µs/call # 73 times (67µs+0s) by Class::MOP::Class::_construct_class_instance at line 88 of Class/MOP/Class.pm, avg 919ns/call # 70 times (83µs+0s) by Class::MOP::Class::_single_metaclass_is_compatible at line 282 of Class/MOP/Class.pm, avg 1µs/call # 10 times (14µs+0s) by Class::MOP::Class::_class_metaclass_is_compatible at line 252 of Class/MOP/Class.pm, avg 1µs/call # 9 times (16µs+0s) by Moose::Meta::Class::initialize at line 79 of Moose/Meta/Class.pm, avg 2µs/call # 7 times (27µs+0s) by Moose::init_meta at line 164 of Moose.pm, avg 4µs/call # 7 times (13µs+0s) by Class::MOP::Package::initialize at line 32 of Class/MOP/Package.pm, avg 2µs/call # 4 times (13µs+0s) by Moose::Role::init_meta at line 126 of Moose/Role.pm, avg 3µs/call # 4 times (4µs+0s) by Moose::Meta::Role::initialize at line 183 of Moose/Meta/Role.pm, avg 1µs/call # once (3µs+0s) by Any::Moose::_backer_of at line 111 of Any/Moose.pm sub get_metaclass_by_name { $METAS{$_[0]} }
56 | 80 | 237µs |  |  | # spent 190µs within Class::MOP::store_metaclass_by_name which was called 80 times, avg 2µs/call: # 73 times (175µs+0s) by Class::MOP::Class::_construct_class_instance at line 113 of Class/MOP/Class.pm, avg 2µs/call # 7 times (15µs+0s) by Class::MOP::Package::initialize at line 39 of Class/MOP/Package.pm, avg 2µs/call sub store_metaclass_by_name { $METAS{$_[0]} = $_[1] }
57 |  |  |  |  | sub weaken_metaclass { weaken($METAS{$_[0]}) }
58 | 88 | 486µs | 88 | 111µs | # spent 484µs (373+111) within Class::MOP::metaclass_is_weak which was called 88 times, avg 5µs/call: # 58 times (235µs+72µs) by Class::MOP::Class::_construct_instance at line 527 of Class/MOP/Class.pm, avg 5µs/call # 30 times (138µs+39µs) by Class::MOP::Class::_inline_preserve_weak_metaclasses at line 691 of Class/MOP/Class.pm, avg 6µs/call sub metaclass_is_weak { isweak($METAS{$_[0]}) } # spent 111µs making 88 calls to Scalar::Util::isweak, avg 1µs/call
59 |  |  |  |  | sub does_metaclass_exist { exists $METAS{$_[0]} && defined $METAS{$_[0]} }
60 |  |  |  |  | sub remove_metaclass_by_name { delete $METAS{$_[0]}; return }
61 |  |  |  |  |
62 |  |  |  |  | # This handles instances as well as class names
63 |  |  |  |  | # spent 580µs (511+69) within Class::MOP::class_of which was called 90 times, avg 6µs/call: # 26 times (107µs+15µs) by Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:42] at line 42 of Moose/Exporter.pm, avg 5µs/call # 15 times (112µs+16µs) by Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:225] at line 225 of Moose/Exporter.pm, avg 9µs/call # 11 times (47µs+7µs) by Moose::Meta::Class::excludes_role at line 258 of Moose/Meta/Class.pm, avg 5µs/call # 11 times (46µs+8µs) by Class::MOP::Class::_superclasses_updated at line 970 of Class/MOP/Class.pm, avg 5µs/call # 10 times (101µs+7µs) by Moose::Meta::Class::superclasses at line 555 of Moose/Meta/Class.pm, avg 11µs/call # 9 times (29µs+4µs) by Moose::Meta::Attribute::BEGIN@24 at line 712 of Moose/Util/TypeConstraints.pm, avg 4µs/call # 4 times (27µs+4µs) by Moose::Util::find_meta at line 47 of Moose/Util.pm, avg 8µs/call # 3 times (35µs+5µs) by Moose::Meta::Class::does_role at line 238 of Moose/Meta/Class.pm, avg 14µs/call # once (7µs+1µs) by Class::MOP::Object::_new at line 24 of Class/MOP/Object.pm sub class_of {
64 | 270 | 687µs |  |  | return unless defined $_[0];
65 |  |  | 90 | 69µs | my $class = blessed($_[0]) || $_[0]; # spent 69µs making 90 calls to Scalar::Util::blessed, avg 764ns/call
66 |  |  |  |  | return $METAS{$class};
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | # NOTE:
70 |  |  |  |  | # We only cache metaclasses, meaning instances of
71 |  |  |  |  | # Class::MOP::Class. We do not cache instance of
72 |  |  |  |  | # Class::MOP::Package or Class::MOP::Module. Mostly
73 |  |  |  |  | # because I don't yet see a good reason to do so.
74 |  |  |  |  | }
75 |  |  |  |  |
76 |  |  |  |  | # spent 8µs within Class::MOP::load_class which was called: # once (8µs+0s) by MooseX::Traits::Util::resolve_traits at line 49 of MooseX/Traits/Util.pm sub load_class {
77 | 1 | 17µs | 1 | 110µs | goto &Class::Load::load_class; # spent 110µs making 1 call to Class::Load::load_class
78 |  |  |  |  | }
79 |  |  |  |  |
80 |  |  |  |  | sub load_first_existing_class {
81 |  |  |  |  | goto &Class::Load::load_first_existing_class;
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | sub is_class_loaded {
85 |  |  |  |  | goto &Class::Load::is_class_loaded;
86 |  |  |  |  | }
87 |  |  |  |  |
88 |  |  |  |  | # spent 700µs within Class::MOP::_definition_context which was called 123 times, avg 6µs/call: # 3 times (18µs+0s) by Moose::BEGIN@36 at line 309 of Moose/Meta/Role.pm, avg 6µs/call # 2 times (17µs+0s) by Moose::BEGIN@36 at line 92 of Moose/Meta/Role.pm, avg 8µs/call # once (12µs+0s) by Moose::Meta::TypeCoercion::BEGIN@14 at line 31 of Moose/Meta/Attribute.pm # once (11µs+0s) by Moose::BEGIN@30 at line 32 of Moose/Meta/TypeCoercion.pm # once (11µs+0s) by Moose::BEGIN@28 at line 38 of Moose/Meta/Class.pm # once (10µs+0s) by Moose::Util::TypeConstraints::BEGIN@33 at line 24 of Moose/Meta/TypeConstraint/Union.pm # once (10µs+0s) by Moose::Exporter::BEGIN@13 at line 133 # once (10µs+0s) by Moose::BEGIN@39 at line 22 of Moose/Meta/Role/Application/RoleSummation.pm # once (10µs+0s) by Moose::BEGIN@29 at line 28 of Moose/Meta/TypeConstraint.pm # once (10µs+0s) by Moose::BEGIN@30 at line 20 of Moose/Meta/TypeCoercion.pm # once (10µs+0s) by Moose::BEGIN@29 at line 112 of Moose/Meta/TypeConstraint.pm # once (10µs+0s) by Moose::BEGIN@40 at line 19 of Moose/Meta/Role/Application/ToClass.pm # once (9µs+0s) by Moose::Util::TypeConstraints::BEGIN@42 at line 18 of Moose/Meta/TypeConstraint/Registry.pm # once (9µs+0s) by Moose::BEGIN@38 at line 17 of Moose/Meta/Role/Application.pm # once (9µs+0s) by Moose::Util::TypeConstraints::BEGIN@36 at line 19 of Moose/Meta/TypeConstraint/Class.pm # once (9µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 19 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (9µs+0s) by Moose::Meta::Role::BEGIN@19 at line 18 of Moose/Meta/Role/Attribute.pm # once (9µs+0s) by Moose::BEGIN@37 at line 24 of Moose/Meta/Role/Composite.pm # once (9µs+0s) by Moose::BEGIN@42 at line 21 of Moose/Meta/Role/Application/ToInstance.pm # once (9µs+0s) by Moose::Util::TypeConstraints::BEGIN@38 at line 18 of Moose/Meta/TypeConstraint/Enum.pm # once (9µs+0s) by Moose::Meta::Role::BEGIN@21 at line 22 of Moose/Meta/Role/Method/Required.pm # once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@37 at line 19 of Moose/Meta/TypeConstraint/Role.pm # once (8µs+0s) by Moose::Meta::Role::BEGIN@22 at line 17 of Moose/Meta/Role/Method/Conflicting.pm # once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@39 at line 22 of Moose/Meta/TypeConstraint/DuckType.pm # once (7µs+0s) by Moose::BEGIN@29 at line 46 of Moose/Meta/TypeConstraint.pm # once (7µs+0s) by base::import at line 14 of Moose/Meta/Mixin/AttributeCore.pm # once (6µs+0s) by Moose::Exporter::BEGIN@13 at line 534 # once (6µs+0s) by Moose::BEGIN@29 at line 32 of Moose/Meta/TypeConstraint.pm # once (6µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 19 of Moose/Meta/TypeConstraint/Parameterized.pm # once (6µs+0s) by Moose::Exporter::BEGIN@13 at line 137 # once (6µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 25 of Moose/Meta/TypeConstraint/Parameterized.pm # once (6µs+0s) by Moose::Meta::Role::BEGIN@19 at line 25 of Moose/Meta/Role/Attribute.pm # once (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 460 # once (5µs+0s) by Moose::BEGIN@40 at line 24 of Moose/Meta/Role/Application/ToClass.pm # once (5µs+0s) by Moose::BEGIN@28 at line 44 of Moose/Meta/Class.pm # once (5µs+0s) by Moose::BEGIN@37 at line 37 of Moose/Meta/Role/Composite.pm # once (5µs+0s) by Moose::Util::TypeConstraints::BEGIN@42 at line 28 of Moose/Meta/TypeConstraint/Registry.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 490 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 355 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 562 # once (5µs+0s) by Moose::BEGIN@38 at line 24 of Moose/Meta/Role/Application.pm # once (5µs+0s) by Moose::BEGIN@29 at line 102 of Moose/Meta/TypeConstraint.pm # once (5µs+0s) by Moose::BEGIN@30 at line 23 of Moose/Meta/TypeCoercion.pm # once (5µs+0s) by Moose::Util::TypeConstraints::BEGIN@38 at line 23 of Moose/Meta/TypeConstraint/Enum.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 250 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 618 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 572 # once (5µs+0s) by Moose::BEGIN@28 at line 55 of Moose/Meta/Class.pm # once (5µs+0s) by Moose::BEGIN@36 at line 128 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::Meta::Role::BEGIN@19 at line 32 of Moose/Meta/Role/Attribute.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 198 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 543 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 291 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 649 # once (5µs+0s) by Moose::BEGIN@36 at line 155 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::BEGIN@36 at line 134 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::BEGIN@36 at line 401 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 370 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 287 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 479 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 625 # once (5µs+0s) by Moose::BEGIN@29 at line 118 of Moose/Meta/TypeConstraint.pm # once (5µs+0s) by Moose::BEGIN@28 at line 61 of Moose/Meta/Class.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 178 # once (5µs+0s) by Moose::BEGIN@29 at line 78 of Moose/Meta/TypeConstraint.pm # once (5µs+0s) by Moose::BEGIN@29 at line 43 of Moose/Meta/TypeConstraint.pm # once (5µs+0s) by Moose::BEGIN@36 at line 148 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::BEGIN@36 at line 355 of Moose/Meta/Role.pm # once (5µs+0s) by Moose::Meta::Role::BEGIN@19 at line 46 of Moose/Meta/Role/Attribute.pm # once (5µs+0s) by Moose::BEGIN@37 at line 40 of Moose/Meta/Role/Composite.pm # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 581 # once (5µs+0s) by Moose::Exporter::BEGIN@13 at line 417 # once (4µs+0s) by Moose::BEGIN@29 at line 91 of Moose/Meta/TypeConstraint.pm # once (4µs+0s) by Moose::BEGIN@29 at line 52 of Moose/Meta/TypeConstraint.pm # once (4µs+0s) by Moose::Meta::Role::BEGIN@19 at line 39 of Moose/Meta/Role/Attribute.pm # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 433 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 551 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 504 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 223 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 150 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 441 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 511 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 378 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 497 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 597 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 270 # once (4µs+0s) by Moose::BEGIN@28 at line 47 of Moose/Meta/Class.pm # once (4µs+0s) by Moose::BEGIN@36 at line 169 of Moose/Meta/Role.pm # once (4µs+0s) by Moose::BEGIN@36 at line 141 of Moose/Meta/Role.pm # once (4µs+0s) by Moose::BEGIN@29 at line 84 of Moose/Meta/TypeConstraint.pm # once (4µs+0s) by Moose::BEGIN@36 at line 162 of Moose/Meta/Role.pm # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 386 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 401 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 182 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 394 # once (4µs+0s) by base::import at line 21 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 327 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 635 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 601 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 307 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 425 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 409 # once (4µs+0s) by Moose::BEGIN@28 at line 67 of Moose/Meta/Class.pm # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 338 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 518 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 317 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 642 # once (4µs+0s) by Moose::Exporter::BEGIN@13 at line 449 # once (4µs+0s) by base::import at line 84 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 48 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 101 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 69 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 92 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 35 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 28 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 42 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 62 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 55 of Moose/Meta/Mixin/AttributeCore.pm # once (4µs+0s) by base::import at line 76 of Moose/Meta/Mixin/AttributeCore.pm sub _definition_context {
89 | 369 | 904µs |  |  | my %context;
90 |  |  |  |  | @context{qw(package file line)} = caller(1);
91 |  |  |  |  |
92 |  |  |  |  | return (
93 |  |  |  |  | definition_context => \%context,
94 |  |  |  |  | );
95 |  |  |  |  | }
96 |  |  |  |  |
97 |  |  |  |  | ## ----------------------------------------------------------------------------
98 |  |  |  |  | ## Setting up our environment ...
99 |  |  |  |  | ## ----------------------------------------------------------------------------
100 |  |  |  |  | ## Class::MOP needs to have a few things in the global perl environment so
101 |  |  |  |  | ## that it can operate effectively. Those things are done here.
102 |  |  |  |  | ## ----------------------------------------------------------------------------
103 |  |  |  |  |
104 |  |  |  |  | # ... nothing yet actually ;)
105 |  |  |  |  |
106 |  |  |  |  | ## ----------------------------------------------------------------------------
107 |  |  |  |  | ## Bootstrapping
108 |  |  |  |  | ## ----------------------------------------------------------------------------
109 |  |  |  |  | ## The code below here is to bootstrap our MOP with itself. This is also
110 |  |  |  |  | ## sometimes called "tying the knot". By doing this, we make it much easier
111 |  |  |  |  | ## to extend the MOP through subclassing and such since now you can use the
112 |  |  |  |  | ## MOP itself to extend itself.
113 |  |  |  |  | ##
114 |  |  |  |  | ## Yes, I know, thats weird and insane, but it's a good thing, trust me :)
115 |  |  |  |  | ## ----------------------------------------------------------------------------
116 |  |  |  |  |
117 |  |  |  |  | # We need to add in the meta-attributes here so that
118 |  |  |  |  | # any subclass of Class::MOP::* will be able to
119 |  |  |  |  | # inherit them using _construct_instance
120 |  |  |  |  |
121 |  |  |  |  | ## --------------------------------------------------------
122 |  |  |  |  | ## Class::MOP::Mixin::HasMethods
123 |  |  |  |  |
124 |  |  |  |  | Class::MOP::Mixin::HasMethods->meta->add_attribute(
125 |  |  |  |  | Class::MOP::Attribute->new('_methods' => (
126 |  |  |  |  | reader => {
127 |  |  |  |  | # NOTE:
128 |  |  |  |  | # we just alias the original method
129 |  |  |  |  | # rather than re-produce it here
130 |  |  |  |  | '_method_map' => \&Class::MOP::Mixin::HasMethods::_method_map
131 |  |  |  |  | },
132 | 13 | 44µs |  |  | # spent 34µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:132] which was called 13 times, avg 3µs/call: # 9 times (23µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 3µs/call # 4 times (11µs+0s) by Moose::Meta::Role::_new at line 15 of (eval 189)[Eval/Closure.pm:125], avg 3µs/call default => sub { {} },
133 | 1 | 26µs | 4 | 1.40ms | _definition_context(), # spent 700µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 636µs making 1 call to Class::MOP::Mixin::meta # spent 53µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::_definition_context
134 |  |  |  |  | ))
135 |  |  |  |  | );
136 |  |  |  |  |
137 | 1 | 11µs | 4 | 284µs | Class::MOP::Mixin::HasMethods->meta->add_attribute( # spent 240µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 24µs making 1 call to Class::MOP::Attribute::new # spent 14µs making 1 call to Class::MOP::Mixin::meta # spent 6µs making 1 call to Class::MOP::_definition_context
138 |  |  |  |  | Class::MOP::Attribute->new('method_metaclass' => (
139 |  |  |  |  | reader => {
140 |  |  |  |  | # NOTE:
141 |  |  |  |  | # we just alias the original method
142 |  |  |  |  | # rather than re-produce it here
143 |  |  |  |  | 'method_metaclass' => \&Class::MOP::Mixin::HasMethods::method_metaclass
144 |  |  |  |  | },
145 |  |  |  |  | default => 'Class::MOP::Method',
146 |  |  |  |  | _definition_context(),
147 |  |  |  |  | ))
148 |  |  |  |  | );
149 |  |  |  |  |
150 | 1 | 10µs | 4 | 255µs | Class::MOP::Mixin::HasMethods->meta->add_attribute( # spent 223µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
151 |  |  |  |  | Class::MOP::Attribute->new('wrapped_method_metaclass' => (
152 |  |  |  |  | reader => {
153 |  |  |  |  | # NOTE:
154 |  |  |  |  | # we just alias the original method
155 |  |  |  |  | # rather than re-produce it here
156 |  |  |  |  | 'wrapped_method_metaclass' => \&Class::MOP::Mixin::HasMethods::wrapped_method_metaclass
157 |  |  |  |  | },
158 |  |  |  |  | default => 'Class::MOP::Method::Wrapped',
159 |  |  |  |  | _definition_context(),
160 |  |  |  |  | ))
161 |  |  |  |  | );
162 |  |  |  |  |
163 |  |  |  |  | ## --------------------------------------------------------
164 |  |  |  |  | ## Class::MOP::Mixin::HasMethods
165 |  |  |  |  |
166 |  |  |  |  | Class::MOP::Mixin::HasAttributes->meta->add_attribute(
167 |  |  |  |  | Class::MOP::Attribute->new('attributes' => (
168 |  |  |  |  | reader => {
169 |  |  |  |  | # NOTE: we need to do this in order
170 |  |  |  |  | # for the instance meta-object to
171 |  |  |  |  | # not fall into meta-circular death
172 |  |  |  |  | #
173 |  |  |  |  | # we just alias the original method
174 |  |  |  |  | # rather than re-produce it here
175 |  |  |  |  | '_attribute_map' => \&Class::MOP::Mixin::HasAttributes::_attribute_map
176 |  |  |  |  | },
177 | 13 | 43µs |  |  | # spent 28µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:177] which was called 13 times, avg 2µs/call: # 9 times (20µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call # 4 times (8µs+0s) by Moose::Meta::Role::_new at line 63 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call default => sub { {} },
178 | 1 | 15µs | 4 | 584µs | _definition_context(), # spent 319µs making 1 call to Class::MOP::Mixin::meta # spent 233µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 27µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
179 |  |  |  |  | ))
180 |  |  |  |  | );
181 |  |  |  |  |
182 | 1 | 10µs | 4 | 251µs | Class::MOP::Mixin::HasAttributes->meta->add_attribute( # spent 220µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
183 |  |  |  |  | Class::MOP::Attribute->new('attribute_metaclass' => (
184 |  |  |  |  | reader => {
185 |  |  |  |  | # NOTE:
186 |  |  |  |  | # we just alias the original method
187 |  |  |  |  | # rather than re-produce it here
188 |  |  |  |  | 'attribute_metaclass' => \&Class::MOP::Mixin::HasAttributes::attribute_metaclass
189 |  |  |  |  | },
190 |  |  |  |  | default => 'Class::MOP::Attribute',
191 |  |  |  |  | _definition_context(),
192 |  |  |  |  | ))
193 |  |  |  |  | );
194 |  |  |  |  |
195 |  |  |  |  | ## --------------------------------------------------------
196 |  |  |  |  | ## Class::MOP::Package
197 |  |  |  |  |
198 | 1 | 14µs | 4 | 618µs | Class::MOP::Package->meta->add_attribute( # spent 355µs making 1 call to Class::MOP::Object::meta # spent 242µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
199 |  |  |  |  | Class::MOP::Attribute->new('package' => (
200 |  |  |  |  | reader => {
201 |  |  |  |  | # NOTE: we need to do this in order
202 |  |  |  |  | # for the instance meta-object to
203 |  |  |  |  | # not fall into meta-circular death
204 |  |  |  |  | #
205 |  |  |  |  | # we just alias the original method
206 |  |  |  |  | # rather than re-produce it here
207 |  |  |  |  | 'name' => \&Class::MOP::Package::name
208 |  |  |  |  | },
209 |  |  |  |  | _definition_context(),
210 |  |  |  |  | ))
211 |  |  |  |  | );
212 |  |  |  |  |
213 |  |  |  |  | Class::MOP::Package->meta->add_attribute(
214 |  |  |  |  | Class::MOP::Attribute->new('namespace' => (
215 |  |  |  |  | reader => {
216 |  |  |  |  | # NOTE:
217 |  |  |  |  | # we just alias the original method
218 |  |  |  |  | # rather than re-produce it here
219 |  |  |  |  | 'namespace' => \&Class::MOP::Package::namespace
220 |  |  |  |  | },
221 |  |  |  |  | init_arg => undef,
222 | 13 | 45µs |  |  | # spent 27µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:222] which was called 13 times, avg 2µs/call: # 9 times (20µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call # 4 times (7µs+0s) by Moose::Meta::Role::_new at line 93 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call default => sub { \undef },
223 | 1 | 12µs | 4 | 300µs | _definition_context(), # spent 263µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 22µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
224 |  |  |  |  | ))
225 |  |  |  |  | );
226 |  |  |  |  |
227 |  |  |  |  | ## --------------------------------------------------------
228 |  |  |  |  | ## Class::MOP::Module
229 |  |  |  |  |
230 |  |  |  |  | # NOTE:
231 |  |  |  |  | # yeah this is kind of stretching things a bit,
232 |  |  |  |  | # but truthfully the version should be an attribute
233 |  |  |  |  | # of the Module, the weirdness comes from having to
234 |  |  |  |  | # stick to Perl 5 convention and store it in the
235 |  |  |  |  | # $VERSION package variable. Basically if you just
236 |  |  |  |  | # squint at it, it will look how you want it to look.
237 |  |  |  |  | # Either as a package variable, or as a attribute of
238 |  |  |  |  | # the metaclass, isn't abstraction great :)
239 |  |  |  |  |
240 |  |  |  |  | Class::MOP::Module->meta->add_attribute(
241 |  |  |  |  | Class::MOP::Attribute->new('version' => (
242 |  |  |  |  | reader => {
243 |  |  |  |  | # NOTE:
244 |  |  |  |  | # we just alias the original method
245 |  |  |  |  | # rather than re-produce it here
246 |  |  |  |  | 'version' => \&Class::MOP::Module::version
247 |  |  |  |  | },
248 |  |  |  |  | init_arg => undef,
249 | 13 | 38µs |  |  | # spent 26µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:249] which was called 13 times, avg 2µs/call: # 9 times (20µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call # 4 times (7µs+0s) by Moose::Meta::Role::_new at line 123 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call default => sub { \undef },
250 | 1 | 17µs | 4 | 567µs | _definition_context(), # spent 295µs making 1 call to Class::MOP::Object::meta # spent 243µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 23µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
251 |  |  |  |  | ))
252 |  |  |  |  | );
253 |  |  |  |  |
254 |  |  |  |  | # NOTE:
255 |  |  |  |  | # By following the same conventions as version here,
256 |  |  |  |  | # we are opening up the possibility that people can
257 |  |  |  |  | # use the $AUTHORITY in non-Class::MOP modules as
258 |  |  |  |  | # well.
259 |  |  |  |  |
260 |  |  |  |  | Class::MOP::Module->meta->add_attribute(
261 |  |  |  |  | Class::MOP::Attribute->new('authority' => (
262 |  |  |  |  | reader => {
263 |  |  |  |  | # NOTE:
264 |  |  |  |  | # we just alias the original method
265 |  |  |  |  | # rather than re-produce it here
266 |  |  |  |  | 'authority' => \&Class::MOP::Module::authority
267 |  |  |  |  | },
268 |  |  |  |  | init_arg => undef,
269 | 13 | 42µs |  |  | # spent 24µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:269] which was called 13 times, avg 2µs/call: # 9 times (16µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call # 4 times (8µs+0s) by Moose::Meta::Role::_new at line 66 of (eval 189)[Eval/Closure.pm:125], avg 2µs/call default => sub { \undef },
270 | 1 | 12µs | 4 | 250µs | _definition_context(), # spent 215µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
271 |  |  |  |  | ))
272 |  |  |  |  | );
273 |  |  |  |  |
274 |  |  |  |  | ## --------------------------------------------------------
275 |  |  |  |  | ## Class::MOP::Class
276 |  |  |  |  |
277 |  |  |  |  | Class::MOP::Class->meta->add_attribute(
278 |  |  |  |  | Class::MOP::Attribute->new('superclasses' => (
279 |  |  |  |  | accessor => {
280 |  |  |  |  | # NOTE:
281 |  |  |  |  | # we just alias the original method
282 |  |  |  |  | # rather than re-produce it here
283 |  |  |  |  | 'superclasses' => \&Class::MOP::Class::superclasses
284 |  |  |  |  | },
285 |  |  |  |  | init_arg => undef,
286 | 9 | 36µs |  |  | # spent 23µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:286] which was called 9 times, avg 3µs/call: # 9 times (23µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 3µs/call default => sub { \undef },
287 | 1 | 15µs | 4 | 913µs | _definition_context(), # spent 573µs making 1 call to Class::MOP::Object::meta # spent 311µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 25µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
288 |  |  |  |  | ))
289 |  |  |  |  | );
290 |  |  |  |  |
291 | 1 | 8µs | 4 | 230µs | Class::MOP::Class->meta->add_attribute( # spent 197µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Attribute::new # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
292 |  |  |  |  | Class::MOP::Attribute->new('instance_metaclass' => (
293 |  |  |  |  | reader => {
294 |  |  |  |  | # NOTE: we need to do this in order
295 |  |  |  |  | # for the instance meta-object to
296 |  |  |  |  | # not fall into meta-circular death
297 |  |  |  |  | #
298 |  |  |  |  | # we just alias the original method
299 |  |  |  |  | # rather than re-produce it here
300 |  |  |  |  | 'instance_metaclass' => \&Class::MOP::Class::instance_metaclass
301 |  |  |  |  | },
302 |  |  |  |  | default => 'Class::MOP::Instance',
303 |  |  |  |  | _definition_context(),
304 |  |  |  |  | ))
305 |  |  |  |  | );
306 |  |  |  |  |
307 | 1 | 7µs | 4 | 221µs | Class::MOP::Class->meta->add_attribute( # spent 188µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 19µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
308 |  |  |  |  | Class::MOP::Attribute->new('immutable_trait' => (
309 |  |  |  |  | reader => {
310 |  |  |  |  | 'immutable_trait' => \&Class::MOP::Class::immutable_trait
311 |  |  |  |  | },
312 |  |  |  |  | default => "Class::MOP::Class::Immutable::Trait",
313 |  |  |  |  | _definition_context(),
314 |  |  |  |  | ))
315 |  |  |  |  | );
316 |  |  |  |  |
317 | 1 | 7µs | 4 | 225µs | Class::MOP::Class->meta->add_attribute( # spent 195µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
318 |  |  |  |  | Class::MOP::Attribute->new('constructor_name' => (
319 |  |  |  |  | reader => {
320 |  |  |  |  | 'constructor_name' => \&Class::MOP::Class::constructor_name,
321 |  |  |  |  | },
322 |  |  |  |  | default => "new",
323 |  |  |  |  | _definition_context(),
324 |  |  |  |  | ))
325 |  |  |  |  | );
326 |  |  |  |  |
327 | 1 | 7µs | 4 | 221µs | Class::MOP::Class->meta->add_attribute( # spent 191µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
328 |  |  |  |  | Class::MOP::Attribute->new('constructor_class' => (
329 |  |  |  |  | reader => {
330 |  |  |  |  | 'constructor_class' => \&Class::MOP::Class::constructor_class,
331 |  |  |  |  | },
332 |  |  |  |  | default => "Class::MOP::Method::Constructor",
333 |  |  |  |  | _definition_context(),
334 |  |  |  |  | ))
335 |  |  |  |  | );
336 |  |  |  |  |
337 |  |  |  |  |
338 | 1 | 7µs | 4 | 217µs | Class::MOP::Class->meta->add_attribute( # spent 189µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
339 |  |  |  |  | Class::MOP::Attribute->new('destructor_class' => (
340 |  |  |  |  | reader => {
341 |  |  |  |  | 'destructor_class' => \&Class::MOP::Class::destructor_class,
342 |  |  |  |  | },
343 |  |  |  |  | _definition_context(),
344 |  |  |  |  | ))
345 |  |  |  |  | );
346 |  |  |  |  |
347 |  |  |  |  | # NOTE:
348 |  |  |  |  | # we don't actually need to tie the knot with
349 |  |  |  |  | # Class::MOP::Class here, it is actually handled
350 |  |  |  |  | # within Class::MOP::Class itself in the
351 |  |  |  |  | # _construct_class_instance method.
352 |  |  |  |  |
353 |  |  |  |  | ## --------------------------------------------------------
354 |  |  |  |  | ## Class::MOP::Mixin::AttributeCore
355 | 1 | 11µs | 4 | 560µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 300µs making 1 call to Class::MOP::Mixin::meta # spent 237µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
356 |  |  |  |  | Class::MOP::Attribute->new('name' => (
357 |  |  |  |  | reader => {
358 |  |  |  |  | # NOTE: we need to do this in order
359 |  |  |  |  | # for the instance meta-object to
360 |  |  |  |  | # not fall into meta-circular death
361 |  |  |  |  | #
362 |  |  |  |  | # we just alias the original method
363 |  |  |  |  | # rather than re-produce it here
364 |  |  |  |  | 'name' => \&Class::MOP::Mixin::AttributeCore::name
365 |  |  |  |  | },
366 |  |  |  |  | _definition_context(),
367 |  |  |  |  | ))
368 |  |  |  |  | );
369 |  |  |  |  |
370 | 1 | 8µs | 4 | 398µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 360µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 23µs making 1 call to Class::MOP::Attribute::new # spent 11µs making 1 call to Class::MOP::Mixin::meta # spent 5µs making 1 call to Class::MOP::_definition_context
371 |  |  |  |  | Class::MOP::Attribute->new('accessor' => (
372 |  |  |  |  | reader => { 'accessor' => \&Class::MOP::Mixin::AttributeCore::accessor },
373 |  |  |  |  | predicate => { 'has_accessor' => \&Class::MOP::Mixin::AttributeCore::has_accessor },
374 |  |  |  |  | _definition_context(),
375 |  |  |  |  | ))
376 |  |  |  |  | );
377 |  |  |  |  |
378 | 1 | 8µs | 4 | 351µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 314µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 22µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
379 |  |  |  |  | Class::MOP::Attribute->new('reader' => (
380 |  |  |  |  | reader => { 'reader' => \&Class::MOP::Mixin::AttributeCore::reader },
381 |  |  |  |  | predicate => { 'has_reader' => \&Class::MOP::Mixin::AttributeCore::has_reader },
382 |  |  |  |  | _definition_context(),
383 |  |  |  |  | ))
384 |  |  |  |  | );
385 |  |  |  |  |
386 | 1 | 8µs | 4 | 357µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 322µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
387 |  |  |  |  | Class::MOP::Attribute->new('initializer' => (
388 |  |  |  |  | reader => { 'initializer' => \&Class::MOP::Mixin::AttributeCore::initializer },
389 |  |  |  |  | predicate => { 'has_initializer' => \&Class::MOP::Mixin::AttributeCore::has_initializer },
390 |  |  |  |  | _definition_context(),
391 |  |  |  |  | ))
392 |  |  |  |  | );
393 |  |  |  |  |
394 | 1 | 7µs | 4 | 240µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 204µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
395 |  |  |  |  | Class::MOP::Attribute->new('definition_context' => (
396 |  |  |  |  | reader => { 'definition_context' => \&Class::MOP::Mixin::AttributeCore::definition_context },
397 |  |  |  |  | _definition_context(),
398 |  |  |  |  | ))
399 |  |  |  |  | );
400 |  |  |  |  |
401 | 1 | 8µs | 4 | 357µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 321µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
402 |  |  |  |  | Class::MOP::Attribute->new('writer' => (
403 |  |  |  |  | reader => { 'writer' => \&Class::MOP::Mixin::AttributeCore::writer },
404 |  |  |  |  | predicate => { 'has_writer' => \&Class::MOP::Mixin::AttributeCore::has_writer },
405 |  |  |  |  | _definition_context(),
406 |  |  |  |  | ))
407 |  |  |  |  | );
408 |  |  |  |  |
409 | 1 | 8µs | 4 | 346µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 311µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
410 |  |  |  |  | Class::MOP::Attribute->new('predicate' => (
411 |  |  |  |  | reader => { 'predicate' => \&Class::MOP::Mixin::AttributeCore::predicate },
412 |  |  |  |  | predicate => { 'has_predicate' => \&Class::MOP::Mixin::AttributeCore::has_predicate },
413 |  |  |  |  | _definition_context(),
414 |  |  |  |  | ))
415 |  |  |  |  | );
416 |  |  |  |  |
417 | 1 | 8µs | 4 | 360µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 321µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 24µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 5µs making 1 call to Class::MOP::_definition_context
418 |  |  |  |  | Class::MOP::Attribute->new('clearer' => (
419 |  |  |  |  | reader => { 'clearer' => \&Class::MOP::Mixin::AttributeCore::clearer },
420 |  |  |  |  | predicate => { 'has_clearer' => \&Class::MOP::Mixin::AttributeCore::has_clearer },
421 |  |  |  |  | _definition_context(),
422 |  |  |  |  | ))
423 |  |  |  |  | );
424 |  |  |  |  |
425 | 1 | 7µs | 4 | 353µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 318µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
426 |  |  |  |  | Class::MOP::Attribute->new('builder' => (
427 |  |  |  |  | reader => { 'builder' => \&Class::MOP::Mixin::AttributeCore::builder },
428 |  |  |  |  | predicate => { 'has_builder' => \&Class::MOP::Mixin::AttributeCore::has_builder },
429 |  |  |  |  | _definition_context(),
430 |  |  |  |  | ))
431 |  |  |  |  | );
432 |  |  |  |  |
433 | 1 | 8µs | 4 | 372µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 319µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 27µs making 1 call to Class::MOP::Mixin::meta # spent 22µs making 1 call to Class::MOP::Attribute::new # spent 4µs making 1 call to Class::MOP::_definition_context
434 |  |  |  |  | Class::MOP::Attribute->new('init_arg' => (
435 |  |  |  |  | reader => { 'init_arg' => \&Class::MOP::Mixin::AttributeCore::init_arg },
436 |  |  |  |  | predicate => { 'has_init_arg' => \&Class::MOP::Mixin::AttributeCore::has_init_arg },
437 |  |  |  |  | _definition_context(),
438 |  |  |  |  | ))
439 |  |  |  |  | );
440 |  |  |  |  |
441 | 1 | 8µs | 4 | 244µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 209µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
442 |  |  |  |  | Class::MOP::Attribute->new('default' => (
443 |  |  |  |  | # default has a custom 'reader' method ...
444 |  |  |  |  | predicate => { 'has_default' => \&Class::MOP::Mixin::AttributeCore::has_default },
445 |  |  |  |  | _definition_context(),
446 |  |  |  |  | ))
447 |  |  |  |  | );
448 |  |  |  |  |
449 | 1 | 9µs | 4 | 476µs | Class::MOP::Mixin::AttributeCore->meta->add_attribute( # spent 436µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 26µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Mixin::meta # spent 4µs making 1 call to Class::MOP::_definition_context
450 |  |  |  |  | Class::MOP::Attribute->new('insertion_order' => (
451 |  |  |  |  | reader => { 'insertion_order' => \&Class::MOP::Mixin::AttributeCore::insertion_order },
452 |  |  |  |  | writer => { '_set_insertion_order' => \&Class::MOP::Mixin::AttributeCore::_set_insertion_order },
453 |  |  |  |  | predicate => { 'has_insertion_order' => \&Class::MOP::Mixin::AttributeCore::has_insertion_order },
454 |  |  |  |  | _definition_context(),
455 |  |  |  |  | ))
456 |  |  |  |  | );
457 |  |  |  |  |
458 |  |  |  |  | ## --------------------------------------------------------
459 |  |  |  |  | ## Class::MOP::Attribute
460 | 1 | 12µs | 4 | 734µs | Class::MOP::Attribute->meta->add_attribute( # spent 456µs making 1 call to Class::MOP::Object::meta # spent 249µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 23µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
461 |  |  |  |  | Class::MOP::Attribute->new('associated_class' => (
462 |  |  |  |  | reader => {
463 |  |  |  |  | # NOTE: we need to do this in order
464 |  |  |  |  | # for the instance meta-object to
465 |  |  |  |  | # not fall into meta-circular death
466 |  |  |  |  | #
467 |  |  |  |  | # we just alias the original method
468 |  |  |  |  | # rather than re-produce it here
469 |  |  |  |  | 'associated_class' => \&Class::MOP::Attribute::associated_class
470 |  |  |  |  | },
471 |  |  |  |  | _definition_context(),
472 |  |  |  |  | ))
473 |  |  |  |  | );
474 |  |  |  |  |
475 |  |  |  |  | Class::MOP::Attribute->meta->add_attribute(
476 |  |  |  |  | Class::MOP::Attribute->new('associated_methods' => (
477 |  |  |  |  | reader => { 'associated_methods' => \&Class::MOP::Attribute::associated_methods },
478 | 9 | 55µs |  |  | # spent 23µs within Class::MOP::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP.pm:478] which was called 9 times, avg 3µs/call: # 8 times (21µs+0s) by Moose::Meta::Attribute::_new at line 21 of (eval 156)[Eval/Closure.pm:125], avg 3µs/call # once (2µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm default => sub { [] },
479 | 1 | 9µs | 4 | 239µs | _definition_context(), # spent 194µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 29µs making 1 call to Class::MOP::Attribute::new # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
480 |  |  |  |  | ))
481 |  |  |  |  | );
482 |  |  |  |  |
483 |  |  |  |  | Class::MOP::Attribute->meta->add_method('clone' => sub {
484 |  |  |  |  | my $self = shift;
485 |  |  |  |  | $self->meta->clone_object($self, @_);
486 | 1 | 5µs | 2 | 69µs | }); # spent 60µs making 1 call to Class::MOP::Mixin::HasMethods::add_method # spent 10µs making 1 call to Class::MOP::Object::meta
487 |  |  |  |  |
488 |  |  |  |  | ## --------------------------------------------------------
489 |  |  |  |  | ## Class::MOP::Method
490 | 1 | 11µs | 4 | 519µs | Class::MOP::Method->meta->add_attribute( # spent 269µs making 1 call to Class::MOP::Object::meta # spent 225µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
491 |  |  |  |  | Class::MOP::Attribute->new('body' => (
492 |  |  |  |  | reader => { 'body' => \&Class::MOP::Method::body },
493 |  |  |  |  | _definition_context(),
494 |  |  |  |  | ))
495 |  |  |  |  | );
496 |  |  |  |  |
497 | 1 | 7µs | 4 | 353µs | Class::MOP::Method->meta->add_attribute( # spent 323µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 11µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
498 |  |  |  |  | Class::MOP::Attribute->new('associated_metaclass' => (
499 |  |  |  |  | reader => { 'associated_metaclass' => \&Class::MOP::Method::associated_metaclass },
500 |  |  |  |  | _definition_context(),
501 |  |  |  |  | ))
502 |  |  |  |  | );
503 |  |  |  |  |
504 | 1 | 7µs | 4 | 371µs | Class::MOP::Method->meta->add_attribute( # spent 342µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
505 |  |  |  |  | Class::MOP::Attribute->new('package_name' => (
506 |  |  |  |  | reader => { 'package_name' => \&Class::MOP::Method::package_name },
507 |  |  |  |  | _definition_context(),
508 |  |  |  |  | ))
509 |  |  |  |  | );
510 |  |  |  |  |
511 | 1 | 7µs | 4 | 334µs | Class::MOP::Method->meta->add_attribute( # spent 304µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
512 |  |  |  |  | Class::MOP::Attribute->new('name' => (
513 |  |  |  |  | reader => { 'name' => \&Class::MOP::Method::name },
514 |  |  |  |  | _definition_context(),
515 |  |  |  |  | ))
516 |  |  |  |  | );
517 |  |  |  |  |
518 | 1 | 9µs | 4 | 610µs | Class::MOP::Method->meta->add_attribute( # spent 575µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
519 |  |  |  |  | Class::MOP::Attribute->new('original_method' => (
520 |  |  |  |  | reader => { 'original_method' => \&Class::MOP::Method::original_method },
521 |  |  |  |  | writer => { '_set_original_method' => \&Class::MOP::Method::_set_original_method },
522 |  |  |  |  | _definition_context(),
523 |  |  |  |  | ))
524 |  |  |  |  | );
525 |  |  |  |  |
526 |  |  |  |  | ## --------------------------------------------------------
527 |  |  |  |  | ## Class::MOP::Method::Wrapped
528 |  |  |  |  |
529 |  |  |  |  | # NOTE:
530 |  |  |  |  | # the way this item is initialized, this
531 |  |  |  |  | # really does not follow the standard
532 |  |  |  |  | # practices of attributes, but we put
533 |  |  |  |  | # it here for completeness
534 | 1 | 11µs | 4 | 433µs | Class::MOP::Method::Wrapped->meta->add_attribute( # spent 310µs making 1 call to Class::MOP::Object::meta # spent 99µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Class::MOP::Attribute::new # spent 6µs making 1 call to Class::MOP::_definition_context
535 |  |  |  |  | Class::MOP::Attribute->new('modifier_table' => (
536 |  |  |  |  | _definition_context(),
537 |  |  |  |  | ))
538 |  |  |  |  | );
539 |  |  |  |  |
540 |  |  |  |  | ## --------------------------------------------------------
541 |  |  |  |  | ## Class::MOP::Method::Generated
542 |  |  |  |  |
543 | 1 | 12µs | 4 | 590µs | Class::MOP::Method::Generated->meta->add_attribute( # spent 322µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 246µs making 1 call to Class::MOP::Object::meta # spent 18µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
544 |  |  |  |  | Class::MOP::Attribute->new('is_inline' => (
545 |  |  |  |  | reader => { 'is_inline' => \&Class::MOP::Method::Generated::is_inline },
546 |  |  |  |  | default => 0,
547 |  |  |  |  | _definition_context(),
548 |  |  |  |  | ))
549 |  |  |  |  | );
550 |  |  |  |  |
551 | 1 | 7µs | 4 | 333µs | Class::MOP::Method::Generated->meta->add_attribute( # spent 302µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
552 |  |  |  |  | Class::MOP::Attribute->new('definition_context' => (
553 |  |  |  |  | reader => { 'definition_context' => \&Class::MOP::Method::Generated::definition_context },
554 |  |  |  |  | _definition_context(),
555 |  |  |  |  | ))
556 |  |  |  |  | );
557 |  |  |  |  |
558 |  |  |  |  |
559 |  |  |  |  | ## --------------------------------------------------------
560 |  |  |  |  | ## Class::MOP::Method::Inlined
561 |  |  |  |  |
562 | 1 | 12µs | 4 | 603µs | Class::MOP::Method::Inlined->meta->add_attribute( # spent 317µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 265µs making 1 call to Class::MOP::Object::meta # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
563 |  |  |  |  | Class::MOP::Attribute->new('_expected_method_class' => (
564 |  |  |  |  | reader => { '_expected_method_class' => \&Class::MOP::Method::Inlined::_expected_method_class },
565 |  |  |  |  | _definition_context(),
566 |  |  |  |  | ))
567 |  |  |  |  | );
568 |  |  |  |  |
569 |  |  |  |  | ## --------------------------------------------------------
570 |  |  |  |  | ## Class::MOP::Method::Accessor
571 |  |  |  |  |
572 | 1 | 12µs | 4 | 532µs | Class::MOP::Method::Accessor->meta->add_attribute( # spent 282µs making 1 call to Class::MOP::Object::meta # spent 227µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 18µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
573 |  |  |  |  | Class::MOP::Attribute->new('attribute' => (
574 |  |  |  |  | reader => {
575 |  |  |  |  | 'associated_attribute' => \&Class::MOP::Method::Accessor::associated_attribute
576 |  |  |  |  | },
577 |  |  |  |  | _definition_context(),
578 |  |  |  |  | ))
579 |  |  |  |  | );
580 |  |  |  |  |
581 | 1 | 7µs | 4 | 324µs | Class::MOP::Method::Accessor->meta->add_attribute( # spent 294µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
582 |  |  |  |  | Class::MOP::Attribute->new('accessor_type' => (
583 |  |  |  |  | reader => { 'accessor_type' => \&Class::MOP::Method::Accessor::accessor_type },
584 |  |  |  |  | _definition_context(),
585 |  |  |  |  | ))
586 |  |  |  |  | );
587 |  |  |  |  |
588 |  |  |  |  | ## --------------------------------------------------------
589 |  |  |  |  | ## Class::MOP::Method::Constructor
590 |  |  |  |  |
591 |  |  |  |  | Class::MOP::Method::Constructor->meta->add_attribute(
592 |  |  |  |  | Class::MOP::Attribute->new('options' => (
593 |  |  |  |  | reader => {
594 |  |  |  |  | 'options' => \&Class::MOP::Method::Constructor::options
595 |  |  |  |  | },
596 |  |  |  |  | default => sub { +{} },
597 | 1 | 14µs | 4 | 609µs | _definition_context(), # spent 317µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 263µs making 1 call to Class::MOP::Object::meta # spent 25µs making 1 call to Class::MOP::Attribute::new # spent 4µs making 1 call to Class::MOP::_definition_context
598 |  |  |  |  | ))
599 |  |  |  |  | );
600 |  |  |  |  |
601 | 1 | 7µs | 4 | 227µs | Class::MOP::Method::Constructor->meta->add_attribute( # spent 197µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
602 |  |  |  |  | Class::MOP::Attribute->new('associated_metaclass' => (
603 |  |  |  |  | init_arg => "metaclass", # FIXME alias and rename
604 |  |  |  |  | reader => {
605 |  |  |  |  | 'associated_metaclass' => \&Class::MOP::Method::Constructor::associated_metaclass
606 |  |  |  |  | },
607 |  |  |  |  | _definition_context(),
608 |  |  |  |  | ))
609 |  |  |  |  | );
610 |  |  |  |  |
611 |  |  |  |  | ## --------------------------------------------------------
612 |  |  |  |  | ## Class::MOP::Instance
613 |  |  |  |  |
614 |  |  |  |  | # NOTE:
615 |  |  |  |  | # these don't yet do much of anything, but are just
616 |  |  |  |  | # included for completeness
617 |  |  |  |  |
618 | 1 | 11µs | 4 | 519µs | Class::MOP::Instance->meta->add_attribute( # spent 262µs making 1 call to Class::MOP::Object::meta # spent 235µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 16µs making 1 call to Class::MOP::Attribute::new # spent 5µs making 1 call to Class::MOP::_definition_context
619 |  |  |  |  | Class::MOP::Attribute->new('associated_metaclass',
620 |  |  |  |  | reader => { associated_metaclass => \&Class::MOP::Instance::associated_metaclass },
621 |  |  |  |  | _definition_context(),
622 |  |  |  |  | ),
623 |  |  |  |  | );
624 |  |  |  |  |
625 | 1 | 7µs | 4 | 224µs | Class::MOP::Instance->meta->add_attribute( # spent 194µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
626 |  |  |  |  | Class::MOP::Attribute->new('_class_name',
627 |  |  |  |  | init_arg => undef,
628 |  |  |  |  | reader => { _class_name => \&Class::MOP::Instance::_class_name },
629 |  |  |  |  | #lazy => 1, # not yet supported by Class::MOP but out our version does it anyway
630 |  |  |  |  | #default => sub { $_[0]->associated_metaclass->name },
631 |  |  |  |  | _definition_context(),
632 |  |  |  |  | ),
633 |  |  |  |  | );
634 |  |  |  |  |
635 | 1 | 7µs | 4 | 232µs | Class::MOP::Instance->meta->add_attribute( # spent 197µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
636 |  |  |  |  | Class::MOP::Attribute->new('attributes',
637 |  |  |  |  | reader => { attributes => \&Class::MOP::Instance::get_all_attributes },
638 |  |  |  |  | _definition_context(),
639 |  |  |  |  | ),
640 |  |  |  |  | );
641 |  |  |  |  |
642 | 1 | 13µs | 4 | 254µs | Class::MOP::Instance->meta->add_attribute( # spent 226µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
643 |  |  |  |  | Class::MOP::Attribute->new('slots',
644 |  |  |  |  | reader => { slots => \&Class::MOP::Instance::slots },
645 |  |  |  |  | _definition_context(),
646 |  |  |  |  | ),
647 |  |  |  |  | );
648 |  |  |  |  |
649 | 1 | 10µs | 4 | 249µs | Class::MOP::Instance->meta->add_attribute( # spent 219µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 15µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
650 |  |  |  |  | Class::MOP::Attribute->new('slot_hash',
651 |  |  |  |  | reader => { slot_hash => \&Class::MOP::Instance::slot_hash },
652 |  |  |  |  | _definition_context(),
653 |  |  |  |  | ),
654 |  |  |  |  | );
655 |  |  |  |  |
656 |  |  |  |  | ## --------------------------------------------------------
657 |  |  |  |  | ## Class::MOP::Object
658 |  |  |  |  |
659 |  |  |  |  | # need to replace the meta method there with a real meta method object
660 | 1 | 14µs | 2 | 1.32ms | Class::MOP::Object->meta->_add_meta_method('meta'); # spent 1.31ms making 1 call to Class::MOP::Mixin::HasMethods::_add_meta_method # spent 10µs making 1 call to Class::MOP::Object::meta
661 |  |  |  |  |
662 |  |  |  |  | ## --------------------------------------------------------
663 |  |  |  |  | ## Class::MOP::Mixin
664 |  |  |  |  |
665 |  |  |  |  | # need to replace the meta method there with a real meta method object
666 | 1 | 11µs | 2 | 553µs | Class::MOP::Mixin->meta->_add_meta_method('meta'); # spent 539µs making 1 call to Class::MOP::Mixin::HasMethods::_add_meta_method # spent 14µs making 1 call to Class::MOP::Mixin::meta
667 |  |  |  |  |
668 | 1 | 142µs |  |  | require Class::MOP::Deprecated unless our $no_deprecated;
669 |  |  |  |  |
670 |  |  |  |  | # we need the meta instance of the meta instance to be created now, in order
671 |  |  |  |  | # for the constructor to be able to use it
672 | 1 | 6µs | 2 | 144µs | Class::MOP::Instance->meta->get_meta_instance; # spent 130µs making 1 call to Class::MOP::Class::get_meta_instance # spent 14µs making 1 call to Class::MOP::Object::meta
673 |  |  |  |  |
674 |  |  |  |  | # pretend the add_method never happenned. it hasn't yet affected anything
675 | 1 | 2µs | 1 | 9µs | undef Class::MOP::Instance->meta->{_package_cache_flag}; # spent 9µs making 1 call to Class::MOP::Object::meta
676 |  |  |  |  |
677 |  |  |  |  | ## --------------------------------------------------------
678 |  |  |  |  | ## Now close all the Class::MOP::* classes
679 |  |  |  |  |
680 |  |  |  |  | # NOTE: we don't need to inline the the accessors this only lengthens
681 |  |  |  |  | # the compile time of the MOP, and gives us no actual benefits.
682 |  |  |  |  |
683 |  |  |  |  | $_->meta->make_immutable(
684 |  |  |  |  | inline_constructor => 0,
685 |  |  |  |  | constructor_name => "_new",
686 |  |  |  |  | inline_accessors => 0,
687 | 1 | 80µs | 28 | 14.6ms | ) for qw/ # spent 14.1ms making 14 calls to Class::MOP::Class::make_immutable, avg 1.01ms/call # spent 523µs making 14 calls to Class::MOP::Object::meta, avg 37µs/call
688 |  |  |  |  | Class::MOP::Package
689 |  |  |  |  | Class::MOP::Module
690 |  |  |  |  | Class::MOP::Class
691 |  |  |  |  |
692 |  |  |  |  | Class::MOP::Attribute
693 |  |  |  |  | Class::MOP::Method
694 |  |  |  |  | Class::MOP::Instance
695 |  |  |  |  |
696 |  |  |  |  | Class::MOP::Object
697 |  |  |  |  |
698 |  |  |  |  | Class::MOP::Method::Generated
699 |  |  |  |  | Class::MOP::Method::Inlined
700 |  |  |  |  |
701 |  |  |  |  | Class::MOP::Method::Accessor
702 |  |  |  |  | Class::MOP::Method::Constructor
703 |  |  |  |  | Class::MOP::Method::Wrapped
704 |  |  |  |  |
705 |  |  |  |  | Class::MOP::Method::Meta
706 |  |  |  |  | Class::MOP::Method::Overload
707 | 1 | 200ns |  |  | /;
708 |  |  |  |  |
709 |  |  |  |  | $_->meta->make_immutable(
710 |  |  |  |  | inline_constructor => 0,
711 |  |  |  |  | constructor_name => undef,
712 |  |  |  |  | inline_accessors => 0,
713 | 1 | 24µs | 8 | 420µs | ) for qw/ # spent 381µs making 4 calls to Class::MOP::Class::make_immutable, avg 95µs/call # spent 40µs making 4 calls to Class::MOP::Mixin::meta, avg 10µs/call
714 |  |  |  |  | Class::MOP::Mixin
715 |  |  |  |  | Class::MOP::Mixin::AttributeCore
716 |  |  |  |  | Class::MOP::Mixin::HasAttributes
717 |  |  |  |  | Class::MOP::Mixin::HasMethods
718 | 1 | 200ns |  |  | /;
719 |  |  |  |  |
720 | 1 | 171µs |  |  | 1;
721 |  |  |  |  |
722 |  |  |  |  | # ABSTRACT: A Meta Object Protocol for Perl 5
723 |  |  |  |  |
- - |  |  |  |  |
726 |  |  |  |  | =pod
727 |  |  |  |  |
728 |  |  |  |  | =head1 NAME
729 |  |  |  |  |
730 |  |  |  |  | Class::MOP - A Meta Object Protocol for Perl 5
731 |  |  |  |  |
732 |  |  |  |  | =head1 VERSION
733 |  |  |  |  |
734 |  |  |  |  | version 2.0602
735 |  |  |  |  |
736 |  |  |  |  | =head1 DESCRIPTION
737 |  |  |  |  |
738 |  |  |  |  | This module is a fully functioning meta object protocol for the
739 |  |  |  |  | Perl 5 object system. It makes no attempt to change the behavior or
740 |  |  |  |  | characteristics of the Perl 5 object system, only to create a
741 |  |  |  |  | protocol for its manipulation and introspection.
742 |  |  |  |  |
743 |  |  |  |  | That said, it does attempt to create the tools for building a rich set
744 |  |  |  |  | of extensions to the Perl 5 object system. Every attempt has been made
745 |  |  |  |  | to abide by the spirit of the Perl 5 object system that we all know
746 |  |  |  |  | and love.
747 |  |  |  |  |
748 |  |  |  |  | This documentation is sparse on conceptual details. We suggest looking
749 |  |  |  |  | at the items listed in the L<SEE ALSO> section for more
750 |  |  |  |  | information. In particular the book "The Art of the Meta Object
751 |  |  |  |  | Protocol" was very influential in the development of this system.
752 |  |  |  |  |
753 |  |  |  |  | =head2 What is a Meta Object Protocol?
754 |  |  |  |  |
755 |  |  |  |  | A meta object protocol is an API to an object system.
756 |  |  |  |  |
757 |  |  |  |  | To be more specific, it abstracts the components of an object system
758 |  |  |  |  | (classes, object, methods, object attributes, etc.). These
759 |  |  |  |  | abstractions can then be used to inspect and manipulate the object
760 |  |  |  |  | system which they describe.
761 |  |  |  |  |
762 |  |  |  |  | It can be said that there are two MOPs for any object system; the
763 |  |  |  |  | implicit MOP and the explicit MOP. The implicit MOP handles things
764 |  |  |  |  | like method dispatch or inheritance, which happen automatically as
765 |  |  |  |  | part of how the object system works. The explicit MOP typically
766 |  |  |  |  | handles the introspection/reflection features of the object system.
767 |  |  |  |  |
768 |  |  |  |  | All object systems have implicit MOPs. Without one, they would not
769 |  |  |  |  | work. Explicit MOPs are much less common, and depending on the
770 |  |  |  |  | language can vary from restrictive (Reflection in Java or C#) to wide
771 |  |  |  |  | open (CLOS is a perfect example).
772 |  |  |  |  |
773 |  |  |  |  | =head2 Yet Another Class Builder! Why?
774 |  |  |  |  |
775 |  |  |  |  | This is B<not> a class builder so much as a I<class builder
776 |  |  |  |  | B<builder>>. The intent is that an end user will not use this module
777 |  |  |  |  | directly, but instead this module is used by module authors to build
778 |  |  |  |  | extensions and features onto the Perl 5 object system.
779 |  |  |  |  |
780 |  |  |  |  | This system is used by L<Moose>, which supplies a powerful class
781 |  |  |  |  | builder system built entirely on top of C<Class::MOP>.
782 |  |  |  |  |
783 |  |  |  |  | =head2 Who is this module for?
784 |  |  |  |  |
785 |  |  |  |  | This module is for anyone who has ever created or wanted to create a
786 |  |  |  |  | module for the Class:: namespace. The tools which this module provides
787 |  |  |  |  | make doing complex Perl 5 wizardry simpler, by removing such barriers
788 |  |  |  |  | as the need to hack symbol tables, or understand the fine details of
789 |  |  |  |  | method dispatch.
790 |  |  |  |  |
791 |  |  |  |  | =head2 What changes do I have to make to use this module?
792 |  |  |  |  |
793 |  |  |  |  | This module was designed to be as unintrusive as possible. Many of its
794 |  |  |  |  | features are accessible without B<any> change to your existing
795 |  |  |  |  | code. It is meant to be a complement to your existing code and not an
796 |  |  |  |  | intrusion on your code base. Unlike many other B<Class::> modules,
797 |  |  |  |  | this module B<does not> require you subclass it, or even that you
798 |  |  |  |  | C<use> it in within your module's package.
799 |  |  |  |  |
800 |  |  |  |  | The only features which require additions to your code are the
801 |  |  |  |  | attribute handling and instance construction features, and these are
802 |  |  |  |  | both completely optional features. The only reason for this is because
803 |  |  |  |  | Perl 5's object system does not actually have these features built
804 |  |  |  |  | in. More information about this feature can be found below.
805 |  |  |  |  |
806 |  |  |  |  | =head2 About Performance
807 |  |  |  |  |
808 |  |  |  |  | It is a common misconception that explicit MOPs are a performance hit.
809 |  |  |  |  | This is not a universal truth, it is a side-effect of some specific
810 |  |  |  |  | implementations. For instance, using Java reflection is slow because
811 |  |  |  |  | the JVM cannot take advantage of any compiler optimizations, and the
812 |  |  |  |  | JVM has to deal with much more runtime type information as well.
813 |  |  |  |  |
814 |  |  |  |  | Reflection in C# is marginally better as it was designed into the
815 |  |  |  |  | language and runtime (the CLR). In contrast, CLOS (the Common Lisp
816 |  |  |  |  | Object System) was built to support an explicit MOP, and so
817 |  |  |  |  | performance is tuned for it.
818 |  |  |  |  |
819 |  |  |  |  | This library in particular does its absolute best to avoid putting
820 |  |  |  |  | B<any> drain at all upon your code's performance. In fact, by itself
821 |  |  |  |  | it does nothing to affect your existing code. So you only pay for what
822 |  |  |  |  | you actually use.
823 |  |  |  |  |
824 |  |  |  |  | =head2 About Metaclass compatibility
825 |  |  |  |  |
826 |  |  |  |  | This module makes sure that all metaclasses created are both upwards
827 |  |  |  |  | and downwards compatible. The topic of metaclass compatibility is
828 |  |  |  |  | highly esoteric and is something only encountered when doing deep and
829 |  |  |  |  | involved metaclass hacking. There are two basic kinds of metaclass
830 |  |  |  |  | incompatibility; upwards and downwards.
831 |  |  |  |  |
832 |  |  |  |  | Upwards metaclass compatibility means that the metaclass of a
833 |  |  |  |  | given class is either the same as (or a subclass of) all of the
834 |  |  |  |  | class's ancestors.
835 |  |  |  |  |
836 |  |  |  |  | Downward metaclass compatibility means that the metaclasses of a
837 |  |  |  |  | given class's ancestors are all the same as (or a subclass of) that
838 |  |  |  |  | metaclass.
839 |  |  |  |  |
840 |  |  |  |  | Here is a diagram showing a set of two classes (C<A> and C<B>) and
841 |  |  |  |  | two metaclasses (C<Meta::A> and C<Meta::B>) which have correct
842 |  |  |  |  | metaclass compatibility both upwards and downwards.
843 |  |  |  |  |
844 |  |  |  |  | +---------+ +---------+
845 |  |  |  |  | | Meta::A |<----| Meta::B | <....... (instance of )
846 |  |  |  |  | +---------+ +---------+ <------- (inherits from)
847 |  |  |  |  | ^ ^
848 |  |  |  |  | : :
849 |  |  |  |  | +---------+ +---------+
850 |  |  |  |  | | A |<----| B |
851 |  |  |  |  | +---------+ +---------+
852 |  |  |  |  |
853 |  |  |  |  | In actuality, I<all> of a class's metaclasses must be compatible,
854 |  |  |  |  | not just the class metaclass. That includes the instance, attribute,
855 |  |  |  |  | and method metaclasses, as well as the constructor and destructor
856 |  |  |  |  | classes.
857 |  |  |  |  |
858 |  |  |  |  | C<Class::MOP> will attempt to fix some simple types of
859 |  |  |  |  | incompatibilities. If all the metaclasses for the parent class are
860 |  |  |  |  | I<subclasses> of the child's metaclasses then we can simply replace
861 |  |  |  |  | the child's metaclasses with the parent's. In addition, if the child
862 |  |  |  |  | is missing a metaclass that the parent has, we can also just make the
863 |  |  |  |  | child use the parent's metaclass.
864 |  |  |  |  |
865 |  |  |  |  | As I said this is a highly esoteric topic and one you will only run
866 |  |  |  |  | into if you do a lot of subclassing of L<Class::MOP::Class>. If you
867 |  |  |  |  | are interested in why this is an issue see the paper I<Uniform and
868 |  |  |  |  | safe metaclass composition> linked to in the L<SEE ALSO> section of
869 |  |  |  |  | this document.
870 |  |  |  |  |
871 |  |  |  |  | =head2 Using custom metaclasses
872 |  |  |  |  |
873 |  |  |  |  | Always use the L<metaclass> pragma when using a custom metaclass, this
874 |  |  |  |  | will ensure the proper initialization order and not accidentally
875 |  |  |  |  | create an incorrect type of metaclass for you. This is a very rare
876 |  |  |  |  | problem, and one which can only occur if you are doing deep metaclass
877 |  |  |  |  | programming. So in other words, don't worry about it.
878 |  |  |  |  |
879 |  |  |  |  | Note that if you're using L<Moose> we encourage you to I<not> use the
880 |  |  |  |  | L<metaclass> pragma, and instead use L<Moose::Util::MetaRole> to apply
881 |  |  |  |  | roles to a class's metaclasses. This topic is covered at length in
882 |  |  |  |  | various L<Moose::Cookbook> recipes.
883 |  |  |  |  |
884 |  |  |  |  | =head1 PROTOCOLS
885 |  |  |  |  |
886 |  |  |  |  | The meta-object protocol is divided into 4 main sub-protocols:
887 |  |  |  |  |
888 |  |  |  |  | =head2 The Class protocol
889 |  |  |  |  |
890 |  |  |  |  | This provides a means of manipulating and introspecting a Perl 5
891 |  |  |  |  | class. It handles symbol table hacking for you, and provides a rich
892 |  |  |  |  | set of methods that go beyond simple package introspection.
893 |  |  |  |  |
894 |  |  |  |  | See L<Class::MOP::Class> for more details.
895 |  |  |  |  |
896 |  |  |  |  | =head2 The Attribute protocol
897 |  |  |  |  |
898 |  |  |  |  | This provides a consistent representation for an attribute of a Perl 5
899 |  |  |  |  | class. Since there are so many ways to create and handle attributes in
900 |  |  |  |  | Perl 5 OO, the Attribute protocol provide as much of a unified
901 |  |  |  |  | approach as possible. Of course, you are always free to extend this
902 |  |  |  |  | protocol by subclassing the appropriate classes.
903 |  |  |  |  |
904 |  |  |  |  | See L<Class::MOP::Attribute> for more details.
905 |  |  |  |  |
906 |  |  |  |  | =head2 The Method protocol
907 |  |  |  |  |
908 |  |  |  |  | This provides a means of manipulating and introspecting methods in the
909 |  |  |  |  | Perl 5 object system. As with attributes, there are many ways to
910 |  |  |  |  | approach this topic, so we try to keep it pretty basic, while still
911 |  |  |  |  | making it possible to extend the system in many ways.
912 |  |  |  |  |
913 |  |  |  |  | See L<Class::MOP::Method> for more details.
914 |  |  |  |  |
915 |  |  |  |  | =head2 The Instance protocol
916 |  |  |  |  |
917 |  |  |  |  | This provides a layer of abstraction for creating object instances.
918 |  |  |  |  | Since the other layers use this protocol, it is relatively easy to
919 |  |  |  |  | change the type of your instances from the default hash reference to
920 |  |  |  |  | some other type of reference. Several examples are provided in the
921 |  |  |  |  | F<examples/> directory included in this distribution.
922 |  |  |  |  |
923 |  |  |  |  | See L<Class::MOP::Instance> for more details.
924 |  |  |  |  |
925 |  |  |  |  | =head1 FUNCTIONS
926 |  |  |  |  |
927 |  |  |  |  | Note that this module does not export any constants or functions.
928 |  |  |  |  |
929 |  |  |  |  | =head2 Utility functions
930 |  |  |  |  |
931 |  |  |  |  | Note that these are all called as B<functions, not methods>.
932 |  |  |  |  |
933 |  |  |  |  | =over 4
934 |  |  |  |  |
935 |  |  |  |  | =item B<Class::MOP::get_code_info($code)>
936 |  |  |  |  |
937 |  |  |  |  | This function returns two values, the name of the package the C<$code>
938 |  |  |  |  | is from and the name of the C<$code> itself. This is used by several
939 |  |  |  |  | elements of the MOP to determine where a given C<$code> reference is
940 |  |  |  |  | from.
941 |  |  |  |  |
942 |  |  |  |  | =item B<Class::MOP::class_of($instance_or_class_name)>
943 |  |  |  |  |
944 |  |  |  |  | This will return the metaclass of the given instance or class name. If the
945 |  |  |  |  | class lacks a metaclass, no metaclass will be initialized, and C<undef> will be
946 |  |  |  |  | returned.
947 |  |  |  |  |
948 |  |  |  |  | =back
949 |  |  |  |  |
950 |  |  |  |  | =head2 Metaclass cache functions
951 |  |  |  |  |
952 |  |  |  |  | C<Class::MOP> holds a cache of metaclasses. The following are functions
953 |  |  |  |  | (B<not methods>) which can be used to access that cache. It is not
954 |  |  |  |  | recommended that you mess with these. Bad things could happen, but if
955 |  |  |  |  | you are brave and willing to risk it: go for it!
956 |  |  |  |  |
957 |  |  |  |  | =over 4
958 |  |  |  |  |
959 |  |  |  |  | =item B<Class::MOP::get_all_metaclasses>
960 |  |  |  |  |
961 |  |  |  |  | This will return a hash of all the metaclass instances that have
962 |  |  |  |  | been cached by L<Class::MOP::Class>, keyed by the package name.
963 |  |  |  |  |
964 |  |  |  |  | =item B<Class::MOP::get_all_metaclass_instances>
965 |  |  |  |  |
966 |  |  |  |  | This will return a list of all the metaclass instances that have
967 |  |  |  |  | been cached by L<Class::MOP::Class>.
968 |  |  |  |  |
969 |  |  |  |  | =item B<Class::MOP::get_all_metaclass_names>
970 |  |  |  |  |
971 |  |  |  |  | This will return a list of all the metaclass names that have
972 |  |  |  |  | been cached by L<Class::MOP::Class>.
973 |  |  |  |  |
974 |  |  |  |  | =item B<Class::MOP::get_metaclass_by_name($name)>
975 |  |  |  |  |
976 |  |  |  |  | This will return a cached L<Class::MOP::Class> instance, or nothing
977 |  |  |  |  | if no metaclass exists with that C<$name>.
978 |  |  |  |  |
979 |  |  |  |  | =item B<Class::MOP::store_metaclass_by_name($name, $meta)>
980 |  |  |  |  |
981 |  |  |  |  | This will store a metaclass in the cache at the supplied C<$key>.
982 |  |  |  |  |
983 |  |  |  |  | =item B<Class::MOP::weaken_metaclass($name)>
984 |  |  |  |  |
985 |  |  |  |  | In rare cases (e.g. anonymous metaclasses) it is desirable to
986 |  |  |  |  | store a weakened reference in the metaclass cache. This
987 |  |  |  |  | function will weaken the reference to the metaclass stored
988 |  |  |  |  | in C<$name>.
989 |  |  |  |  |
990 |  |  |  |  | =item B<Class::MOP::metaclass_is_weak($name)>
991 |  |  |  |  |
992 |  |  |  |  | Returns true if the metaclass for C<$name> has been weakened
993 |  |  |  |  | (via C<weaken_metaclass>).
994 |  |  |  |  |
995 |  |  |  |  | =item B<Class::MOP::does_metaclass_exist($name)>
996 |  |  |  |  |
997 |  |  |  |  | This will return true of there exists a metaclass stored in the
998 |  |  |  |  | C<$name> key, and return false otherwise.
999 |  |  |  |  |
1000 |  |  |  |  | =item B<Class::MOP::remove_metaclass_by_name($name)>
1001 |  |  |  |  |
1002 |  |  |  |  | This will remove the metaclass stored in the C<$name> key.
1003 |  |  |  |  |
1004 |  |  |  |  | =back
1005 |  |  |  |  |
1006 |  |  |  |  | Some utility functions (such as C<Class::MOP::load_class>) that were
1007 |  |  |  |  | previously defined in C<Class::MOP> regarding loading of classes have been
1008 |  |  |  |  | extracted to L<Class::Load>. Please see L<Class::Load> for documentation.
1009 |  |  |  |  |
1010 |  |  |  |  | =head1 SEE ALSO
1011 |  |  |  |  |
1012 |  |  |  |  | =head2 Books
1013 |  |  |  |  |
1014 |  |  |  |  | There are very few books out on Meta Object Protocols and Metaclasses
1015 |  |  |  |  | because it is such an esoteric topic. The following books are really
1016 |  |  |  |  | the only ones I have found. If you know of any more, B<I<please>>
1017 |  |  |  |  | email me and let me know, I would love to hear about them.
1018 |  |  |  |  |
1019 |  |  |  |  | =over 4
1020 |  |  |  |  |
1021 |  |  |  |  | =item I<The Art of the Meta Object Protocol>
1022 |  |  |  |  |
1023 |  |  |  |  | =item I<Advances in Object-Oriented Metalevel Architecture and Reflection>
1024 |  |  |  |  |
1025 |  |  |  |  | =item I<Putting MetaClasses to Work>
1026 |  |  |  |  |
1027 |  |  |  |  | =item I<Smalltalk: The Language>
1028 |  |  |  |  |
1029 |  |  |  |  | =back
1030 |  |  |  |  |
1031 |  |  |  |  | =head2 Papers
1032 |  |  |  |  |
1033 |  |  |  |  | =over 4
1034 |  |  |  |  |
1035 |  |  |  |  | =item "Uniform and safe metaclass composition"
1036 |  |  |  |  |
1037 |  |  |  |  | An excellent paper by the people who brought us the original Traits paper.
1038 |  |  |  |  | This paper is on how Traits can be used to do safe metaclass composition,
1039 |  |  |  |  | and offers an excellent introduction section which delves into the topic of
1040 |  |  |  |  | metaclass compatibility.
1041 |  |  |  |  |
1042 |  |  |  |  | L<http://scg.unibe.ch/archive/papers/Duca05ySafeMetaclassTrait.pdf>
1043 |  |  |  |  |
1044 |  |  |  |  | =item "Safe Metaclass Programming"
1045 |  |  |  |  |
1046 |  |  |  |  | This paper seems to precede the above paper, and propose a mix-in based
1047 |  |  |  |  | approach as opposed to the Traits based approach. Both papers have similar
1048 |  |  |  |  | information on the metaclass compatibility problem space.
1049 |  |  |  |  |
1050 |  |  |  |  | L<http://citeseer.ist.psu.edu/37617.html>
1051 |  |  |  |  |
1052 |  |  |  |  | =back
1053 |  |  |  |  |
1054 |  |  |  |  | =head2 Prior Art
1055 |  |  |  |  |
1056 |  |  |  |  | =over 4
1057 |  |  |  |  |
1058 |  |  |  |  | =item The Perl 6 MetaModel work in the Pugs project
1059 |  |  |  |  |
1060 |  |  |  |  | =over 4
1061 |  |  |  |  |
1062 |  |  |  |  | =item L<http://svn.openfoundry.org/pugs/misc/Perl-MetaModel/>
1063 |  |  |  |  |
1064 |  |  |  |  | =item L<http://github.com/perl6/p5-modules/tree/master/Perl6-ObjectSpace/>
1065 |  |  |  |  |
1066 |  |  |  |  | =back
1067 |  |  |  |  |
1068 |  |  |  |  | =back
1069 |  |  |  |  |
1070 |  |  |  |  | =head2 Articles
1071 |  |  |  |  |
1072 |  |  |  |  | =over 4
1073 |  |  |  |  |
1074 |  |  |  |  | =item CPAN Module Review of Class::MOP
1075 |  |  |  |  |
1076 |  |  |  |  | L<http://www.oreillynet.com/onlamp/blog/2006/06/cpan_module_review_classmop.html>
1077 |  |  |  |  |
1078 |  |  |  |  | =back
1079 |  |  |  |  |
1080 |  |  |  |  | =head1 SIMILAR MODULES
1081 |  |  |  |  |
1082 |  |  |  |  | As I have said above, this module is a class-builder-builder, so it is
1083 |  |  |  |  | not the same thing as modules like L<Class::Accessor> and
1084 |  |  |  |  | L<Class::MethodMaker>. That being said there are very few modules on CPAN
1085 |  |  |  |  | with similar goals to this module. The one I have found which is most
1086 |  |  |  |  | like this module is L<Class::Meta>, although its philosophy and the MOP it
1087 |  |  |  |  | creates are very different from this modules.
1088 |  |  |  |  |
1089 |  |  |  |  | =head1 BUGS
1090 |  |  |  |  |
1091 |  |  |  |  | All complex software has bugs lurking in it, and this module is no
1092 |  |  |  |  | exception.
1093 |  |  |  |  |
1094 |  |  |  |  | Please report any bugs to C<bug-class-mop@rt.cpan.org>, or through the
1095 |  |  |  |  | web interface at L<http://rt.cpan.org>.
1096 |  |  |  |  |
1097 |  |  |  |  | You can also discuss feature requests or possible bugs on the Moose
1098 |  |  |  |  | mailing list (moose@perl.org) or on IRC at
1099 |  |  |  |  | L<irc://irc.perl.org/#moose>.
1100 |  |  |  |  |
1101 |  |  |  |  | =head1 ACKNOWLEDGEMENTS
1102 |  |  |  |  |
1103 |  |  |  |  | =over 4
1104 |  |  |  |  |
1105 |  |  |  |  | =item Rob Kinyon
1106 |  |  |  |  |
1107 |  |  |  |  | Thanks to Rob for actually getting the development of this module kick-started.
1108 |  |  |  |  |
1109 |  |  |  |  | =back
1110 |  |  |  |  |
1111 |  |  |  |  | =head1 AUTHOR
1112 |  |  |  |  |
1113 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
1114 |  |  |  |  |
1115 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
1116 |  |  |  |  |
1117 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
1118 |  |  |  |  |
1119 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
1120 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
1121 |  |  |  |  |
1122 |  |  |  |  | =cut
1123 |  |  |  |  |
1124 |  |  |  |  |
1125 |  |  |  |  | __END__
|  |  |  |  | # spent 22µs within Class::MOP::__ANON__ which was called 17 times, avg 1µs/call: # 17 times (22µs+0s) by Class::MOP::Class::class_precedence_list at line 1006 of Class/MOP/Class.pm, avg 1µs/call sub Class::MOP::__ANON__; # xsub
|  |  |  |  | # spent 623µs within Class::MOP::get_code_info which was called 519 times, avg 1µs/call: # 390 times (480µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 81 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call # 125 times (136µs+0s) by Class::MOP::Mixin::HasMethods::_code_is_mine at line 95 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call # 4 times (7µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 264 of Moose/Exporter.pm, avg 2µs/call sub Class::MOP::get_code_info; # xsub