Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moo conversion #140

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use inc::Module::Install;

all_from 'lib/Text/Xslate.pm';

requires 'Mouse' => '0.61';
requires 'Moo' => '2.000001';
requires 'Data::MessagePack' => '0.38';
requires 'parent' => '0.221';
requires 'Scalar::Util' => '1.14';
Expand Down
4 changes: 2 additions & 2 deletions lib/Text/Xslate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ sub _compiler {
my $compiler = $self->{compiler};

if(!ref $compiler){
require Mouse;
Mouse::load_class($compiler);
require Class::Load;
Class::Load::load_class($compiler);

my $input_layer = $self->input_layer;
$compiler = $compiler->new(
Expand Down
36 changes: 19 additions & 17 deletions lib/Text/Xslate/Compiler.pm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package Text::Xslate::Compiler;
use Mouse;
use Mouse::Util::TypeConstraints;
use Moo 2.000001;

use Scalar::Util ();
use Carp ();

use MooX::Types::MooseLike::Base qw(:all);

use Text::Xslate::Parser;
use Text::Xslate::Util qw(
$DEBUG
Expand Down Expand Up @@ -126,68 +127,68 @@ my %builtin = (

has lvar_id => ( # local variable id
is => 'rw',
isa => 'Int',
isa => Int,

init_arg => undef,
);

has lvar => ( # local variable id table
is => 'rw',
isa => 'HashRef[Int]',
isa => HashRef[Int],

init_arg => undef,
);

has const => (
is => 'rw',
isa => 'ArrayRef',
isa => ArrayRef,

init_arg => undef,
);

has macro_table => (
is => 'rw',
isa => 'HashRef',
isa => HashRef,

predicate => 'has_macro_table',
init_arg => undef,
);

has engine => ( # Xslate engine
is => 'ro',
isa => 'Object',
isa => Object,
required => 0,
weak_ref => 1,
);

has dependencies => (
is => 'ro',
isa => 'ArrayRef',
isa => ArrayRef,
init_arg => undef,
);

has type => (
is => 'rw',
isa => enum([qw(html xml text)]),
isa => Enum[qw(html xml text)],
default => 'html',
);

has syntax => (
is => 'rw',

default => 'Kolon',
default => sub{'Kolon'},
);

has parser_option => (
is => 'rw',
isa => 'HashRef',
isa => HashRef,

default => sub { {} },
);

has parser => (
is => 'rw',
isa => 'Object', # Text::Xslate::Parser
isa => Object, # Text::Xslate::Parser

handles => [qw(define_function)],

Expand All @@ -204,11 +205,13 @@ has input_layer => (
sub _build_parser {
my($self) = @_;
my $syntax = $self->syntax;

if(ref($syntax)) {
return $syntax;
}
else {
my $parser_class = Mouse::Util::load_first_existing_class(
require Class::Load;
my $parser_class = Class::Load::load_first_existing_class(
"Text::Xslate::Syntax::" . $syntax,
$syntax,
);
Expand All @@ -227,7 +230,7 @@ has cascade => (

has [qw(header footer macro)] => (
is => 'rw',
isa => 'ArrayRef',
isa => ArrayRef,
);

has current_file => (
Expand All @@ -244,7 +247,7 @@ has file => (

has overridden_builtin => (
is => 'ro',
isa => 'HashRef',
isa => HashRef,

default => sub { +{} },
);
Expand Down Expand Up @@ -1594,8 +1597,7 @@ sub _error {
die $self->make_error($message, $self->file, $line);
}

no Mouse;
no Mouse::Util::TypeConstraints;
no Moo;

__PACKAGE__->meta->make_immutable;
__END__
Expand Down
4 changes: 2 additions & 2 deletions lib/Text/Xslate/PP/Opcode.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Text::Xslate::PP::Opcode;
use Mouse;
use Moo 2.000001;
extends qw(Text::Xslate::PP::State);

our $VERSION = '3.3.4';
Expand Down Expand Up @@ -635,7 +635,7 @@ sub proccall {
}
}

no Mouse;
no Moo;
__PACKAGE__->meta->make_immutable();
__END__

Expand Down
4 changes: 2 additions & 2 deletions lib/Text/Xslate/PP/State.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Text::Xslate::PP::State; # implement tx_state_t
use Mouse;
use Moo 2.000001;

use Text::Xslate::Util qw(neat p $DEBUG);
use Text::Xslate::PP;
Expand Down Expand Up @@ -234,7 +234,7 @@ sub bad_arg {
return $st->error($context, "Wrong number of arguments for %s", $name);
}

no Mouse;
no Moo;
__PACKAGE__->meta->make_immutable;
1;
__END__
Expand Down
17 changes: 10 additions & 7 deletions lib/Text/Xslate/PP/Type/Macro.pm
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
package Text::Xslate::PP::Type::Macro;
use Mouse;

use warnings FATAL => 'recursion';

use Moo 2.000001;
use MooX::Types::MooseLike::Base qw(:all);

use overload
'&{}' => \&as_code_ref,
fallback => 1,
;

has name => (
is => 'ro',
isa => 'Str',
isa => Str,

required => 1,
);

has addr => (
is => 'ro',
isa => 'Int',
isa => Int,

required => 1,
);

has nargs => (
is => 'rw',
isa => 'Int',
isa => Int,

default => 0,
);

has outer => (
is => 'rw',
isa => 'Int',
isa => Int,

default => 0,
);

has state => (
is => 'rw',
isa => 'Object',
isa => Object,

required => 1,
weak_ref => 1,
Expand All @@ -53,7 +56,7 @@ sub as_code_ref {
};
}

no Mouse;
no Moo;
__PACKAGE__->meta->make_immutable;
__END__

Expand Down
4 changes: 2 additions & 2 deletions lib/Text/Xslate/PP/Type/Pair.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package Text::Xslate::PP::Type::Pair;
use Mouse;
use Moo 2.000001;

has [qw(key value)] => (
is => 'rw',
required => 1,
);

no Mouse;
no Moo;
__PACKAGE__->meta->make_immutable();
__END__

Expand Down
Loading