bool mods for Visual C++

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4285 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-02-10 22:33:53 +00:00
commit be2645fa50

View file

@ -39,7 +39,7 @@
is no guarantee that a bool is the same size as an int so we have to do this */ is no guarantee that a bool is the same size as an int so we have to do this */
%typemap(in) bool (int tempb) "if (Tcl_GetIntFromObj(interp,$input,&tempb) == TCL_ERROR) SWIG_fail; %typemap(in) bool (int tempb) "if (Tcl_GetIntFromObj(interp,$input,&tempb) == TCL_ERROR) SWIG_fail;
$1 = (bool) tempb;"; $1 = tempb ? true : false;";
/* These will pass an integer as an unsigned long. However, the implementation is crippled due /* These will pass an integer as an unsigned long. However, the implementation is crippled due
to limited precision in Tcl */ to limited precision in Tcl */
@ -83,8 +83,7 @@
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)
{ {
long ltemp; long ltemp;
if (Tcl_GetLongFromObj(interp, $input, &ltemp) != TCL_OK) { if (Tcl_GetLongFromObj(interp, $input, &ltemp) != TCL_OK) {
@ -94,6 +93,17 @@
$1 = &temp; $1 = &temp;
} }
%typemap(in) const bool & (bool temp)
{
long ltemp;
if (Tcl_GetLongFromObj(interp, $input, &ltemp) != TCL_OK) {
SWIG_fail;
}
temp = ltemp ? true : false;
$1 = &temp;
}
%typemap(in) const float & (float temp), %typemap(in) const float & (float temp),
const double & (double temp) const double & (double temp)
{ {
@ -270,7 +280,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; long temp;
if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) { if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) {
@ -279,6 +289,15 @@
$1 = ($1_type) temp; $1 = ($1_type) temp;
} }
%typemap(varin) bool
{
long temp;
if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) {
return (char*) "Type error. expected an integer";
}
$1 = temp ? true : false;
}
%typemap(varin) long long "$1 = (long long) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);"; %typemap(varin) long long "$1 = (long long) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);";
%typemap(varin) unsigned long long "$1 = (unsigned long long) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);"; %typemap(varin) unsigned long long "$1 = (unsigned long long) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);";
@ -433,7 +452,7 @@
const unsigned int &, const unsigned short &, const unsigned long &, const unsigned int &, const unsigned short &, const unsigned long &,
const long long &, const unsigned long long &, const long long &, const unsigned long long &,
enum SWIGTYPE, enum SWIGTYPE,
bool, const bool & bool, const bool &
{ {
long tmp; long tmp;
if (Tcl_GetLongFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0; if (Tcl_GetLongFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0;