Kavorka
view release on metacpan or search on metacpan
}
},
"runtime" : {
"recommends" : {
"Type::Tiny::XS" : "0.010"
},
"requires" : {
"Exporter::Tiny" : "0.026",
"Module::Runtime" : "0",
"Moo" : "1.003001",
"PadWalker" : "0",
"Parse::Keyword" : "0.06",
"Return::Type" : "0.004",
"Sub::Util" : "0",
"Type::Parser" : "0.032",
"Type::Registry" : "0.032",
"Type::Utils" : "0.032",
"Types::Standard" : "0.032",
"match::simple" : "0",
"namespace::sweep" : "0.006",
"perl" : "5.014"
version: '0.039'
Parse::KeywordX:
file: lib/Parse/KeywordX.pm
version: '0.039'
recommends:
Type::Tiny::XS: '0.010'
requires:
Exporter::Tiny: '0.026'
Module::Runtime: '0'
Moo: '1.003001'
PadWalker: '0'
Parse::Keyword: '0.06'
Return::Type: '0.004'
Sub::Util: '0'
Type::Parser: '0.032'
Type::Registry: '0.032'
Type::Utils: '0.032'
Types::Standard: '0.032'
match::simple: '0'
namespace::sweep: '0.006'
perl: '5.014'
Makefile.PL view on Meta::CPAN
configure => { requires => { "ExtUtils::MakeMaker" => 6.17 } },
develop => { suggests => { "Data::Alias" => 0, "Dist::Inkt" => 0.001 } },
runtime => {
recommends => { "Type::Tiny::XS" => "0.010" },
requires => {
"Exporter::Tiny" => 0.026,
"match::simple" => 0,
"Module::Runtime" => 0,
"Moo" => 1.003001,
"namespace::sweep" => 0.006,
"PadWalker" => 0,
"Parse::Keyword" => 0.06,
"perl" => 5.014,
"Return::Type" => 0.004,
"Sub::Util" => 0,
"Type::Parser" => 0.032,
"Type::Registry" => 0.032,
"Type::Utils" => 0.032,
"Types::Standard" => 0.032,
},
},
Kavorka method signatures via the meta object protocol.
Kavorka::Manual::API provides more details and examples using the
introspection API.
CAVEATS
* As noted in Kavorka::Manual::PrototypeAndAttributes, subroutine
attributes don't work properly for anonymous functions.
* This module is based on Parse::Keyword, which has a chronically broken
implementation of closures. Kavorka uses PadWalker to attempt to work
around the problem. This mostly seems to work, but you may experience
some problems in edge cases, especially for anonymous functions and
methods.
* If importing Kavorka's method modifiers into Moo/Mouse/Moose classes,
pay attention to load order:
use Moose;
use Kavorka -all; # ok
doap-deps:develop-suggestion [ doap-deps:on "Data::Alias"^^doap-deps:CpanId ], [ doap-deps:on "Dist::Inkt 0.001"^^doap-deps:CpanId ];
doap-deps:runtime-recommendation [
doap-deps:on "Type::Tiny::XS 0.010"^^doap-deps:CpanId;
];
doap-deps:runtime-requirement [ doap-deps:on "perl 5.014"^^doap-deps:CpanId ], [
doap-deps:on "Exporter::Tiny 0.026"^^doap-deps:CpanId;
], [ doap-deps:on "Type::Utils 0.032"^^doap-deps:CpanId ], [
doap-deps:on "Types::Standard 0.032"^^doap-deps:CpanId;
], [ doap-deps:on "match::simple"^^doap-deps:CpanId ], [
doap-deps:on "namespace::sweep 0.006"^^doap-deps:CpanId;
], [ doap-deps:on "Module::Runtime 0"^^doap-deps:CpanId ], [ doap-deps:on "Moo 1.003001"^^doap-deps:CpanId ], [ doap-deps:on "PadWalker 0"^^doap-deps:CpanId ], [
doap-deps:on "Parse::Keyword 0.06"^^doap-deps:CpanId;
], [ doap-deps:on "Return::Type 0.004"^^doap-deps:CpanId ], [ doap-deps:on "Sub::Util"^^doap-deps:CpanId ], [
doap-deps:on "Type::Parser 0.032"^^doap-deps:CpanId;
rdfs:comment "Fix for comma-delimited type lists.";
], [
doap-deps:on "Type::Registry 0.032"^^doap-deps:CpanId;
];
doap-deps:test-recommendation [ doap-deps:on "Moose 2.0000"^^doap-deps:CpanId ], [ doap-deps:on "Mouse 1.00"^^doap-deps:CpanId ], [ doap-deps:on "Class::Tiny"^^doap-deps:CpanId ], [
doap-deps:on "Role::Tiny 1.003000"^^doap-deps:CpanId;
], [
lib/Kavorka.pm view on Meta::CPAN
use 5.014;
use strict;
use warnings;
no warnings 'void';
use Carp ();
use Exporter::Tiny ();
use PadWalker ();
use Parse::Keyword ();
use Module::Runtime ();
use Scalar::Util ();
use Sub::Util ();
package Kavorka;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.039';
lib/Kavorka.pm view on Meta::CPAN
# Install sub
my @r = wantarray
? $subroutine->install_sub
: scalar($subroutine->install_sub);
# Workarounds for closure issues in Parse::Keyword
if ($subroutine->is_anonymous)
{
my $orig = $r[0];
my $caller_vars = PadWalker::peek_my(1);
@r = Sub::Util::set_subname($subroutine->package."::__ANON__", sub {
$subroutine->_poke_pads($caller_vars);
goto $orig;
});
&Scalar::Util::set_prototype($r[0], $_) for grep defined, prototype($orig);
$INFO{ $r[0] } = $subroutine;
Scalar::Util::weaken($INFO{ $r[0] });
}
else
{
$subroutine->_poke_pads( PadWalker::peek_my(1) );
}
# Prevents a cycle between %INFO and $subroutine.
Scalar::Util::weaken($subroutine->{body})
unless Scalar::Util::isweak($subroutine->{body});
wantarray ? @r : $r[0];
},
);
lib/Kavorka.pm view on Meta::CPAN
=over
=item *
As noted in L<Kavorka::Manual::PrototypeAndAttributes>, subroutine
attributes don't work properly for anonymous functions.
=item *
This module is based on L<Parse::Keyword>, which has a chronically
broken implementation of closures. Kavorka uses L<PadWalker> to attempt
to work around the problem. This mostly seems to work, but you may
experience some problems in edge cases, especially for anonymous
functions and methods.
=item *
If importing Kavorka's method modifiers into Moo/Mouse/Moose classes,
pay attention to load order:
use Moose;
lib/Kavorka/Sub.pm view on Meta::CPAN
{
my $self = shift;
my $code = $self->body;
if ($self->is_anonymous)
{
# no installation
}
elsif ($self->is_lexical)
{
require PadWalker;
PadWalker::peek_my(2)->{ $self->declared_name } = \$code;
}
else
{
my $name = $self->qualified_name;
no strict 'refs';
*{$name} = $code;
}
$code;
}
lib/Kavorka/Sub.pm view on Meta::CPAN
\@pads;
}
sub _poke_pads
{
my $self = shift;
my ($vars) = @_;
for my $code (@{$self->_pads_to_poke})
{
my $closed_over = PadWalker::closed_over($code);
ref($vars->{$_}) && ($closed_over->{$_} = $vars->{$_})
for keys %$closed_over;
PadWalker::set_closed_over($code, $closed_over);
}
();
}
1;
__END__
=pod
lib/Parse/KeywordX.pm view on Meta::CPAN
use warnings;
use Exporter::Tiny ();
package Parse::KeywordX;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.039';
use Text::Balanced qw( extract_bracketed );
use PadWalker qw( closed_over set_closed_over peek_my );
use Parse::Keyword {};
our @ISA = qw( Exporter::Tiny );
our @EXPORT = qw( parse_name parse_variable parse_trait parse_block_or_match );
#### From p5-mop-redux
sub read_tokenish ()
{
my $token = '';
if ((my $next = lex_peek) =~ /[\$\@\%]/)
( run in 0.974 second using v1.01-cache-2.11-cpan-05444aca049 )