bool typemaps rewrite to keep Visual C++ happy
Fixes to SWIGTYPE& varin and varout typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4261 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5dd9257b33
commit
562ba55a1a
1 changed files with 24 additions and 7 deletions
|
|
@ -50,7 +50,7 @@
|
||||||
%typemap(in,parse="s") char *, char [ANY] "";
|
%typemap(in,parse="s") char *, char [ANY] "";
|
||||||
|
|
||||||
/* Boolean values. Have to convert from a long since */
|
/* Boolean values. Have to convert from a long since */
|
||||||
%typemap(in) bool "$1 = (bool) PyInt_AsLong($input);
|
%typemap(in) bool "$1 = PyInt_AsLong($input) ? true : false;
|
||||||
if (PyErr_Occurred()) SWIG_fail;";
|
if (PyErr_Occurred()) SWIG_fail;";
|
||||||
|
|
||||||
/* Enum values. */
|
/* Enum values. */
|
||||||
|
|
@ -85,12 +85,16 @@
|
||||||
const unsigned short & (unsigned short temp),
|
const unsigned short & (unsigned short temp),
|
||||||
const unsigned long & (unsigned long temp),
|
const unsigned long & (unsigned long temp),
|
||||||
const signed char & (signed char temp),
|
const signed char & (signed char temp),
|
||||||
const unsigned char & (unsigned char temp),
|
const unsigned char & (unsigned char temp)
|
||||||
const bool & (bool temp)
|
|
||||||
"temp = ($*1_ltype) PyInt_AsLong($input);
|
"temp = ($*1_ltype) PyInt_AsLong($input);
|
||||||
if (PyErr_Occurred()) SWIG_fail;
|
if (PyErr_Occurred()) SWIG_fail;
|
||||||
$1 = &temp;";
|
$1 = &temp;";
|
||||||
|
|
||||||
|
%typemap(in) const bool & (bool temp)
|
||||||
|
"temp = PyInt_AsLong($input) ? true : false;
|
||||||
|
if (PyErr_Occurred()) SWIG_fail;
|
||||||
|
$1 = &temp;";
|
||||||
|
|
||||||
%typemap(in) const float & (float temp),
|
%typemap(in) const float & (float temp),
|
||||||
const double & (double temp)
|
const double & (double temp)
|
||||||
"temp = ($*1_ltype) PyFloat_AsDouble($input);
|
"temp = ($*1_ltype) PyFloat_AsDouble($input);
|
||||||
|
|
@ -188,7 +192,7 @@
|
||||||
|
|
||||||
/* --- Variable input --- */
|
/* --- Variable input --- */
|
||||||
|
|
||||||
%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, bool, enum SWIGTYPE
|
%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE
|
||||||
{
|
{
|
||||||
long temp = PyInt_AsLong($input);
|
long temp = PyInt_AsLong($input);
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
|
@ -198,6 +202,16 @@
|
||||||
$1 = ($1_type) temp;
|
$1 = ($1_type) temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) bool
|
||||||
|
{
|
||||||
|
long temp = PyInt_AsLong($input);
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "C variable '$name ($1_ltype)'");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
$1 = temp ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(varin) long long {
|
%typemap(varin) long long {
|
||||||
long long temp = PyLong_AsLongLong($input);
|
long long temp = PyLong_AsLongLong($input);
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
|
@ -308,7 +322,7 @@
|
||||||
PyErr_SetString(PyExc_TypeError, "C variable '$name ($1_ltype)'");
|
PyErr_SetString(PyExc_TypeError, "C variable '$name ($1_ltype)'");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
$1 = ($1_ltype) temp;
|
$1 = *($1_ltype) temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(varin) void * {
|
%typemap(varin) void * {
|
||||||
|
|
@ -353,8 +367,11 @@
|
||||||
%typemap(varout) char * "$result = $1 ? PyString_FromString($1) : Py_BuildValue((char*)\"\");";
|
%typemap(varout) char * "$result = $1 ? PyString_FromString($1) : Py_BuildValue((char*)\"\");";
|
||||||
%typemap(varout) char "$result = Py_BuildValue((char*)\"c\",$1);";
|
%typemap(varout) char "$result = Py_BuildValue((char*)\"c\",$1);";
|
||||||
|
|
||||||
/* Pointers, references, and arrays */
|
/* Pointers and arrays */
|
||||||
%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 0);";
|
%typemap(varout) SWIGTYPE *, SWIGTYPE [] "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 0);";
|
||||||
|
|
||||||
|
/* References */
|
||||||
|
%typemap(varout) SWIGTYPE & "$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);";
|
||||||
|
|
||||||
/* Member pointer */
|
/* Member pointer */
|
||||||
%typemap(varout) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor);";
|
%typemap(varout) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor);";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue