Skip to content

Commit

Permalink
Change comma_list in grammar to always produce an array ref.
Browse files Browse the repository at this point in the history
Fix 'implements' to handle multiple classes.
  • Loading branch information
timbunce committed Jul 10, 2010
1 parent bc1ffdd commit 2605a35
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 50 deletions.
8 changes: 5 additions & 3 deletions lib/Java/Javap/Generator/Std.pm
Expand Up @@ -156,8 +156,8 @@ sub _cast_names {
my $class_parent = defined $ast->{parent} ? $type_caster->cast($ast->{parent}) : '';
$ast->{cast_parent} = ($class_parent eq 'Mu') ? '' : $class_parent;

my $class_implements = defined $ast->{implements} ? $type_caster->cast($ast->{implements}) : '';
$ast->{cast_implements} = ($class_implements eq 'Mu') ? '' : $class_implements;
my @class_implements = map { $type_caster->cast($_) } @{ $ast->{implements} };
$ast->{cast_implements} = \@class_implements;

foreach my $element (@{$ast->{contents}}) {
next unless $element->{body_element} =~ /^(method|constructor)/;
Expand Down Expand Up @@ -232,6 +232,8 @@ sub _get_prologue {
my $target = $type_caster->cast($ast->{parent});
$perl_types{$target}++;
}

$perl_types{$_}++ for @{ $ast->{cast_implements} };

foreach my $element (@{$ast->{contents}}) {

Expand Down Expand Up @@ -347,7 +349,7 @@ sub _get_template_for_class {

class [% ast.perl_qualified_name %]
[%- ast.cast_parent == '' ? '' : ' is ' %][% ast.cast_parent -%]
[%- IF ast.cast_implements != '' %] does [% ast.cast_implements %] [% END -%]
[%- IF ast.cast_implements.size > 0 %] does [% ast.cast_implements.join(" does ") %] [% END -%]
{

[% FOREACH element IN ast.method_list %]
Expand Down

0 comments on commit 2605a35

Please sign in to comment.