2 * Copyright (c) Zmanda, Inc. All Rights Reserved.
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11 * License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
29 %typemap(in) guint64 {
30 $1 = amglue_SvU64($input);
34 $1 = amglue_SvI64($input);
37 %typemap(in) guint32 {
38 $1 = amglue_SvU32($input);
42 $1 = amglue_SvI32($input);
45 %typemap(in) guint16 {
46 $1 = amglue_SvU16($input);
50 $1 = amglue_SvI16($input);
54 $1 = amglue_SvU8($input);
58 $1 = amglue_SvI8($input);
61 /* remaining types depend on the complier to optimize out constant sizeof()
62 * expressions. The SWIG preprocessor can't perform calculations based on
65 %define typemap_in_unsigned(type)
67 if (sizeof(type) == 1) {
68 $1 = amglue_SvU8($input);
69 } else if (sizeof(type) == 2) {
70 $1 = amglue_SvU16($input);
71 } else if (sizeof(type) == 4) {
72 $1 = amglue_SvU32($input);
73 } else if (sizeof(type) == 8) {
74 $1 = amglue_SvU64($input);
76 croak("Unexpected type >64 bits?"); /* should be optimized out unless sizeof(type) > 8 */
81 typemap_in_unsigned(unsigned int)
82 typemap_in_unsigned(guint)
83 typemap_in_unsigned(unsigned short)
84 typemap_in_unsigned(gushort)
85 typemap_in_unsigned(size_t)
86 typemap_in_unsigned(gsize)
87 typemap_in_unsigned(unsigned long long)
88 typemap_in_unsigned(unsigned long)
89 typemap_in_unsigned(gulong)
90 typemap_in_unsigned(off_t)
91 typemap_in_unsigned(ptrdiff_t)
92 typemap_in_unsigned(uintmax_t)
94 %define typemap_in_signed(type)
96 if (sizeof(type) == 1) {
97 $1 = amglue_SvI8($input);
98 } else if (sizeof(type) == 2) {
99 $1 = amglue_SvI16($input);
100 } else if (sizeof(type) == 4) {
101 $1 = amglue_SvI32($input);
102 } else if (sizeof(type) == 8) {
103 $1 = amglue_SvI64($input);
105 g_critical("Unexpected type >64 bits?"); /* should be optimized out unless sizeof(type) > 8 */
110 typemap_in_signed(int)
111 typemap_in_signed(gint)
112 typemap_in_signed(signed int)
113 typemap_in_signed(short)
114 typemap_in_signed(gshort)
115 typemap_in_signed(signed short)
116 typemap_in_signed(ssize_t)
117 typemap_in_signed(gssize)
118 typemap_in_signed(long long)
119 typemap_in_signed(signed long long)
120 typemap_in_signed(long)
121 typemap_in_signed(signed long)
122 typemap_in_signed(glong)
123 typemap_in_signed(intmax_t)
129 /* All conversions from C to Perl create Math::BigInt objects, even when the
130 * C datatype is 32 bits or smaller. This is to ensure that Perl's automatic
131 * promotion to double does not silently corrupt arithmetic on large numbers.
134 /* (these all use newSV*64, relying on C to upcast to a 64-bit integer) */
136 %define typemap_out_unsigned(type)
138 $result = sv_2mortal(amglue_newSVu64($1));
143 typemap_out_unsigned(guint64)
144 typemap_out_unsigned(guint32)
145 typemap_out_unsigned(guint16)
146 typemap_out_unsigned(guint8)
147 typemap_out_unsigned(unsigned int)
148 typemap_out_unsigned(guint)
149 typemap_out_unsigned(unsigned short)
150 typemap_out_unsigned(gushort)
151 typemap_out_unsigned(size_t)
152 typemap_out_unsigned(gsize)
153 typemap_out_unsigned(unsigned long long)
154 typemap_out_unsigned(unsigned long)
155 typemap_out_unsigned(gulong)
156 typemap_out_unsigned(off_t)
157 typemap_out_unsigned(ptrdiff_t)
158 typemap_out_unsigned(uintmax_t)
160 %define typemap_out_signed(type)
162 $result = sv_2mortal(amglue_newSVi64($1));
167 typemap_out_signed(gint64)
168 typemap_out_signed(gint32)
169 typemap_out_signed(gint16)
170 typemap_out_signed(gint8)
171 typemap_out_signed(int)
172 typemap_out_signed(gint)
173 typemap_out_signed(signed int)
174 typemap_out_signed(short)
175 typemap_out_signed(gshort)
176 typemap_out_signed(signed short)
177 typemap_out_signed(ssize_t)
178 typemap_out_signed(gssize)
179 typemap_out_signed(long long)
180 typemap_out_signed(signed long long)
181 typemap_out_signed(long)
182 typemap_out_signed(signed long)
183 typemap_out_signed(glong)
184 typemap_out_signed(intmax_t)