| 1 | # $Id: Compile.pm,v 1.2 2007-01-02 22:03:22 pajas Exp $ | ||
| 2 | |||
| 3 | package XML::XSH2::Compile; | ||
| 4 | use Module::Compile -base; | ||
| 5 | |||
| 6 | use vars qw($VERSION); | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | $VERSION='2.2.10'; # VERSION TEMPLATE | ||
| 10 | |||
| 11 | sub pmc_compile { | ||
| 12 | my ($class, $source) = @_; | ||
| 13 | require XML::XSH2; | ||
| 14 | my $dump=''; | ||
| 15 | $XML::XSH2::Functions::DUMP=\$dump; | ||
| 16 | XML::XSH2::set_compile_only_mode(1); | ||
| 17 | XML::XSH2::set_quiet(1); | ||
| 18 | XML::XSH2::xsh($source); | ||
| 19 | return $dump; | ||
| 20 | }; | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | XML::XSH2::Compile - Create modules with built-in XSH commands | ||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | package Foo; | ||
| 31 | |||
| 32 | # perl code | ||
| 33 | |||
| 34 | use XML::XSH2::Compile; | ||
| 35 | |||
| 36 | # XSH Language commands (see L<XSH>) | ||
| 37 | |||
| 38 | no XML::XSH2::Compile; | ||
| 39 | |||
| 40 | # perl code | ||
| 41 | 1; | ||
| 42 | |||
| 43 | =head1 DESCRIPTION | ||
| 44 | |||
| 45 | With this module one can efficiently embed XSH2 scripts into Perl | ||
| 46 | modules. In this respect, it is similar to C<XML::XSH2::Inline>, but | ||
| 47 | with C<XML::XSH2::Compile>, all XSH2 blocks are compiled into Perl | ||
| 48 | code the first time the module is run. This makes them execute faster | ||
| 49 | any later time. The compiled result is cached in a ".pmc" file. | ||
| 50 | |||
| 51 | See L<Module::Compile> for more details. | ||
| 52 | |||
| 53 | =head1 REQUIRES | ||
| 54 | |||
| 55 | Module::Compile, XML::XSH2 | ||
| 56 | |||
| 57 | =head1 EXPORTS | ||
| 58 | |||
| 59 | None. | ||
| 60 | |||
| 61 | =head1 AUTHOR | ||
| 62 | |||
| 63 | Petr Pajas, pajas@matfyz.cz | ||
| 64 | |||
| 65 | =head1 SEE ALSO | ||
| 66 | |||
| 67 | L<Module::Compile>, L<xsh>, L<XSH>, L<XML::XSH2>, L<XML::XSH2::Inline> | ||
| 68 | |||
| 69 | =cut | ||
| 70 |