added backward comp for old As/Check/From methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5785 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5a656bf645
commit
299d8fc456
1 changed files with 36 additions and 0 deletions
|
|
@ -20,6 +20,12 @@
|
||||||
#define SWIG_STD_EXTEND_COMPARISON
|
#define SWIG_STD_EXTEND_COMPARISON
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use the following macro if you need the old common
|
||||||
|
// methods (SwigInt_FromBool,SwigNumber_Check,...).
|
||||||
|
//
|
||||||
|
// #define SWIG_STD_BACKWARD_COMP
|
||||||
|
|
||||||
//
|
//
|
||||||
// Common code for supporting the STD C++ namespace
|
// Common code for supporting the STD C++ namespace
|
||||||
//
|
//
|
||||||
|
|
@ -428,3 +434,33 @@ namespace swigpy {
|
||||||
#define %std_definst(Class,...)
|
#define %std_definst(Class,...)
|
||||||
#define %std_definst_2(Class,...)
|
#define %std_definst_2(Class,...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Backward compatibility
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef SWIG_STD_BACKWARD_COMP
|
||||||
|
%{
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
PyObject* SwigInt_FromBool(bool b) {
|
||||||
|
return PyInt_FromLong(b ? 1L : 0L);
|
||||||
|
}
|
||||||
|
double SwigNumber_Check(PyObject* o) {
|
||||||
|
return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o);
|
||||||
|
}
|
||||||
|
double SwigNumber_AsDouble(PyObject* o) {
|
||||||
|
return PyFloat_Check(o) ? PyFloat_AsDouble(o)
|
||||||
|
: (PyInt_Check(o) ? double(PyInt_AsLong(o))
|
||||||
|
: double(PyLong_AsLong(o)));
|
||||||
|
}
|
||||||
|
PyObject* SwigString_FromString(const std::string& s) {
|
||||||
|
return PyString_FromStringAndSize(s.data(),s.size());
|
||||||
|
}
|
||||||
|
std::string SwigString_AsString(PyObject* o) {
|
||||||
|
return std::string(PyString_AsString(o));
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue