[Templates-svn] r1105 - in trunk: lib/Template lib/Template/Stash t

svn at template-toolkit.org svn at template-toolkit.org
Mon Jan 21 18:59:46 GMT 2008


Author: abw
Date: 2008-01-21 18:59:28 +0000 (Mon, 21 Jan 2008)
New Revision: 1105

Modified:
   trunk/lib/Template/Stash.pm
   trunk/lib/Template/Stash/XS.pm
   trunk/t/stash-xs.t
   trunk/t/stash.t
Log:
Exposed dotop() method in Template::Stash and added some tests

Modified: trunk/lib/Template/Stash/XS.pm
===================================================================
--- trunk/lib/Template/Stash/XS.pm	2008-01-21 15:35:17 UTC (rev 1104)
+++ trunk/lib/Template/Stash/XS.pm	2008-01-21 18:59:28 UTC (rev 1105)
@@ -15,54 +15,42 @@
 use Template::Stash;
 
 BEGIN {
-  require DynaLoader;
-  @Template::Stash::XS::ISA = qw( DynaLoader Template::Stash );
+    require DynaLoader;
+    @Template::Stash::XS::ISA = qw( DynaLoader Template::Stash );
 
-  eval {
-    bootstrap Template::Stash::XS $Template::VERSION;
-  };
-  if ($@) {
-    die "Couldn't load Template::Stash::XS $Template::VERSION:\n\n$@\n";
-  }
+    eval {
+        bootstrap Template::Stash::XS $Template::VERSION;
+    };
+    if ($@) {
+        die "Couldn't load Template::Stash::XS $Template::VERSION:\n\n$@\n";
+    }
 }
 
 
 sub DESTROY {
-  # no op
-  1;
+    # no op
+    1;
 }
 
 
 # catch missing method calls here so perl doesn't barf 
 # trying to load *.al files 
 sub AUTOLOAD {
-  my ($self, @args) = @_;
-  my @c             = caller(0);
-  my $auto	    = $AUTOLOAD;
+    my ($self, @args) = @_;
+    my @c             = caller(0);
+    my $auto	    = $AUTOLOAD;
 
-  $auto =~ s/.*:://;
-  $self =~ s/=.*//;
+    $auto =~ s/.*:://;
+    $self =~ s/=.*//;
 
-  die "Can't locate object method \"$auto\"" .
-      " via package \"$self\" at $c[1] line $c[2]\n";
+    die "Can't locate object method \"$auto\"" .
+        " via package \"$self\" at $c[1] line $c[2]\n";
 }
 
 1;
 
 __END__
 
-
-#------------------------------------------------------------------------
-# IMPORTANT NOTE
-#   This documentation is generated automatically from source
-#   templates.  Any changes you make here may be lost.
-# 
-#   The 'docsrc' documentation source bundle is available for download
-#   from http://www.template-toolkit.org/docs.html and contains all
-#   the source templates, XML files, scripts, etc., from which the
-#   documentation for the Template Toolkit is built.
-#------------------------------------------------------------------------
-
 =head1 NAME
 
 Template::Stash::XS - High-speed variable stash written in C
@@ -129,27 +117,17 @@
 
 =head1 AUTHORS
 
-Andy Wardley E<lt>abw at tt2.orgE<gt>
+Andy Wardley E<lt>abw at wardley.orgE<gt> L<http://wardley.org/>
 
 Doug Steinwand E<lt>dsteinwand at citysearch.comE<gt>
 
-=head1 VERSION
-
-Template Toolkit version 2.19, released on 27 April 2007.
-
-
-
 =head1 COPYRIGHT
 
-  Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
+Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.
 
-
 This module is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.
 
-
-
 =head1 SEE ALSO
 
-L<Template::Stash|Template::Stash>
-
+L<Template::Stash>

Modified: trunk/lib/Template/Stash.pm
===================================================================
--- trunk/lib/Template/Stash.pm	2008-01-21 15:35:17 UTC (rev 1104)
+++ trunk/lib/Template/Stash.pm	2008-01-21 18:59:28 UTC (rev 1105)
@@ -27,7 +27,11 @@
 our $DEBUG   = 0 unless defined $DEBUG;
 our $PRIVATE = qr/^[_.]/;
 
+# alias _dotop() to dotop() so that we have a consistent method name
+# between the Perl and XS stash implementations
+*dotop = \&_dotop;
 
+
 #------------------------------------------------------------------------
 # Virtual Methods
 #

Modified: trunk/t/stash-xs.t
===================================================================
--- trunk/t/stash-xs.t	2008-01-21 15:35:17 UTC (rev 1104)
+++ trunk/t/stash-xs.t	2008-01-21 18:59:28 UTC (rev 1105)
@@ -104,6 +104,9 @@
 $stash->set( 'bar.buz' => 100 );
 match( $stash->get('bar.buz'), 100 );
 
+# test the dotop() method
+match( $stash->dotop({ foo => 10 }, 'foo'), 10 );
+
 my $stash_dbg = Template::Stash::XS->new({ %$data, _DEBUG => 1 });
 
 my $ttlist = [

Modified: trunk/t/stash.t
===================================================================
--- trunk/t/stash.t	2008-01-21 15:35:17 UTC (rev 1104)
+++ trunk/t/stash.t	2008-01-21 18:59:28 UTC (rev 1105)
@@ -90,6 +90,10 @@
 $stash->set( 'bar.buz' => 100 );
 match( $stash->get('bar.buz'), 100 );
 
+# test the dotop() method
+match( $stash->dotop({ foo => 10 }, 'foo'), 10 );
+
+
 my $ttlist = [
     'default' => Template->new(),
     'warn'    => Template->new(DEBUG => DEBUG_UNDEF, DEBUG_FORMAT => ''),




More information about the templates-svn mailing list