Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (59 sloc) 1.869 kb
079230e @ingydotnet Start adding comments to Mo.pm
authored
1 # The first two lines are left alone in the compressed source.
dc1f1da @ingydotnet VERSION happier on own line
authored
2 package Mo;
460ed65 @ingydotnet v0.39
authored
3 $VERSION=0.39;
5a2d680 @ingydotnet Released version 0.22
authored
4
079230e @ingydotnet Start adding comments to Mo.pm
authored
5 # 'no' is a shorter 'use', but we really don't want warnings.
1c4ad6c @ingydotnet 487
authored
6 no warnings;
079230e @ingydotnet Start adding comments to Mo.pm
authored
7 # We need the package name to be relocatable for inlining. Adding the :: makes
baa5f7a @carloslima Fix comment, remove extra whitespace. Nothing, really.
carloslima authored
8 # everything shorter thereafter. We do that a lot for
079230e @ingydotnet Start adding comments to Mo.pm
authored
9 # golfing reasons. Scary.
1556a1e @dams fix https://rt.cpan.org/Public/Bug/Display.html?id=76664 and https://rt....
dams authored
10 my $MoPKG = __PACKAGE__.'::';
8cb90d0 @ingydotnet Start breaking things apart.
authored
11
079230e @ingydotnet Start adding comments to Mo.pm
authored
12 # This is our minimal constructor. Can we make it faster? We should have tests
13 # for that.
dab07c3 @dams golfing that doesn't break on 5.10.1
dams authored
14 *{$MoPKG.Object::new} = sub {
56f2663 @carloslima Returns to previous behavior of enabling lazy=>1/0 when importing defaul...
carloslima authored
15 my $class = shift;
16 my $self = bless {@_}, $class;
17 my %nonlazy_defaults = %{ $class . :: . EAGERINIT };
18 map { $self->{$_} = $nonlazy_defaults{$_}->() if !exists $self->{$_} }
19 keys %nonlazy_defaults;
20 $self
8cb90d0 @ingydotnet Start breaking things apart.
authored
21 };
22
dab07c3 @dams golfing that doesn't break on 5.10.1
dams authored
23 *{$MoPKG.import} = sub {
079230e @ingydotnet Start adding comments to Mo.pm
authored
24 # Set warnings for the caller.
f7767f2 @ingydotnet fix vim highlighting
authored
25 import warnings;
079230e @ingydotnet Start adding comments to Mo.pm
authored
26 # This is a golf for: use strict(); strict->import;
f7767f2 @ingydotnet fix vim highlighting
authored
27 $^H |= 1538;
1556a1e @dams fix https://rt.cpan.org/Public/Bug/Display.html?id=76664 and https://rt....
dams authored
28 my ($caller_pkg, %exports, %options) = caller.'::';
46662d5 @alexrj Features architecture refactored to allow for easy combination of multip...
alexrj authored
29 shift;
079230e @ingydotnet Start adding comments to Mo.pm
authored
30 # Load each feature and call its &e.
31 eval "no Mo::$_",
32 &{$MoPKG.$_.::e}(
33 $caller_pkg,
34 \%exports,
35a0a1d @ingydotnet Released version 0.30
authored
35 \%options,
36 \@_
079230e @ingydotnet Start adding comments to Mo.pm
authored
37 ) for @_;
baa5f7a @carloslima Fix comment, remove extra whitespace. Nothing, really.
carloslima authored
38 return if $exports{M};
46662d5 @alexrj Features architecture refactored to allow for easy combination of multip...
alexrj authored
39 %exports = (
dab07c3 @dams golfing that doesn't break on 5.10.1
dams authored
40 extends, sub {
41 eval "no $_[0]()";
42 @{ $caller_pkg . ISA } = $_[0];
99818e7 @ingydotnet plugin system is working now.
authored
43 },
dab07c3 @dams golfing that doesn't break on 5.10.1
dams authored
44 has, sub {
845d105 @wchristian code now contains long var names which are shortened automatically
wchristian authored
45 my $name = shift;
46662d5 @alexrj Features architecture refactored to allow for easy combination of multip...
alexrj authored
46 my $method =
99818e7 @ingydotnet plugin system is working now.
authored
47 sub {
48 $#_
845d105 @wchristian code now contains long var names which are shortened automatically
wchristian authored
49 ? $_[0]{$name} = $_[1]
50 : $_[0]{$name};
99818e7 @ingydotnet plugin system is working now.
authored
51 };
2e4155d @carloslima Accepts terse syntax using odd number of arguments
carloslima authored
52 @_ = ( default, @_ ) if !($#_%2);
748ea26 @ingydotnet Change handlers to options
authored
53 $method = $options{$_}->($method, $name, @_)
54 for sort keys %options;
46662d5 @alexrj Features architecture refactored to allow for easy combination of multip...
alexrj authored
55 *{ $caller_pkg . $name } = $method;
99818e7 @ingydotnet plugin system is working now.
authored
56 },
46662d5 @alexrj Features architecture refactored to allow for easy combination of multip...
alexrj authored
57 %exports,
99818e7 @ingydotnet plugin system is working now.
authored
58 );
079230e @ingydotnet Start adding comments to Mo.pm
authored
59 *{ $caller_pkg . $_} = $exports{$_}
60 for keys %exports;
dab07c3 @dams golfing that doesn't break on 5.10.1
dams authored
61 @{ $caller_pkg . ISA } = $MoPKG.Object;
1c4ad6c @ingydotnet 487
authored
62 };
Something went wrong with that request. Please try again.