NAME

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

SYNOPSIS

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

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

DESCRIPTION

This is a generator which uses TT to make output.

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. Also (optionally) pass it a hash reference of Template Toolkit constructor arguments. These are passed directory to Template's new method, so see its docs for what is allowed.

If you do not supply TT constructor arguments, you will get these by default:

{
    INCLUDE_PATH => 'templates:.',
    POST_CHOMP   => 1
}
generate

This is the workhorse of this module. It takes information about your java .class file and generates Perl 6 code. Actually, what it generates depends entirely on the TT template you supply. That could be Perl 5 or even (horrors) Python or Ruby code.

Parameters:

class_file - for documentation, the name of the java .class file
ast        - the syntax tree you got from the parser
template   - the name of a TT template

Use Java::Javap::Grammar to generate the ast. The template will have to live in the current directory or a subdirectory of it called 'templates', unless you pass TT constructor args.

The template fully controls the output.

new

For use by Java::Javap::Generator. You could call it directly, passing it the TT constructor arguments as described above. That would bypass the factory.

tt_args_set

Accessor for changing 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.