Java::Javap::Generator::Perl6 - uses Template Toolkit to spit out Perl 6
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.
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
.
Call this as a class method on Java::Javap::Generator
. Pass it Perl6
to ask it for an instance of this class.
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):
for documentation, the name of the java .class file
the syntax tree you got from the parser
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, } );
For use by Java::Javap::Generator
. You could call it directly, that would bypass the factory.
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.
Accessor for getting the TT constructor arguments. Mainly for internal use.
Nothing, it's all OO
Java::Javap::Generator Java::Javap Java::Javap::Grammar java2perl6api
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.