NAME

Java::Javap::Generator::Std - uses TT to spit out Perl 6

SYNOPSIS

useJava::Javap::Generator; 
my $gen = Java::Javap::Generator->get_generator( 'Std' );
my $output = $gen->generate(
        'com.example.InterfaceName',
        $tree,
        $javap_flags,
);

where $tree is a Java::Javap abstract syntax tree (AST).

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 _get_template_for_class.

METHODS

get_generator

Call this as a class method on Java::Javap::Generator. Pass it Std 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_flags

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( 'Std' );
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

Accessr 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

AUTHOR

COPYRIGHT AND LICENSE

Copyright (C) 2007, Phil Crow

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.