Tim Bunce > Java-2Perl6API-0.11 > Java::Javap::Generator::Perl6

Download:
Java-2Perl6API-0.11.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Java::Javap::Generator::Perl6 - uses Template Toolkit to spit out Perl 6

SYNOPSIS ^

    use Java::Javap::Generator;
    my $gen = Java::Javap::Generator->get_generator( 'Perl6' );
    my $output = $gen->generate(
        {
            $class_file  => 'com.example.InterfaceName',
            $ast         => $tree,
            $javap_command => $javap_command,
        }
    );

where $tree is a Java::Javap abstract syntax tree (AST). Note that parameters are named.

DESCRIPTION ^

This is a generator which uses TT to make output. It's templates are strings inside this module. To change templates, subclass and override _get_template_for_interface and/or _get_template_for_class.

METHODS ^

get_generator

Call this as a class method on Java::Javap::Generator. Pass it Perl6 to ask it for an instance of this class.

generate

This is the workhorse of this module. It takes information about your java .class file and generates Perl 6 code.

Parameters (these are named, pass them in a hashref, see below):

class_file

for documentation, the name of the java .class file

ast

the syntax tree you got from the parser

javap_command

for documentation, the flags used on the javap command line

Use Java::Javap::Grammar to generate the ast.

Example:

 my $parser = Java::Javap::Grammar->new();
 my $decomp = `javap com.example.SomeInterface`;
 my $tree   = $parser->comp_unit( $decomp );
 my $jenny  = Java::Javap::Generator->get_generator( 'Perl6' );
 my $output = $jenny->generate(
      {
          class_file  => $class_file,
          ast         => $tree,
      }
 );
new

For use by Java::Javap::Generator. You could call it directly, that would bypass the factory.

tt_args_set

By default, the TT objects used internally will have this TT constructor parameter:

    { POST_CHOMP   => 1 }

Use this accessor to change the TT constructor arguments. You may call this at any time. The new method uses this accessor.

Since generate makes a new TT object for each call, any changes you make via this method will apply to subsequent calls.

tt_args

Accessor for getting the TT constructor arguments. Mainly for internal use.

EXPORT ^

Nothing, it's all OO

SEE ALSO

Java::Javap::Generator Java::Javap Java::Javap::Grammar java2perl6api

AUTHOR ^

COPYRIGHT AND LICENSE ^

Copyright (C) 2007, Phil Crow Copyright (C) 2010, Tim Bunce

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: