Always pass wrapper objects by const reference in C++ wrappers

Passing them by value doesn't seem to have any advantages, as the copy
will be made internally anyhow if the original function took them by
value and doing an extra one doesn't seem necessary, but does have a big
drawback of not compiling if the class doesn't define a copy ctor.
This commit is contained in:
Vadim Zeitlin 2021-11-24 02:14:38 +01:00
commit adb96f8b7a

View file

@ -819,6 +819,10 @@ private:
}
if (ptype_desc) {
// It doesn't seem like it can ever be useful to pass an object by value to a wrapper function and it can fail if it doesn't have a copy ctor (see
// code related to has_copy_ctor_ in our dtor above), so always pass it by const reference instead.
Append(typestr, " const&");
Append(ptype_desc->wrap_end(), ".swig_self()");
}
break;