From 2c36063a7492009c86275915f8cc1a7081eb833f Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 24 Nov 2023 22:24:51 +0100 Subject: [PATCH] Frame c'tor w/o std::move --- Base/Axis/Frame.cpp | 4 ++-- Base/Axis/Frame.h | 2 +- GUI/Model/Device/InstrumentItems.cpp | 6 +++--- auto/Wrap/libBornAgainBase.py | 2 +- auto/Wrap/libBornAgainBase_wrap.cpp | 29 ++++++++++++---------------- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Base/Axis/Frame.cpp b/Base/Axis/Frame.cpp index 1178ba25bdd..5e25bbb8b02 100644 --- a/Base/Axis/Frame.cpp +++ b/Base/Axis/Frame.cpp @@ -18,8 +18,8 @@ #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" -Frame::Frame(CloneableVector<const Scale> axes) - : m_axes(std::move(axes)) +Frame::Frame(const CloneableVector<const Scale>& axes) + : m_axes(axes) , m_size(FrameUtil::product_size(m_axes.reference())) { } diff --git a/Base/Axis/Frame.h b/Base/Axis/Frame.h index ebc420dbfd4..7b8b0b817f4 100644 --- a/Base/Axis/Frame.h +++ b/Base/Axis/Frame.h @@ -27,7 +27,7 @@ class Scale; class Frame { public: //! Constructor that takes ownership of supplied axes. - Frame(CloneableVector<const Scale> axes); + Frame(const CloneableVector<const Scale>& axes); Frame(const Scale* ax0); Frame(const Scale* ax0, const Scale* ax1); Frame(const Frame&); diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp index 55f082734f7..2af8e505b71 100644 --- a/GUI/Model/Device/InstrumentItems.cpp +++ b/GUI/Model/Device/InstrumentItems.cpp @@ -414,13 +414,13 @@ Frame SpecularInstrumentItem::makeFrame() const return Frame({}); Scale* ax0 = pointwise_axis->axis()->clone(); std::vector<const Scale*> f{ax0}; - return Frame(std::move(f)); + return Frame(f); } Scale axis = axis_item->makeScale("alpha_i (rad)"); std::vector<const Scale*> f{axis.clone()}; - return Frame(std::move(f)); + return Frame(f); } ISimulation* SpecularInstrumentItem::createSimulation(const MultiLayer& sample) const @@ -510,7 +510,7 @@ Frame DepthprobeInstrumentItem::makeFrame() const Scale xAxis = axis_item->makeScale("alpha_i (rad)"); Scale zAxis = m_zAxis.createAxis("z (nm)"); std::vector<const Scale*> axes{xAxis.clone(), zAxis.clone()}; - return Frame(std::move(axes)); + return Frame(axes); } ISimulation* DepthprobeInstrumentItem::createSimulation(const MultiLayer& sample) const diff --git a/auto/Wrap/libBornAgainBase.py b/auto/Wrap/libBornAgainBase.py index 9b51f55352d..309ad1a0dc2 100644 --- a/auto/Wrap/libBornAgainBase.py +++ b/auto/Wrap/libBornAgainBase.py @@ -1914,7 +1914,7 @@ class Frame(object): def __init__(self, *args): r""" - __init__(Frame self, CloneableVector< Scale const > axes) -> Frame + __init__(Frame self, CloneableVector< Scale const > const & axes) -> Frame __init__(Frame self, Scale ax0) -> Frame __init__(Frame self, Scale ax0, Scale ax1) -> Frame __init__(Frame self, Frame arg2) -> Frame diff --git a/auto/Wrap/libBornAgainBase_wrap.cpp b/auto/Wrap/libBornAgainBase_wrap.cpp index 916dbfbd205..366b79d563a 100644 --- a/auto/Wrap/libBornAgainBase_wrap.cpp +++ b/auto/Wrap/libBornAgainBase_wrap.cpp @@ -26380,28 +26380,23 @@ fail: SWIGINTERN PyObject *_wrap_new_Frame__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - SwigValueWrapper< CloneableVector< Scale const > > arg1 ; - void *argp1 ; + CloneableVector< Scale const > *arg1 = 0 ; + void *argp1 = 0 ; int res1 = 0 ; Frame *result = 0 ; if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; - { - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_CloneableVectorT_Scale_const_t, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', argument " "1"" of type '" "CloneableVector< Scale const >""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Frame" "', argument " "1"" of type '" "CloneableVector< Scale const >""'"); - } else { - CloneableVector< Scale const > * temp = reinterpret_cast< CloneableVector< Scale const > * >(argp1); - arg1 = *temp; - if (SWIG_IsNewObj(res1)) delete temp; - } + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_CloneableVectorT_Scale_const_t, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Frame" "', argument " "1"" of type '" "CloneableVector< Scale const > const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Frame" "', argument " "1"" of type '" "CloneableVector< Scale const > const &""'"); } + arg1 = reinterpret_cast< CloneableVector< Scale const > * >(argp1); { try { - result = (Frame *)new Frame(arg1); + result = (Frame *)new Frame((CloneableVector< Scale const > const &)*arg1); } catch (const std::exception& ex) { // message shown in the Python interpreter const std::string msg { @@ -26572,7 +26567,7 @@ SWIGINTERN PyObject *_wrap_new_Frame(PyObject *self, PyObject *args) { fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Frame'.\n" " Possible C/C++ prototypes are:\n" - " Frame::Frame(CloneableVector< Scale const >)\n" + " Frame::Frame(CloneableVector< Scale const > const &)\n" " Frame::Frame(Scale const *)\n" " Frame::Frame(Scale const *,Scale const *)\n" " Frame::Frame(Frame const &)\n"); @@ -29706,7 +29701,7 @@ static PyMethodDef SwigMethods[] = { { "EquiDivision", _wrap_EquiDivision, METH_VARARGS, "EquiDivision(std::string name, size_t N, double start, double end) -> Scale"}, { "EquiScan", _wrap_EquiScan, METH_VARARGS, "EquiScan(std::string name, size_t N, double start, double end) -> Scale"}, { "new_Frame", _wrap_new_Frame, METH_VARARGS, "\n" - "Frame(CloneableVector< Scale const > axes)\n" + "Frame(CloneableVector< Scale const > const & axes)\n" "Frame(Scale ax0)\n" "Frame(Scale ax0, Scale ax1)\n" "new_Frame(Frame arg1) -> Frame\n" -- GitLab