]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Scope.pm
This is 0.03
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Scope.pm
index 1a57c613f36fbf1513be0a3f72d5ea3d331939d7..a9e85b651bc78436c4460fef174a9c7a30e5fbbe 100644 (file)
@@ -9,17 +9,17 @@ LaTeX::TikZ::Scope - An object modeling a TikZ scope or layer.
 
 =head1 VERSION
 
-Version 0.02
+Version 0.03
 
 =cut
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 use Sub::Name ();
 
 use LaTeX::TikZ::Tools;
 
-use Any::Moose;
+use Mouse;
 
 =head1 ATTRIBUTES
 
@@ -49,7 +49,7 @@ has '_mods_cache' => (
 
 has 'body' => (
  is       => 'ro',
- isa      => 'LaTeX::TikZ::Scope|ArrayRef[Str]',
+ isa      => 'ArrayRef[Str]',
  required => 1,
  init_arg => 'body',
 );
@@ -69,6 +69,14 @@ around 'BUILDARGS' => sub {
   }
  }
 
+ my $body = $args{body};
+ if ($my_tc->check($body)) {
+  push @$mods, $body->mods;
+  $args{body} = $body->body;
+ }
+
+ $args{mods} = $mods;
+
  $class->$orig(%args);
 };
 
@@ -89,23 +97,8 @@ sub BUILD {
 
 =head1 METHODS
 
-=head2 C<flatten>
-
 =cut
 
-sub flatten {
- my ($scope) = @_;
-
- do {
-  my $body = $scope->body;
-  return $scope unless $my_tc->check($body);
-  $scope = $scope->new(
-   mods => [ $scope->mods, $body->mods ],
-   body => $body->body,
-  );
- } while (1);
-}
-
 my $inter = Sub::Name::subname('inter' => sub {
  my ($lh, $rh) = @_;
 
@@ -135,8 +128,6 @@ my $inter = Sub::Name::subname('inter' => sub {
 sub instantiate {
  my ($scope) = @_;
 
- $scope = $scope->flatten;
-
  my ($layer, @clips, @raw_mods);
  for ($scope->mods) {
   my $type = $_->type;
@@ -192,10 +183,8 @@ sub fold {
  my (@left, @right);
 
  if ($my_tc->check($left)) {
-  $left = $left->flatten;
 
   if ($my_tc->check($right)) {
-   $right = $right->flatten;
 
    my ($only_left, $common, $only_right) = $inter->(
     $left->_mods_cache,
@@ -274,7 +263,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2010 Vincent Pit, all rights reserved.
+Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.