| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm |
| Statements | Executed 3856 statements in 10.1ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 3.90ms | 73.8ms | Moose::Exporter::BEGIN@13 |
| 13 | 1 | 1 | 1.02ms | 7.47ms | Moose::Exporter::__ANON__[:137] |
| 13 | 13 | 13 | 876µs | 49.1ms | Moose::Exporter::__ANON__[:492] |
| 1 | 1 | 1 | 846µs | 1.09ms | Moose::Exporter::BEGIN@15 |
| 88 | 1 | 1 | 736µs | 1.49ms | Moose::Exporter::__ANON__[:352] |
| 88 | 1 | 1 | 535µs | 535µs | Moose::Exporter::_late_curry_wrapper |
| 3 | 1 | 1 | 366µs | 603µs | Moose::Exporter::_make_sub_exporter_params |
| 13 | 1 | 1 | 326µs | 326µs | Moose::Exporter::_collect_metaroles |
| 1 | 1 | 1 | 274µs | 282µs | Moose::Exporter::_remove_keywords |
| 3 | 1 | 1 | 218µs | 2.90ms | Moose::Exporter::build_import_methods |
| 13 | 1 | 1 | 193µs | 669µs | Moose::Exporter::_apply_metaroles |
| 13 | 1 | 1 | 144µs | 227µs | Moose::Exporter::_strip_traits |
| 41 | 2 | 1 | 142µs | 142µs | Moose::Exporter::_sub_from_package |
| 90 | 1 | 1 | 133µs | 133µs | Moose::Exporter::__ANON__[:280] |
| 26 | 2 | 1 | 108µs | 230µs | Moose::Exporter::__ANON__[:42] |
| 13 | 1 | 1 | 101µs | 128µs | Moose::Exporter::_strip_metaclass |
| 15 | 1 | 1 | 100µs | 228µs | Moose::Exporter::__ANON__[:225] |
| 13 | 1 | 1 | 92µs | 113µs | Moose::Exporter::_strip_meta_name |
| 3 | 3 | 3 | 90µs | 2.99ms | Moose::Exporter::setup_import_methods |
| 16 | 1 | 1 | 70µs | 70µs | Moose::Exporter::_make_wrapped_sub_with_meta |
| 13 | 1 | 1 | 53µs | 53µs | Moose::Exporter::_get_caller |
| 3 | 1 | 1 | 50µs | 50µs | Moose::Exporter::_make_init_meta |
| 3 | 1 | 1 | 43µs | 71µs | Moose::Exporter::_follow_also |
| 3 | 1 | 1 | 43µs | 1.48ms | Moose::Exporter::_make_exporter |
| 1 | 1 | 1 | 36µs | 318µs | Moose::Exporter::__ANON__[:678] |
| 22 | 1 | 1 | 31µs | 31µs | Moose::Exporter::_flag_as_reexport (xsub) |
| 3 | 1 | 1 | 29µs | 29µs | Moose::Exporter::_make_import_sub |
| 3 | 3 | 3 | 29µs | 74µs | Moose::Exporter::import |
| 3 | 1 | 1 | 23µs | 23µs | Moose::Exporter::_make_unimport_sub |
| 3 | 1 | 1 | 18µs | 18µs | Moose::Exporter::_parse_trait_aliases |
| 1 | 1 | 1 | 17µs | 207µs | Moose::Exporter::BEGIN@17 |
| 3 | 1 | 1 | 14µs | 14µs | Moose::Exporter::_follow_also_real |
| 1 | 1 | 1 | 14µs | 31µs | Moose::Exporter::BEGIN@133 |
| 1 | 1 | 1 | 13µs | 37µs | Moose::Exporter::BEGIN@688 |
| 1 | 1 | 1 | 11µs | 58µs | Moose::Exporter::BEGIN@14 |
| 1 | 1 | 1 | 9µs | 9µs | Moose::Exporter::BEGIN@2 |
| 1 | 1 | 1 | 8µs | 23µs | Moose::Exporter::BEGIN@132 |
| 1 | 1 | 1 | 8µs | 21µs | Moose::Exporter::BEGIN@10 |
| 2 | 1 | 1 | 7µs | 7µs | Moose::Exporter::_export_is_flagged (xsub) |
| 1 | 1 | 1 | 7µs | 32µs | Moose::Exporter::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 17µs | Moose::Exporter::BEGIN@294 |
| 1 | 1 | 1 | 7µs | 29µs | Moose::Exporter::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 11µs | Moose::Exporter::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 27µs | Moose::Exporter::BEGIN@18 |
| 1 | 1 | 1 | 6µs | 13µs | Moose::Exporter::BEGIN@698 |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:201] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:329] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:361] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:383] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:496] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:510] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:522] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::__ANON__[:750] |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_apply_meta_traits |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_curry_wrapper |
| 0 | 0 | 0 | 0s | 0s | Moose::Exporter::_make_wrapped_sub |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Exporter; | ||||
| 2 | # spent 9µs within Moose::Exporter::BEGIN@2 which was called:
# once (9µs+0s) by Moose::BEGIN@19 at line 4 | ||||
| 3 | 1 | 4µs | $Moose::Exporter::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 22µs | 1 | 9µs | } # spent 9µs making 1 call to Moose::Exporter::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 1µs | $Moose::Exporter::VERSION = '2.0602'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 3 | 17µs | 2 | 16µs | # spent 11µs (7+4) within Moose::Exporter::BEGIN@9 which was called:
# once (7µs+4µs) by Moose::BEGIN@19 at line 9 # spent 11µs making 1 call to Moose::Exporter::BEGIN@9
# spent 4µs making 1 call to strict::import |
| 10 | 3 | 25µs | 2 | 35µs | # spent 21µs (8+13) within Moose::Exporter::BEGIN@10 which was called:
# once (8µs+13µs) by Moose::BEGIN@19 at line 10 # spent 21µs making 1 call to Moose::Exporter::BEGIN@10
# spent 14µs making 1 call to warnings::import |
| 11 | |||||
| 12 | 3 | 17µs | 2 | 56µs | # spent 32µs (7+24) within Moose::Exporter::BEGIN@12 which was called:
# once (7µs+24µs) by Moose::BEGIN@19 at line 12 # spent 32µs making 1 call to Moose::Exporter::BEGIN@12
# spent 24µs making 1 call to Exporter::import |
| 13 | 3 | 126µs | 1 | 73.8ms | # spent 73.8ms (3.90+69.9) within Moose::Exporter::BEGIN@13 which was called:
# once (3.90ms+69.9ms) by Moose::BEGIN@19 at line 13 # spent 73.8ms making 1 call to Moose::Exporter::BEGIN@13 |
| 14 | 3 | 23µs | 2 | 105µs | # spent 58µs (11+47) within Moose::Exporter::BEGIN@14 which was called:
# once (11µs+47µs) by Moose::BEGIN@19 at line 14 # spent 58µs making 1 call to Moose::Exporter::BEGIN@14
# spent 47µs making 1 call to Exporter::import |
| 15 | 3 | 193µs | 1 | 1.09ms | # spent 1.09ms (846µs+242µs) within Moose::Exporter::BEGIN@15 which was called:
# once (846µs+242µs) by Moose::BEGIN@19 at line 15 # spent 1.09ms making 1 call to Moose::Exporter::BEGIN@15 |
| 16 | 3 | 21µs | 2 | 50µs | # spent 29µs (7+22) within Moose::Exporter::BEGIN@16 which was called:
# once (7µs+22µs) by Moose::BEGIN@19 at line 16 # spent 29µs making 1 call to Moose::Exporter::BEGIN@16
# spent 22µs making 1 call to Exporter::import |
| 17 | 3 | 58µs | 3 | 398µs | # spent 207µs (17+191) within Moose::Exporter::BEGIN@17 which was called:
# once (17µs+191µs) by Moose::BEGIN@19 at line 17 # spent 207µs making 1 call to Moose::Exporter::BEGIN@17
# spent 165µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
# spent 26µs making 1 call to UNIVERSAL::VERSION |
| 18 | 3 | 345µs | 2 | 47µs | # spent 27µs (7+20) within Moose::Exporter::BEGIN@18 which was called:
# once (7µs+20µs) by Moose::BEGIN@19 at line 18 # spent 27µs making 1 call to Moose::Exporter::BEGIN@18
# spent 20µs making 1 call to Exporter::import |
| 19 | |||||
| 20 | 1 | 200ns | my %EXPORT_SPEC; | ||
| 21 | |||||
| 22 | # spent 2.99ms (90µs+2.90) within Moose::Exporter::setup_import_methods which was called 3 times, avg 997µs/call:
# once (56µs+1.07ms) by Moose::Meta::Attribute::BEGIN@24 at line 44 of Moose/Util/TypeConstraints.pm
# once (19µs+924µs) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 131 of Moose.pm
# once (14µs+908µs) by Any::Moose::_install_module at line 91 of Moose/Role.pm | ||||
| 23 | 3 | 10µs | my ( $class, %args ) = @_; | ||
| 24 | |||||
| 25 | 3 | 7µs | $args{exporting_package} ||= caller(); | ||
| 26 | |||||
| 27 | 3 | 74µs | 3 | 2.90ms | $class->build_import_methods( # spent 2.90ms making 3 calls to Moose::Exporter::build_import_methods, avg 967µs/call |
| 28 | %args, | ||||
| 29 | install => [qw(import unimport init_meta)] | ||||
| 30 | ); | ||||
| 31 | } | ||||
| 32 | |||||
| 33 | # A reminder to intrepid Moose hackers | ||||
| 34 | # there may be more than one level of exporter | ||||
| 35 | # don't make doy cry. -- perigrin | ||||
| 36 | |||||
| 37 | # spent 2.90ms (218µs+2.68) within Moose::Exporter::build_import_methods which was called 3 times, avg 967µs/call:
# 3 times (218µs+2.68ms) by Moose::Exporter::setup_import_methods at line 27, avg 967µs/call | ||||
| 38 | 3 | 9µs | my ( $class, %args ) = @_; | ||
| 39 | |||||
| 40 | 3 | 3µs | my $exporting_package = $args{exporting_package} ||= caller(); | ||
| 41 | |||||
| 42 | 29 | 113µs | 26 | 122µs | # spent 230µs (108+122) within 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] which was called 26 times, avg 9µs/call:
# 13 times (66µs+69µs) by Moose::Exporter::_apply_metaroles at line 539, avg 10µs/call
# 13 times (42µs+53µ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:137] at line 108, avg 7µs/call # spent 122µs making 26 calls to Class::MOP::class_of, avg 5µs/call |
| 43 | |||||
| 44 | 3 | 4µs | $EXPORT_SPEC{$exporting_package} = \%args; | ||
| 45 | |||||
| 46 | 3 | 11µs | 3 | 71µs | my @exports_from = $class->_follow_also($exporting_package); # spent 71µs making 3 calls to Moose::Exporter::_follow_also, avg 24µs/call |
| 47 | |||||
| 48 | 3 | 3µs | my $export_recorder = {}; | ||
| 49 | 3 | 2µs | my $is_reexport = {}; | ||
| 50 | |||||
| 51 | 3 | 17µs | 3 | 603µs | my $exports = $class->_make_sub_exporter_params( # spent 603µs making 3 calls to Moose::Exporter::_make_sub_exporter_params, avg 201µs/call |
| 52 | [ $exporting_package, @exports_from ], | ||||
| 53 | $export_recorder, | ||||
| 54 | $is_reexport, | ||||
| 55 | $args{meta_lookup}, # so that we don't pass through the default | ||||
| 56 | ); | ||||
| 57 | |||||
| 58 | 3 | 10µs | 3 | 1.48ms | my $exporter = $class->_make_exporter( # spent 1.48ms making 3 calls to Moose::Exporter::_make_exporter, avg 493µs/call |
| 59 | $exports, | ||||
| 60 | $is_reexport, | ||||
| 61 | $meta_lookup, | ||||
| 62 | ); | ||||
| 63 | |||||
| 64 | 3 | 900ns | my %methods; | ||
| 65 | 3 | 15µs | 3 | 29µs | $methods{import} = $class->_make_import_sub( # spent 29µs making 3 calls to Moose::Exporter::_make_import_sub, avg 10µs/call |
| 66 | $exporting_package, | ||||
| 67 | $exporter, | ||||
| 68 | \@exports_from, | ||||
| 69 | $is_reexport, | ||||
| 70 | $meta_lookup, | ||||
| 71 | ); | ||||
| 72 | |||||
| 73 | 3 | 11µs | 3 | 23µs | $methods{unimport} = $class->_make_unimport_sub( # spent 23µs making 3 calls to Moose::Exporter::_make_unimport_sub, avg 8µs/call |
| 74 | $exporting_package, | ||||
| 75 | $exports, | ||||
| 76 | $export_recorder, | ||||
| 77 | $is_reexport, | ||||
| 78 | $meta_lookup, | ||||
| 79 | ); | ||||
| 80 | |||||
| 81 | 3 | 10µs | 3 | 50µs | $methods{init_meta} = $class->_make_init_meta( # spent 50µs making 3 calls to Moose::Exporter::_make_init_meta, avg 17µs/call |
| 82 | $exporting_package, | ||||
| 83 | \%args, | ||||
| 84 | $meta_lookup, | ||||
| 85 | ); | ||||
| 86 | |||||
| 87 | 3 | 16µs | 3 | 142µs | my $package = Class::MOP::Package->initialize($exporting_package); # spent 142µs making 3 calls to Class::MOP::Package::initialize, avg 47µs/call |
| 88 | 3 | 7µs | for my $to_install ( @{ $args{install} || [] } ) { | ||
| 89 | 9 | 6µs | my $symbol = '&' . $to_install; | ||
| 90 | next | ||||
| 91 | 9 | 19µs | 6 | 188µs | unless $methods{$to_install} # spent 188µs making 6 calls to Class::MOP::Package::has_package_symbol, avg 31µs/call |
| 92 | && !$package->has_package_symbol($symbol); | ||||
| 93 | 6 | 15µs | 6 | 98µs | $package->add_package_symbol( $symbol, $methods{$to_install} ); # spent 98µs making 6 calls to Class::MOP::Package::add_package_symbol, avg 16µs/call |
| 94 | } | ||||
| 95 | |||||
| 96 | 3 | 15µs | return ( $methods{import}, $methods{unimport}, $methods{init_meta} ); | ||
| 97 | } | ||||
| 98 | |||||
| 99 | # spent 1.48ms (43µs+1.44) within Moose::Exporter::_make_exporter which was called 3 times, avg 493µs/call:
# 3 times (43µs+1.44ms) by Moose::Exporter::build_import_methods at line 58, avg 493µs/call | ||||
| 100 | 3 | 4µs | my ($class, $exports, $is_reexport, $meta_lookup) = @_; | ||
| 101 | |||||
| 102 | return Sub::Exporter::build_exporter( | ||||
| 103 | { | ||||
| 104 | exports => $exports, | ||||
| 105 | groups => { default => [':all'] }, | ||||
| 106 | # spent 7.47ms (1.02+6.45) within Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:137] which was called 13 times, avg 575µs/call:
# 13 times (1.02ms+6.45ms) by Sub::Exporter::_do_import at line 799 of Sub/Exporter.pm, avg 575µs/call | ||||
| 107 | 13 | 11µs | my ($arg, $to_export) = @_; | ||
| 108 | 13 | 29µs | 13 | 95µs | my $meta = $meta_lookup->($arg->{into}); # spent 95µs making 13 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:42], avg 7µs/call |
| 109 | |||||
| 110 | 13 | 15µs | 2 | 1.32ms | goto &Sub::Exporter::default_installer unless $meta; # spent 1.32ms making 2 calls to Sub::Exporter::default_installer, avg 662µs/call |
| 111 | |||||
| 112 | # don't overwrite existing symbols with our magically flagged | ||||
| 113 | # version of it if we would install the same sub that's already | ||||
| 114 | # in the importer | ||||
| 115 | |||||
| 116 | 11 | 5µs | my @filtered_to_export; | ||
| 117 | 11 | 3µs | my %installed; | ||
| 118 | 11 | 86µs | for (my $i = 0; $i < @{ $to_export }; $i += 2) { | ||
| 119 | 140 | 93µs | my ($as, $cv) = @{ $to_export }[$i, $i + 1]; | ||
| 120 | |||||
| 121 | 140 | 218µs | 140 | 1.15ms | next if !ref($as) # spent 1.15ms making 140 calls to Class::MOP::Package::has_package_symbol, avg 8µs/call |
| 122 | && $meta->has_package_symbol('&' . $as) | ||||
| 123 | && $meta->get_package_symbol('&' . $as) == $cv; | ||||
| 124 | |||||
| 125 | 140 | 65µs | push @filtered_to_export, $as, $cv; | ||
| 126 | 140 | 124µs | $installed{$as} = 1 unless ref $as; | ||
| 127 | 11 | 6µs | } | ||
| 128 | |||||
| 129 | 11 | 28µs | 11 | 5.18ms | Sub::Exporter::default_installer($arg, \@filtered_to_export); # spent 5.18ms making 11 calls to Sub::Exporter::default_installer, avg 471µs/call |
| 130 | |||||
| 131 | 11 | 68µs | for my $name ( keys %{$is_reexport} ) { | ||
| 132 | 3 | 19µs | 2 | 38µs | # spent 23µs (8+15) within Moose::Exporter::BEGIN@132 which was called:
# once (8µs+15µs) by Moose::BEGIN@19 at line 132 # spent 23µs making 1 call to Moose::Exporter::BEGIN@132
# spent 15µs making 1 call to strict::unimport |
| 133 | 3 | 680µs | 2 | 48µs | # spent 31µs (14+17) within Moose::Exporter::BEGIN@133 which was called:
# once (14µs+17µs) by Moose::BEGIN@19 at line 133 # spent 31µs making 1 call to Moose::Exporter::BEGIN@133
# spent 17µs making 1 call to warnings::unimport |
| 134 | 22 | 9µs | next unless exists $installed{$name}; | ||
| 135 | 22 | 133µs | 22 | 31µs | _flag_as_reexport( \*{ join q{::}, $arg->{into}, $name } ); # spent 31µs making 22 calls to Moose::Exporter::_flag_as_reexport, avg 1µs/call |
| 136 | } | ||||
| 137 | }, | ||||
| 138 | } | ||||
| 139 | 3 | 43µs | 3 | 1.44ms | ); # spent 1.44ms making 3 calls to Sub::Exporter::build_exporter, avg 479µs/call |
| 140 | } | ||||
| 141 | |||||
| 142 | { | ||||
| 143 | 2 | 1µs | my $seen = {}; | ||
| 144 | |||||
| 145 | # spent 71µs (43+28) within Moose::Exporter::_follow_also which was called 3 times, avg 24µs/call:
# 3 times (43µs+28µs) by Moose::Exporter::build_import_methods at line 46, avg 24µs/call | ||||
| 146 | 3 | 3µs | my $class = shift; | ||
| 147 | 3 | 2µs | my $exporting_package = shift; | ||
| 148 | |||||
| 149 | 3 | 6µs | local %$seen = ( $exporting_package => 1 ); | ||
| 150 | |||||
| 151 | 3 | 40µs | 6 | 28µs | return uniq( _follow_also_real($exporting_package) ); # spent 14µs making 3 calls to Moose::Exporter::_follow_also_real, avg 5µs/call
# spent 13µs making 3 calls to List::MoreUtils::uniq, avg 4µs/call |
| 152 | } | ||||
| 153 | |||||
| 154 | # spent 14µs within Moose::Exporter::_follow_also_real which was called 3 times, avg 5µs/call:
# 3 times (14µs+0s) by Moose::Exporter::_follow_also at line 151, avg 5µs/call | ||||
| 155 | 3 | 2µs | my $exporting_package = shift; | ||
| 156 | |||||
| 157 | 3 | 3µs | if ( !exists $EXPORT_SPEC{$exporting_package} ) { | ||
| 158 | my $loaded = is_class_loaded($exporting_package); | ||||
| 159 | |||||
| 160 | die "Package in also ($exporting_package) does not seem to " | ||||
| 161 | . "use Moose::Exporter" | ||||
| 162 | . ( $loaded ? "" : " (is it loaded?)" ); | ||||
| 163 | } | ||||
| 164 | |||||
| 165 | 3 | 3µs | my $also = $EXPORT_SPEC{$exporting_package}{also}; | ||
| 166 | |||||
| 167 | 3 | 16µs | return unless defined $also; | ||
| 168 | |||||
| 169 | my @also = ref $also ? @{$also} : $also; | ||||
| 170 | |||||
| 171 | for my $package (@also) { | ||||
| 172 | die | ||||
| 173 | "Circular reference in 'also' parameter to Moose::Exporter between $exporting_package and $package" | ||||
| 174 | if $seen->{$package}; | ||||
| 175 | |||||
| 176 | $seen->{$package} = 1; | ||||
| 177 | } | ||||
| 178 | |||||
| 179 | return map { $_, _follow_also_real($_) } @also; | ||||
| 180 | } | ||||
| 181 | } | ||||
| 182 | |||||
| 183 | # spent 18µs within Moose::Exporter::_parse_trait_aliases which was called 3 times, avg 6µs/call:
# 3 times (18µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 254, avg 6µs/call | ||||
| 184 | 3 | 2µs | my $class = shift; | ||
| 185 | 3 | 3µs | my ($package, $aliases) = @_; | ||
| 186 | |||||
| 187 | 3 | 700ns | my @ret; | ||
| 188 | 3 | 6µs | for my $alias (@$aliases) { | ||
| 189 | my $name; | ||||
| 190 | if (ref($alias)) { | ||||
| 191 | reftype($alias) eq 'ARRAY' | ||||
| 192 | or Moose->throw_error(reftype($alias) . " references are not " | ||||
| 193 | . "valid arguments to the 'trait_aliases' " | ||||
| 194 | . "option"); | ||||
| 195 | |||||
| 196 | ($alias, $name) = @$alias; | ||||
| 197 | } | ||||
| 198 | else { | ||||
| 199 | ($name = $alias) =~ s/.*:://; | ||||
| 200 | } | ||||
| 201 | push @ret, subname "${package}::${name}" => sub () { $alias }; | ||||
| 202 | } | ||||
| 203 | |||||
| 204 | 3 | 10µs | return @ret; | ||
| 205 | } | ||||
| 206 | |||||
| 207 | # spent 603µs (366+237) within Moose::Exporter::_make_sub_exporter_params which was called 3 times, avg 201µs/call:
# 3 times (366µs+237µs) by Moose::Exporter::build_import_methods at line 51, avg 201µs/call | ||||
| 208 | 3 | 2µs | my $class = shift; | ||
| 209 | 3 | 1µs | my $packages = shift; | ||
| 210 | 3 | 1µs | my $export_recorder = shift; | ||
| 211 | 3 | 700ns | my $is_reexport = shift; | ||
| 212 | 3 | 3µs | my $meta_lookup_override = shift; | ||
| 213 | |||||
| 214 | 3 | 1µs | my %exports; | ||
| 215 | 3 | 1µs | my $current_meta_lookup; | ||
| 216 | |||||
| 217 | 3 | 4µs | for my $package ( @{$packages} ) { | ||
| 218 | 3 | 2µs | my $args = $EXPORT_SPEC{$package} | ||
| 219 | or die "The $package package does not use Moose::Exporter\n"; | ||||
| 220 | |||||
| 221 | 3 | 2µs | $current_meta_lookup = $meta_lookup_override || $args->{meta_lookup}; | ||
| 222 | 3 | 1µs | $meta_lookup_override = $current_meta_lookup; | ||
| 223 | |||||
| 224 | my $meta_lookup = $current_meta_lookup | ||||
| 225 | 18 | 100µs | 15 | 128µs | # spent 228µs (100+128) within 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] which was called 15 times, avg 15µs/call:
# 15 times (100µs+128µs) by Moose::Role::has or Moose::Role::requires or Moose::extends or Moose::has or Moose::with at line 381, avg 15µs/call # spent 128µs making 15 calls to Class::MOP::class_of, avg 9µs/call |
| 226 | |||||
| 227 | 3 | 5µs | for my $name ( @{ $args->{with_meta} } ) { | ||
| 228 | 16 | 23µs | 16 | 54µs | my $sub = $class->_sub_from_package( $package, $name ) # spent 54µs making 16 calls to Moose::Exporter::_sub_from_package, avg 3µs/call |
| 229 | or next; | ||||
| 230 | |||||
| 231 | 16 | 8µs | my $fq_name = $package . '::' . $name; | ||
| 232 | |||||
| 233 | 16 | 37µs | 16 | 70µs | $exports{$name} = $class->_make_wrapped_sub_with_meta( # spent 70µs making 16 calls to Moose::Exporter::_make_wrapped_sub_with_meta, avg 4µs/call |
| 234 | $fq_name, | ||||
| 235 | $sub, | ||||
| 236 | $export_recorder, | ||||
| 237 | $meta_lookup, | ||||
| 238 | ) unless exists $exports{$name}; | ||||
| 239 | } | ||||
| 240 | |||||
| 241 | 3 | 6µs | for my $name ( @{ $args->{with_caller} } ) { | ||
| 242 | my $sub = $class->_sub_from_package( $package, $name ) | ||||
| 243 | or next; | ||||
| 244 | |||||
| 245 | my $fq_name = $package . '::' . $name; | ||||
| 246 | |||||
| 247 | $exports{$name} = $class->_make_wrapped_sub( | ||||
| 248 | $fq_name, | ||||
| 249 | $sub, | ||||
| 250 | $export_recorder, | ||||
| 251 | ) unless exists $exports{$name}; | ||||
| 252 | } | ||||
| 253 | |||||
| 254 | 3 | 11µs | 3 | 18µs | my @extra_exports = $class->_parse_trait_aliases( # spent 18µs making 3 calls to Moose::Exporter::_parse_trait_aliases, avg 6µs/call |
| 255 | $package, $args->{trait_aliases}, | ||||
| 256 | ); | ||||
| 257 | 3 | 8µs | for my $name ( @{ $args->{as_is} }, @extra_exports ) { | ||
| 258 | 29 | 6µs | my ( $sub, $coderef_name ); | ||
| 259 | |||||
| 260 | 29 | 11µs | if ( ref $name ) { | ||
| 261 | 4 | 1µs | $sub = $name; | ||
| 262 | |||||
| 263 | 4 | 800ns | my $coderef_pkg; | ||
| 264 | 4 | 21µs | 4 | 7µs | ( $coderef_pkg, $coderef_name ) # spent 7µs making 4 calls to Class::MOP::get_code_info, avg 2µs/call |
| 265 | = Class::MOP::get_code_info($name); | ||||
| 266 | |||||
| 267 | 4 | 4µs | if ( $coderef_pkg ne $package ) { | ||
| 268 | $is_reexport->{$coderef_name} = 1; | ||||
| 269 | } | ||||
| 270 | } | ||||
| 271 | else { | ||||
| 272 | 25 | 33µs | 25 | 88µs | $sub = $class->_sub_from_package( $package, $name ) # spent 88µs making 25 calls to Moose::Exporter::_sub_from_package, avg 4µs/call |
| 273 | or next; | ||||
| 274 | |||||
| 275 | 25 | 9µs | $coderef_name = $name; | ||
| 276 | } | ||||
| 277 | |||||
| 278 | 29 | 30µs | $export_recorder->{$sub} = 1; | ||
| 279 | |||||
| 280 | 90 | 191µs | # spent 133µs within Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:280] which was called 90 times, avg 1µs/call:
# 90 times (133µs+0s) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 1µs/call | ||
| 281 | 29 | 69µs | unless exists $exports{$coderef_name}; | ||
| 282 | } | ||||
| 283 | } | ||||
| 284 | |||||
| 285 | 3 | 13µs | return \%exports; | ||
| 286 | } | ||||
| 287 | |||||
| 288 | sub _sub_from_package { | ||||
| 289 | 41 | 12µs | my $sclass = shift; | ||
| 290 | 41 | 10µs | my $package = shift; | ||
| 291 | 41 | 10µs | my $name = shift; | ||
| 292 | |||||
| 293 | 41 | 17µs | my $sub = do { | ||
| 294 | 3 | 1.86ms | 2 | 27µs | # spent 17µs (7+10) within Moose::Exporter::BEGIN@294 which was called:
# once (7µs+10µs) by Moose::BEGIN@19 at line 294 # spent 17µs making 1 call to Moose::Exporter::BEGIN@294
# spent 10µs making 1 call to strict::unimport |
| 295 | 41 | 51µs | \&{ $package . '::' . $name }; | ||
| 296 | }; | ||||
| 297 | |||||
| 298 | 41 | 82µs | return $sub if defined &$sub; | ||
| 299 | |||||
| 300 | Carp::cluck "Trying to export undefined sub ${package}::${name}"; | ||||
| 301 | |||||
| 302 | return; | ||||
| 303 | } | ||||
| 304 | |||||
| 305 | 1 | 100ns | our $CALLER; | ||
| 306 | |||||
| 307 | sub _make_wrapped_sub { | ||||
| 308 | my $self = shift; | ||||
| 309 | my $fq_name = shift; | ||||
| 310 | my $sub = shift; | ||||
| 311 | my $export_recorder = shift; | ||||
| 312 | |||||
| 313 | # We need to set the package at import time, so that when | ||||
| 314 | # package Foo imports has(), we capture "Foo" as the | ||||
| 315 | # package. This lets other packages call Foo::has() and get | ||||
| 316 | # the right package. This is done for backwards compatibility | ||||
| 317 | # with existing production code, not because this is a good | ||||
| 318 | # idea ;) | ||||
| 319 | return sub { | ||||
| 320 | my $caller = $CALLER; | ||||
| 321 | |||||
| 322 | my $wrapper = $self->_curry_wrapper( $sub, $fq_name, $caller ); | ||||
| 323 | |||||
| 324 | my $sub = subname( $fq_name => $wrapper ); | ||||
| 325 | |||||
| 326 | $export_recorder->{$sub} = 1; | ||||
| 327 | |||||
| 328 | return $sub; | ||||
| 329 | }; | ||||
| 330 | } | ||||
| 331 | |||||
| 332 | # spent 70µs within Moose::Exporter::_make_wrapped_sub_with_meta which was called 16 times, avg 4µs/call:
# 16 times (70µs+0s) by Moose::Exporter::_make_sub_exporter_params at line 233, avg 4µs/call | ||||
| 333 | 16 | 6µs | my $self = shift; | ||
| 334 | 16 | 4µs | my $fq_name = shift; | ||
| 335 | 16 | 4µs | my $sub = shift; | ||
| 336 | 16 | 3µs | my $export_recorder = shift; | ||
| 337 | 16 | 4µs | my $meta_lookup = shift; | ||
| 338 | |||||
| 339 | # spent 1.49ms (736µs+751µs) within Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:352] which was called 88 times, avg 17µs/call:
# 88 times (736µs+751µs) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 17µs/call | ||||
| 340 | 88 | 35µs | my $caller = $CALLER; | ||
| 341 | |||||
| 342 | 88 | 155µs | 88 | 535µs | my $wrapper = $self->_late_curry_wrapper( # spent 535µs making 88 calls to Moose::Exporter::_late_curry_wrapper, avg 6µs/call |
| 343 | $sub, $fq_name, | ||||
| 344 | $meta_lookup => $caller | ||||
| 345 | ); | ||||
| 346 | |||||
| 347 | 88 | 388µs | 88 | 216µs | my $sub = subname( $fq_name => $wrapper ); # spent 216µs making 88 calls to Sub::Name::subname, avg 2µs/call |
| 348 | |||||
| 349 | 88 | 143µs | $export_recorder->{$sub} = 1; | ||
| 350 | |||||
| 351 | 88 | 180µs | return $sub; | ||
| 352 | 16 | 63µs | }; | ||
| 353 | } | ||||
| 354 | |||||
| 355 | sub _curry_wrapper { | ||||
| 356 | my $class = shift; | ||||
| 357 | my $sub = shift; | ||||
| 358 | my $fq_name = shift; | ||||
| 359 | my @extra = @_; | ||||
| 360 | |||||
| 361 | my $wrapper = sub { $sub->( @extra, @_ ) }; | ||||
| 362 | if ( my $proto = prototype $sub ) { | ||||
| 363 | |||||
| 364 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
| 365 | # ignore the fact that we're passing "private variables" | ||||
| 366 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
| 367 | } | ||||
| 368 | return $wrapper; | ||||
| 369 | } | ||||
| 370 | |||||
| 371 | # spent 535µs within Moose::Exporter::_late_curry_wrapper which was called 88 times, avg 6µs/call:
# 88 times (535µs+0s) 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:352] at line 342, avg 6µs/call | ||||
| 372 | 88 | 28µs | my $class = shift; | ||
| 373 | 88 | 28µs | my $sub = shift; | ||
| 374 | 88 | 29µs | my $fq_name = shift; | ||
| 375 | 88 | 22µs | my $extra = shift; | ||
| 376 | 88 | 76µs | my @ex_args = @_; | ||
| 377 | |||||
| 378 | my $wrapper = sub { | ||||
| 379 | |||||
| 380 | # resolve curried arguments at runtime via this closure | ||||
| 381 | 15 | 58µs | 15 | 228µs | my @curry = ( $extra->(@ex_args) ); # spent 228µs making 15 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:225], avg 15µs/call |
| 382 | 15 | 96µs | 15 | 129ms | return $sub->( @curry, @_ ); # spent 107ms making 3 calls to Moose::with, avg 35.8ms/call
# spent 14.3ms making 6 calls to Moose::has, avg 2.39ms/call
# spent 7.27ms making 2 calls to Moose::extends, avg 3.64ms/call, recursion: max depth 1, sum of overlapping time 797µs
# spent 669µs making 2 calls to Moose::Role::has, avg 334µs/call
# spent 252µs making 2 calls to Moose::Role::requires, avg 126µs/call |
| 383 | 88 | 193µs | }; | ||
| 384 | |||||
| 385 | 88 | 39µs | if ( my $proto = prototype $sub ) { | ||
| 386 | |||||
| 387 | # XXX - Perl's prototype sucks. Use & to make set_prototype | ||||
| 388 | # ignore the fact that we're passing "private variables" | ||||
| 389 | &Scalar::Util::set_prototype( $wrapper, $proto ); | ||||
| 390 | } | ||||
| 391 | 88 | 223µs | return $wrapper; | ||
| 392 | } | ||||
| 393 | |||||
| 394 | # spent 29µs within Moose::Exporter::_make_import_sub which was called 3 times, avg 10µs/call:
# 3 times (29µs+0s) by Moose::Exporter::build_import_methods at line 65, avg 10µs/call | ||||
| 395 | 3 | 1µs | shift; | ||
| 396 | 3 | 2µs | my $exporting_package = shift; | ||
| 397 | 3 | 1µs | my $exporter = shift; | ||
| 398 | 3 | 2µs | my $exports_from = shift; | ||
| 399 | 3 | 1µs | my $is_reexport = shift; | ||
| 400 | 3 | 1µs | my $meta_lookup = shift; | ||
| 401 | |||||
| 402 | # spent 49.1ms (876µs+48.3) within Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:492] which was called 13 times, avg 3.78ms/call:
# once (120µs+6.47ms) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@6 at line 6 of lib/Tapper/MCP/Scheduler/PrioQueue.pm
# once (69µs+4.82ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 6 of lib/Tapper/MCP/Scheduler/Controller.pm
# once (66µs+4.71ms) by Tapper::MCP::Scheduler::Algorithm::BEGIN@6 at line 6 of lib/Tapper/MCP/Scheduler/Algorithm.pm
# once (66µs+4.49ms) by Tapper::MCP::BEGIN@8 at line 8 of lib/Tapper/MCP.pm
# once (66µs+4.46ms) by Tapper::Producer::Temare::BEGIN@11 at line 11 of Tapper/Producer/Temare.pm
# once (63µs+4.45ms) by Tapper::MCP::Net::BEGIN@9 at line 9 of lib/Tapper/MCP/Net.pm
# once (57µs+4.09ms) by Tapper::Base::BEGIN@10 at line 10 of Tapper/Base.pm
# once (63µs+3.26ms) by Any::Moose::_install_module at line 2 of (eval 240)[Any/Moose.pm:152]
# once (65µs+2.97ms) by MooseX::Traits::BEGIN@2 at line 2 of MooseX/Traits.pm
# once (61µs+2.89ms) by Tapper::MCP::Net::TAP::BEGIN@7 at line 7 of lib/Tapper/MCP/Net/TAP.pm
# once (65µs+2.82ms) by Tapper::MCP::Scheduler::Algorithm::WFQ::BEGIN@5 at line 5 of lib/Tapper/MCP/Scheduler/Algorithm/WFQ.pm
# once (65µs+1.47ms) by Moose::BEGIN@44 at line 44 of Moose.pm
# once (51µs+1.36ms) by Moose::Role::BEGIN@22 at line 22 of Moose/Role.pm | ||||
| 403 | |||||
| 404 | # I think we could use Sub::Exporter's collector feature | ||||
| 405 | # to do this, but that would be rather gross, since that | ||||
| 406 | # feature isn't really designed to return a value to the | ||||
| 407 | # caller of the exporter sub. | ||||
| 408 | # | ||||
| 409 | # Also, this makes sure we preserve backwards compat for | ||||
| 410 | # _get_caller, so it always sees the arguments in the | ||||
| 411 | # expected order. | ||||
| 412 | 13 | 6µs | my $traits; | ||
| 413 | 13 | 54µs | 13 | 227µs | ( $traits, @_ ) = _strip_traits(@_); # spent 227µs making 13 calls to Moose::Exporter::_strip_traits, avg 17µs/call |
| 414 | |||||
| 415 | 13 | 5µs | my $metaclass; | ||
| 416 | 13 | 47µs | 13 | 128µs | ( $metaclass, @_ ) = _strip_metaclass(@_); # spent 128µs making 13 calls to Moose::Exporter::_strip_metaclass, avg 10µs/call |
| 417 | 13 | 8µs | $metaclass | ||
| 418 | = Moose::Util::resolve_metaclass_alias( 'Class' => $metaclass ) | ||||
| 419 | if defined $metaclass && length $metaclass; | ||||
| 420 | |||||
| 421 | 13 | 4µs | my $meta_name; | ||
| 422 | 13 | 48µs | 13 | 113µs | ( $meta_name, @_ ) = _strip_meta_name(@_); # spent 113µs making 13 calls to Moose::Exporter::_strip_meta_name, avg 9µs/call |
| 423 | |||||
| 424 | # Normally we could look at $_[0], but in some weird cases | ||||
| 425 | # (involving goto &Moose::import), $_[0] ends as something | ||||
| 426 | # else (like Squirrel). | ||||
| 427 | 13 | 12µs | my $class = $exporting_package; | ||
| 428 | |||||
| 429 | 13 | 39µs | 13 | 53µs | $CALLER = _get_caller(@_); # spent 53µs making 13 calls to Moose::Exporter::_get_caller, avg 4µs/call |
| 430 | |||||
| 431 | # this works because both pragmas set $^H (see perldoc | ||||
| 432 | # perlvar) which affects the current compilation - | ||||
| 433 | # i.e. the file who use'd us - which is why we don't need | ||||
| 434 | # to do anything special to make it affect that file | ||||
| 435 | # rather than this one (which is already compiled) | ||||
| 436 | |||||
| 437 | 13 | 39µs | 13 | 48µs | strict->import; # spent 48µs making 13 calls to strict::import, avg 4µs/call |
| 438 | 13 | 36µs | 13 | 198µs | warnings->import; # spent 198µs making 13 calls to warnings::import, avg 15µs/call |
| 439 | |||||
| 440 | 13 | 3µs | my $did_init_meta; | ||
| 441 | 26 | 161µs | 13 | 41µs | for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # spent 41µs making 13 calls to UNIVERSAL::can, avg 3µs/call |
| 442 | |||||
| 443 | # init_meta can apply a role, which when loaded uses | ||||
| 444 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
| 445 | # to protect against that. | ||||
| 446 | 11 | 9µs | local $CALLER = $CALLER; | ||
| 447 | 11 | 61µs | 11 | 29.7ms | $c->init_meta( # spent 23.8ms making 7 calls to Moose::init_meta, avg 3.40ms/call
# spent 5.88ms making 4 calls to Moose::Role::init_meta, avg 1.47ms/call |
| 448 | for_class => $CALLER, | ||||
| 449 | metaclass => $metaclass, | ||||
| 450 | meta_name => $meta_name, | ||||
| 451 | ); | ||||
| 452 | 11 | 20µs | $did_init_meta = 1; | ||
| 453 | } | ||||
| 454 | |||||
| 455 | { | ||||
| 456 | # The metaroles will use Moose::Role, which in turn uses | ||||
| 457 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
| 458 | # to protect against that. | ||||
| 459 | 26 | 21µs | local $CALLER = $CALLER; | ||
| 460 | 13 | 49µs | 13 | 669µs | _apply_metaroles( # spent 669µs making 13 calls to Moose::Exporter::_apply_metaroles, avg 51µs/call |
| 461 | $CALLER, | ||||
| 462 | [$class, @$exports_from], | ||||
| 463 | $meta_lookup | ||||
| 464 | ); | ||||
| 465 | } | ||||
| 466 | |||||
| 467 | 13 | 13µs | if ( $did_init_meta && @{$traits} ) { | ||
| 468 | |||||
| 469 | # The traits will use Moose::Role, which in turn uses | ||||
| 470 | # Moose::Exporter, which in turn sets $CALLER, so we need | ||||
| 471 | # to protect against that. | ||||
| 472 | local $CALLER = $CALLER; | ||||
| 473 | _apply_meta_traits( $CALLER, $traits, $meta_lookup ); | ||||
| 474 | } | ||||
| 475 | elsif ( @{$traits} ) { | ||||
| 476 | require Moose; | ||||
| 477 | Moose->throw_error( | ||||
| 478 | "Cannot provide traits when $class does not have an init_meta() method" | ||||
| 479 | ); | ||||
| 480 | } | ||||
| 481 | |||||
| 482 | 13 | 14µs | my ( undef, @args ) = @_; | ||
| 483 | 13 | 10µs | my $extra = shift @args if ref $args[0] eq 'HASH'; | ||
| 484 | |||||
| 485 | 13 | 5µs | $extra ||= {}; | ||
| 486 | 13 | 14µs | if ( !$extra->{into} ) { | ||
| 487 | 13 | 15µs | $extra->{into_level} ||= 0; | ||
| 488 | 13 | 6µs | $extra->{into_level}++; | ||
| 489 | } | ||||
| 490 | |||||
| 491 | 13 | 113µs | 13 | 17.1ms | $class->$exporter( $extra, @args ); # spent 17.1ms making 13 calls to Sub::Exporter::__ANON__[Sub/Exporter.pm:756], avg 1.32ms/call |
| 492 | 3 | 23µs | }; | ||
| 493 | } | ||||
| 494 | |||||
| 495 | # spent 227µs (144+83) within Moose::Exporter::_strip_traits which was called 13 times, avg 17µs/call:
# 13 times (144µs+83µ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:492] at line 413, avg 17µs/call | ||||
| 496 | 26 | 179µs | 13 | 83µs | my $idx = first_index { ( $_ || '' ) eq '-traits' } @_; # spent 83µs making 13 calls to List::MoreUtils::firstidx, avg 6µs/call |
| 497 | |||||
| 498 | 13 | 66µs | return ( [], @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 499 | |||||
| 500 | my $traits = $_[ $idx + 1 ]; | ||||
| 501 | |||||
| 502 | splice @_, $idx, 2; | ||||
| 503 | |||||
| 504 | $traits = [$traits] unless ref $traits; | ||||
| 505 | |||||
| 506 | return ( $traits, @_ ); | ||||
| 507 | } | ||||
| 508 | |||||
| 509 | # spent 128µs (101+27) within Moose::Exporter::_strip_metaclass which was called 13 times, avg 10µs/call:
# 13 times (101µs+27µ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:492] at line 416, avg 10µs/call | ||||
| 510 | 26 | 91µs | 13 | 27µs | my $idx = first_index { ( $_ || '' ) eq '-metaclass' } @_; # spent 27µs making 13 calls to List::MoreUtils::firstidx, avg 2µs/call |
| 511 | |||||
| 512 | 13 | 53µs | return ( undef, @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 513 | |||||
| 514 | my $metaclass = $_[ $idx + 1 ]; | ||||
| 515 | |||||
| 516 | splice @_, $idx, 2; | ||||
| 517 | |||||
| 518 | return ( $metaclass, @_ ); | ||||
| 519 | } | ||||
| 520 | |||||
| 521 | # spent 113µs (92+21) within Moose::Exporter::_strip_meta_name which was called 13 times, avg 9µs/call:
# 13 times (92µs+21µ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:492] at line 422, avg 9µs/call | ||||
| 522 | 26 | 78µs | 13 | 21µs | my $idx = first_index { ( $_ || '' ) eq '-meta_name' } @_; # spent 21µs making 13 calls to List::MoreUtils::firstidx, avg 2µs/call |
| 523 | |||||
| 524 | 13 | 51µs | return ( 'meta', @_ ) unless $idx >= 0 && $#_ >= $idx + 1; | ||
| 525 | |||||
| 526 | my $meta_name = $_[ $idx + 1 ]; | ||||
| 527 | |||||
| 528 | splice @_, $idx, 2; | ||||
| 529 | |||||
| 530 | return ( $meta_name, @_ ); | ||||
| 531 | } | ||||
| 532 | |||||
| 533 | # spent 669µs (193+475) within Moose::Exporter::_apply_metaroles which was called 13 times, avg 51µs/call:
# 13 times (193µs+475µ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:492] at line 460, avg 51µs/call | ||||
| 534 | 13 | 19µs | my ($class, $exports_from, $meta_lookup) = @_; | ||
| 535 | |||||
| 536 | 13 | 28µs | 13 | 326µs | my $metaroles = _collect_metaroles($exports_from); # spent 326µs making 13 calls to Moose::Exporter::_collect_metaroles, avg 25µs/call |
| 537 | 13 | 12µs | my $base_class_roles = delete $metaroles->{base_class_roles}; | ||
| 538 | |||||
| 539 | 13 | 34µs | 13 | 135µs | my $meta = $meta_lookup->($class); # spent 135µs making 13 calls to Moose::Exporter::__ANON__[Moose/Exporter.pm:42], avg 10µs/call |
| 540 | # for instance, Moose.pm uses Moose::Util::TypeConstraints | ||||
| 541 | 13 | 10µs | return unless $meta; | ||
| 542 | |||||
| 543 | 11 | 11µs | Moose::Util::MetaRole::apply_metaroles( | ||
| 544 | for => $meta, | ||||
| 545 | %$metaroles, | ||||
| 546 | ) if keys %$metaroles; | ||||
| 547 | |||||
| 548 | 11 | 76µs | 11 | 14µs | Moose::Util::MetaRole::apply_base_class_roles( # spent 14µs making 11 calls to UNIVERSAL::isa, avg 1µs/call |
| 549 | for => $meta, | ||||
| 550 | roles => $base_class_roles, | ||||
| 551 | ) if $meta->isa('Class::MOP::Class') | ||||
| 552 | && $base_class_roles && @$base_class_roles; | ||||
| 553 | } | ||||
| 554 | |||||
| 555 | # spent 326µs within Moose::Exporter::_collect_metaroles which was called 13 times, avg 25µs/call:
# 13 times (326µs+0s) by Moose::Exporter::_apply_metaroles at line 536, avg 25µs/call | ||||
| 556 | 13 | 7µs | my ($exports_from) = @_; | ||
| 557 | |||||
| 558 | 13 | 93µs | my @old_style_role_types = map { "${_}_roles" } qw( | ||
| 559 | metaclass | ||||
| 560 | attribute_metaclass | ||||
| 561 | method_metaclass | ||||
| 562 | wrapped_method_metaclass | ||||
| 563 | instance_metaclass | ||||
| 564 | constructor_class | ||||
| 565 | destructor_class | ||||
| 566 | error_class | ||||
| 567 | ); | ||||
| 568 | |||||
| 569 | 13 | 4µs | my %class_metaroles; | ||
| 570 | 13 | 3µs | my %role_metaroles; | ||
| 571 | 13 | 3µs | my @base_class_roles; | ||
| 572 | 13 | 3µs | my %old_style_roles; | ||
| 573 | |||||
| 574 | 13 | 14µs | for my $exporter (@$exports_from) { | ||
| 575 | 13 | 15µs | my $data = $EXPORT_SPEC{$exporter}; | ||
| 576 | |||||
| 577 | 13 | 11µs | if (exists $data->{class_metaroles}) { | ||
| 578 | for my $type (keys %{ $data->{class_metaroles} }) { | ||||
| 579 | push @{ $class_metaroles{$type} ||= [] }, | ||||
| 580 | @{ $data->{class_metaroles}{$type} }; | ||||
| 581 | } | ||||
| 582 | } | ||||
| 583 | |||||
| 584 | 13 | 10µs | if (exists $data->{role_metaroles}) { | ||
| 585 | for my $type (keys %{ $data->{role_metaroles} }) { | ||||
| 586 | push @{ $role_metaroles{$type} ||= [] }, | ||||
| 587 | @{ $data->{role_metaroles}{$type} }; | ||||
| 588 | } | ||||
| 589 | } | ||||
| 590 | |||||
| 591 | 13 | 11µs | if (exists $data->{base_class_roles}) { | ||
| 592 | push @base_class_roles, @{ $data->{base_class_roles} }; | ||||
| 593 | } | ||||
| 594 | |||||
| 595 | 13 | 19µs | for my $type (@old_style_role_types) { | ||
| 596 | 104 | 50µs | if (exists $data->{$type}) { | ||
| 597 | push @{ $old_style_roles{$type} ||= [] }, | ||||
| 598 | @{ $data->{$type} }; | ||||
| 599 | } | ||||
| 600 | } | ||||
| 601 | } | ||||
| 602 | |||||
| 603 | return { | ||||
| 604 | 13 | 101µs | (keys(%class_metaroles) | ||
| 605 | ? (class_metaroles => \%class_metaroles) | ||||
| 606 | : ()), | ||||
| 607 | (keys(%role_metaroles) | ||||
| 608 | ? (role_metaroles => \%role_metaroles) | ||||
| 609 | : ()), | ||||
| 610 | (@base_class_roles | ||||
| 611 | ? (base_class_roles => \@base_class_roles) | ||||
| 612 | : ()), | ||||
| 613 | %old_style_roles, | ||||
| 614 | }; | ||||
| 615 | } | ||||
| 616 | |||||
| 617 | sub _apply_meta_traits { | ||||
| 618 | my ( $class, $traits, $meta_lookup ) = @_; | ||||
| 619 | |||||
| 620 | return unless @{$traits}; | ||||
| 621 | |||||
| 622 | my $meta = $meta_lookup->($class); | ||||
| 623 | |||||
| 624 | my $type = ( split /::/, ref $meta )[-1] | ||||
| 625 | or Moose->throw_error( | ||||
| 626 | 'Cannot determine metaclass type for trait application . Meta isa ' | ||||
| 627 | . ref $meta ); | ||||
| 628 | |||||
| 629 | my @resolved_traits = map { | ||||
| 630 | ref $_ | ||||
| 631 | ? $_ | ||||
| 632 | : Moose::Util::resolve_metatrait_alias( $type => $_ ) | ||||
| 633 | } @$traits; | ||||
| 634 | |||||
| 635 | return unless @resolved_traits; | ||||
| 636 | |||||
| 637 | my %args = ( for => $class ); | ||||
| 638 | |||||
| 639 | if ( $meta->isa('Moose::Meta::Role') ) { | ||||
| 640 | $args{role_metaroles} = { role => \@resolved_traits }; | ||||
| 641 | } | ||||
| 642 | else { | ||||
| 643 | $args{class_metaroles} = { class => \@resolved_traits }; | ||||
| 644 | } | ||||
| 645 | |||||
| 646 | Moose::Util::MetaRole::apply_metaroles(%args); | ||||
| 647 | } | ||||
| 648 | |||||
| 649 | # spent 53µs within Moose::Exporter::_get_caller which was called 13 times, avg 4µs/call:
# 13 times (53µs+0s) 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:492] at line 429, avg 4µs/call | ||||
| 650 | |||||
| 651 | # 1 extra level because it's called by import so there's a layer | ||||
| 652 | # of indirection | ||||
| 653 | 13 | 6µs | my $offset = 1; | ||
| 654 | |||||
| 655 | return | ||||
| 656 | 13 | 67µs | ( ref $_[1] && defined $_[1]->{into} ) ? $_[1]->{into} | ||
| 657 | : ( ref $_[1] && defined $_[1]->{into_level} ) | ||||
| 658 | ? caller( $offset + $_[1]->{into_level} ) | ||||
| 659 | : caller($offset); | ||||
| 660 | } | ||||
| 661 | |||||
| 662 | # spent 23µs within Moose::Exporter::_make_unimport_sub which was called 3 times, avg 8µs/call:
# 3 times (23µs+0s) by Moose::Exporter::build_import_methods at line 73, avg 8µs/call | ||||
| 663 | 3 | 1µs | shift; | ||
| 664 | 3 | 2µs | my $exporting_package = shift; | ||
| 665 | 3 | 1µs | my $exports = shift; | ||
| 666 | 3 | 900ns | my $export_recorder = shift; | ||
| 667 | 3 | 1µs | my $is_reexport = shift; | ||
| 668 | 3 | 1µs | my $meta_lookup = shift; | ||
| 669 | |||||
| 670 | # spent 318µs (36+282) within Moose::Exporter::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Exporter.pm:678] which was called:
# once (36µs+282µs) by MooseX::Traits::BEGIN@86 at line 86 of MooseX/Traits.pm | ||||
| 671 | 1 | 2µs | my $caller = scalar caller(); | ||
| 672 | Moose::Exporter->_remove_keywords( | ||||
| 673 | $caller, | ||||
| 674 | 1 | 30µs | 1 | 282µs | [ keys %{$exports} ], # spent 282µs making 1 call to Moose::Exporter::_remove_keywords |
| 675 | $export_recorder, | ||||
| 676 | $is_reexport, | ||||
| 677 | ); | ||||
| 678 | 3 | 18µs | }; | ||
| 679 | } | ||||
| 680 | |||||
| 681 | # spent 282µs (274+7) within Moose::Exporter::_remove_keywords which was called:
# once (274µs+7µ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:678] at line 674 | ||||
| 682 | 1 | 1µs | shift; | ||
| 683 | 1 | 1µs | my $package = shift; | ||
| 684 | 1 | 1µs | my $keywords = shift; | ||
| 685 | 1 | 1µs | my $recorded_exports = shift; | ||
| 686 | 1 | 900ns | my $is_reexport = shift; | ||
| 687 | |||||
| 688 | 3 | 51µs | 2 | 61µs | # spent 37µs (13+24) within Moose::Exporter::BEGIN@688 which was called:
# once (13µs+24µs) by Moose::BEGIN@19 at line 688 # spent 37µs making 1 call to Moose::Exporter::BEGIN@688
# spent 24µs making 1 call to strict::unimport |
| 689 | |||||
| 690 | 1 | 15µs | foreach my $name ( @{$keywords} ) { | ||
| 691 | 14 | 59µs | if ( defined &{ $package . '::' . $name } ) { | ||
| 692 | 14 | 40µs | my $sub = \&{ $package . '::' . $name }; | ||
| 693 | |||||
| 694 | # make sure it is from us | ||||
| 695 | 14 | 26µs | next unless $recorded_exports->{$sub}; | ||
| 696 | |||||
| 697 | 14 | 11µs | if ( $is_reexport->{$name} ) { | ||
| 698 | 3 | 293µs | 2 | 21µs | # spent 13µs (6+8) within Moose::Exporter::BEGIN@698 which was called:
# once (6µs+8µs) by Moose::BEGIN@19 at line 698 # spent 13µs making 1 call to Moose::Exporter::BEGIN@698
# spent 8µs making 1 call to strict::unimport |
| 699 | next | ||||
| 700 | unless _export_is_flagged( | ||||
| 701 | 2 | 39µs | 2 | 7µs | \*{ join q{::} => $package, $name } ); # spent 7µs making 2 calls to Moose::Exporter::_export_is_flagged, avg 4µs/call |
| 702 | } | ||||
| 703 | |||||
| 704 | # and if it is from us, then undef the slot | ||||
| 705 | 14 | 92µs | delete ${ $package . '::' }{$name}; | ||
| 706 | } | ||||
| 707 | } | ||||
| 708 | } | ||||
| 709 | |||||
| 710 | # maintain this for now for backcompat | ||||
| 711 | # make sure to return a sub to install in the same circumstances as previously | ||||
| 712 | # but this functionality now happens at the end of ->import | ||||
| 713 | # spent 50µs within Moose::Exporter::_make_init_meta which was called 3 times, avg 17µs/call:
# 3 times (50µs+0s) by Moose::Exporter::build_import_methods at line 81, avg 17µs/call | ||||
| 714 | 3 | 1µs | shift; | ||
| 715 | 3 | 2µs | my $class = shift; | ||
| 716 | 3 | 1µs | my $args = shift; | ||
| 717 | 3 | 1µs | my $meta_lookup = shift; | ||
| 718 | |||||
| 719 | 3 | 700ns | my %old_style_roles; | ||
| 720 | 3 | 16µs | for my $role ( | ||
| 721 | map {"${_}_roles"} | ||||
| 722 | qw( | ||||
| 723 | metaclass | ||||
| 724 | attribute_metaclass | ||||
| 725 | method_metaclass | ||||
| 726 | wrapped_method_metaclass | ||||
| 727 | instance_metaclass | ||||
| 728 | constructor_class | ||||
| 729 | destructor_class | ||||
| 730 | error_class | ||||
| 731 | ) | ||||
| 732 | ) { | ||||
| 733 | 24 | 12µs | $old_style_roles{$role} = $args->{$role} | ||
| 734 | if exists $args->{$role}; | ||||
| 735 | } | ||||
| 736 | |||||
| 737 | 3 | 1µs | my %base_class_roles; | ||
| 738 | 3 | 2µs | %base_class_roles = ( roles => $args->{base_class_roles} ) | ||
| 739 | if exists $args->{base_class_roles}; | ||||
| 740 | |||||
| 741 | my %new_style_roles = map { $_ => $args->{$_} } | ||||
| 742 | 3 | 5µs | grep { exists $args->{$_} } qw( class_metaroles role_metaroles ); | ||
| 743 | |||||
| 744 | 3 | 11µs | return unless %new_style_roles || %old_style_roles || %base_class_roles; | ||
| 745 | |||||
| 746 | return sub { | ||||
| 747 | shift; | ||||
| 748 | my %opts = @_; | ||||
| 749 | $meta_lookup->($opts{for_class}); | ||||
| 750 | }; | ||||
| 751 | } | ||||
| 752 | |||||
| 753 | # spent 74µs (29+45) within Moose::Exporter::import which was called 3 times, avg 25µs/call:
# once (11µs+23µs) by Moose::BEGIN@19 at line 19 of Moose.pm
# once (9µs+12µs) by Moose::Role::BEGIN@20 at line 20 of Moose/Role.pm
# once (9µs+10µs) by Moose::Util::TypeConstraints::BEGIN@13 at line 13 of Moose/Util/TypeConstraints.pm | ||||
| 754 | 3 | 5µs | 3 | 6µs | strict->import; # spent 6µs making 3 calls to strict::import, avg 2µs/call |
| 755 | 3 | 15µs | 3 | 39µs | warnings->import; # spent 39µs making 3 calls to warnings::import, avg 13µs/call |
| 756 | } | ||||
| 757 | |||||
| 758 | 1 | 5µs | 1; | ||
| 759 | |||||
| 760 | # ABSTRACT: make an import() and unimport() just like Moose.pm | ||||
| 761 | |||||
| - - | |||||
| 764 | =pod | ||||
| 765 | |||||
| 766 | =head1 NAME | ||||
| 767 | |||||
| 768 | Moose::Exporter - make an import() and unimport() just like Moose.pm | ||||
| 769 | |||||
| 770 | =head1 VERSION | ||||
| 771 | |||||
| 772 | version 2.0602 | ||||
| 773 | |||||
| 774 | =head1 SYNOPSIS | ||||
| 775 | |||||
| 776 | package MyApp::Moose; | ||||
| 777 | |||||
| 778 | use Moose (); | ||||
| 779 | use Moose::Exporter; | ||||
| 780 | |||||
| 781 | Moose::Exporter->setup_import_methods( | ||||
| 782 | with_meta => [ 'has_rw', 'sugar2' ], | ||||
| 783 | as_is => [ 'sugar3', \&Some::Random::thing ], | ||||
| 784 | also => 'Moose', | ||||
| 785 | ); | ||||
| 786 | |||||
| 787 | sub has_rw { | ||||
| 788 | my ( $meta, $name, %options ) = @_; | ||||
| 789 | $meta->add_attribute( | ||||
| 790 | $name, | ||||
| 791 | is => 'rw', | ||||
| 792 | %options, | ||||
| 793 | ); | ||||
| 794 | } | ||||
| 795 | |||||
| 796 | # then later ... | ||||
| 797 | package MyApp::User; | ||||
| 798 | |||||
| 799 | use MyApp::Moose; | ||||
| 800 | |||||
| 801 | has 'name'; | ||||
| 802 | has_rw 'size'; | ||||
| 803 | thing; | ||||
| 804 | |||||
| 805 | no MyApp::Moose; | ||||
| 806 | |||||
| 807 | =head1 DESCRIPTION | ||||
| 808 | |||||
| 809 | This module encapsulates the exporting of sugar functions in a | ||||
| 810 | C<Moose.pm>-like manner. It does this by building custom C<import> and | ||||
| 811 | C<unimport> methods for your module, based on a spec you provide. | ||||
| 812 | |||||
| 813 | It also lets you "stack" Moose-alike modules so you can export Moose's sugar | ||||
| 814 | as well as your own, along with sugar from any random C<MooseX> module, as | ||||
| 815 | long as they all use C<Moose::Exporter>. This feature exists to let you bundle | ||||
| 816 | a set of MooseX modules into a policy module that developers can use directly | ||||
| 817 | instead of using Moose itself. | ||||
| 818 | |||||
| 819 | To simplify writing exporter modules, C<Moose::Exporter> also imports | ||||
| 820 | C<strict> and C<warnings> into your exporter module, as well as into | ||||
| 821 | modules that use it. | ||||
| 822 | |||||
| 823 | =head1 METHODS | ||||
| 824 | |||||
| 825 | This module provides two public methods: | ||||
| 826 | |||||
| 827 | =over 4 | ||||
| 828 | |||||
| 829 | =item B<< Moose::Exporter->setup_import_methods(...) >> | ||||
| 830 | |||||
| 831 | When you call this method, C<Moose::Exporter> builds custom C<import> and | ||||
| 832 | C<unimport> methods for your module. The C<import> method | ||||
| 833 | will export the functions you specify, and can also re-export functions | ||||
| 834 | exported by some other module (like C<Moose.pm>). If you pass any parameters | ||||
| 835 | for L<Moose::Util::MetaRole>, the C<import> method will also call | ||||
| 836 | C<Moose::Util::MetaRole::apply_metaroles> and | ||||
| 837 | C<Moose::Util::MetaRole::apply_base_class_roles> as needed, after making | ||||
| 838 | sure the metaclass is initialized. | ||||
| 839 | |||||
| 840 | The C<unimport> method cleans the caller's namespace of all the exported | ||||
| 841 | functions. This includes any functions you re-export from other | ||||
| 842 | packages. However, if the consumer of your package also imports those | ||||
| 843 | functions from the original package, they will I<not> be cleaned. | ||||
| 844 | |||||
| 845 | Note that if any of these methods already exist, they will not be | ||||
| 846 | overridden, you will have to use C<build_import_methods> to get the | ||||
| 847 | coderef that would be installed. | ||||
| 848 | |||||
| 849 | This method accepts the following parameters: | ||||
| 850 | |||||
| 851 | =over 8 | ||||
| 852 | |||||
| 853 | =item * with_meta => [ ... ] | ||||
| 854 | |||||
| 855 | This list of function I<names only> will be wrapped and then exported. The | ||||
| 856 | wrapper will pass the metaclass object for the caller as its first argument. | ||||
| 857 | |||||
| 858 | Many sugar functions will need to use this metaclass object to do something to | ||||
| 859 | the calling package. | ||||
| 860 | |||||
| 861 | =item * as_is => [ ... ] | ||||
| 862 | |||||
| 863 | This list of function names or sub references will be exported as-is. You can | ||||
| 864 | identify a subroutine by reference, which is handy to re-export some other | ||||
| 865 | module's functions directly by reference (C<\&Some::Package::function>). | ||||
| 866 | |||||
| 867 | If you do export some other package's function, this function will never be | ||||
| 868 | removed by the C<unimport> method. The reason for this is we cannot know if | ||||
| 869 | the caller I<also> explicitly imported the sub themselves, and therefore wants | ||||
| 870 | to keep it. | ||||
| 871 | |||||
| 872 | =item * trait_aliases => [ ... ] | ||||
| 873 | |||||
| 874 | This is a list of package names which should have shortened aliases exported, | ||||
| 875 | similar to the functionality of L<aliased>. Each element in the list can be | ||||
| 876 | either a package name, in which case the export will be named as the last | ||||
| 877 | namespace component of the package, or an arrayref, whose first element is the | ||||
| 878 | package to alias to, and second element is the alias to export. | ||||
| 879 | |||||
| 880 | =item * also => $name or \@names | ||||
| 881 | |||||
| 882 | This is a list of modules which contain functions that the caller | ||||
| 883 | wants to export. These modules must also use C<Moose::Exporter>. The | ||||
| 884 | most common use case will be to export the functions from C<Moose.pm>. | ||||
| 885 | Functions specified by C<with_meta> or C<as_is> take precedence over | ||||
| 886 | functions exported by modules specified by C<also>, so that a module | ||||
| 887 | can selectively override functions exported by another module. | ||||
| 888 | |||||
| 889 | C<Moose::Exporter> also makes sure all these functions get removed | ||||
| 890 | when C<unimport> is called. | ||||
| 891 | |||||
| 892 | =item * meta_lookup => sub { ... } | ||||
| 893 | |||||
| 894 | This is a function which will be called to provide the metaclass | ||||
| 895 | to be operated upon by the exporter. This is an advanced feature | ||||
| 896 | intended for use by package generator modules in the vein of | ||||
| 897 | L<MooseX::Role::Parameterized> in order to simplify reusing sugar | ||||
| 898 | from other modules that use C<Moose::Exporter>. This function is | ||||
| 899 | used, for example, to select the metaclass to bind to functions | ||||
| 900 | that are exported using the C<with_meta> option. | ||||
| 901 | |||||
| 902 | This function will receive one parameter: the class name into which | ||||
| 903 | the sugar is being exported. The default implementation is: | ||||
| 904 | |||||
| 905 | sub { Class::MOP::class_of(shift) } | ||||
| 906 | |||||
| 907 | Accordingly, this function is expected to return a metaclass. | ||||
| 908 | |||||
| 909 | =back | ||||
| 910 | |||||
| 911 | You can also provide parameters for C<Moose::Util::MetaRole::apply_metaroles> | ||||
| 912 | and C<Moose::Util::MetaRole::base_class_roles>. Specifically, valid parameters | ||||
| 913 | are "class_metaroles", "role_metaroles", and "base_class_roles". | ||||
| 914 | |||||
| 915 | =item B<< Moose::Exporter->build_import_methods(...) >> | ||||
| 916 | |||||
| 917 | Returns two code refs, one for C<import> and one for C<unimport>. | ||||
| 918 | |||||
| 919 | Accepts the additional C<install> option, which accepts an arrayref of method | ||||
| 920 | names to install into your exporting package. The valid options are C<import> | ||||
| 921 | and C<unimport>. Calling C<setup_import_methods> is equivalent | ||||
| 922 | to calling C<build_import_methods> with C<< install => [qw(import unimport)] >> | ||||
| 923 | except that it doesn't also return the methods. | ||||
| 924 | |||||
| 925 | The C<import> method is built using L<Sub::Exporter>. This means that it can | ||||
| 926 | take a hashref of the form C<< { into => $package } >> to specify the package | ||||
| 927 | it operates on. | ||||
| 928 | |||||
| 929 | Used by C<setup_import_methods>. | ||||
| 930 | |||||
| 931 | =back | ||||
| 932 | |||||
| 933 | =head1 IMPORTING AND init_meta | ||||
| 934 | |||||
| 935 | If you want to set an alternative base object class or metaclass class, see | ||||
| 936 | above for details on how this module can call L<Moose::Util::MetaRole> for | ||||
| 937 | you. | ||||
| 938 | |||||
| 939 | If you want to do something that is not supported by this module, simply | ||||
| 940 | define an C<init_meta> method in your class. The C<import> method that | ||||
| 941 | C<Moose::Exporter> generates for you will call this method (if it exists). It | ||||
| 942 | will always pass the caller to this method via the C<for_class> parameter. | ||||
| 943 | |||||
| 944 | Most of the time, your C<init_meta> method will probably just call C<< | ||||
| 945 | Moose->init_meta >> to do the real work: | ||||
| 946 | |||||
| 947 | sub init_meta { | ||||
| 948 | shift; # our class name | ||||
| 949 | return Moose->init_meta( @_, metaclass => 'My::Metaclass' ); | ||||
| 950 | } | ||||
| 951 | |||||
| 952 | =head1 METACLASS TRAITS | ||||
| 953 | |||||
| 954 | The C<import> method generated by C<Moose::Exporter> will allow the | ||||
| 955 | user of your module to specify metaclass traits in a C<-traits> | ||||
| 956 | parameter passed as part of the import: | ||||
| 957 | |||||
| 958 | use Moose -traits => 'My::Meta::Trait'; | ||||
| 959 | |||||
| 960 | use Moose -traits => [ 'My::Meta::Trait', 'My::Other::Trait' ]; | ||||
| 961 | |||||
| 962 | These traits will be applied to the caller's metaclass | ||||
| 963 | instance. Providing traits for an exporting class that does not create | ||||
| 964 | a metaclass for the caller is an error. | ||||
| 965 | |||||
| 966 | =head1 BUGS | ||||
| 967 | |||||
| 968 | See L<Moose/BUGS> for details on reporting bugs. | ||||
| 969 | |||||
| 970 | =head1 AUTHOR | ||||
| 971 | |||||
| 972 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
| 973 | |||||
| 974 | =head1 COPYRIGHT AND LICENSE | ||||
| 975 | |||||
| 976 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
| 977 | |||||
| 978 | This is free software; you can redistribute it and/or modify it under | ||||
| 979 | the same terms as the Perl 5 programming language system itself. | ||||
| 980 | |||||
| 981 | =cut | ||||
| 982 | |||||
| 983 | |||||
| 984 | __END__ | ||||
# spent 7µs within Moose::Exporter::_export_is_flagged which was called 2 times, avg 4µs/call:
# 2 times (7µs+0s) by Moose::Exporter::_remove_keywords at line 701, avg 4µs/call | |||||
# spent 31µs within Moose::Exporter::_flag_as_reexport which was called 22 times, avg 1µs/call:
# 22 times (31µs+0s) 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:137] at line 135, avg 1µs/call |