| 1 |
# GMP module external subroutine type mappings. |
| 2 |
|
| 3 |
# Copyright 2001, 2003 Free Software Foundation, Inc. |
| 4 |
# |
| 5 |
# This file is part of the GNU MP Library. |
| 6 |
# |
| 7 |
# The GNU MP Library is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of either: |
| 9 |
# |
| 10 |
# * the GNU Lesser General Public License as published by the Free |
| 11 |
# Software Foundation; either version 3 of the License, or (at your |
| 12 |
# option) any later version. |
| 13 |
# |
| 14 |
# or |
| 15 |
# |
| 16 |
# * the GNU General Public License as published by the Free Software |
| 17 |
# Foundation; either version 2 of the License, or (at your option) any |
| 18 |
# later version. |
| 19 |
# |
| 20 |
# or both in parallel, as here. |
| 21 |
# |
| 22 |
# The GNU MP Library is distributed in the hope that it will be useful, but |
| 23 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 24 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 25 |
# for more details. |
| 26 |
# |
| 27 |
# You should have received copies of the GNU General Public License and the |
| 28 |
# GNU Lesser General Public License along with the GNU MP Library. If not, |
| 29 |
# see https://www.gnu.org/licenses/. |
| 30 |
|
| 31 |
|
| 32 |
TYPEMAP |
| 33 |
const_string T_PV |
| 34 |
const_string_assume CONST_STRING_ASSUME |
| 35 |
mpz MPZ |
| 36 |
mpq MPQ |
| 37 |
mpf MPF |
| 38 |
mpz_assume MPZ_ASSUME |
| 39 |
mpq_assume MPQ_ASSUME |
| 40 |
mpf_assume MPF_ASSUME |
| 41 |
mpz_coerce MPZ_COERCE |
| 42 |
mpq_coerce MPQ_COERCE |
| 43 |
mpf_coerce_st0 MPF_COERCE_ST0 |
| 44 |
mpf_coerce_def MPF_COERCE_DEF |
| 45 |
randstate RANDSTATE |
| 46 |
ulong_coerce ULONG_COERCE |
| 47 |
malloced_string MALLOCED_STRING |
| 48 |
order_noswap ORDER_NOSWAP |
| 49 |
dummy DUMMY |
| 50 |
# perl 5.005 doesn't have UV in its standard typemap, so use this instead |
| 51 |
gmp_UV GMP_UV |
| 52 |
|
| 53 |
|
| 54 |
INPUT |
| 55 |
MPZ |
| 56 |
class_or_croak ($arg, mpz_class); $var = SvMPZ($arg); |
| 57 |
MPQ |
| 58 |
class_or_croak ($arg, mpq_class); $var = SvMPQ($arg); |
| 59 |
MPF |
| 60 |
class_or_croak ($arg, mpf_class); $var = SvMPF($arg); |
| 61 |
MPZ_ASSUME |
| 62 |
MPZ_ASSUME ($var, $arg) |
| 63 |
MPQ_ASSUME |
| 64 |
MPQ_ASSUME ($var, $arg) |
| 65 |
MPF_ASSUME |
| 66 |
MPF_ASSUME ($var, $arg) |
| 67 |
MPZ_COERCE |
| 68 |
$var = coerce_mpz (tmp_mpz_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg) |
| 69 |
MPQ_COERCE |
| 70 |
$var = coerce_mpq (tmp_mpq_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg) |
| 71 |
MPF_COERCE_ST0 |
| 72 |
/* precision follows ST(0) */ |
| 73 |
assert (sv_derived_from (ST(0), mpf_class)); |
| 74 |
$var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, |
| 75 |
$arg, mpf_get_prec (SvMPF(ST(0)))) |
| 76 |
MPF_COERCE_DEF |
| 77 |
/* default precision used */ |
| 78 |
$var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, |
| 79 |
$arg, mpf_get_default_prec()) |
| 80 |
RANDSTATE |
| 81 |
class_or_croak ($arg, rand_class); $var = SvRANDSTATE($arg); |
| 82 |
ULONG_COERCE |
| 83 |
$var = coerce_ulong ($arg) |
| 84 |
ORDER_NOSWAP |
| 85 |
assert ($arg != &PL_sv_yes); |
| 86 |
DUMMY |
| 87 |
/* dummy $var */ |
| 88 |
CONST_STRING_ASSUME |
| 89 |
/* No need to check for SvPOKp and use SvPV, this mapping is |
| 90 |
only used for overload_constant, which always gets literal |
| 91 |
strings. */ |
| 92 |
assert (SvPOK ($arg)); |
| 93 |
$var = SvPVX ($arg); |
| 94 |
|
| 95 |
|
| 96 |
OUTPUT |
| 97 |
MPZ |
| 98 |
sv_bless (sv_setref_pv ($arg, NULL, $var), mpz_class_hv); |
| 99 |
MPQ |
| 100 |
sv_bless (sv_setref_pv ($arg, NULL, $var), mpq_class_hv); |
| 101 |
MPF |
| 102 |
sv_bless (sv_setref_pv ($arg, NULL, $var), mpf_class_hv); |
| 103 |
RANDSTATE |
| 104 |
sv_setref_pv ($arg, rand_class, $var); |
| 105 |
MALLOCED_STRING |
| 106 |
sv_usepvn_mg ($arg, $var, strlen($var)); |
| 107 |
GMP_UV |
| 108 |
sv_setuv ($arg, (UV) ($var)); |