~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/demos/perl/typemap

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 the GNU Lesser General Public License as published
 
9
# by the Free Software Foundation; either version 2.1 of the License, or (at
 
10
# your option) any later version.
 
11
#
 
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.
 
16
#
 
17
# You should have received a copy of the GNU Lesser General Public License
 
18
# along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 
19
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
20
# MA 02111-1307, USA.
 
21
 
 
22
 
 
23
TYPEMAP
 
24
const_string            T_PV
 
25
const_string_assume     CONST_STRING_ASSUME
 
26
mpz                     MPZ
 
27
mpq                     MPQ
 
28
mpf                     MPF
 
29
mpz_assume              MPZ_ASSUME
 
30
mpq_assume              MPQ_ASSUME
 
31
mpf_assume              MPF_ASSUME
 
32
mpz_coerce              MPZ_COERCE
 
33
mpq_coerce              MPQ_COERCE
 
34
mpf_coerce_st0          MPF_COERCE_ST0
 
35
mpf_coerce_def          MPF_COERCE_DEF
 
36
randstate               RANDSTATE
 
37
ulong_coerce            ULONG_COERCE
 
38
malloced_string         MALLOCED_STRING
 
39
order_noswap            ORDER_NOSWAP
 
40
dummy                   DUMMY
 
41
# perl 5.005 doesn't have UV in its standard typemap, so use this instead
 
42
gmp_UV                  GMP_UV
 
43
 
 
44
 
 
45
INPUT
 
46
MPZ
 
47
        class_or_croak ($arg, mpz_class); $var = SvMPZ($arg);
 
48
MPQ
 
49
        class_or_croak ($arg, mpq_class); $var = SvMPQ($arg);
 
50
MPF
 
51
        class_or_croak ($arg, mpf_class); $var = SvMPF($arg);
 
52
MPZ_ASSUME
 
53
        MPZ_ASSUME ($var, $arg)
 
54
MPQ_ASSUME
 
55
        MPQ_ASSUME ($var, $arg)
 
56
MPF_ASSUME
 
57
        MPF_ASSUME ($var, $arg)
 
58
MPZ_COERCE
 
59
        $var = coerce_mpz (tmp_mpz_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
 
60
MPQ_COERCE
 
61
        $var = coerce_mpq (tmp_mpq_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
 
62
MPF_COERCE_ST0
 
63
        /* precision follows ST(0) */
 
64
        assert (sv_derived_from (ST(0), mpf_class));
 
65
        $var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
 
66
                           $arg, mpf_get_prec (SvMPF(ST(0))))
 
67
MPF_COERCE_DEF
 
68
        /* default precision used */
 
69
        $var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
 
70
                           $arg, mpf_get_default_prec())
 
71
RANDSTATE
 
72
        class_or_croak ($arg, rand_class); $var = SvRANDSTATE($arg);
 
73
ULONG_COERCE
 
74
        $var = coerce_ulong ($arg)
 
75
ORDER_NOSWAP
 
76
        assert ($arg != &PL_sv_yes);
 
77
DUMMY
 
78
        /* dummy $var */        
 
79
CONST_STRING_ASSUME
 
80
        /* No need to check for SvPOKp and use SvPV, this mapping is
 
81
           only used for overload_constant, which always gets literal
 
82
           strings.  */
 
83
        assert (SvPOK ($arg));
 
84
        $var = SvPVX ($arg);
 
85
 
 
86
 
 
87
OUTPUT
 
88
MPZ
 
89
    sv_bless (sv_setref_pv ($arg, NULL, $var), mpz_class_hv);
 
90
MPQ
 
91
    sv_bless (sv_setref_pv ($arg, NULL, $var), mpq_class_hv);
 
92
MPF
 
93
    sv_bless (sv_setref_pv ($arg, NULL, $var), mpf_class_hv);
 
94
RANDSTATE
 
95
    sv_setref_pv ($arg, rand_class, $var);
 
96
MALLOCED_STRING
 
97
    sv_usepvn_mg ($arg, $var, strlen($var));
 
98
GMP_UV
 
99
    sv_setuv ($arg, (UV) ($var));