From 4f0297d8b20e5ed4d7b1a50233fdfcecaab1e3dc Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 23 Aug 2024 13:58:12 +0200 Subject: [PATCH] Re-enable explicit tagging and validation of derived in subtype --- src/ifcparse/IfcFile.cpp | 3 +++ src/ifcwrap/IfcParseWrapper.i | 11 +++++++++-- src/ifcwrap/utils/typemaps_out.i | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ifcparse/IfcFile.cpp b/src/ifcparse/IfcFile.cpp index 47232b95cb..6228884120 100644 --- a/src/ifcparse/IfcFile.cpp +++ b/src/ifcparse/IfcFile.cpp @@ -67,6 +67,9 @@ namespace { fn(IfcParse::TokenFunc::asInt(t)); } else if (t.type == IfcParse::Token_STRING) { fn(IfcParse::TokenFunc::asStringRef(t)); + } else if (t.type == IfcParse::Token_OPERATOR && t.value_char == '*') { + // This is only in place for the validator + fn(Derived{}); } } diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index d81e6af3ba..3c687e1713 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -763,8 +763,15 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas } else if constexpr (is_std_vector_v) { return pythonize_vector(v); } else if constexpr (std::is_same_v) { - return pythonize(v.value()); - } else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v) { + return pythonize(std::string(v.value())); + } else if constexpr (std::is_same_v) { + if (feature_use_attribute_value_derived) { + return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN); + } else { + Py_INCREF(Py_None); + return static_cast(Py_None); + } + } else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) { Py_INCREF(Py_None); return static_cast(Py_None); } else { diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 0efccaa12d..ea5648030e 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -43,7 +43,17 @@ } else if constexpr (is_std_vector_v) { return pythonize_vector(v); } else if constexpr (std::is_same_v) { - return pythonize(v.value()); + return pythonize(std::string(v.value())); + } else if constexpr (std::is_same_v) { + if (feature_use_attribute_value_derived) { + return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN); + } else { + Py_INCREF(Py_None); + return static_cast(Py_None); + } + } else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) { + Py_INCREF(Py_None); + return static_cast(Py_None); } else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v) { Py_INCREF(Py_None); return static_cast(Py_None);