From 3bb8b0cb9a30f7d9cc5287c2aec3620724dfd9b8 Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Fri, 28 Aug 2026 19:35:23 +0100 Subject: [PATCH] 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 --- src/ifcwrap/utils/type_conversion.i | 6 +++--- src/ifcwrap/utils/typemaps_out.i | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 1fc5df9010..41cded53a7 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -161,7 +161,7 @@ template <> int cast_pyobject(PyObject* element) { - return static_cast(PyInt_AsLong(element)); + return static_cast(PyLong_AsLong(element)); } 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 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 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); } diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 3e41e6f08a..735dc22136 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -1,5 +1,5 @@ %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* { @@ -24,7 +24,7 @@ %typemap(out) ifcopenshell::simple_type::data_type { 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 {