Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mo inlined
  • Loading branch information
ingydotnet committed Sep 26, 2011
1 parent b8b83cd commit 471b0ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Changes
@@ -1,4 +1,9 @@
---
version: 0.24
date:
changes:
- Use new Mo, inlined.
---
version: 0.23
date: Wed Sep 21 23:47:33 CEST 2011
changes:
Expand Down
2 changes: 1 addition & 1 deletion lib/TestML.pm
Expand Up @@ -18,7 +18,7 @@ package TestML;

use TestML::Runtime;

our $VERSION = '0.23';
our $VERSION = '0.24';

use constant XXX_skip => 1;
our $DumpModule = 'YAML::XS';
Expand Down
16 changes: 11 additions & 5 deletions lib/TestML/Mo.pm
Expand Up @@ -6,19 +6,25 @@
# copyright: 2010, 2011

package TestML::Mo;
use Mo;
# use Mo qw'default builder';
no warnings;my$K=__PACKAGE__."::";*{$K.'Object::new'}=sub{my$c=shift;my$s=bless{@_},$c;my@B;do{@B=($c.'::BUILD',@B)}while($c)=@{$c.'::ISA'};exists&$_&&&$_($s)for@B;$s};*{$K.'import'}=sub{import warnings;$^H|=1538;my$P=caller."::";my%e=(extends=>sub{eval"no $_[0]()";@{$P.'ISA'}=$_[0]},has=>sub{my$n=shift;*{$P.$n}=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}}},);for(@_[1..$#_]){eval"require Mo::$_;1";%e=&{$K."${_}::e"}($P=>%e)}*{$P.$_}=$e{$_}for keys%e;@{$P.'ISA'}=$K.'Object'};*{$K.'default::e'}=sub{my$P=shift;my%e=@_;my$o=$e{has};$e{has}=sub{my($n,%a)=@_;my$d=$a{default};*{$P.$n}=$d?sub{$#_?$_[0]{$n}=$_[1]:!exists$_[0]{$n}?$_[0]{$n}=$_[0]->$d:$_[0]{$n}}:$o->(@_)};%e};*{$K.'builder::e'}=sub{my$P=shift;my%e=@_;my$o=$e{has};$e{has}=sub{my($n,%a)=@_;my$b=$a{builder};*{$P.$n}=$b?sub{$#_?$_[0]{$n}=$_[1]:!exists$_[0]{$n}?$_[0]{$n}=$_[0]->$b:$_[0]{$n}}:$o->(@_)};%e};
use strict;
use warnings;
no strict 'refs';
no warnings 'redefine';

sub import {
my $import = \&{__PACKAGE__ . '::import'};
*import = sub {
my $p = caller;
no strict 'refs';
if (not defined &{$p.'::XXX'}) {
*{$p.'::WWW'} = \&WWW;
*{$p.'::XXX'} = \&XXX;
*{$p.'::YYY'} = \&YYY;
*{$p.'::ZZZ'} = \&ZZZ;
}
goto &Mo::import;
}
push @_, qw(builder default);
goto &$import;
};

use constant XXX_skip => 1;
our $DumpModule = 'YAML::XS';
Expand Down

0 comments on commit 471b0ce

Please sign in to comment.