diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-10 14:17:52 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-10 14:17:52 -0400 |
commit | 818958abaf7ad4f86101f88e74caf688b23be9a3 (patch) | |
tree | 0dca925e22a60be5b63405e49c531d1ca93d9d2c /lib/Exporter/Lexical.pm | |
parent | a571380fee1cfd63ba816842df95777ac9b2b0cb (diff) | |
download | exporter-lexical-818958abaf7ad4f86101f88e74caf688b23be9a3.tar.gz exporter-lexical-818958abaf7ad4f86101f88e74caf688b23be9a3.zip |
initial (non-working) implementation
Diffstat (limited to 'lib/Exporter/Lexical.pm')
-rw-r--r-- | lib/Exporter/Lexical.pm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Exporter/Lexical.pm b/lib/Exporter/Lexical.pm index e69de29..d7f0ee3 100644 --- a/lib/Exporter/Lexical.pm +++ b/lib/Exporter/Lexical.pm @@ -0,0 +1,40 @@ +package Exporter::Lexical; +use strict; +use warnings; +# ABSTRACT: exporter for lexical subs + +use XSLoader; +XSLoader::load( + __PACKAGE__, + # we need to be careful not to touch $VERSION at compile time, otherwise + # DynaLoader will assume it's set and check against it, which will cause + # fail when being run in the checkout without dzil having set the actual + # $VERSION + exists $Exporter::Lexical::{VERSION} + ? ${ $Exporter::Lexical::{VERSION} } : (), +); + +sub import { + my $package = shift; + my $caller = caller; + + my $import = sub { + my $caller_stash = do { + no strict 'refs'; + \%{ $caller . '::' }; + }; + my @exports = @{ $caller_stash->{EXPORT} }; + my %exports = map { $_ => \&{ $caller_stash->{$_} } } @exports; + + for my $export (keys %exports) { + lexical_import($export, $exports{$export}); + } + }; + + { + no strict 'refs'; + *{ $caller . '::import' } = $import; + } +} + +1; |