📄 integers.swg
字号:
/* * Copyright (c) Zmanda, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * * Contact information: Zmanda Inc., 505 N Mathlida Ave, Suite 120 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com */%{#include "amglue.h"%}/* * perl -> C (input) */%typemap(in) guint64 { $1 = amglue_SvU64($input);}%typemap(in) gint64 { $1 = amglue_SvI64($input);}%typemap(in) guint32 { $1 = amglue_SvU32($input);}%typemap(in) gint32 { $1 = amglue_SvI32($input);}%typemap(in) guint16 { $1 = amglue_SvU16($input);}%typemap(in) gint16 { $1 = amglue_SvI16($input);}%typemap(in) guint8 { $1 = amglue_SvU8($input);}%typemap(in) gint8 { $1 = amglue_SvI8($input);}/* remaining types depend on the complier to optimize out constant sizeof() * expressions. The SWIG preprocessor can't perform calculations based on * sizeof(). */%define typemap_in_unsigned(type)%typemap(in) type { if (sizeof(type) == 1) { $1 = amglue_SvU8($input); } else if (sizeof(type) == 2) { $1 = amglue_SvU16($input); } else if (sizeof(type) == 4) { $1 = amglue_SvU32($input); } else if (sizeof(type) == 8) { $1 = amglue_SvU64($input); } else { croak("Unexpected type >64 bits?"); /* should be optimized out unless sizeof(type) > 8 */ }}%enddeftypemap_in_unsigned(unsigned int)typemap_in_unsigned(guint)typemap_in_unsigned(unsigned short)typemap_in_unsigned(gushort)typemap_in_unsigned(size_t)typemap_in_unsigned(gsize)typemap_in_unsigned(unsigned long long)typemap_in_unsigned(unsigned long)typemap_in_unsigned(gulong)typemap_in_unsigned(off_t)typemap_in_unsigned(ptrdiff_t)typemap_in_unsigned(uintmax_t)%define typemap_in_signed(type)%typemap(in) type { if (sizeof(type) == 1) { $1 = amglue_SvI8($input); } else if (sizeof(type) == 2) { $1 = amglue_SvI16($input); } else if (sizeof(type) == 4) { $1 = amglue_SvI32($input); } else if (sizeof(type) == 8) { $1 = amglue_SvI64($input); } else { g_critical("Unexpected type >64 bits?"); /* should be optimized out unless sizeof(type) > 8 */ }}%enddeftypemap_in_signed(int)typemap_in_signed(gint)typemap_in_signed(signed int)typemap_in_signed(short)typemap_in_signed(gshort)typemap_in_signed(signed short)typemap_in_signed(ssize_t)typemap_in_signed(gssize)typemap_in_signed(long long)typemap_in_signed(signed long long)typemap_in_signed(long)typemap_in_signed(signed long)typemap_in_signed(glong)typemap_in_signed(intmax_t)/* * C -> perl (output) *//* All conversions from C to Perl create Math::BigInt objects, even when the * C datatype is 32 bits or smaller. This is to ensure that Perl's automatic * promotion to double does not silently corrupt arithmetic on large numbers. *//* (these all use newSV*64, relying on C to upcast to a 64-bit integer) */%define typemap_out_unsigned(type)%typemap(out) type { $result = sv_2mortal(amglue_newSVu64($1)); argvi++;}%enddeftypemap_out_unsigned(guint64)typemap_out_unsigned(guint32)typemap_out_unsigned(guint16)typemap_out_unsigned(guint8)typemap_out_unsigned(unsigned int)typemap_out_unsigned(guint)typemap_out_unsigned(unsigned short)typemap_out_unsigned(gushort)typemap_out_unsigned(size_t)typemap_out_unsigned(gsize)typemap_out_unsigned(unsigned long long)typemap_out_unsigned(unsigned long)typemap_out_unsigned(gulong)typemap_out_unsigned(off_t)typemap_out_unsigned(ptrdiff_t)typemap_out_unsigned(uintmax_t)%define typemap_out_signed(type)%typemap(out) type { $result = sv_2mortal(amglue_newSVi64($1)); argvi++;}%enddeftypemap_out_signed(gint64)typemap_out_signed(gint32)typemap_out_signed(gint16)typemap_out_signed(gint8)typemap_out_signed(int)typemap_out_signed(gint)typemap_out_signed(signed int)typemap_out_signed(short)typemap_out_signed(gshort)typemap_out_signed(signed short)typemap_out_signed(ssize_t)typemap_out_signed(gssize)typemap_out_signed(long long)typemap_out_signed(signed long long)typemap_out_signed(long)typemap_out_signed(signed long)typemap_out_signed(glong)typemap_out_signed(intmax_t)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -