From 45c3c27fb534db69d915781ec56f26b52836ad1d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 3 Apr 2019 13:55:29 +0200 Subject: [PATCH] Fixes for mapping declaration subtypes to SWIG --- src/ifcwrap/utils/type_conversion.i | 14 +++++++++++++- src/ifcwrap/utils/typemaps_out.i | 10 +--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 52c4ce1c4e..cbbb479110 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -106,6 +106,18 @@ // Conversion functions to convert STL vectors into Python objects %{ + swig_type_info* declaration_type_to_swig(const IfcParse::declaration* t) { + if (t->as_entity()) { + return SWIGTYPE_p_IfcParse__entity; + } else if (t->as_type_declaration()) { + return SWIGTYPE_p_IfcParse__type_declaration; + } else if (t->as_select_type()) { + return SWIGTYPE_p_IfcParse__select_type; + } else if (t->as_enumeration_type()) { + return SWIGTYPE_p_IfcParse__enumeration_type; + } + } + 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); } @@ -115,7 +127,7 @@ PyObject* pythonize(const IfcParse::attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__attribute, 0); } PyObject* pythonize(const IfcParse::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__inverse_attribute, 0); } PyObject* pythonize(const IfcParse::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__entity, 0); } - PyObject* pythonize(const IfcParse::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__declaration, 0); } + PyObject* pythonize(const IfcParse::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); } // NB: This cannot be temporary as a Python object is constructed from a pointer to the address of this object PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); } diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 338898db69..fbb12ed7da 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -11,15 +11,7 @@ } %typemap(out) IfcParse::declaration* { - if ($1->as_entity()) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_entity()), SWIGTYPE_p_IfcParse__entity, 0); - } else if ($1->as_type_declaration()) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_type_declaration()), SWIGTYPE_p_IfcParse__type_declaration, 0); - } else if ($1->as_select_type()) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_select_type()), SWIGTYPE_p_IfcParse__select_type, 0); - } else if ($1->as_enumeration_type()) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_enumeration_type()), SWIGTYPE_p_IfcParse__enumeration_type, 0); - } + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0); } %typemap(out) IfcParse::parameter_type* {