diff --git a/scripts/downloadAndBuildSwig.sh b/scripts/downloadAndBuildSwig.sh index 261192f667..29ce32890b 100755 --- a/scripts/downloadAndBuildSwig.sh +++ b/scripts/downloadAndBuildSwig.sh @@ -18,13 +18,13 @@ cd "${AMICI_PATH}/ThirdParty/" if [[ ! -d ${SWIG_DIR} ]]; then if [[ ! -f ${SWIG_ARCHIVE} ]] - then wget ${SWIG_URL} + then wget "${SWIG_URL}" fi - tar -xzf ${SWIG_ARCHIVE} + tar -xzf "${SWIG_ARCHIVE}" fi -cd ${SWIG_DIR} +cd "${SWIG_DIR}" ./configure \ --prefix="${PREFIX}" \ --without-alllang \ @@ -38,6 +38,6 @@ echo "================" echo "SWIG installation successful" echo echo "To use this version of SWIG, add directory ${SWIG_BIN_DIR} to your PATH," -echo "e.g. adding the following line to your .bashrc:" +echo "e.g., adding the following line to your ~/.bashrc:" echo " export PATH=${SWIG_BIN_DIR}:\$PATH" echo "================" diff --git a/swig/solver_cvodes.i b/swig/solver_cvodes.i index 52feb1f4dd..7e2c28a17e 100644 --- a/swig/solver_cvodes.i +++ b/swig/solver_cvodes.i @@ -9,5 +9,16 @@ using namespace amici; %newobject amici::CVodeSolver::clone; %feature("notabstract") amici::CVodeSolver; +// Required with SWIG 4.2.0 https://github.com/AMICI-dev/AMICI/issues/2275 +%extend amici::CVodeSolver { + CVodeSolver() { + return new CVodeSolver(); + } + + CVodeSolver(Solver const& solver) { + return new CVodeSolver(dynamic_cast(solver)); + } +} + // Process symbols in header %include "amici/solver_cvodes.h" diff --git a/swig/solver_idas.i b/swig/solver_idas.i index b4a49a836f..7ec9f663bb 100644 --- a/swig/solver_idas.i +++ b/swig/solver_idas.i @@ -9,5 +9,16 @@ using namespace amici; %newobject amici::IDASolver::clone; %feature("notabstract") amici::IDASolver; +// Required for SWIG 4.2.0 https://github.com/AMICI-dev/AMICI/issues/2275 +%extend amici::IDASolver { + IDASolver() { + return new IDASolver(); + } + + IDASolver(Solver const& solver) { + return new IDASolver(dynamic_cast(solver)); + } +} + // Process symbols in header %include "amici/solver_idas.h" diff --git a/tests/cpp/unittests/testMisc.cpp b/tests/cpp/unittests/testMisc.cpp index f18de96b79..1f464b3433 100644 --- a/tests/cpp/unittests/testMisc.cpp +++ b/tests/cpp/unittests/testMisc.cpp @@ -261,6 +261,13 @@ TEST(SolverIdasTest, DefaultConstructableAndNotLeaky) IDASolver solver; } +TEST(SolverIdasTest, CopyCtor) +{ + IDASolver solver1; + IDASolver solver2(solver1); +} + + class SolverTest : public ::testing::Test { protected: