1 # GMP module external subroutine type mappings.
3 # Copyright 2001, 2003 Free Software Foundation, Inc.
5 # This file is part of the GNU MP Library.
7 # The GNU MP Library is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as published
9 # by the Free Software Foundation; either version 3 of the License, or (at
10 # your option) any later version.
12 # The GNU MP Library is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 # License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
23 const_string_assume CONST_STRING_ASSUME
32 mpf_coerce_st0 MPF_COERCE_ST0
33 mpf_coerce_def MPF_COERCE_DEF
35 ulong_coerce ULONG_COERCE
36 malloced_string MALLOCED_STRING
37 order_noswap ORDER_NOSWAP
39 # perl 5.005 doesn't have UV in its standard typemap, so use this instead
45 class_or_croak ($arg, mpz_class); $var = SvMPZ($arg);
47 class_or_croak ($arg, mpq_class); $var = SvMPQ($arg);
49 class_or_croak ($arg, mpf_class); $var = SvMPF($arg);
51 MPZ_ASSUME ($var, $arg)
53 MPQ_ASSUME ($var, $arg)
55 MPF_ASSUME ($var, $arg)
57 $var = coerce_mpz (tmp_mpz_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
59 $var = coerce_mpq (tmp_mpq_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
61 /* precision follows ST(0) */
62 assert (sv_derived_from (ST(0), mpf_class));
63 $var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
64 $arg, mpf_get_prec (SvMPF(ST(0))))
66 /* default precision used */
67 $var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
68 $arg, mpf_get_default_prec())
70 class_or_croak ($arg, rand_class); $var = SvRANDSTATE($arg);
72 $var = coerce_ulong ($arg)
74 assert ($arg != &PL_sv_yes);
78 /* No need to check for SvPOKp and use SvPV, this mapping is
79 only used for overload_constant, which always gets literal
81 assert (SvPOK ($arg));
87 sv_bless (sv_setref_pv ($arg, NULL, $var), mpz_class_hv);
89 sv_bless (sv_setref_pv ($arg, NULL, $var), mpq_class_hv);
91 sv_bless (sv_setref_pv ($arg, NULL, $var), mpf_class_hv);
93 sv_setref_pv ($arg, rand_class, $var);
95 sv_usepvn_mg ($arg, $var, strlen($var));
97 sv_setuv ($arg, (UV) ($var));