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:
parent
98f992e704
commit
4b5c817793
3 changed files with 33 additions and 66 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
Version 1.3.37 (30 December 2008)
|
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
|
2009-01-10: wsfulton
|
||||||
Patch #1992756 from Colin McDonald - %contract not working for classes
|
Patch #1992756 from Colin McDonald - %contract not working for classes
|
||||||
in namespace
|
in namespace
|
||||||
|
|
|
||||||
22
Lib/r/r.swg
22
Lib/r/r.swg
|
|
@ -55,7 +55,8 @@ SWIG_InitializeModule(0);
|
||||||
|
|
||||||
%typemap(out) void "";
|
%typemap(out) void "";
|
||||||
|
|
||||||
%typemap(in) int *, int[ANY] %{
|
%typemap(in) int *, int[ANY],
|
||||||
|
long *, long[ANY] %{
|
||||||
$1 = INTEGER($input);
|
$1 = INTEGER($input);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -77,7 +78,7 @@ SWIG_InitializeModule(0);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%typemap(scheck) int %{
|
%typemap(scheck) int, long %{
|
||||||
if(length($input) > 1) {
|
if(length($input) > 1) {
|
||||||
warning("using only the first element of $input")
|
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);
|
$1 = %static_cast(INTEGER($input)[0], $1_ltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out,noblock=1) int
|
%typemap(out,noblock=1) int, long
|
||||||
"$result = Rf_ScalarInteger($1);";
|
"$result = Rf_ScalarInteger($1);";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -172,18 +174,16 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype);
|
||||||
%typemap(out,noblock=1) bool
|
%typemap(out,noblock=1) bool
|
||||||
"$result = Rf_ScalarLogical($1);";
|
"$result = Rf_ScalarLogical($1);";
|
||||||
|
|
||||||
%typemap(in,noblock=1) unsigned int,
|
%typemap(in,noblock=1)
|
||||||
unsigned long,
|
|
||||||
float,
|
float,
|
||||||
double,
|
double
|
||||||
long
|
|
||||||
{
|
{
|
||||||
$1 = %static_cast(REAL($input)[0], $1_ltype);
|
$1 = %static_cast(REAL($input)[0], $1_ltype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Why is this here ? */
|
||||||
%typemap(out,noblock=1) unsigned int *
|
/* %typemap(out,noblock=1) unsigned int *
|
||||||
"$result = ScalarReal(*($1));";
|
"$result = ScalarReal(*($1));"; */
|
||||||
|
|
||||||
%Rruntime %{
|
%Rruntime %{
|
||||||
setMethod('[', "ExternalReference",
|
setMethod('[', "ExternalReference",
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,18 @@
|
||||||
%apply int {std::size_t}
|
%apply int {std::size_t}
|
||||||
%apply int {ptrdiff_t}
|
%apply int {ptrdiff_t}
|
||||||
%apply int {std::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") double, double*, double & "numeric";
|
||||||
%typemap("rtype") float, float *, float & "numeric";
|
%typemap("rtype") float, float *, float & "numeric";
|
||||||
%typemap("rtype") char *, char ** "character";
|
%typemap("rtype") char *, char ** "character";
|
||||||
|
|
@ -41,11 +47,7 @@
|
||||||
|
|
||||||
%typemap(scoercein) int, int *, int &
|
%typemap(scoercein) int, int *, int &
|
||||||
%{ $input = as.integer($input); %}
|
%{ $input = as.integer($input); %}
|
||||||
%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t &
|
%typemap(scoercein) long, long *, long &
|
||||||
%{ $input = as.integer($input); %}
|
|
||||||
%typemap(scoercein) unsigned long, unsigned long *, unsigned long &
|
|
||||||
%{ $input = as.integer($input); %}
|
|
||||||
%typemap(scoercein) unsigned int, unsigned int *, unsigned int &
|
|
||||||
%{ $input = as.integer($input); %}
|
%{ $input = as.integer($input); %}
|
||||||
%typemap(scoercein) double, double *, double &
|
%typemap(scoercein) double, double *, double &
|
||||||
%{ %}
|
%{ %}
|
||||||
|
|
@ -90,45 +92,16 @@
|
||||||
|
|
||||||
%typemap(scoercein) bool, bool *, bool &
|
%typemap(scoercein) bool, bool *, bool &
|
||||||
"$input = as.logical($input) ";
|
"$input = as.logical($input) ";
|
||||||
/*
|
|
||||||
%typemap(scoercein) int,
|
%typemap(scoercein) int,
|
||||||
int *,
|
int *,
|
||||||
int &,
|
int &,
|
||||||
int[ANY],
|
int[ANY],
|
||||||
size_t,
|
long,
|
||||||
std::size_t,
|
long *,
|
||||||
size_t &,
|
long &,
|
||||||
std::size_t &
|
long[ANY]
|
||||||
"$input = as.integer($input) ";
|
"$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,
|
%typemap(scoercein) char *, string, std::string,
|
||||||
string &, std::string &
|
string &, std::string &
|
||||||
%{ $input = as($input, "character") %}
|
%{ $input = as($input, "character") %}
|
||||||
|
|
@ -156,30 +129,20 @@ string &, std::string &
|
||||||
%typemap(scoerceout) char,
|
%typemap(scoerceout) char,
|
||||||
char *,
|
char *,
|
||||||
char &,
|
char &,
|
||||||
unsigned int,
|
|
||||||
unsigned int &,
|
|
||||||
unsigned long,
|
|
||||||
unsigned long &,
|
|
||||||
double,
|
double,
|
||||||
double &,
|
double &,
|
||||||
float,
|
float,
|
||||||
float &,
|
float &,
|
||||||
long,
|
|
||||||
long &,
|
|
||||||
long long,
|
|
||||||
long long &,
|
|
||||||
int,
|
int,
|
||||||
int &,
|
int &,
|
||||||
|
long,
|
||||||
|
long &,
|
||||||
bool,
|
bool,
|
||||||
bool &,
|
bool &,
|
||||||
string,
|
string,
|
||||||
std::string,
|
std::string,
|
||||||
string &,
|
string &,
|
||||||
std::string &,
|
std::string &,
|
||||||
size_t,
|
|
||||||
std::size_t,
|
|
||||||
size_t &,
|
|
||||||
std::size_t &,
|
|
||||||
void
|
void
|
||||||
%{ %}
|
%{ %}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue