diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 12582c4c1e..a4ebb234bc 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -66,12 +66,6 @@ namespace IfcUtil { %rename("entity_instance") IfcLateBoundEntity; %rename("file") IfcFile; -%include "utils/type_conversion.i" - -%include "utils/typemaps_in.i" - -%include "utils/typemaps_out.i" - %extend IfcParse::IfcFile { IfcParse::IfcLateBoundEntity* by_id(unsigned id) { return (IfcParse::IfcLateBoundEntity*) $self->entityById(id); diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index 602110d255..4fb584a088 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -17,7 +17,6 @@ * * ********************************************************************************/ -%include "std_vector.i" %include "std_string.i" %include "exception.i" @@ -49,46 +48,11 @@ #endif %} -// The following typemaps are an alternative for the read-only std::vector -// implementations provided by SWIG, as passing STL objects across dynamic -// library boundaries can be problematic. -%typemap(out) std::pair { - $result = PyTuple_New($1.second); - for (unsigned i = 0; i < $1.second; ++i) { - PyTuple_SetItem($result, i, PyFloat_FromDouble($1.first[i])); - } -} -%typemap(out) std::pair { - $result = PyTuple_New($1.second); - for (unsigned i = 0; i < $1.second; ++i) { - PyTuple_SetItem($result, i, PyFloat_FromDouble($1.first[i])); - } -} -%typemap(out) std::pair { - $result = PyTuple_New($1.second); - for (unsigned i = 0; i < $1.second; ++i) { - PyTuple_SetItem($result, i, PyLong_FromLong($1.first[i])); - } -} -%typemap(out) std::pair { - $result = PyTuple_New($1.second); - for (unsigned i = 0; i < $1.second; ++i) { - PyTuple_SetItem($result, i, PyUnicode_FromString($1.first[i]->c_str())); - } -} -%typemap(out) std::pair { - $result = PyTuple_New($1.second); - for (unsigned i = 0; i < $1.second; ++i) { - PyTuple_SetItem($result, i, SWIG_NewPointerObj(SWIG_as_voidptr(&$1.first[i]), SWIGTYPE_p_IfcGeom__Material, 0)); - } -} -%typemap(out) std::vector { - $result = PyTuple_New($1.size()); - unsigned i = 0; - for (std::vector::const_iterator it = $1.begin(); it != $1.end(); ++it) { - PyTuple_SetItem($result, i++, PyLong_FromLong(*it)); - } -} +%include "utils/type_conversion.i" + +%include "utils/typemaps_in.i" + +%include "utils/typemaps_out.i" %include "IfcGeomWrapper.i" %include "IfcParseWrapper.i" diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 12ce207b65..604be11ced 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -107,6 +107,7 @@ // Conversion functions to convert STL vectors into Python objects %{ PyObject* pythonize(const int& t) { return PyInt_FromLong(t); } + PyObject* pythonize(const unsigned int& t) { return PyInt_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 PyString_FromString(t.c_str()); } diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index aa27c95bd6..5680a07ab5 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -97,10 +97,11 @@ $result = pythonize_vector($1); } %typemap(out) const std::vector& { - $result = pythonize_vector($1); + $result = pythonize_vector(*$1); } %enddef CREATE_VECTOR_TYPEMAP_OUT(int) +CREATE_VECTOR_TYPEMAP_OUT(unsigned int) CREATE_VECTOR_TYPEMAP_OUT(double) CREATE_VECTOR_TYPEMAP_OUT(std::string)