[MzScheme] Typemaps for all integral types now accept the full range
of integral values, and they signal an error when a value outside the valid range is passed. [Guile] Typemaps for all integral types now signal an error when a value outside the valid range is passed. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8844 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4f7aeb6bdb
commit
b63f275984
8 changed files with 138 additions and 28 deletions
|
|
@ -19,8 +19,11 @@
|
|||
#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME)
|
||||
#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2newstr SWIG_Guile_scm2newstr
|
||||
#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_ulong2scm scm_ulong2num
|
||||
#define gh_long2scm scm_long2num
|
||||
#define gh_str02scm scm_makfrom0str
|
||||
|
|
|
|||
|
|
@ -7,6 +7,23 @@
|
|||
|
||||
%runtime "swigrun.swg"
|
||||
%runtime "guile_gh_run.swg"
|
||||
|
||||
#define SWIG_convert_short(o) \
|
||||
SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \
|
||||
(1 << (8 * sizeof(short) - 1)) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_short(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, \
|
||||
(1 << (8 * sizeof(short))) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_int(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \
|
||||
FUNC_NAME, $argnum)
|
||||
|
||||
#define gh_scm2short(a) SWIG_convert_short(a)
|
||||
#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a)
|
||||
#define gh_scm2uint(a) SWIG_convert_unsigned_int(a)
|
||||
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
|
|
|||
|
|
@ -68,6 +68,29 @@ GSWIG_scm2char (SCM s)
|
|||
# define SCM_OUTPUT_PORT_P SCM_OUTPORTP
|
||||
#endif
|
||||
|
||||
static long
|
||||
SWIG_convert_integer(SCM o,
|
||||
long lower_bound, long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
long value = gh_scm2long(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
SWIG_convert_unsigned_integer(SCM o,
|
||||
unsigned long lower_bound,
|
||||
unsigned long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
unsigned long value = gh_scm2ulong(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
static swig_type_info *SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) {
|
||||
swig_module_info *iter;
|
||||
if (!module) return 0;
|
||||
|
|
|
|||
|
|
@ -263,11 +263,11 @@
|
|||
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer);
|
||||
SIMPLE_MAP(short, gh_scm2int, gh_int2scm, integer);
|
||||
SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer);
|
||||
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue