Skip to content

Commit

Permalink
Fix Solver copyctor issues with swig4.2 (#2276)
Browse files Browse the repository at this point in the history
* Fix Solver copyctor issues with swig4.2

Closes #2275
  • Loading branch information
dweindl authored Jan 24, 2024
1 parent 786b586 commit 35cd14e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/downloadAndBuildSwig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 "================"
11 changes: 11 additions & 0 deletions swig/solver_cvodes.i
Original file line number Diff line number Diff line change
Expand Up @@ -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<CVodeSolver const&>(solver));
}
}

// Process symbols in header
%include "amici/solver_cvodes.h"
11 changes: 11 additions & 0 deletions swig/solver_idas.i
Original file line number Diff line number Diff line change
Expand Up @@ -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<IDASolver const&>(solver));
}
}

// Process symbols in header
%include "amici/solver_idas.h"
7 changes: 7 additions & 0 deletions tests/cpp/unittests/testMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ TEST(SolverIdasTest, DefaultConstructableAndNotLeaky)
IDASolver solver;
}

TEST(SolverIdasTest, CopyCtor)
{
IDASolver solver1;
IDASolver solver2(solver1);
}



class SolverTest : public ::testing::Test {
protected:
Expand Down

0 comments on commit 35cd14e

Please sign in to comment.