Fix integer handling in r. unsigned values where getting handled

incorrected as reals leading to crashes


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11052 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Joseph Wang 2009-01-11 00:08:37 +00:00
commit 4b5c817793
3 changed files with 33 additions and 66 deletions

View file

@ -1,6 +1,10 @@
Version 1.3.37 (30 December 2008)
=================================
2009-01-10: drjoe
Fix integer handling in r to deal correctly with signed
and unsigned issues
2009-01-10: wsfulton
Patch #1992756 from Colin McDonald - %contract not working for classes
in namespace

View file

@ -55,7 +55,8 @@ SWIG_InitializeModule(0);
%typemap(out) void "";
%typemap(in) int *, int[ANY] %{
%typemap(in) int *, int[ANY],
long *, long[ANY] %{
$1 = INTEGER($input);
%}
@ -77,7 +78,7 @@ SWIG_InitializeModule(0);
%}
%typemap(scheck) int %{
%typemap(scheck) int, long %{
if(length($input) > 1) {
warning("using only the first element of $input")
}
@ -157,11 +158,12 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype);
}
%typemap(in,noblock=1) int {
%typemap(in,noblock=1) int, long
{
$1 = %static_cast(INTEGER($input)[0], $1_ltype);
}
%typemap(out,noblock=1) int
%typemap(out,noblock=1) int, long
"$result = Rf_ScalarInteger($1);";
@ -172,18 +174,16 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype);
%typemap(out,noblock=1) bool
"$result = Rf_ScalarLogical($1);";
%typemap(in,noblock=1) unsigned int,
unsigned long,
%typemap(in,noblock=1)
float,
double,
long
double
{
$1 = %static_cast(REAL($input)[0], $1_ltype);
}
%typemap(out,noblock=1) unsigned int *
"$result = ScalarReal(*($1));";
/* Why is this here ? */
/* %typemap(out,noblock=1) unsigned int *
"$result = ScalarReal(*($1));"; */
%Rruntime %{
setMethod('[', "ExternalReference",

View file

@ -8,12 +8,18 @@
%apply int {std::size_t}
%apply int {ptrdiff_t}
%apply int {std::ptrdiff_t}
%apply int {signed int}
%apply int {unsigned int}
%apply int {short}
%apply int {unsigned short}
%typemap("rtype") long, long *, long & "numeric";
%apply long {long long}
%apply long {signed long long}
%apply long {unsigned long long}
%apply long {unsigned long}
%apply long {unsigned long}
%typemap("rtype") long, long * "numeric";
%typemap("rtype") unsigned long,
unsigned long * "numeric";
%typemap("rtype") unsigned int,
unsigned int * "numeric";
%typemap("rtype") double, double*, double & "numeric";
%typemap("rtype") float, float *, float & "numeric";
%typemap("rtype") char *, char ** "character";
@ -41,11 +47,7 @@
%typemap(scoercein) int, int *, int &
%{ $input = as.integer($input); %}
%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t &
%{ $input = as.integer($input); %}
%typemap(scoercein) unsigned long, unsigned long *, unsigned long &
%{ $input = as.integer($input); %}
%typemap(scoercein) unsigned int, unsigned int *, unsigned int &
%typemap(scoercein) long, long *, long &
%{ $input = as.integer($input); %}
%typemap(scoercein) double, double *, double &
%{ %}
@ -90,45 +92,16 @@
%typemap(scoercein) bool, bool *, bool &
"$input = as.logical($input) ";
/*
%typemap(scoercein) int,
int *,
int &,
int[ANY],
size_t,
std::size_t,
size_t &,
std::size_t &
long,
long *,
long &,
long[ANY]
"$input = as.integer($input) ";
%typemap(scoercein) unsigned int,
unsigned long,
double,
float,
long,
long long,
unsigned int[],
unsigned long[],
double[],
float[],
long[],
long long[],
unsigned int[ANY],
unsigned long[ANY],
double[ANY],
float[ANY],
long[ANY],
long long[ANY],
unsigned int *,
unsigned long *,
double*,
float*,
long*,
long long *
%{ $input = as.numeric($input) %}
*/
%typemap(scoercein) char *, string, std::string,
string &, std::string &
%{ $input = as($input, "character") %}
@ -156,30 +129,20 @@ string &, std::string &
%typemap(scoerceout) char,
char *,
char &,
unsigned int,
unsigned int &,
unsigned long,
unsigned long &,
double,
double &,
float,
float &,
long,
long &,
long long,
long long &,
int,
int &,
long,
long &,
bool,
bool &,
string,
std::string,
string &,
std::string &,
size_t,
std::size_t,
size_t &,
std::size_t &,
void
%{ %}