1#============================================================= -*-Perl-*-
2#
3# Template::Stash::XS
4#
5# DESCRIPTION
6#
7#   Perl bootstrap for XS module. Inherits methods from
8#   Template::Stash when not implemented in the XS module.
9#
10#========================================================================
11
12package Template::Stash::XS;
13
14use strict;
15use warnings;
16use Template;
17use Template::Stash;
18
19our $AUTOLOAD;
20
21BEGIN {
22    require DynaLoader;
23    @Template::Stash::XS::ISA = qw( DynaLoader Template::Stash );
24
25    eval {
26        bootstrap Template::Stash::XS $Template::VERSION;
27    };
28    if ($@) {
29        die "Couldn't load Template::Stash::XS $Template::VERSION:\n\n$@\n";
30    }
31}
32
33sub DESTROY {
34    # no op
35    1;
36}
37
38
39# catch missing method calls here so perl doesn't barf
40# trying to load *.al files
41
42sub AUTOLOAD {
43    my ($self, @args) = @_;
44    my @c             = caller(0);
45    my $auto	    = $AUTOLOAD;
46
47    $auto =~ s/.*:://;
48    $self =~ s/=.*//;
49
50    die "Can't locate object method \"$auto\"" .
51        " via package \"$self\" at $c[1] line $c[2]\n";
52}
53
541;
55
56__END__
57
58=head1 NAME
59
60Template::Stash::XS - High-speed variable stash written in C
61
62=head1 SYNOPSIS
63
64    use Template;
65    use Template::Stash::XS;
66
67    my $stash = Template::Stash::XS->new(\%vars);
68    my $tt2   = Template->new({ STASH => $stash });
69
70=head1 DESCRIPTION
71
72The Template:Stash::XS module is an implementation of the
73Template::Stash written in C.  The "XS" in the name refers to Perl's
74XS extension system for interfacing Perl to C code.  It works just
75like the regular Perl implementation of Template::Stash but runs about
76twice as fast.
77
78The easiest way to use the XS stash is to configure the Template
79Toolkit to use it by default.  You can do this at installation time
80(when you run C<perl Makefile.PL>) by answering 'y' to the questions:
81
82    Do you want to build the XS Stash module?      y
83    Do you want to use the XS Stash by default?    y
84
85See the F<INSTALL> file distributed with the Template Toolkit for further
86details on installation.
87
88If you don't elect to use the XS stash by default then you should use
89the C<STASH> configuration item when you create a new Template object.
90This should reference an XS stash object that you have created
91manually.
92
93    use Template;
94    use Template::Stash::XS;
95
96    my $stash = Template::Stash::XS->new(\%vars);
97    my $tt2   = Template->new({ STASH => $stash });
98
99Alternately, you can set the C<$Template::Config::STASH> package
100variable like so:
101
102    use Template;
103    use Template::Config;
104
105    $Template::Config::STASH = 'Template::Stash::XS';
106
107    my $tt2 = Template->new();
108
109The XS stash will then be automatically used.
110
111If you want to use the XS stash by default and don't want to
112re-install the Template Toolkit, then you can manually modify the
113C<Template/Config.pm> module near line 42 to read:
114
115    $STASH = 'Template::Stash::XS';
116
117=head1 BUGS
118
119Please report bugs to the Template Toolkit mailing list
120templates@template-toolkit.org
121
122=head1 AUTHORS
123
124Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/>
125
126Doug Steinwand E<lt>dsteinwand@citysearch.comE<gt>
127
128=head1 COPYRIGHT
129
130Copyright (C) 1996-2012 Andy Wardley.  All Rights Reserved.
131
132This module is free software; you can redistribute it and/or
133modify it under the same terms as Perl itself.
134
135=head1 SEE ALSO
136
137L<Template::Stash>
138