@@ -7,6 +7,33 @@ use 5.008;
77
88our $VERSION = ' 0.51' ;
99
10+ use Module::Implementation;
11+
12+ use Exporter qw( import ) ;
13+
14+ BEGIN {
15+ # This env var exists for the benefit of the PurePerlTests dzil plugin, which only knows how to
16+ # set an env var to a true value.
17+ if ( $ENV {SPECIO_TEST_PP } ) {
18+ # # no critic (Variables::RequireLocalizedPunctuationVars)
19+ $ENV {SPECIO_IMPLEMENTATION } = ' PP' ;
20+ }
21+
22+ my $loader = Module::Implementation::build_loader_sub(
23+ implementations => [ ' XS' , ' PP' ],
24+ symbols => [' _clone' ],
25+ );
26+ $loader -> ();
27+ }
28+
29+ # It's a bit weird to put this in the root module, but this way the env var that
30+ # Module::Implementation::build_loader_sub uses will be named "SPECIO_IMPLEMENTATION". That way, if
31+ # in the future there are other optional XS components besides the Clone implementation, we don't
32+ # end up with a bunch of different env vars.
33+ #
34+ # # no critic (Modules::ProhibitAutomaticExportation)
35+ our @EXPORT = qw( _clone ) ;
36+
10371;
1138
1239# ABSTRACT: Type constraints and coercions for Perl
@@ -406,6 +433,12 @@ have much better subroutine names for any frames.
406433
407434=back
408435
436+ =head1 FORCING PURE PERL MODE
437+
438+ For some use cases (notably fatpacking a program), you may want to force Specio
439+ to use pure Perl code instead of XS code. This can be done by setting the
440+ environment variable C<SPECIO_IMPLEMENTATION > to C<PP > .
441+
409442=head1 WHY THE NAME?
410443
411444This distro was originally called "Type", but that's an awfully generic top
@@ -414,4 +447,3 @@ the word "species". It's short, relatively easy to type, and not used by any
414447other distro.
415448
416449=cut
417-
0 commit comments