Support swig 4.5 (#9324)

Current swig has removed support for python2 macros, breaking the build.
See: https://github.com/swig/swig/blob/5872e9b4176cf59ce4e31b010c29a4cebf32960f/CHANGES#L391
This commit is contained in:
Bruno Postle
2026-08-28 19:35:23 +01:00
parent ff5e3b57cb
commit 3bb8b0cb9a
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -161,7 +161,7 @@
template <> template <>
int cast_pyobject(PyObject* element) { int cast_pyobject(PyObject* element) {
return static_cast<int>(PyInt_AsLong(element)); return static_cast<int>(PyLong_AsLong(element));
} }
template <> template <>
@@ -255,9 +255,9 @@
} }
} }
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); } PyObject* pythonize(const int& t) { return PyLong_FromLong(t); }
PyObject* pythonize(const int64_t& t) { return PyLong_FromLongLong(t); } PyObject* pythonize(const int64_t& t) { return PyLong_FromLongLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); } PyObject* pythonize(const unsigned int& t) { return PyLong_FromLong(t); }
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); } PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
PyObject* pythonize(const boost::logic::tribool& t) { return boost::logic::indeterminate(t) ? PyUnicode_FromString("UNKNOWN") : PyBool_FromLong((bool)t) ;} PyObject* pythonize(const boost::logic::tribool& t) { return boost::logic::indeterminate(t) ? PyUnicode_FromString("UNKNOWN") : PyBool_FromLong((bool)t) ;}
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); } PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
+2 -2
View File
@@ -1,5 +1,5 @@
%typemap(out) ifcopenshell::argument_type { %typemap(out) ifcopenshell::argument_type {
$result = SWIG_Python_str_FromChar(ifcopenshell::argument_type_to_string($1)); $result = PyUnicode_FromString(ifcopenshell::argument_type_to_string($1));
} }
%typemap(out) ifcopenshell::declaration* { %typemap(out) ifcopenshell::declaration* {
@@ -24,7 +24,7 @@
%typemap(out) ifcopenshell::simple_type::data_type { %typemap(out) ifcopenshell::simple_type::data_type {
static const char* const data_type_strings[] = {"binary", "boolean", "integer", "logical", "number", "real", "string"}; static const char* const data_type_strings[] = {"binary", "boolean", "integer", "logical", "number", "real", "string"};
$result = SWIG_Python_str_FromChar(data_type_strings[(int)$1]); $result = PyUnicode_FromString(data_type_strings[(int)$1]);
} }
%typemap(out) attribute_value { %typemap(out) attribute_value {