diff --git a/docs/web/CMakeLists.txt b/docs/web/CMakeLists.txt index ec1f1ec25..a33ad3089 100644 --- a/docs/web/CMakeLists.txt +++ b/docs/web/CMakeLists.txt @@ -167,6 +167,7 @@ pandoc_html(release-notes-4.0.2 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(release-notes-4.0.3 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(release-notes-4.1 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(release-notes-4.1.1 "--toc" "--toc-depth=2" "--number-sections") +pandoc_html(release-notes-4.1.2 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(release-notes-4.2 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(release-notes-4.2.1 "--toc" "--toc-depth=2" "--number-sections") pandoc_html(theory "--toc" "--toc-depth=2") diff --git a/docs/web/mfront-template.html b/docs/web/mfront-template.html index fcae12ed7..2f46cc7e3 100644 --- a/docs/web/mfront-template.html +++ b/docs/web/mfront-template.html @@ -163,6 +163,7 @@ diff --git a/docs/web/release-notes-4.1.2.md b/docs/web/release-notes-4.1.2.md new file mode 100644 index 000000000..a28310e60 --- /dev/null +++ b/docs/web/release-notes-4.1.2.md @@ -0,0 +1,24 @@ +--- +title: Release notes of the 4.1.2 version of `TFEL`, `MFront` and `MTest` +author: Thomas Helfer +date: 2024 +lang: en-EN +numbersections: true +documentclass: article +from: markdown+tex_math_single_backslash +geometry: + - margin=2cm +papersize: a4 +link-citations: true +colorlinks: true +figPrefixTemplate: "$$i$$" +tblPrefixTemplate: "$$i$$" +secPrefixTemplate: "$$i$$" +eqnPrefixTemplate: "($$i$$)" +--- + +# Issues fixed + +## Issue 514: [material-properties] add try/catch blocks in interfaces for the C family (fortran, C, Cast3M) + +For more details, see writeCErrorTreatment(os, mpd, floating_point_type, use_qt); - os << "}\n" - << "#endif /* MFRONT_NOERRNO_HANDLING */\n"; + + os << "auto " << mpd.output.name << " = " << mpd.output.type << "{};\n"; + this->writeCxxTryBlock(os); + os << mpd.f.body << "\n"; + this->writeCxxCatchBlock(os, mpd, floating_point_type, use_qt); + if (!mpd.inputs.empty()) { + os << "#ifndef MFRONT_NOERRNO_HANDLING\n"; + // can't use std::swap here as errno might be a macro + os << "const auto mfront_errno = errno;\n" + << "errno = mfront_errno_old;\n"; + if (use_qt) { + os << "if((mfront_errno != 0)||" + << "(!tfel::math::ieee754::isfinite(" << mpd.output.name + << ".getValue()))){\n"; + } else { + os << "if((mfront_errno != 0)||" + << "(!tfel::math::ieee754::isfinite(" << mpd.output.name << "))){\n"; + } + this->writeCErrorTreatment(os, mpd, floating_point_type, use_qt); + os << "}\n" + << "#endif /* MFRONT_NOERRNO_HANDLING */\n"; } if ((useQuantities(mpd)) && (!use_qt)) { os << "return " << mpd.output.name << ".getValue();\n"; @@ -612,22 +615,49 @@ namespace mfront { os << "return 0;\n"; } // end of writeMaterialPropertyCheckBoundsBody + void CMaterialPropertyInterfaceBase::writeCxxTryBlock( + std::ostream& os) const { + os << "try{\n"; + } // end of writeCxxCatchBlock + + void CMaterialPropertyInterfaceBase::writeCxxCatchBlock( + std::ostream& os, + const MaterialPropertyDescription& mpd, + const std::string_view floating_point_type, + const bool use_qt) const { + os << "} catch(std::exception&){\n"; + this->returnInvalidValue(os, "e.what()", mpd, floating_point_type, use_qt); + os << "} catch(...){\n"; + this->returnInvalidValue(os, "\"unsupported C++ exception\"", mpd, + floating_point_type, use_qt); + os << "}\n"; + } // end of writeCxxCatchBlock + void CMaterialPropertyInterfaceBase::writeCErrorTreatment( std::ostream& os, const MaterialPropertyDescription& mpd, const std::string_view floating_point_type, const bool use_qt) const { + const auto* msg = "\"invalid call to a C function (errno is not null)\""; + this->returnInvalidValue(os, msg, mpd, floating_point_type, use_qt); + } // end of writeCErrorTreatment + + void CMaterialPropertyInterfaceBase::returnInvalidValue( + std::ostream& os, + std::string_view, + const MaterialPropertyDescription& mpd, + const std::string_view floating_point_type, + const bool use_qt) const { os << "return "; if (use_qt) { os << getOutputType(mpd, std::string{floating_point_type}, true) << "{"; } - os << "std::nan(\"" << this->getFunctionName(mpd) - << ": invalid call to a C function (errno is not null)\")"; + os << "std::nan(\"\")"; if (use_qt) { os << "}"; } os << ";\n"; - } // end of writeCErrorTreatment + } // end of returnInvalidValue CMaterialPropertyInterfaceBase::~CMaterialPropertyInterfaceBase() = default;