From: Bruno Postle <bruno@postle.net>
Date: Fri, 28 Aug 2026 19:35:23 +0100
Subject: 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

Origin: upstream, https://github.com/IfcOpenShell/IfcOpenShell/commit/3bb8b0cb9a30f7d9cc5287c2aec3620724dfd9b8
Bug-Debian: https://bugs.debian.org/1145402
---
 .../cityjson/IfcOpenShell/src/ifcwrap/utils/type_conversion.i | 6 +++---
 .../cityjson/IfcOpenShell/src/ifcwrap/utils/typemaps_out.i    | 4 ++--
 src/ifcwrap/utils/type_conversion.i                           | 6 +++---
 src/ifcwrap/utils/typemaps_out.i                              | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

--- a/src/ifcconvert/cityjson/IfcOpenShell/src/ifcwrap/utils/type_conversion.i
+++ b/src/ifcconvert/cityjson/IfcOpenShell/src/ifcwrap/utils/type_conversion.i
@@ -56,7 +56,7 @@
 
 	template <>
 	int cast_pyobject(PyObject* element) {
-		return static_cast<int>(PyInt_AsLong(element));
+		return static_cast<int>(PyLong_AsLong(element));
 	}
 
 	template <>
@@ -118,8 +118,8 @@
 		}
 	}
 
-	PyObject* pythonize(const int& t)                   { return PyInt_FromLong(t);                                                                  }
-	PyObject* pythonize(const unsigned int& t)          { return PyInt_FromLong(t);                                                                  }
+	PyObject* pythonize(const int& t)                   { return PyLong_FromLong(t);                                                                  }
+	PyObject* pythonize(const unsigned int& t)          { return PyLong_FromLong(t);                                                                  }
 	PyObject* pythonize(const bool& t)                  { return PyBool_FromLong(t);                                                                 }
 	PyObject* pythonize(const double& t)                { return PyFloat_FromDouble(t);                                                              }
 	PyObject* pythonize(const std::string& t)           { return PyUnicode_FromString(t.c_str());                                                    }
--- a/src/ifcconvert/cityjson/IfcOpenShell/src/ifcwrap/utils/typemaps_out.i
+++ b/src/ifcconvert/cityjson/IfcOpenShell/src/ifcwrap/utils/typemaps_out.i
@@ -7,7 +7,7 @@
 }
 
 %typemap(out) IfcUtil::ArgumentType {
-	$result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
+	$result = PyUnicode_FromString(IfcUtil::ArgumentTypeToString($1));
 }
 
 %typemap(out) IfcParse::declaration* {
@@ -26,7 +26,7 @@
 
 %typemap(out) IfcParse::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) std::pair<IfcUtil::ArgumentType, Argument*> {
--- a/src/ifcwrap/utils/type_conversion.i
+++ b/src/ifcwrap/utils/type_conversion.i
@@ -62,7 +62,7 @@
 
 	template <>
 	int cast_pyobject(PyObject* element) {
-		return static_cast<int>(PyInt_AsLong(element));
+		return static_cast<int>(PyLong_AsLong(element));
 	}
 
 	template <>
@@ -156,8 +156,8 @@
 		}
 	}
 
-	PyObject* pythonize(const int& t)                   { return PyInt_FromLong(t);                                                                  }
-	PyObject* pythonize(const unsigned int& t)          { return PyInt_FromLong(t);                                                                  }
+	PyObject* pythonize(const int& t)                   { return PyLong_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);                                                              }
--- a/src/ifcwrap/utils/typemaps_out.i
+++ b/src/ifcwrap/utils/typemaps_out.i
@@ -7,7 +7,7 @@
 }
 
 %typemap(out) IfcUtil::ArgumentType {
-	$result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
+	$result = PyUnicode_FromString(IfcUtil::ArgumentTypeToString($1));
 }
 
 %typemap(out) IfcParse::declaration* {
@@ -28,7 +28,7 @@
 
 %typemap(out) IfcParse::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) AttributeValue {
