Skip to content
Browse files

Fix method stringification in Pod::To::Text, fix slurpy star in Param…

…eter.perl
  • Loading branch information...
1 parent 9b16150 commit 43445e515eeca27b0867e0ebcf5e1336a2d9e1f3 @marcusramberg marcusramberg committed Apr 21, 2012
Showing with 12 additions and 10 deletions.
  1. +7 −5 lib/Pod/To/Text.pm
  2. +5 −5 src/core/Parameter.pm
View
12 lib/Pod/To/Text.pm
@@ -74,10 +74,12 @@ sub declarator2text($pod) {
next unless $pod.WHEREFORE.WHY;
my $what = do given $pod.WHEREFORE {
when Method {
- 'method ' ~ $_.name ~ signature2text($_.signature)
+ my @params=$_.signature.params[1..*];
+ @params.pop if @params[*-1].name eq '%_';
+ 'method ' ~ $_.name ~ signature2text(@params)
}
when Sub {
- 'sub ' ~ $_.name ~ signature2text($_.signature)
+ 'sub ' ~ $_.name ~ signature2text($_.signature.params)
}
when nqp::p6bool(nqp::istype($_.HOW, Metamodel::ClassHOW)) {
'class ' ~ $_.perl
@@ -95,9 +97,9 @@ sub declarator2text($pod) {
return "$what\n{$pod.WHEREFORE.WHY.content}"
}
-sub signature2text($signature) {
- return $signature.params.elems ??
- "(\n\t" ~ $signature.params.map({ $_.perl }).join(", \n\t") ~ "\n)"
+sub signature2text($params) {
+ $params.elems ??
+ "(\n\t" ~ $params.map({ $_.perl }).join(", \n\t") ~ "\n)"
!! "()";
}
View
10 src/core/Parameter.pm
@@ -1,4 +1,4 @@
-my class Parameter {
+My class Parameter {
# XXX constant...
my $SIG_ELEM_BIND_CAPTURE := 1;
my $SIG_ELEM_BIND_PRIVATE_ATTR := 2;
@@ -148,16 +148,16 @@ my class Parameter {
$perl ~= '\\' ~ $name;
} else {
my $default = self.default();
- if self.named {
+ if self.slurpy {
+ $name = '*' ~ $name;
+ } elsif self.named {
my @names := self.named_names;
my $/ := $name ~~ / ^^ $<sigil>=<[$@%&]> $<desigil>=(@names) $$ /;
$name = ':' ~ $name if $/;
$name ~= '!' unless self.optional;
} elsif self.optional && !$default {
$name ~= '?';
- } elsif self.slurpy {
- $name = '*' ~ $name;
- }
+ }
$perl ~= $name;
if $!flags +& $SIG_ELEM_IS_RW {
$perl ~= ' is rw';

0 comments on commit 43445e5

Please sign in to comment.
Something went wrong with that request. Please try again.