* lib/Parrot/Pmc2c/MethodEmitter.pm:
[parrot.git] / config / auto / format.pm
blob6f636c6405db1f2ca03a44c2f1679164ddc41529
1 # Copyright (C) 2001-2003, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/format.pm - Sprintf Formats
8 =head1 DESCRIPTION
10 Figures out what formats should be used for C<sprintf()>.
12 =cut
14 package auto::format;
16 use strict;
17 use warnings;
19 use base qw(Parrot::Configure::Step);
21 use Parrot::Configure::Step;
24 sub _init {
25 my $self = shift;
26 my %data;
27 $data{description} = q{Figuring out what formats should be used for sprintf};
28 $data{result} = q{};
29 return \%data;
32 sub runstep {
33 my ( $self, $conf ) = @_;
35 _set_intvalfmt($conf);
37 _set_floatvalfmt_nvsize($conf);
39 return 1;
42 sub _set_intvalfmt {
43 my $conf = shift;
44 my $ivformat;
45 my $iv = $conf->data->get(qw(iv));
47 if ( $iv eq "int" ) {
48 $ivformat = "%d";
50 elsif ( ( $iv eq "long" ) || ( $iv eq "long int" ) ) {
51 $ivformat = "%ld";
53 elsif ( ( $iv eq "long long" ) || ( $iv eq "long long int" ) ) {
54 $ivformat = "%lld";
56 else {
57 die qq{Configure.pl: Can't find a printf-style format specifier for type '$iv'\n};
59 $conf->data->set( intvalfmt => $ivformat );
62 sub _set_floatvalfmt_nvsize {
63 my $conf = shift;
64 my ( $nv, $floatsize, $doublesize, $ldsize ) =
65 $conf->data->get(qw(nv floatsize doublesize hugefloatvalsize));
66 my ( $nvformat, $nvsize );
67 $nvsize = $floatsize;
68 if ( $nv eq "double" ) {
69 $nvsize = $doublesize;
70 $nvformat = "%f";
72 elsif ( $nv eq "long double" ) {
74 # Stay way from long double for now (it may be 64 or 80 bits)
75 # die "long double not supported at this time, use double.";
76 $nvsize = $ldsize;
77 $nvformat = "%Lf";
79 else {
80 die qq{Configure.pl: Can't find a printf-style format specifier for type '$nv'\n};
83 $conf->data->set(
84 floatvalfmt => $nvformat,
85 nvsize => $nvsize
91 # Local Variables:
92 # mode: cperl
93 # cperl-indent-level: 4
94 # fill-column: 100
95 # End:
96 # vim: expandtab shiftwidth=4: