The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Java::Javap::TypeCast - hash mapping common Java types to Perl 6 equivalents

SYNOPSIS

In a Java::Javap::Generator:: module:

    use Java::Javap::TypeCast;

    my $type_caster = Java::Javap::TypeCast->new();

    my $perl_type   = $type_caster->cast( $java_type );

To adjust the type cast table:

    my $current_types = $type_caster->get_types();

    $current_types->{ com.example.ShouldBeInt } = 'Int';

To replace the whole table:

    $type_caster->set_types( { ... } );

DESCRIPTION

This is a convenience module for Java::Javap::Generator:: modules. They can use it to have a common place to keep conversions of Java type to Perl 6 types. But, generators are under no obligation to use this module.

METHODS

new

Constructs a type caster.

Parameters: none

Returns: a TypeCaster object.

cast

Parameter: a Java type name

Returns: the Perl conversion, if one is in the hash, or the original Java type, with dots replaced by double colons, if not.

get_type_casts

Returns: the current hash (reference). Note that this is a class attribute, so there is only one for all users.

set_type_casts

Parameter: a hash reference to use in all future casts. Again, note that this is a class attribute, so all instaces share it.

AUTHOR

Phil Crow, <crow.phil@gmail.com>

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.