Skip to content

Commit

Permalink
Forgot this bit in my last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Mar 20, 2013
1 parent 50d2a3d commit 5f73dc3
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions lib/perl5i/2/Signatures.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ use Sub::Name;
sub import {
my $class = shift;

my %opts = @_;
$opts{into} ||= caller;
my %opts = @_;
$opts{into} ||= caller;
$opts{invocant} ||= '$self';

my %def_opts = %opts;
delete $def_opts{invocant};

# Define "method"
$class->install_methodhandler(
name => 'method',
%opts
name => 'method',
%opts
);

# Define "func"
$class->install_methodhandler(
name => 'func',
%def_opts
name => 'func',
%def_opts
);
}

Expand All @@ -44,7 +44,7 @@ sub parse_proto {
my $invocant = $self->{invocant};

my $inject = '';
if( $invocant ) {
if ($invocant) {
$invocant = $1 if $proto =~ s{^(\$\w+):\s*}{};
$inject .= "my ${invocant} = shift;";
}
Expand All @@ -53,51 +53,54 @@ sub parse_proto {
return $inject;
}


sub code_for {
my ($self, $name) = @_;
my ( $self, $name ) = @_;

my $signature = $self->{perl5i}{signature};
my $is_method = $self->{invocant} ? 1 : 0;

if (defined $name) {
if ( defined $name ) {
my $pkg = $self->get_curstash_name;
$name = join( '::', $pkg, $name )
unless( $name =~ /::/ );
unless ( $name =~ /::/ );
return sub (&) {
my $code = shift;
( undef, undef, my $end_line ) = caller();
# So caller() gets the subroutine name
no strict 'refs';
*{$name} = subname $name => $code;

$self->set_signature(
code => $code,
signature => $signature,
is_method => $is_method,
code => $code,
signature => $signature,
is_method => $is_method,
end_line => $end_line,
);

return;
};
} else {
}
else {
return sub (&) {
my $code = shift;
( undef, undef, my $end_line ) = caller();

$self->set_signature(
code => $code,
signature => $signature,
is_method => $is_method,
code => $code,
signature => $signature,
is_method => $is_method,
end_line => $end_line,
);
return $code;
};
}
}


sub set_signature {
my $self = shift;
my %args = @_;

my $sig = perl5i::2::CODE::signature($args{code});
my $sig = perl5i::2::CODE::signature( $args{code} );
return $sig if $sig;

$sig = perl5i::2::Signature->new(
Expand Down

2 comments on commit 5f73dc3

@schwern
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't look like the result of our project .perltidyrc.

@exodist
Copy link
Contributor Author

@exodist exodist commented on 5f73dc3 Mar 22, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.